documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964
  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 center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  2832. * @param value1 defines first vector
  2833. * @param value2 defines second vector
  2834. * @param ref defines third vector
  2835. * @returns ref
  2836. */
  2837. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  2838. /**
  2839. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2840. * @param p defines the middle point
  2841. * @param segA defines one point of the segment
  2842. * @param segB defines the other point of the segment
  2843. * @returns the shortest distance
  2844. */
  2845. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2846. }
  2847. /**
  2848. * Class used to store (x,y,z) vector representation
  2849. * A Vector3 is the main object used in 3D geometry
  2850. * It can represent etiher the coordinates of a point the space, either a direction
  2851. * Reminder: js uses a left handed forward facing system
  2852. */
  2853. export class Vector3 {
  2854. private static _UpReadOnly;
  2855. private static _ZeroReadOnly;
  2856. /** @hidden */
  2857. _x: number;
  2858. /** @hidden */
  2859. _y: number;
  2860. /** @hidden */
  2861. _z: number;
  2862. /** @hidden */
  2863. _isDirty: boolean;
  2864. /** Gets or sets the x coordinate */
  2865. get x(): number;
  2866. set x(value: number);
  2867. /** Gets or sets the y coordinate */
  2868. get y(): number;
  2869. set y(value: number);
  2870. /** Gets or sets the z coordinate */
  2871. get z(): number;
  2872. set z(value: number);
  2873. /**
  2874. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2875. * @param x defines the first coordinates (on X axis)
  2876. * @param y defines the second coordinates (on Y axis)
  2877. * @param z defines the third coordinates (on Z axis)
  2878. */
  2879. constructor(x?: number, y?: number, z?: number);
  2880. /**
  2881. * Creates a string representation of the Vector3
  2882. * @returns a string with the Vector3 coordinates.
  2883. */
  2884. toString(): string;
  2885. /**
  2886. * Gets the class name
  2887. * @returns the string "Vector3"
  2888. */
  2889. getClassName(): string;
  2890. /**
  2891. * Creates the Vector3 hash code
  2892. * @returns a number which tends to be unique between Vector3 instances
  2893. */
  2894. getHashCode(): number;
  2895. /**
  2896. * Creates an array containing three elements : the coordinates of the Vector3
  2897. * @returns a new array of numbers
  2898. */
  2899. asArray(): number[];
  2900. /**
  2901. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2902. * @param array defines the destination array
  2903. * @param index defines the offset in the destination array
  2904. * @returns the current Vector3
  2905. */
  2906. toArray(array: FloatArray, index?: number): Vector3;
  2907. /**
  2908. * Update the current vector from an array
  2909. * @param array defines the destination array
  2910. * @param index defines the offset in the destination array
  2911. * @returns the current Vector3
  2912. */
  2913. fromArray(array: FloatArray, index?: number): Vector3;
  2914. /**
  2915. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2916. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2917. */
  2918. toQuaternion(): Quaternion;
  2919. /**
  2920. * Adds the given vector to the current Vector3
  2921. * @param otherVector defines the second operand
  2922. * @returns the current updated Vector3
  2923. */
  2924. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2925. /**
  2926. * Adds the given coordinates to the current Vector3
  2927. * @param x defines the x coordinate of the operand
  2928. * @param y defines the y coordinate of the operand
  2929. * @param z defines the z coordinate of the operand
  2930. * @returns the current updated Vector3
  2931. */
  2932. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2933. /**
  2934. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2935. * @param otherVector defines the second operand
  2936. * @returns the resulting Vector3
  2937. */
  2938. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2939. /**
  2940. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2941. * @param otherVector defines the second operand
  2942. * @param result defines the Vector3 object where to store the result
  2943. * @returns the current Vector3
  2944. */
  2945. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2946. /**
  2947. * Subtract the given vector from the current Vector3
  2948. * @param otherVector defines the second operand
  2949. * @returns the current updated Vector3
  2950. */
  2951. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2952. /**
  2953. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2954. * @param otherVector defines the second operand
  2955. * @returns the resulting Vector3
  2956. */
  2957. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2958. /**
  2959. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2960. * @param otherVector defines the second operand
  2961. * @param result defines the Vector3 object where to store the result
  2962. * @returns the current Vector3
  2963. */
  2964. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  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. * @returns the resulting Vector3
  2971. */
  2972. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2973. /**
  2974. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2975. * @param x defines the x coordinate of the operand
  2976. * @param y defines the y coordinate of the operand
  2977. * @param z defines the z coordinate of the operand
  2978. * @param result defines the Vector3 object where to store the result
  2979. * @returns the current Vector3
  2980. */
  2981. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2982. /**
  2983. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2984. * @returns a new Vector3
  2985. */
  2986. negate(): Vector3;
  2987. /**
  2988. * Negate this vector in place
  2989. * @returns this
  2990. */
  2991. negateInPlace(): Vector3;
  2992. /**
  2993. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2994. * @param result defines the Vector3 object where to store the result
  2995. * @returns the current Vector3
  2996. */
  2997. negateToRef(result: Vector3): Vector3;
  2998. /**
  2999. * Multiplies the Vector3 coordinates by the float "scale"
  3000. * @param scale defines the multiplier factor
  3001. * @returns the current updated Vector3
  3002. */
  3003. scaleInPlace(scale: number): Vector3;
  3004. /**
  3005. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3006. * @param scale defines the multiplier factor
  3007. * @returns a new Vector3
  3008. */
  3009. scale(scale: number): Vector3;
  3010. /**
  3011. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3012. * @param scale defines the multiplier factor
  3013. * @param result defines the Vector3 object where to store the result
  3014. * @returns the current Vector3
  3015. */
  3016. scaleToRef(scale: number, result: Vector3): Vector3;
  3017. /**
  3018. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3019. * @param scale defines the scale factor
  3020. * @param result defines the Vector3 object where to store the result
  3021. * @returns the unmodified current Vector3
  3022. */
  3023. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3024. /**
  3025. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3026. * @param origin defines the origin of the projection ray
  3027. * @param plane defines the plane to project to
  3028. * @returns the projected vector3
  3029. */
  3030. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3031. /**
  3032. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3033. * @param origin defines the origin of the projection ray
  3034. * @param plane defines the plane to project to
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3038. /**
  3039. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3040. * @param otherVector defines the second operand
  3041. * @returns true if both vectors are equals
  3042. */
  3043. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3044. /**
  3045. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3046. * @param otherVector defines the second operand
  3047. * @param epsilon defines the minimal distance to define values as equals
  3048. * @returns true if both vectors are distant less than epsilon
  3049. */
  3050. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3051. /**
  3052. * Returns true if the current Vector3 coordinates equals the given floats
  3053. * @param x defines the x coordinate of the operand
  3054. * @param y defines the y coordinate of the operand
  3055. * @param z defines the z coordinate of the operand
  3056. * @returns true if both vectors are equals
  3057. */
  3058. equalsToFloats(x: number, y: number, z: number): boolean;
  3059. /**
  3060. * Multiplies the current Vector3 coordinates by the given ones
  3061. * @param otherVector defines the second operand
  3062. * @returns the current updated Vector3
  3063. */
  3064. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3065. /**
  3066. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3067. * @param otherVector defines the second operand
  3068. * @returns the new Vector3
  3069. */
  3070. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3071. /**
  3072. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3073. * @param otherVector defines the second operand
  3074. * @param result defines the Vector3 object where to store the result
  3075. * @returns the current Vector3
  3076. */
  3077. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3078. /**
  3079. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3080. * @param x defines the x coordinate of the operand
  3081. * @param y defines the y coordinate of the operand
  3082. * @param z defines the z coordinate of the operand
  3083. * @returns the new Vector3
  3084. */
  3085. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3086. /**
  3087. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3088. * @param otherVector defines the second operand
  3089. * @returns the new Vector3
  3090. */
  3091. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3092. /**
  3093. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3094. * @param otherVector defines the second operand
  3095. * @param result defines the Vector3 object where to store the result
  3096. * @returns the current Vector3
  3097. */
  3098. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3099. /**
  3100. * Divides the current Vector3 coordinates by the given ones.
  3101. * @param otherVector defines the second operand
  3102. * @returns the current updated Vector3
  3103. */
  3104. divideInPlace(otherVector: Vector3): Vector3;
  3105. /**
  3106. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3107. * @param other defines the second operand
  3108. * @returns the current updated Vector3
  3109. */
  3110. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3113. * @param other defines the second operand
  3114. * @returns the current updated Vector3
  3115. */
  3116. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Updates the current Vector3 with the minimal 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. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3125. /**
  3126. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3127. * @param x defines the x coordinate of the operand
  3128. * @param y defines the y coordinate of the operand
  3129. * @param z defines the z coordinate of the operand
  3130. * @returns the current updated Vector3
  3131. */
  3132. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3133. /**
  3134. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3135. * Check if is non uniform within a certain amount of decimal places to account for this
  3136. * @param epsilon the amount the values can differ
  3137. * @returns if the the vector is non uniform to a certain number of decimal places
  3138. */
  3139. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3140. /**
  3141. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3142. */
  3143. get isNonUniform(): boolean;
  3144. /**
  3145. * Gets a new Vector3 from current Vector3 floored values
  3146. * @returns a new Vector3
  3147. */
  3148. floor(): Vector3;
  3149. /**
  3150. * Gets a new Vector3 from current Vector3 floored values
  3151. * @returns a new Vector3
  3152. */
  3153. fract(): Vector3;
  3154. /**
  3155. * Gets the length of the Vector3
  3156. * @returns the length of the Vector3
  3157. */
  3158. length(): number;
  3159. /**
  3160. * Gets the squared length of the Vector3
  3161. * @returns squared length of the Vector3
  3162. */
  3163. lengthSquared(): number;
  3164. /**
  3165. * Normalize the current Vector3.
  3166. * Please note that this is an in place operation.
  3167. * @returns the current updated Vector3
  3168. */
  3169. normalize(): Vector3;
  3170. /**
  3171. * Reorders the x y z properties of the vector in place
  3172. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3173. * @returns the current updated vector
  3174. */
  3175. reorderInPlace(order: string): this;
  3176. /**
  3177. * Rotates the vector around 0,0,0 by a quaternion
  3178. * @param quaternion the rotation quaternion
  3179. * @param result vector to store the result
  3180. * @returns the resulting vector
  3181. */
  3182. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3183. /**
  3184. * Rotates a vector around a given point
  3185. * @param quaternion the rotation quaternion
  3186. * @param point the point to rotate around
  3187. * @param result vector to store the result
  3188. * @returns the resulting vector
  3189. */
  3190. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3191. /**
  3192. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3193. * The cross product is then orthogonal to both current and "other"
  3194. * @param other defines the right operand
  3195. * @returns the cross product
  3196. */
  3197. cross(other: Vector3): Vector3;
  3198. /**
  3199. * Normalize the current Vector3 with the given input length.
  3200. * Please note that this is an in place operation.
  3201. * @param len the length of the vector
  3202. * @returns the current updated Vector3
  3203. */
  3204. normalizeFromLength(len: number): Vector3;
  3205. /**
  3206. * Normalize the current Vector3 to a new vector
  3207. * @returns the new Vector3
  3208. */
  3209. normalizeToNew(): Vector3;
  3210. /**
  3211. * Normalize the current Vector3 to the reference
  3212. * @param reference define the Vector3 to update
  3213. * @returns the updated Vector3
  3214. */
  3215. normalizeToRef(reference: Vector3): Vector3;
  3216. /**
  3217. * Creates a new Vector3 copied from the current Vector3
  3218. * @returns the new Vector3
  3219. */
  3220. clone(): Vector3;
  3221. /**
  3222. * Copies the given vector coordinates to the current Vector3 ones
  3223. * @param source defines the source Vector3
  3224. * @returns the current updated Vector3
  3225. */
  3226. copyFrom(source: DeepImmutable<Vector3>): 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. copyFromFloats(x: number, y: number, z: number): Vector3;
  3235. /**
  3236. * Copies the given floats to the current Vector3 coordinates
  3237. * @param x defines the x coordinate of the operand
  3238. * @param y defines the y coordinate of the operand
  3239. * @param z defines the z coordinate of the operand
  3240. * @returns the current updated Vector3
  3241. */
  3242. set(x: number, y: number, z: number): Vector3;
  3243. /**
  3244. * Copies the given float to the current Vector3 coordinates
  3245. * @param v defines the x, y and z coordinates of the operand
  3246. * @returns the current updated Vector3
  3247. */
  3248. setAll(v: number): Vector3;
  3249. /**
  3250. * Get the clip factor between two vectors
  3251. * @param vector0 defines the first operand
  3252. * @param vector1 defines the second operand
  3253. * @param axis defines the axis to use
  3254. * @param size defines the size along the axis
  3255. * @returns the clip factor
  3256. */
  3257. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3258. /**
  3259. * Get angle between two vectors
  3260. * @param vector0 angle between vector0 and vector1
  3261. * @param vector1 angle between vector0 and vector1
  3262. * @param normal direction of the normal
  3263. * @return the angle between vector0 and vector1
  3264. */
  3265. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3266. /**
  3267. * Returns a new Vector3 set from the index "offset" of the given array
  3268. * @param array defines the source array
  3269. * @param offset defines the offset in the source array
  3270. * @returns the new Vector3
  3271. */
  3272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3273. /**
  3274. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3275. * @param array defines the source array
  3276. * @param offset defines the offset in the source array
  3277. * @returns the new Vector3
  3278. * @deprecated Please use FromArray instead.
  3279. */
  3280. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3281. /**
  3282. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3283. * @param array defines the source array
  3284. * @param offset defines the offset in the source array
  3285. * @param result defines the Vector3 where to store the result
  3286. */
  3287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3288. /**
  3289. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3290. * @param array defines the source array
  3291. * @param offset defines the offset in the source array
  3292. * @param result defines the Vector3 where to store the result
  3293. * @deprecated Please use FromArrayToRef instead.
  3294. */
  3295. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3296. /**
  3297. * Sets the given vector "result" with the given floats.
  3298. * @param x defines the x coordinate of the source
  3299. * @param y defines the y coordinate of the source
  3300. * @param z defines the z coordinate of the source
  3301. * @param result defines the Vector3 where to store the result
  3302. */
  3303. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3304. /**
  3305. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3306. * @returns a new empty Vector3
  3307. */
  3308. static Zero(): Vector3;
  3309. /**
  3310. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3311. * @returns a new unit Vector3
  3312. */
  3313. static One(): Vector3;
  3314. /**
  3315. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3316. * @returns a new up Vector3
  3317. */
  3318. static Up(): Vector3;
  3319. /**
  3320. * Gets a up Vector3 that must not be updated
  3321. */
  3322. static get UpReadOnly(): DeepImmutable<Vector3>;
  3323. /**
  3324. * Gets a zero Vector3 that must not be updated
  3325. */
  3326. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3327. /**
  3328. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3329. * @returns a new down Vector3
  3330. */
  3331. static Down(): Vector3;
  3332. /**
  3333. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3334. * @param rightHandedSystem is the scene right-handed (negative z)
  3335. * @returns a new forward Vector3
  3336. */
  3337. static Forward(rightHandedSystem?: boolean): Vector3;
  3338. /**
  3339. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3340. * @param rightHandedSystem is the scene right-handed (negative-z)
  3341. * @returns a new forward Vector3
  3342. */
  3343. static Backward(rightHandedSystem?: boolean): Vector3;
  3344. /**
  3345. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3346. * @returns a new right Vector3
  3347. */
  3348. static Right(): Vector3;
  3349. /**
  3350. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3351. * @returns a new left Vector3
  3352. */
  3353. static Left(): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set 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. * @returns the transformed Vector3
  3360. */
  3361. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3362. /**
  3363. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3364. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3365. * @param vector defines the Vector3 to transform
  3366. * @param transformation defines the transformation matrix
  3367. * @param result defines the Vector3 where to store the result
  3368. */
  3369. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3370. /**
  3371. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3372. * This method computes tranformed coordinates only, not transformed direction vectors
  3373. * @param x define the x coordinate of the source vector
  3374. * @param y define the y coordinate of the source vector
  3375. * @param z define the z coordinate of the source vector
  3376. * @param transformation defines the transformation matrix
  3377. * @param result defines the Vector3 where to store the result
  3378. */
  3379. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3380. /**
  3381. * Returns a new Vector3 set 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. * @returns the new Vector3
  3386. */
  3387. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3388. /**
  3389. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3390. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3391. * @param vector defines the Vector3 to transform
  3392. * @param transformation defines the transformation matrix
  3393. * @param result defines the Vector3 where to store the result
  3394. */
  3395. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3396. /**
  3397. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3398. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3399. * @param x define the x coordinate of the source vector
  3400. * @param y define the y coordinate of the source vector
  3401. * @param z define the z coordinate of the source vector
  3402. * @param transformation defines the transformation matrix
  3403. * @param result defines the Vector3 where to store the result
  3404. */
  3405. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3406. /**
  3407. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3408. * @param value1 defines the first control point
  3409. * @param value2 defines the second control point
  3410. * @param value3 defines the third control point
  3411. * @param value4 defines the fourth control point
  3412. * @param amount defines the amount on the spline to use
  3413. * @returns the new Vector3
  3414. */
  3415. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3416. /**
  3417. * 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"
  3418. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3419. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3420. * @param value defines the current value
  3421. * @param min defines the lower range value
  3422. * @param max defines the upper range value
  3423. * @returns the new Vector3
  3424. */
  3425. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3426. /**
  3427. * 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"
  3428. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3429. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3430. * @param value defines the current value
  3431. * @param min defines the lower range value
  3432. * @param max defines the upper range value
  3433. * @param result defines the Vector3 where to store the result
  3434. */
  3435. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3436. /**
  3437. * Checks if a given vector is inside a specific range
  3438. * @param v defines the vector to test
  3439. * @param min defines the minimum range
  3440. * @param max defines the maximum range
  3441. */
  3442. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3443. /**
  3444. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3445. * @param value1 defines the first control point
  3446. * @param tangent1 defines the first tangent vector
  3447. * @param value2 defines the second control point
  3448. * @param tangent2 defines the second tangent vector
  3449. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3450. * @returns the new Vector3
  3451. */
  3452. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3453. /**
  3454. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "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. * @returns the new Vector3
  3459. */
  3460. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3461. /**
  3462. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3463. * @param start defines the start value
  3464. * @param end defines the end value
  3465. * @param amount max defines amount between both (between 0 and 1)
  3466. * @param result defines the Vector3 where to store the result
  3467. */
  3468. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3469. /**
  3470. * Returns the dot product (float) between the vectors "left" and "right"
  3471. * @param left defines the left operand
  3472. * @param right defines the right operand
  3473. * @returns the dot product
  3474. */
  3475. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3476. /**
  3477. * Returns a new Vector3 as the cross product of the vectors "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. * @returns the cross product
  3482. */
  3483. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3484. /**
  3485. * Sets the given vector "result" with the cross product of "left" and "right"
  3486. * The cross product is then orthogonal to both "left" and "right"
  3487. * @param left defines the left operand
  3488. * @param right defines the right operand
  3489. * @param result defines the Vector3 where to store the result
  3490. */
  3491. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3492. /**
  3493. * Returns a new Vector3 as the normalization of the given vector
  3494. * @param vector defines the Vector3 to normalize
  3495. * @returns the new Vector3
  3496. */
  3497. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3498. /**
  3499. * Sets the given vector "result" with the normalization of the given first vector
  3500. * @param vector defines the Vector3 to normalize
  3501. * @param result defines the Vector3 where to store the result
  3502. */
  3503. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3504. /**
  3505. * Project a Vector3 onto screen space
  3506. * @param vector defines the Vector3 to project
  3507. * @param world defines the world matrix to use
  3508. * @param transform defines the transform (view x projection) matrix to use
  3509. * @param viewport defines the screen viewport to use
  3510. * @returns the new Vector3
  3511. */
  3512. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3513. /**
  3514. * Project a Vector3 onto screen space to reference
  3515. * @param vector defines the Vector3 to project
  3516. * @param world defines the world matrix to use
  3517. * @param transform defines the transform (view x projection) matrix to use
  3518. * @param viewport defines the screen viewport to use
  3519. * @param result the vector in which the screen space will be stored
  3520. * @returns the new Vector3
  3521. */
  3522. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3523. /** @hidden */
  3524. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3525. /**
  3526. * Unproject from screen space to object space
  3527. * @param source defines the screen space Vector3 to use
  3528. * @param viewportWidth defines the current width of the viewport
  3529. * @param viewportHeight defines the current height of the viewport
  3530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3531. * @param transform defines the transform (view x projection) matrix to use
  3532. * @returns the new Vector3
  3533. */
  3534. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3535. /**
  3536. * Unproject from screen space to object space
  3537. * @param source defines the screen space Vector3 to use
  3538. * @param viewportWidth defines the current width of the viewport
  3539. * @param viewportHeight defines the current height of the viewport
  3540. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3541. * @param view defines the view matrix to use
  3542. * @param projection defines the projection matrix to use
  3543. * @returns the new Vector3
  3544. */
  3545. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3546. /**
  3547. * Unproject from screen space to object space
  3548. * @param source defines the screen space Vector3 to use
  3549. * @param viewportWidth defines the current width of the viewport
  3550. * @param viewportHeight defines the current height of the viewport
  3551. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3552. * @param view defines the view matrix to use
  3553. * @param projection defines the projection matrix to use
  3554. * @param result defines the Vector3 where to store the result
  3555. */
  3556. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3557. /**
  3558. * Unproject from screen space to object space
  3559. * @param sourceX defines the screen space x coordinate to use
  3560. * @param sourceY defines the screen space y coordinate to use
  3561. * @param sourceZ defines the screen space z coordinate to use
  3562. * @param viewportWidth defines the current width of the viewport
  3563. * @param viewportHeight defines the current height of the viewport
  3564. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3565. * @param view defines the view matrix to use
  3566. * @param projection defines the projection matrix to use
  3567. * @param result defines the Vector3 where to store the result
  3568. */
  3569. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3570. /**
  3571. * Gets the minimal coordinate values between two Vector3
  3572. * @param left defines the first operand
  3573. * @param right defines the second operand
  3574. * @returns the new Vector3
  3575. */
  3576. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3577. /**
  3578. * Gets the maximal coordinate values between two Vector3
  3579. * @param left defines the first operand
  3580. * @param right defines the second operand
  3581. * @returns the new Vector3
  3582. */
  3583. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3584. /**
  3585. * Returns the distance between the vectors "value1" and "value2"
  3586. * @param value1 defines the first operand
  3587. * @param value2 defines the second operand
  3588. * @returns the distance
  3589. */
  3590. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3591. /**
  3592. * Returns the squared distance between the vectors "value1" and "value2"
  3593. * @param value1 defines the first operand
  3594. * @param value2 defines the second operand
  3595. * @returns the squared distance
  3596. */
  3597. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3598. /**
  3599. * Returns a new Vector3 located at the center between "value1" and "value2"
  3600. * @param value1 defines the first operand
  3601. * @param value2 defines the second operand
  3602. * @returns the new Vector3
  3603. */
  3604. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3605. /**
  3606. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3607. * @param value1 defines first vector
  3608. * @param value2 defines second vector
  3609. * @param ref defines third vector
  3610. * @returns ref
  3611. */
  3612. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3613. /**
  3614. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3615. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3616. * to something in order to rotate it from its local system to the given target system
  3617. * Note: axis1, axis2 and axis3 are normalized during this operation
  3618. * @param axis1 defines the first axis
  3619. * @param axis2 defines the second axis
  3620. * @param axis3 defines the third axis
  3621. * @returns a new Vector3
  3622. */
  3623. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3624. /**
  3625. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3626. * @param axis1 defines the first axis
  3627. * @param axis2 defines the second axis
  3628. * @param axis3 defines the third axis
  3629. * @param ref defines the Vector3 where to store the result
  3630. */
  3631. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3632. }
  3633. /**
  3634. * Vector4 class created for EulerAngle class conversion to Quaternion
  3635. */
  3636. export class Vector4 {
  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. * Creates a Vector4 object from the given floats.
  3647. * @param x x value of the vector
  3648. * @param y y value of the vector
  3649. * @param z z value of the vector
  3650. * @param w w value of the vector
  3651. */
  3652. constructor(
  3653. /** x value of the vector */
  3654. x: number,
  3655. /** y value of the vector */
  3656. y: number,
  3657. /** z value of the vector */
  3658. z: number,
  3659. /** w value of the vector */
  3660. w: number);
  3661. /**
  3662. * Returns the string with the Vector4 coordinates.
  3663. * @returns a string containing all the vector values
  3664. */
  3665. toString(): string;
  3666. /**
  3667. * Returns the string "Vector4".
  3668. * @returns "Vector4"
  3669. */
  3670. getClassName(): string;
  3671. /**
  3672. * Returns the Vector4 hash code.
  3673. * @returns a unique hash code
  3674. */
  3675. getHashCode(): number;
  3676. /**
  3677. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3678. * @returns the resulting array
  3679. */
  3680. asArray(): number[];
  3681. /**
  3682. * Populates the given array from the given index with the Vector4 coordinates.
  3683. * @param array array to populate
  3684. * @param index index of the array to start at (default: 0)
  3685. * @returns the Vector4.
  3686. */
  3687. toArray(array: FloatArray, index?: number): Vector4;
  3688. /**
  3689. * Update the current vector from an array
  3690. * @param array defines the destination array
  3691. * @param index defines the offset in the destination array
  3692. * @returns the current Vector3
  3693. */
  3694. fromArray(array: FloatArray, index?: number): Vector4;
  3695. /**
  3696. * Adds the given vector to the current Vector4.
  3697. * @param otherVector the vector to add
  3698. * @returns the updated Vector4.
  3699. */
  3700. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3701. /**
  3702. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3703. * @param otherVector the vector to add
  3704. * @returns the resulting vector
  3705. */
  3706. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3707. /**
  3708. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3709. * @param otherVector the vector to add
  3710. * @param result the vector to store the result
  3711. * @returns the current Vector4.
  3712. */
  3713. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3714. /**
  3715. * Subtract in place the given vector from the current Vector4.
  3716. * @param otherVector the vector to subtract
  3717. * @returns the updated Vector4.
  3718. */
  3719. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3720. /**
  3721. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3722. * @param otherVector the vector to add
  3723. * @returns the new vector with the result
  3724. */
  3725. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3726. /**
  3727. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3728. * @param otherVector the vector to subtract
  3729. * @param result the vector to store the result
  3730. * @returns the current Vector4.
  3731. */
  3732. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3733. /**
  3734. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3735. */
  3736. /**
  3737. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3738. * @param x value to subtract
  3739. * @param y value to subtract
  3740. * @param z value to subtract
  3741. * @param w value to subtract
  3742. * @returns new vector containing the result
  3743. */
  3744. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3745. /**
  3746. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3747. * @param x value to subtract
  3748. * @param y value to subtract
  3749. * @param z value to subtract
  3750. * @param w value to subtract
  3751. * @param result the vector to store the result in
  3752. * @returns the current Vector4.
  3753. */
  3754. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3755. /**
  3756. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3757. * @returns a new vector with the negated values
  3758. */
  3759. negate(): Vector4;
  3760. /**
  3761. * Negate this vector in place
  3762. * @returns this
  3763. */
  3764. negateInPlace(): Vector4;
  3765. /**
  3766. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3767. * @param result defines the Vector3 object where to store the result
  3768. * @returns the current Vector4
  3769. */
  3770. negateToRef(result: Vector4): Vector4;
  3771. /**
  3772. * Multiplies the current Vector4 coordinates by scale (float).
  3773. * @param scale the number to scale with
  3774. * @returns the updated Vector4.
  3775. */
  3776. scaleInPlace(scale: number): Vector4;
  3777. /**
  3778. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3779. * @param scale the number to scale with
  3780. * @returns a new vector with the result
  3781. */
  3782. scale(scale: number): Vector4;
  3783. /**
  3784. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3785. * @param scale the number to scale with
  3786. * @param result a vector to store the result in
  3787. * @returns the current Vector4.
  3788. */
  3789. scaleToRef(scale: number, result: Vector4): Vector4;
  3790. /**
  3791. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3792. * @param scale defines the scale factor
  3793. * @param result defines the Vector4 object where to store the result
  3794. * @returns the unmodified current Vector4
  3795. */
  3796. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3797. /**
  3798. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3799. * @param otherVector the vector to compare against
  3800. * @returns true if they are equal
  3801. */
  3802. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3803. /**
  3804. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3805. * @param otherVector vector to compare against
  3806. * @param epsilon (Default: very small number)
  3807. * @returns true if they are equal
  3808. */
  3809. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3810. /**
  3811. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3812. * @param x x value to compare against
  3813. * @param y y value to compare against
  3814. * @param z z value to compare against
  3815. * @param w w value to compare against
  3816. * @returns true if equal
  3817. */
  3818. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3819. /**
  3820. * Multiplies in place the current Vector4 by the given one.
  3821. * @param otherVector vector to multiple with
  3822. * @returns the updated Vector4.
  3823. */
  3824. multiplyInPlace(otherVector: Vector4): Vector4;
  3825. /**
  3826. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3827. * @param otherVector vector to multiple with
  3828. * @returns resulting new vector
  3829. */
  3830. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3831. /**
  3832. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3833. * @param otherVector vector to multiple with
  3834. * @param result vector to store the result
  3835. * @returns the current Vector4.
  3836. */
  3837. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3838. /**
  3839. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3840. * @param x x value multiply with
  3841. * @param y y value multiply with
  3842. * @param z z value multiply with
  3843. * @param w w value multiply with
  3844. * @returns resulting new vector
  3845. */
  3846. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3847. /**
  3848. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3849. * @param otherVector vector to devide with
  3850. * @returns resulting new vector
  3851. */
  3852. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3853. /**
  3854. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3855. * @param otherVector vector to devide with
  3856. * @param result vector to store the result
  3857. * @returns the current Vector4.
  3858. */
  3859. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3860. /**
  3861. * Divides the current Vector3 coordinates by the given ones.
  3862. * @param otherVector vector to devide with
  3863. * @returns the updated Vector3.
  3864. */
  3865. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3866. /**
  3867. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3868. * @param other defines the second operand
  3869. * @returns the current updated Vector4
  3870. */
  3871. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3872. /**
  3873. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3874. * @param other defines the second operand
  3875. * @returns the current updated Vector4
  3876. */
  3877. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3878. /**
  3879. * Gets a new Vector4 from current Vector4 floored values
  3880. * @returns a new Vector4
  3881. */
  3882. floor(): Vector4;
  3883. /**
  3884. * Gets a new Vector4 from current Vector3 floored values
  3885. * @returns a new Vector4
  3886. */
  3887. fract(): Vector4;
  3888. /**
  3889. * Returns the Vector4 length (float).
  3890. * @returns the length
  3891. */
  3892. length(): number;
  3893. /**
  3894. * Returns the Vector4 squared length (float).
  3895. * @returns the length squared
  3896. */
  3897. lengthSquared(): number;
  3898. /**
  3899. * Normalizes in place the Vector4.
  3900. * @returns the updated Vector4.
  3901. */
  3902. normalize(): Vector4;
  3903. /**
  3904. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3905. * @returns this converted to a new vector3
  3906. */
  3907. toVector3(): Vector3;
  3908. /**
  3909. * Returns a new Vector4 copied from the current one.
  3910. * @returns the new cloned vector
  3911. */
  3912. clone(): Vector4;
  3913. /**
  3914. * Updates the current Vector4 with the given one coordinates.
  3915. * @param source the source vector to copy from
  3916. * @returns the updated Vector4.
  3917. */
  3918. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3919. /**
  3920. * Updates the current Vector4 coordinates with the given floats.
  3921. * @param x float to copy from
  3922. * @param y float to copy from
  3923. * @param z float to copy from
  3924. * @param w float to copy from
  3925. * @returns the updated Vector4.
  3926. */
  3927. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3928. /**
  3929. * Updates the current Vector4 coordinates with the given floats.
  3930. * @param x float to set from
  3931. * @param y float to set from
  3932. * @param z float to set from
  3933. * @param w float to set from
  3934. * @returns the updated Vector4.
  3935. */
  3936. set(x: number, y: number, z: number, w: number): Vector4;
  3937. /**
  3938. * Copies the given float to the current Vector3 coordinates
  3939. * @param v defines the x, y, z and w coordinates of the operand
  3940. * @returns the current updated Vector3
  3941. */
  3942. setAll(v: number): Vector4;
  3943. /**
  3944. * Returns a new Vector4 set from the starting index of the given array.
  3945. * @param array the array to pull values from
  3946. * @param offset the offset into the array to start at
  3947. * @returns the new vector
  3948. */
  3949. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3950. /**
  3951. * Updates the given vector "result" from the starting index of the given array.
  3952. * @param array the array to pull values from
  3953. * @param offset the offset into the array to start at
  3954. * @param result the vector to store the result in
  3955. */
  3956. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3957. /**
  3958. * Updates the given vector "result" from the starting index of the given Float32Array.
  3959. * @param array the array to pull values from
  3960. * @param offset the offset into the array to start at
  3961. * @param result the vector to store the result in
  3962. */
  3963. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3964. /**
  3965. * Updates the given vector "result" coordinates from the given floats.
  3966. * @param x float to set from
  3967. * @param y float to set from
  3968. * @param z float to set from
  3969. * @param w float to set from
  3970. * @param result the vector to the floats in
  3971. */
  3972. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3973. /**
  3974. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3975. * @returns the new vector
  3976. */
  3977. static Zero(): Vector4;
  3978. /**
  3979. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3980. * @returns the new vector
  3981. */
  3982. static One(): Vector4;
  3983. /**
  3984. * Returns a new normalized Vector4 from the given one.
  3985. * @param vector the vector to normalize
  3986. * @returns the vector
  3987. */
  3988. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3989. /**
  3990. * Updates the given vector "result" from the normalization of the given one.
  3991. * @param vector the vector to normalize
  3992. * @param result the vector to store the result in
  3993. */
  3994. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3995. /**
  3996. * Returns a vector with the minimum values from the left and right vectors
  3997. * @param left left vector to minimize
  3998. * @param right right vector to minimize
  3999. * @returns a new vector with the minimum of the left and right vector values
  4000. */
  4001. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4002. /**
  4003. * Returns a vector with the maximum values from the left and right vectors
  4004. * @param left left vector to maximize
  4005. * @param right right vector to maximize
  4006. * @returns a new vector with the maximum of the left and right vector values
  4007. */
  4008. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4009. /**
  4010. * Returns the distance (float) between the vectors "value1" and "value2".
  4011. * @param value1 value to calulate the distance between
  4012. * @param value2 value to calulate the distance between
  4013. * @return the distance between the two vectors
  4014. */
  4015. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4016. /**
  4017. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4018. * @param value1 value to calulate the distance between
  4019. * @param value2 value to calulate the distance between
  4020. * @return the distance between the two vectors squared
  4021. */
  4022. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4023. /**
  4024. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4025. * @param value1 value to calulate the center between
  4026. * @param value2 value to calulate the center between
  4027. * @return the center between the two vectors
  4028. */
  4029. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4030. /**
  4031. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4032. * @param value1 defines first vector
  4033. * @param value2 defines second vector
  4034. * @param ref defines third vector
  4035. * @returns ref
  4036. */
  4037. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4038. /**
  4039. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4040. * This methods computes transformed normalized direction vectors only.
  4041. * @param vector the vector to transform
  4042. * @param transformation the transformation matrix to apply
  4043. * @returns the new vector
  4044. */
  4045. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4046. /**
  4047. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4048. * This methods computes transformed normalized direction vectors only.
  4049. * @param vector the vector to transform
  4050. * @param transformation the transformation matrix to apply
  4051. * @param result the vector to store the result in
  4052. */
  4053. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4054. /**
  4055. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4056. * This methods computes transformed normalized direction vectors only.
  4057. * @param x value to transform
  4058. * @param y value to transform
  4059. * @param z value to transform
  4060. * @param w value to transform
  4061. * @param transformation the transformation matrix to apply
  4062. * @param result the vector to store the results in
  4063. */
  4064. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4065. /**
  4066. * Creates a new Vector4 from a Vector3
  4067. * @param source defines the source data
  4068. * @param w defines the 4th component (default is 0)
  4069. * @returns a new Vector4
  4070. */
  4071. static FromVector3(source: Vector3, w?: number): Vector4;
  4072. }
  4073. /**
  4074. * Class used to store quaternion data
  4075. * @see https://en.wikipedia.org/wiki/Quaternion
  4076. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4077. */
  4078. export class Quaternion {
  4079. /** @hidden */
  4080. _x: number;
  4081. /** @hidden */
  4082. _y: number;
  4083. /** @hidden */
  4084. _z: number;
  4085. /** @hidden */
  4086. _w: number;
  4087. /** @hidden */
  4088. _isDirty: boolean;
  4089. /** Gets or sets the x coordinate */
  4090. get x(): number;
  4091. set x(value: number);
  4092. /** Gets or sets the y coordinate */
  4093. get y(): number;
  4094. set y(value: number);
  4095. /** Gets or sets the z coordinate */
  4096. get z(): number;
  4097. set z(value: number);
  4098. /** Gets or sets the w coordinate */
  4099. get w(): number;
  4100. set w(value: number);
  4101. /**
  4102. * Creates a new Quaternion from the given floats
  4103. * @param x defines the first component (0 by default)
  4104. * @param y defines the second component (0 by default)
  4105. * @param z defines the third component (0 by default)
  4106. * @param w defines the fourth component (1.0 by default)
  4107. */
  4108. constructor(x?: number, y?: number, z?: number, w?: number);
  4109. /**
  4110. * Gets a string representation for the current quaternion
  4111. * @returns a string with the Quaternion coordinates
  4112. */
  4113. toString(): string;
  4114. /**
  4115. * Gets the class name of the quaternion
  4116. * @returns the string "Quaternion"
  4117. */
  4118. getClassName(): string;
  4119. /**
  4120. * Gets a hash code for this quaternion
  4121. * @returns the quaternion hash code
  4122. */
  4123. getHashCode(): number;
  4124. /**
  4125. * Copy the quaternion to an array
  4126. * @returns a new array populated with 4 elements from the quaternion coordinates
  4127. */
  4128. asArray(): number[];
  4129. /**
  4130. * Check if two quaternions are equals
  4131. * @param otherQuaternion defines the second operand
  4132. * @return true if the current quaternion and the given one coordinates are strictly equals
  4133. */
  4134. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4135. /**
  4136. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4137. * @param otherQuaternion defines the other quaternion
  4138. * @param epsilon defines the minimal distance to consider equality
  4139. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4140. */
  4141. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4142. /**
  4143. * Clone the current quaternion
  4144. * @returns a new quaternion copied from the current one
  4145. */
  4146. clone(): Quaternion;
  4147. /**
  4148. * Copy a quaternion to the current one
  4149. * @param other defines the other quaternion
  4150. * @returns the updated current quaternion
  4151. */
  4152. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4153. /**
  4154. * Updates the current quaternion with the given float coordinates
  4155. * @param x defines the x coordinate
  4156. * @param y defines the y coordinate
  4157. * @param z defines the z coordinate
  4158. * @param w defines the w coordinate
  4159. * @returns the updated current quaternion
  4160. */
  4161. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4162. /**
  4163. * Updates the current quaternion from the given float coordinates
  4164. * @param x defines the x coordinate
  4165. * @param y defines the y coordinate
  4166. * @param z defines the z coordinate
  4167. * @param w defines the w coordinate
  4168. * @returns the updated current quaternion
  4169. */
  4170. set(x: number, y: number, z: number, w: number): Quaternion;
  4171. /**
  4172. * Adds two quaternions
  4173. * @param other defines the second operand
  4174. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4175. */
  4176. add(other: DeepImmutable<Quaternion>): Quaternion;
  4177. /**
  4178. * Add a quaternion to the current one
  4179. * @param other defines the quaternion to add
  4180. * @returns the current quaternion
  4181. */
  4182. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4183. /**
  4184. * Subtract two quaternions
  4185. * @param other defines the second operand
  4186. * @returns a new quaternion as the subtraction result of the given one from the current one
  4187. */
  4188. subtract(other: Quaternion): Quaternion;
  4189. /**
  4190. * Multiplies the current quaternion by a scale factor
  4191. * @param value defines the scale factor
  4192. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4193. */
  4194. scale(value: number): Quaternion;
  4195. /**
  4196. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4197. * @param scale defines the scale factor
  4198. * @param result defines the Quaternion object where to store the result
  4199. * @returns the unmodified current quaternion
  4200. */
  4201. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4202. /**
  4203. * Multiplies in place the current quaternion by a scale factor
  4204. * @param value defines the scale factor
  4205. * @returns the current modified quaternion
  4206. */
  4207. scaleInPlace(value: number): Quaternion;
  4208. /**
  4209. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4210. * @param scale defines the scale factor
  4211. * @param result defines the Quaternion object where to store the result
  4212. * @returns the unmodified current quaternion
  4213. */
  4214. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4215. /**
  4216. * Multiplies two quaternions
  4217. * @param q1 defines the second operand
  4218. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4219. */
  4220. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4221. /**
  4222. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4223. * @param q1 defines the second operand
  4224. * @param result defines the target quaternion
  4225. * @returns the current quaternion
  4226. */
  4227. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4228. /**
  4229. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4230. * @param q1 defines the second operand
  4231. * @returns the currentupdated quaternion
  4232. */
  4233. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4234. /**
  4235. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4236. * @param ref defines the target quaternion
  4237. * @returns the current quaternion
  4238. */
  4239. conjugateToRef(ref: Quaternion): Quaternion;
  4240. /**
  4241. * Conjugates in place (1-q) the current quaternion
  4242. * @returns the current updated quaternion
  4243. */
  4244. conjugateInPlace(): Quaternion;
  4245. /**
  4246. * Conjugates in place (1-q) the current quaternion
  4247. * @returns a new quaternion
  4248. */
  4249. conjugate(): Quaternion;
  4250. /**
  4251. * Gets length of current quaternion
  4252. * @returns the quaternion length (float)
  4253. */
  4254. length(): number;
  4255. /**
  4256. * Normalize in place the current quaternion
  4257. * @returns the current updated quaternion
  4258. */
  4259. normalize(): Quaternion;
  4260. /**
  4261. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4262. * @param order is a reserved parameter and is ignored for now
  4263. * @returns a new Vector3 containing the Euler angles
  4264. */
  4265. toEulerAngles(order?: string): Vector3;
  4266. /**
  4267. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4268. * @param result defines the vector which will be filled with the Euler angles
  4269. * @returns the current unchanged quaternion
  4270. */
  4271. toEulerAnglesToRef(result: Vector3): Quaternion;
  4272. /**
  4273. * Updates the given rotation matrix with the current quaternion values
  4274. * @param result defines the target matrix
  4275. * @returns the current unchanged quaternion
  4276. */
  4277. toRotationMatrix(result: Matrix): Quaternion;
  4278. /**
  4279. * Updates the current quaternion from the given rotation matrix values
  4280. * @param matrix defines the source matrix
  4281. * @returns the current updated quaternion
  4282. */
  4283. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4284. /**
  4285. * Creates a new quaternion from a rotation matrix
  4286. * @param matrix defines the source matrix
  4287. * @returns a new quaternion created from the given rotation matrix values
  4288. */
  4289. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4290. /**
  4291. * Updates the given quaternion with the given rotation matrix values
  4292. * @param matrix defines the source matrix
  4293. * @param result defines the target quaternion
  4294. */
  4295. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4296. /**
  4297. * Returns the dot product (float) between the quaternions "left" and "right"
  4298. * @param left defines the left operand
  4299. * @param right defines the right operand
  4300. * @returns the dot product
  4301. */
  4302. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4303. /**
  4304. * Checks if the two quaternions are close to each other
  4305. * @param quat0 defines the first quaternion to check
  4306. * @param quat1 defines the second quaternion to check
  4307. * @returns true if the two quaternions are close to each other
  4308. */
  4309. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4310. /**
  4311. * Creates an empty quaternion
  4312. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4313. */
  4314. static Zero(): Quaternion;
  4315. /**
  4316. * Inverse a given quaternion
  4317. * @param q defines the source quaternion
  4318. * @returns a new quaternion as the inverted current quaternion
  4319. */
  4320. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4321. /**
  4322. * Inverse a given quaternion
  4323. * @param q defines the source quaternion
  4324. * @param result the quaternion the result will be stored in
  4325. * @returns the result quaternion
  4326. */
  4327. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4328. /**
  4329. * Creates an identity quaternion
  4330. * @returns the identity quaternion
  4331. */
  4332. static Identity(): Quaternion;
  4333. /**
  4334. * Gets a boolean indicating if the given quaternion is identity
  4335. * @param quaternion defines the quaternion to check
  4336. * @returns true if the quaternion is identity
  4337. */
  4338. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4339. /**
  4340. * Creates a quaternion from a rotation around an axis
  4341. * @param axis defines the axis to use
  4342. * @param angle defines the angle to use
  4343. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4344. */
  4345. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4346. /**
  4347. * Creates a rotation around an axis and stores it into the given quaternion
  4348. * @param axis defines the axis to use
  4349. * @param angle defines the angle to use
  4350. * @param result defines the target quaternion
  4351. * @returns the target quaternion
  4352. */
  4353. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4354. /**
  4355. * Creates a new quaternion from data stored into an array
  4356. * @param array defines the data source
  4357. * @param offset defines the offset in the source array where the data starts
  4358. * @returns a new quaternion
  4359. */
  4360. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4361. /**
  4362. * Updates the given quaternion "result" from the starting index of the given array.
  4363. * @param array the array to pull values from
  4364. * @param offset the offset into the array to start at
  4365. * @param result the quaternion to store the result in
  4366. */
  4367. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4368. /**
  4369. * Create a quaternion from Euler rotation angles
  4370. * @param x Pitch
  4371. * @param y Yaw
  4372. * @param z Roll
  4373. * @returns the new Quaternion
  4374. */
  4375. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4376. /**
  4377. * Updates a quaternion from Euler rotation angles
  4378. * @param x Pitch
  4379. * @param y Yaw
  4380. * @param z Roll
  4381. * @param result the quaternion to store the result
  4382. * @returns the updated quaternion
  4383. */
  4384. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4385. /**
  4386. * Create a quaternion from Euler rotation vector
  4387. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4388. * @returns the new Quaternion
  4389. */
  4390. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4391. /**
  4392. * Updates a quaternion from Euler rotation vector
  4393. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4394. * @param result the quaternion to store the result
  4395. * @returns the updated quaternion
  4396. */
  4397. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4398. /**
  4399. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4400. * @param yaw defines the rotation around Y axis
  4401. * @param pitch defines the rotation around X axis
  4402. * @param roll defines the rotation around Z axis
  4403. * @returns the new quaternion
  4404. */
  4405. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4406. /**
  4407. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4408. * @param yaw defines the rotation around Y axis
  4409. * @param pitch defines the rotation around X axis
  4410. * @param roll defines the rotation around Z axis
  4411. * @param result defines the target quaternion
  4412. */
  4413. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4414. /**
  4415. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4416. * @param alpha defines the rotation around first axis
  4417. * @param beta defines the rotation around second axis
  4418. * @param gamma defines the rotation around third axis
  4419. * @returns the new quaternion
  4420. */
  4421. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4422. /**
  4423. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4424. * @param alpha defines the rotation around first axis
  4425. * @param beta defines the rotation around second axis
  4426. * @param gamma defines the rotation around third axis
  4427. * @param result defines the target quaternion
  4428. */
  4429. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4430. /**
  4431. * 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)
  4432. * @param axis1 defines the first axis
  4433. * @param axis2 defines the second axis
  4434. * @param axis3 defines the third axis
  4435. * @returns the new quaternion
  4436. */
  4437. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4438. /**
  4439. * 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
  4440. * @param axis1 defines the first axis
  4441. * @param axis2 defines the second axis
  4442. * @param axis3 defines the third axis
  4443. * @param ref defines the target quaternion
  4444. */
  4445. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4446. /**
  4447. * Interpolates between two quaternions
  4448. * @param left defines first quaternion
  4449. * @param right defines second quaternion
  4450. * @param amount defines the gradient to use
  4451. * @returns the new interpolated quaternion
  4452. */
  4453. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4454. /**
  4455. * Interpolates between two quaternions and stores it into a target quaternion
  4456. * @param left defines first quaternion
  4457. * @param right defines second quaternion
  4458. * @param amount defines the gradient to use
  4459. * @param result defines the target quaternion
  4460. */
  4461. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4462. /**
  4463. * Interpolate between two quaternions using Hermite interpolation
  4464. * @param value1 defines first quaternion
  4465. * @param tangent1 defines the incoming tangent
  4466. * @param value2 defines second quaternion
  4467. * @param tangent2 defines the outgoing tangent
  4468. * @param amount defines the target quaternion
  4469. * @returns the new interpolated quaternion
  4470. */
  4471. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4472. }
  4473. /**
  4474. * Class used to store matrix data (4x4)
  4475. */
  4476. export class Matrix {
  4477. /**
  4478. * Gets the precision of matrix computations
  4479. */
  4480. static get Use64Bits(): boolean;
  4481. private static _updateFlagSeed;
  4482. private static _identityReadOnly;
  4483. private _isIdentity;
  4484. private _isIdentityDirty;
  4485. private _isIdentity3x2;
  4486. private _isIdentity3x2Dirty;
  4487. /**
  4488. * Gets the update flag of the matrix which is an unique number for the matrix.
  4489. * It will be incremented every time the matrix data change.
  4490. * You can use it to speed the comparison between two versions of the same matrix.
  4491. */
  4492. updateFlag: number;
  4493. private readonly _m;
  4494. /**
  4495. * Gets the internal data of the matrix
  4496. */
  4497. get m(): DeepImmutable<Float32Array | Array<number>>;
  4498. /** @hidden */
  4499. _markAsUpdated(): void;
  4500. /** @hidden */
  4501. private _updateIdentityStatus;
  4502. /**
  4503. * Creates an empty matrix (filled with zeros)
  4504. */
  4505. constructor();
  4506. /**
  4507. * Check if the current matrix is identity
  4508. * @returns true is the matrix is the identity matrix
  4509. */
  4510. isIdentity(): boolean;
  4511. /**
  4512. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4513. * @returns true is the matrix is the identity matrix
  4514. */
  4515. isIdentityAs3x2(): boolean;
  4516. /**
  4517. * Gets the determinant of the matrix
  4518. * @returns the matrix determinant
  4519. */
  4520. determinant(): number;
  4521. /**
  4522. * Returns the matrix as a Float32Array or Array<number>
  4523. * @returns the matrix underlying array
  4524. */
  4525. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4526. /**
  4527. * Returns the matrix as a Float32Array or Array<number>
  4528. * @returns the matrix underlying array.
  4529. */
  4530. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4531. /**
  4532. * Inverts the current matrix in place
  4533. * @returns the current inverted matrix
  4534. */
  4535. invert(): Matrix;
  4536. /**
  4537. * Sets all the matrix elements to zero
  4538. * @returns the current matrix
  4539. */
  4540. reset(): Matrix;
  4541. /**
  4542. * Adds the current matrix with a second one
  4543. * @param other defines the matrix to add
  4544. * @returns a new matrix as the addition of the current matrix and the given one
  4545. */
  4546. add(other: DeepImmutable<Matrix>): Matrix;
  4547. /**
  4548. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4549. * @param other defines the matrix to add
  4550. * @param result defines the target matrix
  4551. * @returns the current matrix
  4552. */
  4553. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4554. /**
  4555. * Adds in place the given matrix to the current matrix
  4556. * @param other defines the second operand
  4557. * @returns the current updated matrix
  4558. */
  4559. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4560. /**
  4561. * Sets the given matrix to the current inverted Matrix
  4562. * @param other defines the target matrix
  4563. * @returns the unmodified current matrix
  4564. */
  4565. invertToRef(other: Matrix): Matrix;
  4566. /**
  4567. * add a value at the specified position in the current Matrix
  4568. * @param index the index of the value within the matrix. between 0 and 15.
  4569. * @param value the value to be added
  4570. * @returns the current updated matrix
  4571. */
  4572. addAtIndex(index: number, value: number): Matrix;
  4573. /**
  4574. * mutiply the specified position in the current Matrix by a value
  4575. * @param index the index of the value within the matrix. between 0 and 15.
  4576. * @param value the value to be added
  4577. * @returns the current updated matrix
  4578. */
  4579. multiplyAtIndex(index: number, value: number): Matrix;
  4580. /**
  4581. * Inserts the translation vector (using 3 floats) in the current matrix
  4582. * @param x defines the 1st component of the translation
  4583. * @param y defines the 2nd component of the translation
  4584. * @param z defines the 3rd component of the translation
  4585. * @returns the current updated matrix
  4586. */
  4587. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4588. /**
  4589. * Adds the translation vector (using 3 floats) in the current matrix
  4590. * @param x defines the 1st component of the translation
  4591. * @param y defines the 2nd component of the translation
  4592. * @param z defines the 3rd component of the translation
  4593. * @returns the current updated matrix
  4594. */
  4595. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4596. /**
  4597. * Inserts the translation vector in the current matrix
  4598. * @param vector3 defines the translation to insert
  4599. * @returns the current updated matrix
  4600. */
  4601. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4602. /**
  4603. * Gets the translation value of the current matrix
  4604. * @returns a new Vector3 as the extracted translation from the matrix
  4605. */
  4606. getTranslation(): Vector3;
  4607. /**
  4608. * Fill a Vector3 with the extracted translation from the matrix
  4609. * @param result defines the Vector3 where to store the translation
  4610. * @returns the current matrix
  4611. */
  4612. getTranslationToRef(result: Vector3): Matrix;
  4613. /**
  4614. * Remove rotation and scaling part from the matrix
  4615. * @returns the updated matrix
  4616. */
  4617. removeRotationAndScaling(): Matrix;
  4618. /**
  4619. * Multiply two matrices
  4620. * @param other defines the second operand
  4621. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4622. */
  4623. multiply(other: DeepImmutable<Matrix>): Matrix;
  4624. /**
  4625. * Copy the current matrix from the given one
  4626. * @param other defines the source matrix
  4627. * @returns the current updated matrix
  4628. */
  4629. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4630. /**
  4631. * Populates the given array from the starting index with the current matrix values
  4632. * @param array defines the target array
  4633. * @param offset defines the offset in the target array where to start storing values
  4634. * @returns the current matrix
  4635. */
  4636. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4637. /**
  4638. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4639. * @param other defines the second operand
  4640. * @param result defines the matrix where to store the multiplication
  4641. * @returns the current matrix
  4642. */
  4643. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4644. /**
  4645. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4646. * @param other defines the second operand
  4647. * @param result defines the array where to store the multiplication
  4648. * @param offset defines the offset in the target array where to start storing values
  4649. * @returns the current matrix
  4650. */
  4651. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4652. /**
  4653. * Check equality between this matrix and a second one
  4654. * @param value defines the second matrix to compare
  4655. * @returns true is the current matrix and the given one values are strictly equal
  4656. */
  4657. equals(value: DeepImmutable<Matrix>): boolean;
  4658. /**
  4659. * Clone the current matrix
  4660. * @returns a new matrix from the current matrix
  4661. */
  4662. clone(): Matrix;
  4663. /**
  4664. * Returns the name of the current matrix class
  4665. * @returns the string "Matrix"
  4666. */
  4667. getClassName(): string;
  4668. /**
  4669. * Gets the hash code of the current matrix
  4670. * @returns the hash code
  4671. */
  4672. getHashCode(): number;
  4673. /**
  4674. * Decomposes the current Matrix into a translation, rotation and scaling components
  4675. * @param scale defines the scale vector3 given as a reference to update
  4676. * @param rotation defines the rotation quaternion given as a reference to update
  4677. * @param translation defines the translation vector3 given as a reference to update
  4678. * @returns true if operation was successful
  4679. */
  4680. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4681. /**
  4682. * Gets specific row of the matrix
  4683. * @param index defines the number of the row to get
  4684. * @returns the index-th row of the current matrix as a new Vector4
  4685. */
  4686. getRow(index: number): Nullable<Vector4>;
  4687. /**
  4688. * Sets the index-th row of the current matrix to the vector4 values
  4689. * @param index defines the number of the row to set
  4690. * @param row defines the target vector4
  4691. * @returns the updated current matrix
  4692. */
  4693. setRow(index: number, row: Vector4): Matrix;
  4694. /**
  4695. * Compute the transpose of the matrix
  4696. * @returns the new transposed matrix
  4697. */
  4698. transpose(): Matrix;
  4699. /**
  4700. * Compute the transpose of the matrix and store it in a given matrix
  4701. * @param result defines the target matrix
  4702. * @returns the current matrix
  4703. */
  4704. transposeToRef(result: Matrix): Matrix;
  4705. /**
  4706. * Sets the index-th row of the current matrix with the given 4 x float values
  4707. * @param index defines the row index
  4708. * @param x defines the x component to set
  4709. * @param y defines the y component to set
  4710. * @param z defines the z component to set
  4711. * @param w defines the w component to set
  4712. * @returns the updated current matrix
  4713. */
  4714. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4715. /**
  4716. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4717. * @param scale defines the scale factor
  4718. * @returns a new matrix
  4719. */
  4720. scale(scale: number): Matrix;
  4721. /**
  4722. * Scale the current matrix values by a factor to a given result matrix
  4723. * @param scale defines the scale factor
  4724. * @param result defines the matrix to store the result
  4725. * @returns the current matrix
  4726. */
  4727. scaleToRef(scale: number, result: Matrix): Matrix;
  4728. /**
  4729. * Scale the current matrix values by a factor and add the result to a given matrix
  4730. * @param scale defines the scale factor
  4731. * @param result defines the Matrix to store the result
  4732. * @returns the current matrix
  4733. */
  4734. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4735. /**
  4736. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4737. * @param ref matrix to store the result
  4738. */
  4739. toNormalMatrix(ref: Matrix): void;
  4740. /**
  4741. * Gets only rotation part of the current matrix
  4742. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4743. */
  4744. getRotationMatrix(): Matrix;
  4745. /**
  4746. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4747. * @param result defines the target matrix to store data to
  4748. * @returns the current matrix
  4749. */
  4750. getRotationMatrixToRef(result: Matrix): Matrix;
  4751. /**
  4752. * Toggles model matrix from being right handed to left handed in place and vice versa
  4753. */
  4754. toggleModelMatrixHandInPlace(): void;
  4755. /**
  4756. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4757. */
  4758. toggleProjectionMatrixHandInPlace(): void;
  4759. /**
  4760. * Creates a matrix from an array
  4761. * @param array defines the source array
  4762. * @param offset defines an offset in the source array
  4763. * @returns a new Matrix set from the starting index of the given array
  4764. */
  4765. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4766. /**
  4767. * Copy the content of an array into a given matrix
  4768. * @param array defines the source array
  4769. * @param offset defines an offset in the source array
  4770. * @param result defines the target matrix
  4771. */
  4772. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4773. /**
  4774. * Stores an array into a matrix after having multiplied each component by a given factor
  4775. * @param array defines the source array
  4776. * @param offset defines the offset in the source array
  4777. * @param scale defines the scaling factor
  4778. * @param result defines the target matrix
  4779. */
  4780. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4781. /**
  4782. * Gets an identity matrix that must not be updated
  4783. */
  4784. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4785. /**
  4786. * Stores a list of values (16) inside a given matrix
  4787. * @param initialM11 defines 1st value of 1st row
  4788. * @param initialM12 defines 2nd value of 1st row
  4789. * @param initialM13 defines 3rd value of 1st row
  4790. * @param initialM14 defines 4th value of 1st row
  4791. * @param initialM21 defines 1st value of 2nd row
  4792. * @param initialM22 defines 2nd value of 2nd row
  4793. * @param initialM23 defines 3rd value of 2nd row
  4794. * @param initialM24 defines 4th value of 2nd row
  4795. * @param initialM31 defines 1st value of 3rd row
  4796. * @param initialM32 defines 2nd value of 3rd row
  4797. * @param initialM33 defines 3rd value of 3rd row
  4798. * @param initialM34 defines 4th value of 3rd row
  4799. * @param initialM41 defines 1st value of 4th row
  4800. * @param initialM42 defines 2nd value of 4th row
  4801. * @param initialM43 defines 3rd value of 4th row
  4802. * @param initialM44 defines 4th value of 4th row
  4803. * @param result defines the target matrix
  4804. */
  4805. 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;
  4806. /**
  4807. * Creates new matrix from a list of values (16)
  4808. * @param initialM11 defines 1st value of 1st row
  4809. * @param initialM12 defines 2nd value of 1st row
  4810. * @param initialM13 defines 3rd value of 1st row
  4811. * @param initialM14 defines 4th value of 1st row
  4812. * @param initialM21 defines 1st value of 2nd row
  4813. * @param initialM22 defines 2nd value of 2nd row
  4814. * @param initialM23 defines 3rd value of 2nd row
  4815. * @param initialM24 defines 4th value of 2nd row
  4816. * @param initialM31 defines 1st value of 3rd row
  4817. * @param initialM32 defines 2nd value of 3rd row
  4818. * @param initialM33 defines 3rd value of 3rd row
  4819. * @param initialM34 defines 4th value of 3rd row
  4820. * @param initialM41 defines 1st value of 4th row
  4821. * @param initialM42 defines 2nd value of 4th row
  4822. * @param initialM43 defines 3rd value of 4th row
  4823. * @param initialM44 defines 4th value of 4th row
  4824. * @returns the new matrix
  4825. */
  4826. 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;
  4827. /**
  4828. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4829. * @param scale defines the scale vector3
  4830. * @param rotation defines the rotation quaternion
  4831. * @param translation defines the translation vector3
  4832. * @returns a new matrix
  4833. */
  4834. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4835. /**
  4836. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4837. * @param scale defines the scale vector3
  4838. * @param rotation defines the rotation quaternion
  4839. * @param translation defines the translation vector3
  4840. * @param result defines the target matrix
  4841. */
  4842. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4843. /**
  4844. * Creates a new identity matrix
  4845. * @returns a new identity matrix
  4846. */
  4847. static Identity(): Matrix;
  4848. /**
  4849. * Creates a new identity matrix and stores the result in a given matrix
  4850. * @param result defines the target matrix
  4851. */
  4852. static IdentityToRef(result: Matrix): void;
  4853. /**
  4854. * Creates a new zero matrix
  4855. * @returns a new zero matrix
  4856. */
  4857. static Zero(): Matrix;
  4858. /**
  4859. * Creates a new rotation matrix for "angle" radians around the X axis
  4860. * @param angle defines the angle (in radians) to use
  4861. * @return the new matrix
  4862. */
  4863. static RotationX(angle: number): Matrix;
  4864. /**
  4865. * Creates a new matrix as the invert of a given matrix
  4866. * @param source defines the source matrix
  4867. * @returns the new matrix
  4868. */
  4869. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4870. /**
  4871. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the Y axis
  4878. * @param angle defines the angle (in radians) to use
  4879. * @return the new matrix
  4880. */
  4881. static RotationY(angle: number): Matrix;
  4882. /**
  4883. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4884. * @param angle defines the angle (in radians) to use
  4885. * @param result defines the target matrix
  4886. */
  4887. static RotationYToRef(angle: number, result: Matrix): void;
  4888. /**
  4889. * Creates a new rotation matrix for "angle" radians around the Z axis
  4890. * @param angle defines the angle (in radians) to use
  4891. * @return the new matrix
  4892. */
  4893. static RotationZ(angle: number): Matrix;
  4894. /**
  4895. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4896. * @param angle defines the angle (in radians) to use
  4897. * @param result defines the target matrix
  4898. */
  4899. static RotationZToRef(angle: number, result: Matrix): void;
  4900. /**
  4901. * Creates a new rotation matrix for "angle" radians around the given axis
  4902. * @param axis defines the axis to use
  4903. * @param angle defines the angle (in radians) to use
  4904. * @return the new matrix
  4905. */
  4906. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4907. /**
  4908. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4909. * @param axis defines the axis to use
  4910. * @param angle defines the angle (in radians) to use
  4911. * @param result defines the target matrix
  4912. */
  4913. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4914. /**
  4915. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4916. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4917. * @param from defines the vector to align
  4918. * @param to defines the vector to align to
  4919. * @param result defines the target matrix
  4920. */
  4921. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4922. /**
  4923. * Creates a rotation matrix
  4924. * @param yaw defines the yaw angle in radians (Y axis)
  4925. * @param pitch defines the pitch angle in radians (X axis)
  4926. * @param roll defines the roll angle in radians (Z axis)
  4927. * @returns the new rotation matrix
  4928. */
  4929. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4930. /**
  4931. * Creates a rotation matrix and stores it in a given matrix
  4932. * @param yaw defines the yaw angle in radians (Y axis)
  4933. * @param pitch defines the pitch angle in radians (X axis)
  4934. * @param roll defines the roll angle in radians (Z axis)
  4935. * @param result defines the target matrix
  4936. */
  4937. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4938. /**
  4939. * Creates a scaling matrix
  4940. * @param x defines the scale factor on X axis
  4941. * @param y defines the scale factor on Y axis
  4942. * @param z defines the scale factor on Z axis
  4943. * @returns the new matrix
  4944. */
  4945. static Scaling(x: number, y: number, z: number): Matrix;
  4946. /**
  4947. * Creates a scaling matrix and stores it in a given matrix
  4948. * @param x defines the scale factor on X axis
  4949. * @param y defines the scale factor on Y axis
  4950. * @param z defines the scale factor on Z axis
  4951. * @param result defines the target matrix
  4952. */
  4953. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4954. /**
  4955. * Creates a translation matrix
  4956. * @param x defines the translation on X axis
  4957. * @param y defines the translation on Y axis
  4958. * @param z defines the translationon Z axis
  4959. * @returns the new matrix
  4960. */
  4961. static Translation(x: number, y: number, z: number): Matrix;
  4962. /**
  4963. * Creates a translation matrix and stores it in a given matrix
  4964. * @param x defines the translation on X axis
  4965. * @param y defines the translation on Y axis
  4966. * @param z defines the translationon Z axis
  4967. * @param result defines the target matrix
  4968. */
  4969. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4970. /**
  4971. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4972. * @param startValue defines the start value
  4973. * @param endValue defines the end value
  4974. * @param gradient defines the gradient factor
  4975. * @returns the new matrix
  4976. */
  4977. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4978. /**
  4979. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4980. * @param startValue defines the start value
  4981. * @param endValue defines the end value
  4982. * @param gradient defines the gradient factor
  4983. * @param result defines the Matrix object where to store data
  4984. */
  4985. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4986. /**
  4987. * Builds a new matrix whose values are computed by:
  4988. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4989. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4990. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4991. * @param startValue defines the first matrix
  4992. * @param endValue defines the second matrix
  4993. * @param gradient defines the gradient between the two matrices
  4994. * @returns the new matrix
  4995. */
  4996. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4997. /**
  4998. * Update a matrix to values which are computed by:
  4999. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5000. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5001. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5002. * @param startValue defines the first matrix
  5003. * @param endValue defines the second matrix
  5004. * @param gradient defines the gradient between the two matrices
  5005. * @param result defines the target matrix
  5006. */
  5007. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5008. /**
  5009. * 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"
  5010. * This function works in left handed mode
  5011. * @param eye defines the final position of the entity
  5012. * @param target defines where the entity should look at
  5013. * @param up defines the up vector for the entity
  5014. * @returns the new matrix
  5015. */
  5016. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5017. /**
  5018. * 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".
  5019. * This function works in left handed mode
  5020. * @param eye defines the final position of the entity
  5021. * @param target defines where the entity should look at
  5022. * @param up defines the up vector for the entity
  5023. * @param result defines the target matrix
  5024. */
  5025. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5026. /**
  5027. * 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"
  5028. * This function works in right handed mode
  5029. * @param eye defines the final position of the entity
  5030. * @param target defines where the entity should look at
  5031. * @param up defines the up vector for the entity
  5032. * @returns the new matrix
  5033. */
  5034. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5035. /**
  5036. * 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".
  5037. * This function works in right handed mode
  5038. * @param eye defines the final position of the entity
  5039. * @param target defines where the entity should look at
  5040. * @param up defines the up vector for the entity
  5041. * @param result defines the target matrix
  5042. */
  5043. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5044. /**
  5045. * Create a left-handed orthographic projection matrix
  5046. * @param width defines the viewport width
  5047. * @param height defines the viewport height
  5048. * @param znear defines the near clip plane
  5049. * @param zfar defines the far clip plane
  5050. * @returns a new matrix as a left-handed orthographic projection matrix
  5051. */
  5052. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5053. /**
  5054. * Store a left-handed orthographic projection to a given matrix
  5055. * @param width defines the viewport width
  5056. * @param height defines the viewport height
  5057. * @param znear defines the near clip plane
  5058. * @param zfar defines the far clip plane
  5059. * @param result defines the target matrix
  5060. */
  5061. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5062. /**
  5063. * Create a left-handed orthographic projection matrix
  5064. * @param left defines the viewport left coordinate
  5065. * @param right defines the viewport right coordinate
  5066. * @param bottom defines the viewport bottom coordinate
  5067. * @param top defines the viewport top coordinate
  5068. * @param znear defines the near clip plane
  5069. * @param zfar defines the far clip plane
  5070. * @returns a new matrix as a left-handed orthographic projection matrix
  5071. */
  5072. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5073. /**
  5074. * Stores a left-handed orthographic projection into a given matrix
  5075. * @param left defines the viewport left coordinate
  5076. * @param right defines the viewport right coordinate
  5077. * @param bottom defines the viewport bottom coordinate
  5078. * @param top defines the viewport top coordinate
  5079. * @param znear defines the near clip plane
  5080. * @param zfar defines the far clip plane
  5081. * @param result defines the target matrix
  5082. */
  5083. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5084. /**
  5085. * Creates a right-handed orthographic projection matrix
  5086. * @param left defines the viewport left coordinate
  5087. * @param right defines the viewport right coordinate
  5088. * @param bottom defines the viewport bottom coordinate
  5089. * @param top defines the viewport top coordinate
  5090. * @param znear defines the near clip plane
  5091. * @param zfar defines the far clip plane
  5092. * @returns a new matrix as a right-handed orthographic projection matrix
  5093. */
  5094. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5095. /**
  5096. * Stores a right-handed orthographic projection into a given matrix
  5097. * @param left defines the viewport left coordinate
  5098. * @param right defines the viewport right coordinate
  5099. * @param bottom defines the viewport bottom coordinate
  5100. * @param top defines the viewport top coordinate
  5101. * @param znear defines the near clip plane
  5102. * @param zfar defines the far clip plane
  5103. * @param result defines the target matrix
  5104. */
  5105. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5106. /**
  5107. * Creates a left-handed perspective projection matrix
  5108. * @param width defines the viewport width
  5109. * @param height defines the viewport height
  5110. * @param znear defines the near clip plane
  5111. * @param zfar defines the far clip plane
  5112. * @returns a new matrix as a left-handed perspective projection matrix
  5113. */
  5114. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5115. /**
  5116. * Creates a left-handed perspective projection matrix
  5117. * @param fov defines the horizontal field of view
  5118. * @param aspect defines the aspect ratio
  5119. * @param znear defines the near clip plane
  5120. * @param zfar defines the far clip plane
  5121. * @returns a new matrix as a left-handed perspective projection matrix
  5122. */
  5123. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5124. /**
  5125. * Stores a left-handed perspective projection into a given matrix
  5126. * @param fov defines the horizontal field of view
  5127. * @param aspect defines the aspect ratio
  5128. * @param znear defines the near clip plane
  5129. * @param zfar defines the far clip plane
  5130. * @param result defines the target matrix
  5131. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5132. */
  5133. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5134. /**
  5135. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5136. * @param fov defines the horizontal field of view
  5137. * @param aspect defines the aspect ratio
  5138. * @param znear defines the near clip plane
  5139. * @param zfar not used as infinity is used as far clip
  5140. * @param result defines the target matrix
  5141. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5142. */
  5143. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5144. /**
  5145. * Creates a right-handed perspective projection matrix
  5146. * @param fov defines the horizontal field of view
  5147. * @param aspect defines the aspect ratio
  5148. * @param znear defines the near clip plane
  5149. * @param zfar defines the far clip plane
  5150. * @returns a new matrix as a right-handed perspective projection matrix
  5151. */
  5152. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5153. /**
  5154. * Stores a right-handed perspective projection into a given matrix
  5155. * @param fov defines the horizontal field of view
  5156. * @param aspect defines the aspect ratio
  5157. * @param znear defines the near clip plane
  5158. * @param zfar defines the far clip plane
  5159. * @param result defines the target matrix
  5160. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5161. */
  5162. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5163. /**
  5164. * Stores a right-handed perspective projection into a given matrix
  5165. * @param fov defines the horizontal field of view
  5166. * @param aspect defines the aspect ratio
  5167. * @param znear defines the near clip plane
  5168. * @param zfar not used as infinity is used as far clip
  5169. * @param result defines the target matrix
  5170. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5171. */
  5172. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5173. /**
  5174. * Stores a perspective projection for WebVR info a given matrix
  5175. * @param fov defines the field of view
  5176. * @param znear defines the near clip plane
  5177. * @param zfar defines the far clip plane
  5178. * @param result defines the target matrix
  5179. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5180. */
  5181. static PerspectiveFovWebVRToRef(fov: {
  5182. upDegrees: number;
  5183. downDegrees: number;
  5184. leftDegrees: number;
  5185. rightDegrees: number;
  5186. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5187. /**
  5188. * Computes a complete transformation matrix
  5189. * @param viewport defines the viewport to use
  5190. * @param world defines the world matrix
  5191. * @param view defines the view matrix
  5192. * @param projection defines the projection matrix
  5193. * @param zmin defines the near clip plane
  5194. * @param zmax defines the far clip plane
  5195. * @returns the transformation matrix
  5196. */
  5197. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5198. /**
  5199. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5200. * @param matrix defines the matrix to use
  5201. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5202. */
  5203. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5204. /**
  5205. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5206. * @param matrix defines the matrix to use
  5207. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5208. */
  5209. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5210. /**
  5211. * Compute the transpose of a given matrix
  5212. * @param matrix defines the matrix to transpose
  5213. * @returns the new matrix
  5214. */
  5215. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5216. /**
  5217. * Compute the transpose of a matrix and store it in a target matrix
  5218. * @param matrix defines the matrix to transpose
  5219. * @param result defines the target matrix
  5220. */
  5221. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5222. /**
  5223. * Computes a reflection matrix from a plane
  5224. * @param plane defines the reflection plane
  5225. * @returns a new matrix
  5226. */
  5227. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5228. /**
  5229. * Computes a reflection matrix from a plane
  5230. * @param plane defines the reflection plane
  5231. * @param result defines the target matrix
  5232. */
  5233. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5234. /**
  5235. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5236. * @param xaxis defines the value of the 1st axis
  5237. * @param yaxis defines the value of the 2nd axis
  5238. * @param zaxis defines the value of the 3rd axis
  5239. * @param result defines the target matrix
  5240. */
  5241. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5242. /**
  5243. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5244. * @param quat defines the quaternion to use
  5245. * @param result defines the target matrix
  5246. */
  5247. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5248. }
  5249. /**
  5250. * @hidden
  5251. */
  5252. export class TmpVectors {
  5253. static Vector2: Vector2[];
  5254. static Vector3: Vector3[];
  5255. static Vector4: Vector4[];
  5256. static Quaternion: Quaternion[];
  5257. static Matrix: Matrix[];
  5258. }
  5259. }
  5260. declare module BABYLON {
  5261. /**
  5262. * Defines potential orientation for back face culling
  5263. */
  5264. export enum Orientation {
  5265. /**
  5266. * Clockwise
  5267. */
  5268. CW = 0,
  5269. /** Counter clockwise */
  5270. CCW = 1
  5271. }
  5272. /** Class used to represent a Bezier curve */
  5273. export class BezierCurve {
  5274. /**
  5275. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5276. * @param t defines the time
  5277. * @param x1 defines the left coordinate on X axis
  5278. * @param y1 defines the left coordinate on Y axis
  5279. * @param x2 defines the right coordinate on X axis
  5280. * @param y2 defines the right coordinate on Y axis
  5281. * @returns the interpolated value
  5282. */
  5283. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5284. }
  5285. /**
  5286. * Defines angle representation
  5287. */
  5288. export class Angle {
  5289. private _radians;
  5290. /**
  5291. * Creates an Angle object of "radians" radians (float).
  5292. * @param radians the angle in radians
  5293. */
  5294. constructor(radians: number);
  5295. /**
  5296. * Get value in degrees
  5297. * @returns the Angle value in degrees (float)
  5298. */
  5299. degrees(): number;
  5300. /**
  5301. * Get value in radians
  5302. * @returns the Angle value in radians (float)
  5303. */
  5304. radians(): number;
  5305. /**
  5306. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5307. * @param a defines first point as the origin
  5308. * @param b defines point
  5309. * @returns a new Angle
  5310. */
  5311. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5312. /**
  5313. * Gets a new Angle object from the given float in radians
  5314. * @param radians defines the angle value in radians
  5315. * @returns a new Angle
  5316. */
  5317. static FromRadians(radians: number): Angle;
  5318. /**
  5319. * Gets a new Angle object from the given float in degrees
  5320. * @param degrees defines the angle value in degrees
  5321. * @returns a new Angle
  5322. */
  5323. static FromDegrees(degrees: number): Angle;
  5324. }
  5325. /**
  5326. * This represents an arc in a 2d space.
  5327. */
  5328. export class Arc2 {
  5329. /** Defines the start point of the arc */
  5330. startPoint: Vector2;
  5331. /** Defines the mid point of the arc */
  5332. midPoint: Vector2;
  5333. /** Defines the end point of the arc */
  5334. endPoint: Vector2;
  5335. /**
  5336. * Defines the center point of the arc.
  5337. */
  5338. centerPoint: Vector2;
  5339. /**
  5340. * Defines the radius of the arc.
  5341. */
  5342. radius: number;
  5343. /**
  5344. * Defines the angle of the arc (from mid point to end point).
  5345. */
  5346. angle: Angle;
  5347. /**
  5348. * Defines the start angle of the arc (from start point to middle point).
  5349. */
  5350. startAngle: Angle;
  5351. /**
  5352. * Defines the orientation of the arc (clock wise/counter clock wise).
  5353. */
  5354. orientation: Orientation;
  5355. /**
  5356. * Creates an Arc object from the three given points : start, middle and end.
  5357. * @param startPoint Defines the start point of the arc
  5358. * @param midPoint Defines the midlle point of the arc
  5359. * @param endPoint Defines the end point of the arc
  5360. */
  5361. constructor(
  5362. /** Defines the start point of the arc */
  5363. startPoint: Vector2,
  5364. /** Defines the mid point of the arc */
  5365. midPoint: Vector2,
  5366. /** Defines the end point of the arc */
  5367. endPoint: Vector2);
  5368. }
  5369. /**
  5370. * Represents a 2D path made up of multiple 2D points
  5371. */
  5372. export class Path2 {
  5373. private _points;
  5374. private _length;
  5375. /**
  5376. * If the path start and end point are the same
  5377. */
  5378. closed: boolean;
  5379. /**
  5380. * Creates a Path2 object from the starting 2D coordinates x and y.
  5381. * @param x the starting points x value
  5382. * @param y the starting points y value
  5383. */
  5384. constructor(x: number, y: number);
  5385. /**
  5386. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5387. * @param x the added points x value
  5388. * @param y the added points y value
  5389. * @returns the updated Path2.
  5390. */
  5391. addLineTo(x: number, y: number): Path2;
  5392. /**
  5393. * 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.
  5394. * @param midX middle point x value
  5395. * @param midY middle point y value
  5396. * @param endX end point x value
  5397. * @param endY end point y value
  5398. * @param numberOfSegments (default: 36)
  5399. * @returns the updated Path2.
  5400. */
  5401. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5402. /**
  5403. * Closes the Path2.
  5404. * @returns the Path2.
  5405. */
  5406. close(): Path2;
  5407. /**
  5408. * Gets the sum of the distance between each sequential point in the path
  5409. * @returns the Path2 total length (float).
  5410. */
  5411. length(): number;
  5412. /**
  5413. * Gets the points which construct the path
  5414. * @returns the Path2 internal array of points.
  5415. */
  5416. getPoints(): Vector2[];
  5417. /**
  5418. * Retreives the point at the distance aways from the starting point
  5419. * @param normalizedLengthPosition the length along the path to retreive the point from
  5420. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5421. */
  5422. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5423. /**
  5424. * Creates a new path starting from an x and y position
  5425. * @param x starting x value
  5426. * @param y starting y value
  5427. * @returns a new Path2 starting at the coordinates (x, y).
  5428. */
  5429. static StartingAt(x: number, y: number): Path2;
  5430. }
  5431. /**
  5432. * Represents a 3D path made up of multiple 3D points
  5433. */
  5434. export class Path3D {
  5435. /**
  5436. * an array of Vector3, the curve axis of the Path3D
  5437. */
  5438. path: Vector3[];
  5439. private _curve;
  5440. private _distances;
  5441. private _tangents;
  5442. private _normals;
  5443. private _binormals;
  5444. private _raw;
  5445. private _alignTangentsWithPath;
  5446. private readonly _pointAtData;
  5447. /**
  5448. * new Path3D(path, normal, raw)
  5449. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5450. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5451. * @param path an array of Vector3, the curve axis of the Path3D
  5452. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5453. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5454. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5455. */
  5456. constructor(
  5457. /**
  5458. * an array of Vector3, the curve axis of the Path3D
  5459. */
  5460. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5461. /**
  5462. * Returns the Path3D array of successive Vector3 designing its curve.
  5463. * @returns the Path3D array of successive Vector3 designing its curve.
  5464. */
  5465. getCurve(): Vector3[];
  5466. /**
  5467. * Returns the Path3D array of successive Vector3 designing its curve.
  5468. * @returns the Path3D array of successive Vector3 designing its curve.
  5469. */
  5470. getPoints(): Vector3[];
  5471. /**
  5472. * @returns the computed length (float) of the path.
  5473. */
  5474. length(): number;
  5475. /**
  5476. * Returns an array populated with tangent vectors on each Path3D curve point.
  5477. * @returns an array populated with tangent vectors on each Path3D curve point.
  5478. */
  5479. getTangents(): Vector3[];
  5480. /**
  5481. * Returns an array populated with normal vectors on each Path3D curve point.
  5482. * @returns an array populated with normal vectors on each Path3D curve point.
  5483. */
  5484. getNormals(): Vector3[];
  5485. /**
  5486. * Returns an array populated with binormal vectors on each Path3D curve point.
  5487. * @returns an array populated with binormal vectors on each Path3D curve point.
  5488. */
  5489. getBinormals(): Vector3[];
  5490. /**
  5491. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5492. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5493. */
  5494. getDistances(): number[];
  5495. /**
  5496. * Returns an interpolated point along this path
  5497. * @param position the position of the point along this path, from 0.0 to 1.0
  5498. * @returns a new Vector3 as the point
  5499. */
  5500. getPointAt(position: number): Vector3;
  5501. /**
  5502. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5503. * @param position the position of the point along this path, from 0.0 to 1.0
  5504. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5505. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5506. */
  5507. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5508. /**
  5509. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5510. * @param position the position of the point along this path, from 0.0 to 1.0
  5511. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5512. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5513. */
  5514. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5515. /**
  5516. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5517. * @param position the position of the point along this path, from 0.0 to 1.0
  5518. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5519. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5520. */
  5521. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5522. /**
  5523. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5524. * @param position the position of the point along this path, from 0.0 to 1.0
  5525. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5526. */
  5527. getDistanceAt(position: number): number;
  5528. /**
  5529. * Returns the array index of the previous point of an interpolated point along this path
  5530. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5531. * @returns the array index
  5532. */
  5533. getPreviousPointIndexAt(position: number): number;
  5534. /**
  5535. * 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)
  5536. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5537. * @returns the sub position
  5538. */
  5539. getSubPositionAt(position: number): number;
  5540. /**
  5541. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5542. * @param target the vector of which to get the closest position to
  5543. * @returns the position of the closest virtual point on this path to the target vector
  5544. */
  5545. getClosestPositionTo(target: Vector3): number;
  5546. /**
  5547. * Returns a sub path (slice) of this path
  5548. * @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
  5549. * @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
  5550. * @returns a sub path (slice) of this path
  5551. */
  5552. slice(start?: number, end?: number): Path3D;
  5553. /**
  5554. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5555. * @param path path which all values are copied into the curves points
  5556. * @param firstNormal which should be projected onto the curve
  5557. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5558. * @returns the same object updated.
  5559. */
  5560. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5561. private _compute;
  5562. private _getFirstNonNullVector;
  5563. private _getLastNonNullVector;
  5564. private _normalVector;
  5565. /**
  5566. * Updates the point at data for an interpolated point along this curve
  5567. * @param position the position of the point along this curve, from 0.0 to 1.0
  5568. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5569. * @returns the (updated) point at data
  5570. */
  5571. private _updatePointAtData;
  5572. /**
  5573. * Updates the point at data from the specified parameters
  5574. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5575. * @param point the interpolated point
  5576. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5577. */
  5578. private _setPointAtData;
  5579. /**
  5580. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5581. */
  5582. private _updateInterpolationMatrix;
  5583. }
  5584. /**
  5585. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5586. * A Curve3 is designed from a series of successive Vector3.
  5587. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5588. */
  5589. export class Curve3 {
  5590. private _points;
  5591. private _length;
  5592. /**
  5593. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5594. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5595. * @param v1 (Vector3) the control point
  5596. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5597. * @param nbPoints (integer) the wanted number of points in the curve
  5598. * @returns the created Curve3
  5599. */
  5600. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5601. /**
  5602. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5603. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5604. * @param v1 (Vector3) the first control point
  5605. * @param v2 (Vector3) the second control point
  5606. * @param v3 (Vector3) the end point of the Cubic Bezier
  5607. * @param nbPoints (integer) the wanted number of points in the curve
  5608. * @returns the created Curve3
  5609. */
  5610. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5611. /**
  5612. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5613. * @param p1 (Vector3) the origin point of the Hermite Spline
  5614. * @param t1 (Vector3) the tangent vector at the origin point
  5615. * @param p2 (Vector3) the end point of the Hermite Spline
  5616. * @param t2 (Vector3) the tangent vector at the end point
  5617. * @param nbPoints (integer) the wanted number of points in the curve
  5618. * @returns the created Curve3
  5619. */
  5620. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5621. /**
  5622. * Returns a Curve3 object along a CatmullRom Spline curve :
  5623. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5624. * @param nbPoints (integer) the wanted number of points between each curve control points
  5625. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5626. * @returns the created Curve3
  5627. */
  5628. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5629. /**
  5630. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5631. * A Curve3 is designed from a series of successive Vector3.
  5632. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5633. * @param points points which make up the curve
  5634. */
  5635. constructor(points: Vector3[]);
  5636. /**
  5637. * @returns the Curve3 stored array of successive Vector3
  5638. */
  5639. getPoints(): Vector3[];
  5640. /**
  5641. * @returns the computed length (float) of the curve.
  5642. */
  5643. length(): number;
  5644. /**
  5645. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5646. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5647. * curveA and curveB keep unchanged.
  5648. * @param curve the curve to continue from this curve
  5649. * @returns the newly constructed curve
  5650. */
  5651. continue(curve: DeepImmutable<Curve3>): Curve3;
  5652. private _computeLength;
  5653. }
  5654. }
  5655. declare module BABYLON {
  5656. /**
  5657. * This represents the main contract an easing function should follow.
  5658. * Easing functions are used throughout the animation system.
  5659. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5660. */
  5661. export interface IEasingFunction {
  5662. /**
  5663. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5664. * of the easing function.
  5665. * The link below provides some of the most common examples of easing functions.
  5666. * @see https://easings.net/
  5667. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5668. * @returns the corresponding value on the curve defined by the easing function
  5669. */
  5670. ease(gradient: number): number;
  5671. }
  5672. /**
  5673. * Base class used for every default easing function.
  5674. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class EasingFunction implements IEasingFunction {
  5677. /**
  5678. * Interpolation follows the mathematical formula associated with the easing function.
  5679. */
  5680. static readonly EASINGMODE_EASEIN: number;
  5681. /**
  5682. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5683. */
  5684. static readonly EASINGMODE_EASEOUT: number;
  5685. /**
  5686. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5687. */
  5688. static readonly EASINGMODE_EASEINOUT: number;
  5689. private _easingMode;
  5690. /**
  5691. * Sets the easing mode of the current function.
  5692. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5693. */
  5694. setEasingMode(easingMode: number): void;
  5695. /**
  5696. * Gets the current easing mode.
  5697. * @returns the easing mode
  5698. */
  5699. getEasingMode(): number;
  5700. /**
  5701. * @hidden
  5702. */
  5703. easeInCore(gradient: number): number;
  5704. /**
  5705. * Given an input gradient between 0 and 1, this returns the corresponding value
  5706. * of the easing function.
  5707. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5708. * @returns the corresponding value on the curve defined by the easing function
  5709. */
  5710. ease(gradient: number): number;
  5711. }
  5712. /**
  5713. * Easing function with a circle shape (see link below).
  5714. * @see https://easings.net/#easeInCirc
  5715. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5716. */
  5717. export class CircleEase extends EasingFunction implements IEasingFunction {
  5718. /** @hidden */
  5719. easeInCore(gradient: number): number;
  5720. }
  5721. /**
  5722. * Easing function with a ease back shape (see link below).
  5723. * @see https://easings.net/#easeInBack
  5724. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5725. */
  5726. export class BackEase extends EasingFunction implements IEasingFunction {
  5727. /** Defines the amplitude of the function */
  5728. amplitude: number;
  5729. /**
  5730. * Instantiates a back ease easing
  5731. * @see https://easings.net/#easeInBack
  5732. * @param amplitude Defines the amplitude of the function
  5733. */
  5734. constructor(
  5735. /** Defines the amplitude of the function */
  5736. amplitude?: number);
  5737. /** @hidden */
  5738. easeInCore(gradient: number): number;
  5739. }
  5740. /**
  5741. * Easing function with a bouncing shape (see link below).
  5742. * @see https://easings.net/#easeInBounce
  5743. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5744. */
  5745. export class BounceEase extends EasingFunction implements IEasingFunction {
  5746. /** Defines the number of bounces */
  5747. bounces: number;
  5748. /** Defines the amplitude of the bounce */
  5749. bounciness: number;
  5750. /**
  5751. * Instantiates a bounce easing
  5752. * @see https://easings.net/#easeInBounce
  5753. * @param bounces Defines the number of bounces
  5754. * @param bounciness Defines the amplitude of the bounce
  5755. */
  5756. constructor(
  5757. /** Defines the number of bounces */
  5758. bounces?: number,
  5759. /** Defines the amplitude of the bounce */
  5760. bounciness?: number);
  5761. /** @hidden */
  5762. easeInCore(gradient: number): number;
  5763. }
  5764. /**
  5765. * Easing function with a power of 3 shape (see link below).
  5766. * @see https://easings.net/#easeInCubic
  5767. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5768. */
  5769. export class CubicEase extends EasingFunction implements IEasingFunction {
  5770. /** @hidden */
  5771. easeInCore(gradient: number): number;
  5772. }
  5773. /**
  5774. * Easing function with an elastic shape (see link below).
  5775. * @see https://easings.net/#easeInElastic
  5776. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5777. */
  5778. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5779. /** Defines the number of oscillations*/
  5780. oscillations: number;
  5781. /** Defines the amplitude of the oscillations*/
  5782. springiness: number;
  5783. /**
  5784. * Instantiates an elastic easing function
  5785. * @see https://easings.net/#easeInElastic
  5786. * @param oscillations Defines the number of oscillations
  5787. * @param springiness Defines the amplitude of the oscillations
  5788. */
  5789. constructor(
  5790. /** Defines the number of oscillations*/
  5791. oscillations?: number,
  5792. /** Defines the amplitude of the oscillations*/
  5793. springiness?: number);
  5794. /** @hidden */
  5795. easeInCore(gradient: number): number;
  5796. }
  5797. /**
  5798. * Easing function with an exponential shape (see link below).
  5799. * @see https://easings.net/#easeInExpo
  5800. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5801. */
  5802. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5803. /** Defines the exponent of the function */
  5804. exponent: number;
  5805. /**
  5806. * Instantiates an exponential easing function
  5807. * @see https://easings.net/#easeInExpo
  5808. * @param exponent Defines the exponent of the function
  5809. */
  5810. constructor(
  5811. /** Defines the exponent of the function */
  5812. exponent?: number);
  5813. /** @hidden */
  5814. easeInCore(gradient: number): number;
  5815. }
  5816. /**
  5817. * Easing function with a power shape (see link below).
  5818. * @see https://easings.net/#easeInQuad
  5819. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5820. */
  5821. export class PowerEase extends EasingFunction implements IEasingFunction {
  5822. /** Defines the power of the function */
  5823. power: number;
  5824. /**
  5825. * Instantiates an power base easing function
  5826. * @see https://easings.net/#easeInQuad
  5827. * @param power Defines the power of the function
  5828. */
  5829. constructor(
  5830. /** Defines the power of the function */
  5831. power?: number);
  5832. /** @hidden */
  5833. easeInCore(gradient: number): number;
  5834. }
  5835. /**
  5836. * Easing function with a power of 2 shape (see link below).
  5837. * @see https://easings.net/#easeInQuad
  5838. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5839. */
  5840. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5841. /** @hidden */
  5842. easeInCore(gradient: number): number;
  5843. }
  5844. /**
  5845. * Easing function with a power of 4 shape (see link below).
  5846. * @see https://easings.net/#easeInQuart
  5847. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5848. */
  5849. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5850. /** @hidden */
  5851. easeInCore(gradient: number): number;
  5852. }
  5853. /**
  5854. * Easing function with a power of 5 shape (see link below).
  5855. * @see https://easings.net/#easeInQuint
  5856. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5857. */
  5858. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5859. /** @hidden */
  5860. easeInCore(gradient: number): number;
  5861. }
  5862. /**
  5863. * Easing function with a sin shape (see link below).
  5864. * @see https://easings.net/#easeInSine
  5865. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5866. */
  5867. export class SineEase extends EasingFunction implements IEasingFunction {
  5868. /** @hidden */
  5869. easeInCore(gradient: number): number;
  5870. }
  5871. /**
  5872. * Easing function with a bezier shape (see link below).
  5873. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5874. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5875. */
  5876. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5877. /** Defines the x component of the start tangent in the bezier curve */
  5878. x1: number;
  5879. /** Defines the y component of the start tangent in the bezier curve */
  5880. y1: number;
  5881. /** Defines the x component of the end tangent in the bezier curve */
  5882. x2: number;
  5883. /** Defines the y component of the end tangent in the bezier curve */
  5884. y2: number;
  5885. /**
  5886. * Instantiates a bezier function
  5887. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5888. * @param x1 Defines the x component of the start tangent in the bezier curve
  5889. * @param y1 Defines the y component of the start tangent in the bezier curve
  5890. * @param x2 Defines the x component of the end tangent in the bezier curve
  5891. * @param y2 Defines the y component of the end tangent in the bezier curve
  5892. */
  5893. constructor(
  5894. /** Defines the x component of the start tangent in the bezier curve */
  5895. x1?: number,
  5896. /** Defines the y component of the start tangent in the bezier curve */
  5897. y1?: number,
  5898. /** Defines the x component of the end tangent in the bezier curve */
  5899. x2?: number,
  5900. /** Defines the y component of the end tangent in the bezier curve */
  5901. y2?: number);
  5902. /** @hidden */
  5903. easeInCore(gradient: number): number;
  5904. }
  5905. }
  5906. declare module BABYLON {
  5907. /**
  5908. * Class used to hold a RBG color
  5909. */
  5910. export class Color3 {
  5911. /**
  5912. * Defines the red component (between 0 and 1, default is 0)
  5913. */
  5914. r: number;
  5915. /**
  5916. * Defines the green component (between 0 and 1, default is 0)
  5917. */
  5918. g: number;
  5919. /**
  5920. * Defines the blue component (between 0 and 1, default is 0)
  5921. */
  5922. b: number;
  5923. /**
  5924. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5925. * @param r defines the red component (between 0 and 1, default is 0)
  5926. * @param g defines the green component (between 0 and 1, default is 0)
  5927. * @param b defines the blue component (between 0 and 1, default is 0)
  5928. */
  5929. constructor(
  5930. /**
  5931. * Defines the red component (between 0 and 1, default is 0)
  5932. */
  5933. r?: number,
  5934. /**
  5935. * Defines the green component (between 0 and 1, default is 0)
  5936. */
  5937. g?: number,
  5938. /**
  5939. * Defines the blue component (between 0 and 1, default is 0)
  5940. */
  5941. b?: number);
  5942. /**
  5943. * Creates a string with the Color3 current values
  5944. * @returns the string representation of the Color3 object
  5945. */
  5946. toString(): string;
  5947. /**
  5948. * Returns the string "Color3"
  5949. * @returns "Color3"
  5950. */
  5951. getClassName(): string;
  5952. /**
  5953. * Compute the Color3 hash code
  5954. * @returns an unique number that can be used to hash Color3 objects
  5955. */
  5956. getHashCode(): number;
  5957. /**
  5958. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5959. * @param array defines the array where to store the r,g,b components
  5960. * @param index defines an optional index in the target array to define where to start storing values
  5961. * @returns the current Color3 object
  5962. */
  5963. toArray(array: FloatArray, index?: number): Color3;
  5964. /**
  5965. * Update the current color with values stored in an array from the starting index of the given array
  5966. * @param array defines the source array
  5967. * @param offset defines an offset in the source array
  5968. * @returns the current Color3 object
  5969. */
  5970. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5971. /**
  5972. * Returns a new Color4 object from the current Color3 and the given alpha
  5973. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5974. * @returns a new Color4 object
  5975. */
  5976. toColor4(alpha?: number): Color4;
  5977. /**
  5978. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5979. * @returns the new array
  5980. */
  5981. asArray(): number[];
  5982. /**
  5983. * Returns the luminance value
  5984. * @returns a float value
  5985. */
  5986. toLuminance(): number;
  5987. /**
  5988. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5989. * @param otherColor defines the second operand
  5990. * @returns the new Color3 object
  5991. */
  5992. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5993. /**
  5994. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5995. * @param otherColor defines the second operand
  5996. * @param result defines the Color3 object where to store the result
  5997. * @returns the current Color3
  5998. */
  5999. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6000. /**
  6001. * Determines equality between Color3 objects
  6002. * @param otherColor defines the second operand
  6003. * @returns true if the rgb values are equal to the given ones
  6004. */
  6005. equals(otherColor: DeepImmutable<Color3>): boolean;
  6006. /**
  6007. * Determines equality between the current Color3 object and a set of r,b,g values
  6008. * @param r defines the red component to check
  6009. * @param g defines the green component to check
  6010. * @param b defines the blue component to check
  6011. * @returns true if the rgb values are equal to the given ones
  6012. */
  6013. equalsFloats(r: number, g: number, b: number): boolean;
  6014. /**
  6015. * Multiplies in place each rgb value by scale
  6016. * @param scale defines the scaling factor
  6017. * @returns the updated Color3
  6018. */
  6019. scale(scale: number): Color3;
  6020. /**
  6021. * Multiplies the rgb values by scale and stores the result into "result"
  6022. * @param scale defines the scaling factor
  6023. * @param result defines the Color3 object where to store the result
  6024. * @returns the unmodified current Color3
  6025. */
  6026. scaleToRef(scale: number, result: Color3): Color3;
  6027. /**
  6028. * Scale the current Color3 values by a factor and add the result to a given Color3
  6029. * @param scale defines the scale factor
  6030. * @param result defines color to store the result into
  6031. * @returns the unmodified current Color3
  6032. */
  6033. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6034. /**
  6035. * Clamps the rgb values by the min and max values and stores the result into "result"
  6036. * @param min defines minimum clamping value (default is 0)
  6037. * @param max defines maximum clamping value (default is 1)
  6038. * @param result defines color to store the result into
  6039. * @returns the original Color3
  6040. */
  6041. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6042. /**
  6043. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6044. * @param otherColor defines the second operand
  6045. * @returns the new Color3
  6046. */
  6047. add(otherColor: DeepImmutable<Color3>): Color3;
  6048. /**
  6049. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6050. * @param otherColor defines the second operand
  6051. * @param result defines Color3 object to store the result into
  6052. * @returns the unmodified current Color3
  6053. */
  6054. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6055. /**
  6056. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6057. * @param otherColor defines the second operand
  6058. * @returns the new Color3
  6059. */
  6060. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6061. /**
  6062. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6063. * @param otherColor defines the second operand
  6064. * @param result defines Color3 object to store the result into
  6065. * @returns the unmodified current Color3
  6066. */
  6067. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6068. /**
  6069. * Copy the current object
  6070. * @returns a new Color3 copied the current one
  6071. */
  6072. clone(): Color3;
  6073. /**
  6074. * Copies the rgb values from the source in the current Color3
  6075. * @param source defines the source Color3 object
  6076. * @returns the updated Color3 object
  6077. */
  6078. copyFrom(source: DeepImmutable<Color3>): Color3;
  6079. /**
  6080. * Updates the Color3 rgb values from the given floats
  6081. * @param r defines the red component to read from
  6082. * @param g defines the green component to read from
  6083. * @param b defines the blue component to read from
  6084. * @returns the current Color3 object
  6085. */
  6086. copyFromFloats(r: number, g: number, b: number): Color3;
  6087. /**
  6088. * Updates the Color3 rgb values from the given floats
  6089. * @param r defines the red component to read from
  6090. * @param g defines the green component to read from
  6091. * @param b defines the blue component to read from
  6092. * @returns the current Color3 object
  6093. */
  6094. set(r: number, g: number, b: number): Color3;
  6095. /**
  6096. * Compute the Color3 hexadecimal code as a string
  6097. * @returns a string containing the hexadecimal representation of the Color3 object
  6098. */
  6099. toHexString(): string;
  6100. /**
  6101. * Computes a new Color3 converted from the current one to linear space
  6102. * @returns a new Color3 object
  6103. */
  6104. toLinearSpace(): Color3;
  6105. /**
  6106. * Converts current color in rgb space to HSV values
  6107. * @returns a new color3 representing the HSV values
  6108. */
  6109. toHSV(): Color3;
  6110. /**
  6111. * Converts current color in rgb space to HSV values
  6112. * @param result defines the Color3 where to store the HSV values
  6113. */
  6114. toHSVToRef(result: Color3): void;
  6115. /**
  6116. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6117. * @param convertedColor defines the Color3 object where to store the linear space version
  6118. * @returns the unmodified Color3
  6119. */
  6120. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6121. /**
  6122. * Computes a new Color3 converted from the current one to gamma space
  6123. * @returns a new Color3 object
  6124. */
  6125. toGammaSpace(): Color3;
  6126. /**
  6127. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6128. * @param convertedColor defines the Color3 object where to store the gamma space version
  6129. * @returns the unmodified Color3
  6130. */
  6131. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6132. private static _BlackReadOnly;
  6133. /**
  6134. * Convert Hue, saturation and value to a Color3 (RGB)
  6135. * @param hue defines the hue
  6136. * @param saturation defines the saturation
  6137. * @param value defines the value
  6138. * @param result defines the Color3 where to store the RGB values
  6139. */
  6140. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6141. /**
  6142. * Creates a new Color3 from the string containing valid hexadecimal values
  6143. * @param hex defines a string containing valid hexadecimal values
  6144. * @returns a new Color3 object
  6145. */
  6146. static FromHexString(hex: string): Color3;
  6147. /**
  6148. * Creates a new Color3 from the starting index of the given array
  6149. * @param array defines the source array
  6150. * @param offset defines an offset in the source array
  6151. * @returns a new Color3 object
  6152. */
  6153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6154. /**
  6155. * Creates a new Color3 from the starting index element of the given array
  6156. * @param array defines the source array to read from
  6157. * @param offset defines the offset in the source array
  6158. * @param result defines the target Color3 object
  6159. */
  6160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6161. /**
  6162. * Creates a new Color3 from integer values (< 256)
  6163. * @param r defines the red component to read from (value between 0 and 255)
  6164. * @param g defines the green component to read from (value between 0 and 255)
  6165. * @param b defines the blue component to read from (value between 0 and 255)
  6166. * @returns a new Color3 object
  6167. */
  6168. static FromInts(r: number, g: number, b: number): Color3;
  6169. /**
  6170. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6171. * @param start defines the start Color3 value
  6172. * @param end defines the end Color3 value
  6173. * @param amount defines the gradient value between start and end
  6174. * @returns a new Color3 object
  6175. */
  6176. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6177. /**
  6178. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6179. * @param left defines the start value
  6180. * @param right defines the end value
  6181. * @param amount defines the gradient factor
  6182. * @param result defines the Color3 object where to store the result
  6183. */
  6184. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6185. /**
  6186. * Returns a Color3 value containing a red color
  6187. * @returns a new Color3 object
  6188. */
  6189. static Red(): Color3;
  6190. /**
  6191. * Returns a Color3 value containing a green color
  6192. * @returns a new Color3 object
  6193. */
  6194. static Green(): Color3;
  6195. /**
  6196. * Returns a Color3 value containing a blue color
  6197. * @returns a new Color3 object
  6198. */
  6199. static Blue(): Color3;
  6200. /**
  6201. * Returns a Color3 value containing a black color
  6202. * @returns a new Color3 object
  6203. */
  6204. static Black(): Color3;
  6205. /**
  6206. * Gets a Color3 value containing a black color that must not be updated
  6207. */
  6208. static get BlackReadOnly(): DeepImmutable<Color3>;
  6209. /**
  6210. * Returns a Color3 value containing a white color
  6211. * @returns a new Color3 object
  6212. */
  6213. static White(): Color3;
  6214. /**
  6215. * Returns a Color3 value containing a purple color
  6216. * @returns a new Color3 object
  6217. */
  6218. static Purple(): Color3;
  6219. /**
  6220. * Returns a Color3 value containing a magenta color
  6221. * @returns a new Color3 object
  6222. */
  6223. static Magenta(): Color3;
  6224. /**
  6225. * Returns a Color3 value containing a yellow color
  6226. * @returns a new Color3 object
  6227. */
  6228. static Yellow(): Color3;
  6229. /**
  6230. * Returns a Color3 value containing a gray color
  6231. * @returns a new Color3 object
  6232. */
  6233. static Gray(): Color3;
  6234. /**
  6235. * Returns a Color3 value containing a teal color
  6236. * @returns a new Color3 object
  6237. */
  6238. static Teal(): Color3;
  6239. /**
  6240. * Returns a Color3 value containing a random color
  6241. * @returns a new Color3 object
  6242. */
  6243. static Random(): Color3;
  6244. }
  6245. /**
  6246. * Class used to hold a RBGA color
  6247. */
  6248. export class Color4 {
  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. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6267. * @param r defines the red component (between 0 and 1, default is 0)
  6268. * @param g defines the green component (between 0 and 1, default is 0)
  6269. * @param b defines the blue component (between 0 and 1, default is 0)
  6270. * @param a defines the alpha component (between 0 and 1, default is 1)
  6271. */
  6272. constructor(
  6273. /**
  6274. * Defines the red component (between 0 and 1, default is 0)
  6275. */
  6276. r?: number,
  6277. /**
  6278. * Defines the green component (between 0 and 1, default is 0)
  6279. */
  6280. g?: number,
  6281. /**
  6282. * Defines the blue component (between 0 and 1, default is 0)
  6283. */
  6284. b?: number,
  6285. /**
  6286. * Defines the alpha component (between 0 and 1, default is 1)
  6287. */
  6288. a?: number);
  6289. /**
  6290. * Adds in place the given Color4 values to the current Color4 object
  6291. * @param right defines the second operand
  6292. * @returns the current updated Color4 object
  6293. */
  6294. addInPlace(right: DeepImmutable<Color4>): Color4;
  6295. /**
  6296. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6297. * @returns the new array
  6298. */
  6299. asArray(): number[];
  6300. /**
  6301. * Stores from the starting index in the given array the Color4 successive values
  6302. * @param array defines the array where to store the r,g,b components
  6303. * @param index defines an optional index in the target array to define where to start storing values
  6304. * @returns the current Color4 object
  6305. */
  6306. toArray(array: number[], index?: number): Color4;
  6307. /**
  6308. * Update the current color with values stored in an array from the starting index of the given array
  6309. * @param array defines the source array
  6310. * @param offset defines an offset in the source array
  6311. * @returns the current Color4 object
  6312. */
  6313. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6314. /**
  6315. * Determines equality between Color4 objects
  6316. * @param otherColor defines the second operand
  6317. * @returns true if the rgba values are equal to the given ones
  6318. */
  6319. equals(otherColor: DeepImmutable<Color4>): boolean;
  6320. /**
  6321. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6322. * @param right defines the second operand
  6323. * @returns a new Color4 object
  6324. */
  6325. add(right: DeepImmutable<Color4>): Color4;
  6326. /**
  6327. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6328. * @param right defines the second operand
  6329. * @returns a new Color4 object
  6330. */
  6331. subtract(right: DeepImmutable<Color4>): Color4;
  6332. /**
  6333. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6334. * @param right defines the second operand
  6335. * @param result defines the Color4 object where to store the result
  6336. * @returns the current Color4 object
  6337. */
  6338. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6339. /**
  6340. * Creates a new Color4 with the current Color4 values multiplied by scale
  6341. * @param scale defines the scaling factor to apply
  6342. * @returns a new Color4 object
  6343. */
  6344. scale(scale: number): Color4;
  6345. /**
  6346. * Multiplies the current Color4 values by scale and stores the result in "result"
  6347. * @param scale defines the scaling factor to apply
  6348. * @param result defines the Color4 object where to store the result
  6349. * @returns the current unmodified Color4
  6350. */
  6351. scaleToRef(scale: number, result: Color4): Color4;
  6352. /**
  6353. * Scale the current Color4 values by a factor and add the result to a given Color4
  6354. * @param scale defines the scale factor
  6355. * @param result defines the Color4 object where to store the result
  6356. * @returns the unmodified current Color4
  6357. */
  6358. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6359. /**
  6360. * Clamps the rgb values by the min and max values and stores the result into "result"
  6361. * @param min defines minimum clamping value (default is 0)
  6362. * @param max defines maximum clamping value (default is 1)
  6363. * @param result defines color to store the result into.
  6364. * @returns the cuurent Color4
  6365. */
  6366. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6367. /**
  6368. * Multipy an Color4 value by another and return a new Color4 object
  6369. * @param color defines the Color4 value to multiply by
  6370. * @returns a new Color4 object
  6371. */
  6372. multiply(color: Color4): Color4;
  6373. /**
  6374. * Multipy a Color4 value by another and push the result in a reference value
  6375. * @param color defines the Color4 value to multiply by
  6376. * @param result defines the Color4 to fill the result in
  6377. * @returns the result Color4
  6378. */
  6379. multiplyToRef(color: Color4, result: Color4): Color4;
  6380. /**
  6381. * Creates a string with the Color4 current values
  6382. * @returns the string representation of the Color4 object
  6383. */
  6384. toString(): string;
  6385. /**
  6386. * Returns the string "Color4"
  6387. * @returns "Color4"
  6388. */
  6389. getClassName(): string;
  6390. /**
  6391. * Compute the Color4 hash code
  6392. * @returns an unique number that can be used to hash Color4 objects
  6393. */
  6394. getHashCode(): number;
  6395. /**
  6396. * Creates a new Color4 copied from the current one
  6397. * @returns a new Color4 object
  6398. */
  6399. clone(): Color4;
  6400. /**
  6401. * Copies the given Color4 values into the current one
  6402. * @param source defines the source Color4 object
  6403. * @returns the current updated Color4 object
  6404. */
  6405. copyFrom(source: Color4): Color4;
  6406. /**
  6407. * Copies the given float values into the current one
  6408. * @param r defines the red component to read from
  6409. * @param g defines the green component to read from
  6410. * @param b defines the blue component to read from
  6411. * @param a defines the alpha component to read from
  6412. * @returns the current updated Color4 object
  6413. */
  6414. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6415. /**
  6416. * Copies the given float values into the current one
  6417. * @param r defines the red component to read from
  6418. * @param g defines the green component to read from
  6419. * @param b defines the blue component to read from
  6420. * @param a defines the alpha component to read from
  6421. * @returns the current updated Color4 object
  6422. */
  6423. set(r: number, g: number, b: number, a: number): Color4;
  6424. /**
  6425. * Compute the Color4 hexadecimal code as a string
  6426. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6427. * @returns a string containing the hexadecimal representation of the Color4 object
  6428. */
  6429. toHexString(returnAsColor3?: boolean): string;
  6430. /**
  6431. * Computes a new Color4 converted from the current one to linear space
  6432. * @returns a new Color4 object
  6433. */
  6434. toLinearSpace(): Color4;
  6435. /**
  6436. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6437. * @param convertedColor defines the Color4 object where to store the linear space version
  6438. * @returns the unmodified Color4
  6439. */
  6440. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6441. /**
  6442. * Computes a new Color4 converted from the current one to gamma space
  6443. * @returns a new Color4 object
  6444. */
  6445. toGammaSpace(): Color4;
  6446. /**
  6447. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6448. * @param convertedColor defines the Color4 object where to store the gamma space version
  6449. * @returns the unmodified Color4
  6450. */
  6451. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6452. /**
  6453. * Creates a new Color4 from the string containing valid hexadecimal values
  6454. * @param hex defines a string containing valid hexadecimal values
  6455. * @returns a new Color4 object
  6456. */
  6457. static FromHexString(hex: string): Color4;
  6458. /**
  6459. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6460. * @param left defines the start value
  6461. * @param right defines the end value
  6462. * @param amount defines the gradient factor
  6463. * @returns a new Color4 object
  6464. */
  6465. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6466. /**
  6467. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6468. * @param left defines the start value
  6469. * @param right defines the end value
  6470. * @param amount defines the gradient factor
  6471. * @param result defines the Color4 object where to store data
  6472. */
  6473. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6474. /**
  6475. * Creates a new Color4 from a Color3 and an alpha value
  6476. * @param color3 defines the source Color3 to read from
  6477. * @param alpha defines the alpha component (1.0 by default)
  6478. * @returns a new Color4 object
  6479. */
  6480. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6481. /**
  6482. * Creates a new Color4 from the starting index element of the given array
  6483. * @param array defines the source array to read from
  6484. * @param offset defines the offset in the source array
  6485. * @returns a new Color4 object
  6486. */
  6487. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6488. /**
  6489. * Creates a new Color4 from the starting index element of the given array
  6490. * @param array defines the source array to read from
  6491. * @param offset defines the offset in the source array
  6492. * @param result defines the target Color4 object
  6493. */
  6494. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6495. /**
  6496. * Creates a new Color3 from integer values (< 256)
  6497. * @param r defines the red component to read from (value between 0 and 255)
  6498. * @param g defines the green component to read from (value between 0 and 255)
  6499. * @param b defines the blue component to read from (value between 0 and 255)
  6500. * @param a defines the alpha component to read from (value between 0 and 255)
  6501. * @returns a new Color3 object
  6502. */
  6503. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6504. /**
  6505. * Check the content of a given array and convert it to an array containing RGBA data
  6506. * If the original array was already containing count * 4 values then it is returned directly
  6507. * @param colors defines the array to check
  6508. * @param count defines the number of RGBA data to expect
  6509. * @returns an array containing count * 4 values (RGBA)
  6510. */
  6511. static CheckColors4(colors: number[], count: number): number[];
  6512. }
  6513. /**
  6514. * @hidden
  6515. */
  6516. export class TmpColors {
  6517. static Color3: Color3[];
  6518. static Color4: Color4[];
  6519. }
  6520. }
  6521. declare module BABYLON {
  6522. /**
  6523. * Defines an interface which represents an animation key frame
  6524. */
  6525. export interface IAnimationKey {
  6526. /**
  6527. * Frame of the key frame
  6528. */
  6529. frame: number;
  6530. /**
  6531. * Value at the specifies key frame
  6532. */
  6533. value: any;
  6534. /**
  6535. * The input tangent for the cubic hermite spline
  6536. */
  6537. inTangent?: any;
  6538. /**
  6539. * The output tangent for the cubic hermite spline
  6540. */
  6541. outTangent?: any;
  6542. /**
  6543. * The animation interpolation type
  6544. */
  6545. interpolation?: AnimationKeyInterpolation;
  6546. }
  6547. /**
  6548. * Enum for the animation key frame interpolation type
  6549. */
  6550. export enum AnimationKeyInterpolation {
  6551. /**
  6552. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6553. */
  6554. STEP = 1
  6555. }
  6556. }
  6557. declare module BABYLON {
  6558. /**
  6559. * Represents the range of an animation
  6560. */
  6561. export class AnimationRange {
  6562. /**The name of the animation range**/
  6563. name: string;
  6564. /**The starting frame of the animation */
  6565. from: number;
  6566. /**The ending frame of the animation*/
  6567. to: number;
  6568. /**
  6569. * Initializes the range of an animation
  6570. * @param name The name of the animation range
  6571. * @param from The starting frame of the animation
  6572. * @param to The ending frame of the animation
  6573. */
  6574. constructor(
  6575. /**The name of the animation range**/
  6576. name: string,
  6577. /**The starting frame of the animation */
  6578. from: number,
  6579. /**The ending frame of the animation*/
  6580. to: number);
  6581. /**
  6582. * Makes a copy of the animation range
  6583. * @returns A copy of the animation range
  6584. */
  6585. clone(): AnimationRange;
  6586. }
  6587. }
  6588. declare module BABYLON {
  6589. /**
  6590. * Composed of a frame, and an action function
  6591. */
  6592. export class AnimationEvent {
  6593. /** The frame for which the event is triggered **/
  6594. frame: number;
  6595. /** The event to perform when triggered **/
  6596. action: (currentFrame: number) => void;
  6597. /** Specifies if the event should be triggered only once**/
  6598. onlyOnce?: boolean | undefined;
  6599. /**
  6600. * Specifies if the animation event is done
  6601. */
  6602. isDone: boolean;
  6603. /**
  6604. * Initializes the animation event
  6605. * @param frame The frame for which the event is triggered
  6606. * @param action The event to perform when triggered
  6607. * @param onlyOnce Specifies if the event should be triggered only once
  6608. */
  6609. constructor(
  6610. /** The frame for which the event is triggered **/
  6611. frame: number,
  6612. /** The event to perform when triggered **/
  6613. action: (currentFrame: number) => void,
  6614. /** Specifies if the event should be triggered only once**/
  6615. onlyOnce?: boolean | undefined);
  6616. /** @hidden */
  6617. _clone(): AnimationEvent;
  6618. }
  6619. }
  6620. declare module BABYLON {
  6621. /**
  6622. * Interface used to define a behavior
  6623. */
  6624. export interface Behavior<T> {
  6625. /** gets or sets behavior's name */
  6626. name: string;
  6627. /**
  6628. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6629. */
  6630. init(): void;
  6631. /**
  6632. * Called when the behavior is attached to a target
  6633. * @param target defines the target where the behavior is attached to
  6634. */
  6635. attach(target: T): void;
  6636. /**
  6637. * Called when the behavior is detached from its target
  6638. */
  6639. detach(): void;
  6640. }
  6641. /**
  6642. * Interface implemented by classes supporting behaviors
  6643. */
  6644. export interface IBehaviorAware<T> {
  6645. /**
  6646. * Attach a behavior
  6647. * @param behavior defines the behavior to attach
  6648. * @returns the current host
  6649. */
  6650. addBehavior(behavior: Behavior<T>): T;
  6651. /**
  6652. * Remove a behavior from the current object
  6653. * @param behavior defines the behavior to detach
  6654. * @returns the current host
  6655. */
  6656. removeBehavior(behavior: Behavior<T>): T;
  6657. /**
  6658. * Gets a behavior using its name to search
  6659. * @param name defines the name to search
  6660. * @returns the behavior or null if not found
  6661. */
  6662. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6663. }
  6664. }
  6665. declare module BABYLON {
  6666. /**
  6667. * Class used to store data that will be store in GPU memory
  6668. */
  6669. export class Buffer {
  6670. private _engine;
  6671. private _buffer;
  6672. /** @hidden */
  6673. _data: Nullable<DataArray>;
  6674. private _updatable;
  6675. private _instanced;
  6676. private _divisor;
  6677. private _isAlreadyOwned;
  6678. /**
  6679. * Gets the byte stride.
  6680. */
  6681. readonly byteStride: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this buffer
  6686. * @param updatable whether the data is updatable
  6687. * @param stride the stride (optional)
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param instanced whether the buffer is instanced (optional)
  6690. * @param useBytes set to true if the stride in in bytes (optional)
  6691. * @param divisor sets an optional divisor for instances (1 by default)
  6692. */
  6693. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6694. /**
  6695. * Create a new VertexBuffer based on the current buffer
  6696. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6697. * @param offset defines offset in the buffer (0 by default)
  6698. * @param size defines the size in floats of attributes (position is 3 for instance)
  6699. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6700. * @param instanced defines if the vertex buffer contains indexed data
  6701. * @param useBytes defines if the offset and stride are in bytes *
  6702. * @param divisor sets an optional divisor for instances (1 by default)
  6703. * @returns the new vertex buffer
  6704. */
  6705. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6706. /**
  6707. * Gets a boolean indicating if the Buffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6730. * @param data defines the data to store
  6731. */
  6732. create(data?: Nullable<DataArray>): void;
  6733. /** @hidden */
  6734. _rebuild(): void;
  6735. /**
  6736. * Update current buffer data
  6737. * @param data defines the data to store
  6738. */
  6739. update(data: DataArray): void;
  6740. /**
  6741. * Updates the data directly.
  6742. * @param data the new data
  6743. * @param offset the new offset
  6744. * @param vertexCount the vertex count (optional)
  6745. * @param useBytes set to true if the offset is in bytes
  6746. */
  6747. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6748. /** @hidden */
  6749. _increaseReferences(): void;
  6750. /**
  6751. * Release all resources
  6752. */
  6753. dispose(): void;
  6754. }
  6755. /**
  6756. * Specialized buffer used to store vertex data
  6757. */
  6758. export class VertexBuffer {
  6759. /** @hidden */
  6760. _buffer: Buffer;
  6761. private _kind;
  6762. private _size;
  6763. private _ownsBuffer;
  6764. private _instanced;
  6765. private _instanceDivisor;
  6766. /**
  6767. * The byte type.
  6768. */
  6769. static readonly BYTE: number;
  6770. /**
  6771. * The unsigned byte type.
  6772. */
  6773. static readonly UNSIGNED_BYTE: number;
  6774. /**
  6775. * The short type.
  6776. */
  6777. static readonly SHORT: number;
  6778. /**
  6779. * The unsigned short type.
  6780. */
  6781. static readonly UNSIGNED_SHORT: number;
  6782. /**
  6783. * The integer type.
  6784. */
  6785. static readonly INT: number;
  6786. /**
  6787. * The unsigned integer type.
  6788. */
  6789. static readonly UNSIGNED_INT: number;
  6790. /**
  6791. * The float type.
  6792. */
  6793. static readonly FLOAT: number;
  6794. /**
  6795. * Gets or sets the instance divisor when in instanced mode
  6796. */
  6797. get instanceDivisor(): number;
  6798. set instanceDivisor(value: number);
  6799. /**
  6800. * Gets the byte stride.
  6801. */
  6802. readonly byteStride: number;
  6803. /**
  6804. * Gets the byte offset.
  6805. */
  6806. readonly byteOffset: number;
  6807. /**
  6808. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6809. */
  6810. readonly normalized: boolean;
  6811. /**
  6812. * Gets the data type of each component in the array.
  6813. */
  6814. readonly type: number;
  6815. /**
  6816. * Constructor
  6817. * @param engine the engine
  6818. * @param data the data to use for this vertex buffer
  6819. * @param kind the vertex buffer kind
  6820. * @param updatable whether the data is updatable
  6821. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6822. * @param stride the stride (optional)
  6823. * @param instanced whether the buffer is instanced (optional)
  6824. * @param offset the offset of the data (optional)
  6825. * @param size the number of components (optional)
  6826. * @param type the type of the component (optional)
  6827. * @param normalized whether the data contains normalized data (optional)
  6828. * @param useBytes set to true if stride and offset are in bytes (optional)
  6829. * @param divisor defines the instance divisor to use (1 by default)
  6830. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6831. */
  6832. 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);
  6833. /** @hidden */
  6834. _rebuild(): void;
  6835. /**
  6836. * Returns the kind of the VertexBuffer (string)
  6837. * @returns a string
  6838. */
  6839. getKind(): string;
  6840. /**
  6841. * Gets a boolean indicating if the VertexBuffer is updatable?
  6842. * @returns true if the buffer is updatable
  6843. */
  6844. isUpdatable(): boolean;
  6845. /**
  6846. * Gets current buffer's data
  6847. * @returns a DataArray or null
  6848. */
  6849. getData(): Nullable<DataArray>;
  6850. /**
  6851. * Gets underlying native buffer
  6852. * @returns underlying native buffer
  6853. */
  6854. getBuffer(): Nullable<DataBuffer>;
  6855. /**
  6856. * Gets the stride in float32 units (i.e. byte stride / 4).
  6857. * May not be an integer if the byte stride is not divisible by 4.
  6858. * @returns the stride in float32 units
  6859. * @deprecated Please use byteStride instead.
  6860. */
  6861. getStrideSize(): number;
  6862. /**
  6863. * Returns the offset as a multiple of the type byte length.
  6864. * @returns the offset in bytes
  6865. * @deprecated Please use byteOffset instead.
  6866. */
  6867. getOffset(): number;
  6868. /**
  6869. * Returns the number of components per vertex attribute (integer)
  6870. * @returns the size in float
  6871. */
  6872. getSize(): number;
  6873. /**
  6874. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6875. * @returns true if this buffer is instanced
  6876. */
  6877. getIsInstanced(): boolean;
  6878. /**
  6879. * Returns the instancing divisor, zero for non-instanced (integer).
  6880. * @returns a number
  6881. */
  6882. getInstanceDivisor(): number;
  6883. /**
  6884. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6885. * @param data defines the data to store
  6886. */
  6887. create(data?: DataArray): void;
  6888. /**
  6889. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6890. * This function will create a new buffer if the current one is not updatable
  6891. * @param data defines the data to store
  6892. */
  6893. update(data: DataArray): void;
  6894. /**
  6895. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6896. * Returns the directly updated WebGLBuffer.
  6897. * @param data the new data
  6898. * @param offset the new offset
  6899. * @param useBytes set to true if the offset is in bytes
  6900. */
  6901. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6902. /**
  6903. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6904. */
  6905. dispose(): void;
  6906. /**
  6907. * Enumerates each value of this vertex buffer as numbers.
  6908. * @param count the number of values to enumerate
  6909. * @param callback the callback function called for each value
  6910. */
  6911. forEach(count: number, callback: (value: number, index: number) => void): void;
  6912. /**
  6913. * Positions
  6914. */
  6915. static readonly PositionKind: string;
  6916. /**
  6917. * Normals
  6918. */
  6919. static readonly NormalKind: string;
  6920. /**
  6921. * Tangents
  6922. */
  6923. static readonly TangentKind: string;
  6924. /**
  6925. * Texture coordinates
  6926. */
  6927. static readonly UVKind: string;
  6928. /**
  6929. * Texture coordinates 2
  6930. */
  6931. static readonly UV2Kind: string;
  6932. /**
  6933. * Texture coordinates 3
  6934. */
  6935. static readonly UV3Kind: string;
  6936. /**
  6937. * Texture coordinates 4
  6938. */
  6939. static readonly UV4Kind: string;
  6940. /**
  6941. * Texture coordinates 5
  6942. */
  6943. static readonly UV5Kind: string;
  6944. /**
  6945. * Texture coordinates 6
  6946. */
  6947. static readonly UV6Kind: string;
  6948. /**
  6949. * Colors
  6950. */
  6951. static readonly ColorKind: string;
  6952. /**
  6953. * Matrix indices (for bones)
  6954. */
  6955. static readonly MatricesIndicesKind: string;
  6956. /**
  6957. * Matrix weights (for bones)
  6958. */
  6959. static readonly MatricesWeightsKind: string;
  6960. /**
  6961. * Additional matrix indices (for bones)
  6962. */
  6963. static readonly MatricesIndicesExtraKind: string;
  6964. /**
  6965. * Additional matrix weights (for bones)
  6966. */
  6967. static readonly MatricesWeightsExtraKind: string;
  6968. /**
  6969. * Deduces the stride given a kind.
  6970. * @param kind The kind string to deduce
  6971. * @returns The deduced stride
  6972. */
  6973. static DeduceStride(kind: string): number;
  6974. /**
  6975. * Gets the byte length of the given type.
  6976. * @param type the type
  6977. * @returns the number of bytes
  6978. */
  6979. static GetTypeByteLength(type: number): number;
  6980. /**
  6981. * Enumerates each value of the given parameters as numbers.
  6982. * @param data the data to enumerate
  6983. * @param byteOffset the byte offset of the data
  6984. * @param byteStride the byte stride of the data
  6985. * @param componentCount the number of components per element
  6986. * @param componentType the type of the component
  6987. * @param count the number of values to enumerate
  6988. * @param normalized whether the data is normalized
  6989. * @param callback the callback function called for each value
  6990. */
  6991. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6992. private static _GetFloatValue;
  6993. }
  6994. }
  6995. declare module BABYLON {
  6996. /**
  6997. * @hidden
  6998. */
  6999. export class IntersectionInfo {
  7000. bu: Nullable<number>;
  7001. bv: Nullable<number>;
  7002. distance: number;
  7003. faceId: number;
  7004. subMeshId: number;
  7005. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7006. }
  7007. }
  7008. declare module BABYLON {
  7009. /**
  7010. * Class used to store bounding sphere information
  7011. */
  7012. export class BoundingSphere {
  7013. /**
  7014. * Gets the center of the bounding sphere in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Radius of the bounding sphere in local space
  7019. */
  7020. radius: number;
  7021. /**
  7022. * Gets the center of the bounding sphere in world space
  7023. */
  7024. readonly centerWorld: Vector3;
  7025. /**
  7026. * Radius of the bounding sphere in world space
  7027. */
  7028. radiusWorld: number;
  7029. /**
  7030. * Gets the minimum vector in local space
  7031. */
  7032. readonly minimum: Vector3;
  7033. /**
  7034. * Gets the maximum vector in local space
  7035. */
  7036. readonly maximum: Vector3;
  7037. private _worldMatrix;
  7038. private static readonly TmpVector3;
  7039. /**
  7040. * Creates a new bounding sphere
  7041. * @param min defines the minimum vector (in local space)
  7042. * @param max defines the maximum vector (in local space)
  7043. * @param worldMatrix defines the new world matrix
  7044. */
  7045. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7046. /**
  7047. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7048. * @param min defines the new minimum vector (in local space)
  7049. * @param max defines the new maximum vector (in local space)
  7050. * @param worldMatrix defines the new world matrix
  7051. */
  7052. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Scale the current bounding sphere by applying a scale factor
  7055. * @param factor defines the scale factor to apply
  7056. * @returns the current bounding box
  7057. */
  7058. scale(factor: number): BoundingSphere;
  7059. /**
  7060. * Gets the world matrix of the bounding box
  7061. * @returns a matrix
  7062. */
  7063. getWorldMatrix(): DeepImmutable<Matrix>;
  7064. /** @hidden */
  7065. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * Tests if the bounding sphere is intersecting the frustum planes
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. /**
  7073. * Tests if the bounding sphere center is in between the frustum planes.
  7074. * Used for optimistic fast inclusion.
  7075. * @param frustumPlanes defines the frustum planes to test
  7076. * @returns true if the sphere center is in between the frustum planes
  7077. */
  7078. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7079. /**
  7080. * Tests if a point is inside the bounding sphere
  7081. * @param point defines the point to test
  7082. * @returns true if the point is inside the bounding sphere
  7083. */
  7084. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Checks if two sphere intersct
  7087. * @param sphere0 sphere 0
  7088. * @param sphere1 sphere 1
  7089. * @returns true if the speres intersect
  7090. */
  7091. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7092. }
  7093. }
  7094. declare module BABYLON {
  7095. /**
  7096. * Class used to store bounding box information
  7097. */
  7098. export class BoundingBox implements ICullable {
  7099. /**
  7100. * Gets the 8 vectors representing the bounding box in local space
  7101. */
  7102. readonly vectors: Vector3[];
  7103. /**
  7104. * Gets the center of the bounding box in local space
  7105. */
  7106. readonly center: Vector3;
  7107. /**
  7108. * Gets the center of the bounding box in world space
  7109. */
  7110. readonly centerWorld: Vector3;
  7111. /**
  7112. * Gets the extend size in local space
  7113. */
  7114. readonly extendSize: Vector3;
  7115. /**
  7116. * Gets the extend size in world space
  7117. */
  7118. readonly extendSizeWorld: Vector3;
  7119. /**
  7120. * Gets the OBB (object bounding box) directions
  7121. */
  7122. readonly directions: Vector3[];
  7123. /**
  7124. * Gets the 8 vectors representing the bounding box in world space
  7125. */
  7126. readonly vectorsWorld: Vector3[];
  7127. /**
  7128. * Gets the minimum vector in world space
  7129. */
  7130. readonly minimumWorld: Vector3;
  7131. /**
  7132. * Gets the maximum vector in world space
  7133. */
  7134. readonly maximumWorld: Vector3;
  7135. /**
  7136. * Gets the minimum vector in local space
  7137. */
  7138. readonly minimum: Vector3;
  7139. /**
  7140. * Gets the maximum vector in local space
  7141. */
  7142. readonly maximum: Vector3;
  7143. private _worldMatrix;
  7144. private static readonly TmpVector3;
  7145. /**
  7146. * @hidden
  7147. */
  7148. _tag: number;
  7149. /**
  7150. * Creates a new bounding box
  7151. * @param min defines the minimum vector (in local space)
  7152. * @param max defines the maximum vector (in local space)
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * Scale the current bounding box by applying a scale factor
  7165. * @param factor defines the scale factor to apply
  7166. * @returns the current bounding box
  7167. */
  7168. scale(factor: number): BoundingBox;
  7169. /**
  7170. * Gets the world matrix of the bounding box
  7171. * @returns a matrix
  7172. */
  7173. getWorldMatrix(): DeepImmutable<Matrix>;
  7174. /** @hidden */
  7175. _update(world: DeepImmutable<Matrix>): void;
  7176. /**
  7177. * Tests if the bounding box is intersecting the frustum planes
  7178. * @param frustumPlanes defines the frustum planes to test
  7179. * @returns true if there is an intersection
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7182. /**
  7183. * Tests if the bounding box is entirely inside the frustum planes
  7184. * @param frustumPlanes defines the frustum planes to test
  7185. * @returns true if there is an inclusion
  7186. */
  7187. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7188. /**
  7189. * Tests if a point is inside the bounding box
  7190. * @param point defines the point to test
  7191. * @returns true if the point is inside the bounding box
  7192. */
  7193. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7194. /**
  7195. * Tests if the bounding box intersects with a bounding sphere
  7196. * @param sphere defines the sphere to test
  7197. * @returns true if there is an intersection
  7198. */
  7199. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7200. /**
  7201. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7202. * @param min defines the min vector to use
  7203. * @param max defines the max vector to use
  7204. * @returns true if there is an intersection
  7205. */
  7206. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7207. /**
  7208. * Tests if two bounding boxes are intersections
  7209. * @param box0 defines the first box to test
  7210. * @param box1 defines the second box to test
  7211. * @returns true if there is an intersection
  7212. */
  7213. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7214. /**
  7215. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7216. * @param minPoint defines the minimum vector of the bounding box
  7217. * @param maxPoint defines the maximum vector of the bounding box
  7218. * @param sphereCenter defines the sphere center
  7219. * @param sphereRadius defines the sphere radius
  7220. * @returns true if there is an intersection
  7221. */
  7222. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7223. /**
  7224. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7225. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7226. * @param frustumPlanes defines the frustum planes to test
  7227. * @return true if there is an inclusion
  7228. */
  7229. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7230. /**
  7231. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7232. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7233. * @param frustumPlanes defines the frustum planes to test
  7234. * @return true if there is an intersection
  7235. */
  7236. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7237. }
  7238. }
  7239. declare module BABYLON {
  7240. /** @hidden */
  7241. export class Collider {
  7242. /** Define if a collision was found */
  7243. collisionFound: boolean;
  7244. /**
  7245. * Define last intersection point in local space
  7246. */
  7247. intersectionPoint: Vector3;
  7248. /**
  7249. * Define last collided mesh
  7250. */
  7251. collidedMesh: Nullable<AbstractMesh>;
  7252. private _collisionPoint;
  7253. private _planeIntersectionPoint;
  7254. private _tempVector;
  7255. private _tempVector2;
  7256. private _tempVector3;
  7257. private _tempVector4;
  7258. private _edge;
  7259. private _baseToVertex;
  7260. private _destinationPoint;
  7261. private _slidePlaneNormal;
  7262. private _displacementVector;
  7263. /** @hidden */
  7264. _radius: Vector3;
  7265. /** @hidden */
  7266. _retry: number;
  7267. private _velocity;
  7268. private _basePoint;
  7269. private _epsilon;
  7270. /** @hidden */
  7271. _velocityWorldLength: number;
  7272. /** @hidden */
  7273. _basePointWorld: Vector3;
  7274. private _velocityWorld;
  7275. private _normalizedVelocity;
  7276. /** @hidden */
  7277. _initialVelocity: Vector3;
  7278. /** @hidden */
  7279. _initialPosition: Vector3;
  7280. private _nearestDistance;
  7281. private _collisionMask;
  7282. get collisionMask(): number;
  7283. set collisionMask(mask: number);
  7284. /**
  7285. * Gets the plane normal used to compute the sliding response (in local space)
  7286. */
  7287. get slidePlaneNormal(): Vector3;
  7288. /** @hidden */
  7289. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7290. /** @hidden */
  7291. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7292. /** @hidden */
  7293. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7294. /** @hidden */
  7295. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7296. /** @hidden */
  7297. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7298. /** @hidden */
  7299. _getResponse(pos: Vector3, vel: Vector3): void;
  7300. }
  7301. }
  7302. declare module BABYLON {
  7303. /**
  7304. * Interface for cullable objects
  7305. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7306. */
  7307. export interface ICullable {
  7308. /**
  7309. * Checks if the object or part of the object is in the frustum
  7310. * @param frustumPlanes Camera near/planes
  7311. * @returns true if the object is in frustum otherwise false
  7312. */
  7313. isInFrustum(frustumPlanes: Plane[]): boolean;
  7314. /**
  7315. * Checks if a cullable object (mesh...) is in the camera frustum
  7316. * Unlike isInFrustum this cheks the full bounding box
  7317. * @param frustumPlanes Camera near/planes
  7318. * @returns true if the object is in frustum otherwise false
  7319. */
  7320. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7321. }
  7322. /**
  7323. * Info for a bounding data of a mesh
  7324. */
  7325. export class BoundingInfo implements ICullable {
  7326. /**
  7327. * Bounding box for the mesh
  7328. */
  7329. readonly boundingBox: BoundingBox;
  7330. /**
  7331. * Bounding sphere for the mesh
  7332. */
  7333. readonly boundingSphere: BoundingSphere;
  7334. private _isLocked;
  7335. private static readonly TmpVector3;
  7336. /**
  7337. * Constructs bounding info
  7338. * @param minimum min vector of the bounding box/sphere
  7339. * @param maximum max vector of the bounding box/sphere
  7340. * @param worldMatrix defines the new world matrix
  7341. */
  7342. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7343. /**
  7344. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7345. * @param min defines the new minimum vector (in local space)
  7346. * @param max defines the new maximum vector (in local space)
  7347. * @param worldMatrix defines the new world matrix
  7348. */
  7349. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7350. /**
  7351. * min vector of the bounding box/sphere
  7352. */
  7353. get minimum(): Vector3;
  7354. /**
  7355. * max vector of the bounding box/sphere
  7356. */
  7357. get maximum(): Vector3;
  7358. /**
  7359. * If the info is locked and won't be updated to avoid perf overhead
  7360. */
  7361. get isLocked(): boolean;
  7362. set isLocked(value: boolean);
  7363. /**
  7364. * Updates the bounding sphere and box
  7365. * @param world world matrix to be used to update
  7366. */
  7367. update(world: DeepImmutable<Matrix>): void;
  7368. /**
  7369. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7370. * @param center New center of the bounding info
  7371. * @param extend New extend of the bounding info
  7372. * @returns the current bounding info
  7373. */
  7374. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7375. /**
  7376. * Scale the current bounding info by applying a scale factor
  7377. * @param factor defines the scale factor to apply
  7378. * @returns the current bounding info
  7379. */
  7380. scale(factor: number): BoundingInfo;
  7381. /**
  7382. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7383. * @param frustumPlanes defines the frustum to test
  7384. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7385. * @returns true if the bounding info is in the frustum planes
  7386. */
  7387. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7388. /**
  7389. * Gets the world distance between the min and max points of the bounding box
  7390. */
  7391. get diagonalLength(): number;
  7392. /**
  7393. * Checks if a cullable object (mesh...) is in the camera frustum
  7394. * Unlike isInFrustum this cheks the full bounding box
  7395. * @param frustumPlanes Camera near/planes
  7396. * @returns true if the object is in frustum otherwise false
  7397. */
  7398. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7399. /** @hidden */
  7400. _checkCollision(collider: Collider): boolean;
  7401. /**
  7402. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7403. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7404. * @param point the point to check intersection with
  7405. * @returns if the point intersects
  7406. */
  7407. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7408. /**
  7409. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7410. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7411. * @param boundingInfo the bounding info to check intersection with
  7412. * @param precise if the intersection should be done using OBB
  7413. * @returns if the bounding info intersects
  7414. */
  7415. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7416. }
  7417. }
  7418. declare module BABYLON {
  7419. /**
  7420. * Extracts minimum and maximum values from a list of indexed positions
  7421. * @param positions defines the positions to use
  7422. * @param indices defines the indices to the positions
  7423. * @param indexStart defines the start index
  7424. * @param indexCount defines the end index
  7425. * @param bias defines bias value to add to the result
  7426. * @return minimum and maximum values
  7427. */
  7428. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7429. minimum: Vector3;
  7430. maximum: Vector3;
  7431. };
  7432. /**
  7433. * Extracts minimum and maximum values from a list of positions
  7434. * @param positions defines the positions to use
  7435. * @param start defines the start index in the positions array
  7436. * @param count defines the number of positions to handle
  7437. * @param bias defines bias value to add to the result
  7438. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7439. * @return minimum and maximum values
  7440. */
  7441. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7442. minimum: Vector3;
  7443. maximum: Vector3;
  7444. };
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class used to manipulate GUIDs
  7449. */
  7450. export class GUID {
  7451. /**
  7452. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7453. * Be aware Math.random() could cause collisions, but:
  7454. * "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"
  7455. * @returns a pseudo random id
  7456. */
  7457. static RandomId(): string;
  7458. }
  7459. }
  7460. declare module BABYLON {
  7461. /**
  7462. * Base class of all the textures in babylon.
  7463. * It groups all the common properties the materials, post process, lights... might need
  7464. * in order to make a correct use of the texture.
  7465. */
  7466. export class BaseTexture extends ThinTexture implements IAnimatable {
  7467. /**
  7468. * Default anisotropic filtering level for the application.
  7469. * It is set to 4 as a good tradeoff between perf and quality.
  7470. */
  7471. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7472. /**
  7473. * Gets or sets the unique id of the texture
  7474. */
  7475. uniqueId: number;
  7476. /**
  7477. * Define the name of the texture.
  7478. */
  7479. name: string;
  7480. /**
  7481. * Gets or sets an object used to store user defined information.
  7482. */
  7483. metadata: any;
  7484. /**
  7485. * For internal use only. Please do not use.
  7486. */
  7487. reservedDataStore: any;
  7488. private _hasAlpha;
  7489. /**
  7490. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7491. */
  7492. set hasAlpha(value: boolean);
  7493. get hasAlpha(): boolean;
  7494. /**
  7495. * Defines if the alpha value should be determined via the rgb values.
  7496. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7497. */
  7498. getAlphaFromRGB: boolean;
  7499. /**
  7500. * Intensity or strength of the texture.
  7501. * It is commonly used by materials to fine tune the intensity of the texture
  7502. */
  7503. level: number;
  7504. /**
  7505. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7506. * This is part of the texture as textures usually maps to one uv set.
  7507. */
  7508. coordinatesIndex: number;
  7509. protected _coordinatesMode: number;
  7510. /**
  7511. * How a texture is mapped.
  7512. *
  7513. * | Value | Type | Description |
  7514. * | ----- | ----------------------------------- | ----------- |
  7515. * | 0 | EXPLICIT_MODE | |
  7516. * | 1 | SPHERICAL_MODE | |
  7517. * | 2 | PLANAR_MODE | |
  7518. * | 3 | CUBIC_MODE | |
  7519. * | 4 | PROJECTION_MODE | |
  7520. * | 5 | SKYBOX_MODE | |
  7521. * | 6 | INVCUBIC_MODE | |
  7522. * | 7 | EQUIRECTANGULAR_MODE | |
  7523. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7524. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7525. */
  7526. set coordinatesMode(value: number);
  7527. get coordinatesMode(): number;
  7528. /**
  7529. * | Value | Type | Description |
  7530. * | ----- | ------------------ | ----------- |
  7531. * | 0 | CLAMP_ADDRESSMODE | |
  7532. * | 1 | WRAP_ADDRESSMODE | |
  7533. * | 2 | MIRROR_ADDRESSMODE | |
  7534. */
  7535. get wrapU(): number;
  7536. set wrapU(value: number);
  7537. /**
  7538. * | Value | Type | Description |
  7539. * | ----- | ------------------ | ----------- |
  7540. * | 0 | CLAMP_ADDRESSMODE | |
  7541. * | 1 | WRAP_ADDRESSMODE | |
  7542. * | 2 | MIRROR_ADDRESSMODE | |
  7543. */
  7544. get wrapV(): number;
  7545. set wrapV(value: number);
  7546. /**
  7547. * | Value | Type | Description |
  7548. * | ----- | ------------------ | ----------- |
  7549. * | 0 | CLAMP_ADDRESSMODE | |
  7550. * | 1 | WRAP_ADDRESSMODE | |
  7551. * | 2 | MIRROR_ADDRESSMODE | |
  7552. */
  7553. wrapR: number;
  7554. /**
  7555. * With compliant hardware and browser (supporting anisotropic filtering)
  7556. * this defines the level of anisotropic filtering in the texture.
  7557. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7558. */
  7559. anisotropicFilteringLevel: number;
  7560. private _isCube;
  7561. /**
  7562. * Define if the texture is a cube texture or if false a 2d texture.
  7563. */
  7564. get isCube(): boolean;
  7565. set isCube(value: boolean);
  7566. /**
  7567. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7568. */
  7569. get is3D(): boolean;
  7570. set is3D(value: boolean);
  7571. /**
  7572. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7573. */
  7574. get is2DArray(): boolean;
  7575. set is2DArray(value: boolean);
  7576. private _gammaSpace;
  7577. /**
  7578. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7579. * HDR texture are usually stored in linear space.
  7580. * This only impacts the PBR and Background materials
  7581. */
  7582. get gammaSpace(): boolean;
  7583. set gammaSpace(gamma: boolean);
  7584. /**
  7585. * Gets or sets whether or not the texture contains RGBD data.
  7586. */
  7587. get isRGBD(): boolean;
  7588. set isRGBD(value: boolean);
  7589. /**
  7590. * Is Z inverted in the texture (useful in a cube texture).
  7591. */
  7592. invertZ: boolean;
  7593. /**
  7594. * Are mip maps generated for this texture or not.
  7595. */
  7596. get noMipmap(): boolean;
  7597. /**
  7598. * @hidden
  7599. */
  7600. lodLevelInAlpha: boolean;
  7601. /**
  7602. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7603. */
  7604. get lodGenerationOffset(): number;
  7605. set lodGenerationOffset(value: number);
  7606. /**
  7607. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7608. */
  7609. get lodGenerationScale(): number;
  7610. set lodGenerationScale(value: number);
  7611. /**
  7612. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7613. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7614. * average roughness values.
  7615. */
  7616. get linearSpecularLOD(): boolean;
  7617. set linearSpecularLOD(value: boolean);
  7618. /**
  7619. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7620. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7621. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7622. */
  7623. get irradianceTexture(): Nullable<BaseTexture>;
  7624. set irradianceTexture(value: Nullable<BaseTexture>);
  7625. /**
  7626. * Define if the texture is a render target.
  7627. */
  7628. isRenderTarget: boolean;
  7629. /**
  7630. * Define the unique id of the texture in the scene.
  7631. */
  7632. get uid(): string;
  7633. /** @hidden */
  7634. _prefiltered: boolean;
  7635. /**
  7636. * Return a string representation of the texture.
  7637. * @returns the texture as a string
  7638. */
  7639. toString(): string;
  7640. /**
  7641. * Get the class name of the texture.
  7642. * @returns "BaseTexture"
  7643. */
  7644. getClassName(): string;
  7645. /**
  7646. * Define the list of animation attached to the texture.
  7647. */
  7648. animations: Animation[];
  7649. /**
  7650. * An event triggered when the texture is disposed.
  7651. */
  7652. onDisposeObservable: Observable<BaseTexture>;
  7653. private _onDisposeObserver;
  7654. /**
  7655. * Callback triggered when the texture has been disposed.
  7656. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7657. */
  7658. set onDispose(callback: () => void);
  7659. protected _scene: Nullable<Scene>;
  7660. /** @hidden */
  7661. _texture: Nullable<InternalTexture>;
  7662. private _uid;
  7663. /**
  7664. * Define if the texture is preventinga material to render or not.
  7665. * If not and the texture is not ready, the engine will use a default black texture instead.
  7666. */
  7667. get isBlocking(): boolean;
  7668. /**
  7669. * Instantiates a new BaseTexture.
  7670. * Base class of all the textures in babylon.
  7671. * It groups all the common properties the materials, post process, lights... might need
  7672. * in order to make a correct use of the texture.
  7673. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7674. */
  7675. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7676. /**
  7677. * Get the scene the texture belongs to.
  7678. * @returns the scene or null if undefined
  7679. */
  7680. getScene(): Nullable<Scene>;
  7681. /** @hidden */
  7682. protected _getEngine(): Nullable<ThinEngine>;
  7683. /**
  7684. * Checks if the texture has the same transform matrix than another texture
  7685. * @param texture texture to check against
  7686. * @returns true if the transforms are the same, else false
  7687. */
  7688. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7689. /**
  7690. * Get the texture transform matrix used to offset tile the texture for istance.
  7691. * @returns the transformation matrix
  7692. */
  7693. getTextureMatrix(): Matrix;
  7694. /**
  7695. * Get the texture reflection matrix used to rotate/transform the reflection.
  7696. * @returns the reflection matrix
  7697. */
  7698. getReflectionTextureMatrix(): Matrix;
  7699. /**
  7700. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7701. * @returns true if ready or not blocking
  7702. */
  7703. isReadyOrNotBlocking(): boolean;
  7704. /**
  7705. * Scales the texture if is `canRescale()`
  7706. * @param ratio the resize factor we want to use to rescale
  7707. */
  7708. scale(ratio: number): void;
  7709. /**
  7710. * Get if the texture can rescale.
  7711. */
  7712. get canRescale(): boolean;
  7713. /** @hidden */
  7714. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7715. /** @hidden */
  7716. _rebuild(): void;
  7717. /**
  7718. * Clones the texture.
  7719. * @returns the cloned texture
  7720. */
  7721. clone(): Nullable<BaseTexture>;
  7722. /**
  7723. * Get the texture underlying type (INT, FLOAT...)
  7724. */
  7725. get textureType(): number;
  7726. /**
  7727. * Get the texture underlying format (RGB, RGBA...)
  7728. */
  7729. get textureFormat(): number;
  7730. /**
  7731. * Indicates that textures need to be re-calculated for all materials
  7732. */
  7733. protected _markAllSubMeshesAsTexturesDirty(): void;
  7734. /**
  7735. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7736. * This will returns an RGBA array buffer containing either in values (0-255) or
  7737. * float values (0-1) depending of the underlying buffer type.
  7738. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7739. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7740. * @param buffer defines a user defined buffer to fill with data (can be null)
  7741. * @returns The Array buffer containing the pixels data.
  7742. */
  7743. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7744. /** @hidden */
  7745. get _lodTextureHigh(): Nullable<BaseTexture>;
  7746. /** @hidden */
  7747. get _lodTextureMid(): Nullable<BaseTexture>;
  7748. /** @hidden */
  7749. get _lodTextureLow(): Nullable<BaseTexture>;
  7750. /**
  7751. * Dispose the texture and release its associated resources.
  7752. */
  7753. dispose(): void;
  7754. /**
  7755. * Serialize the texture into a JSON representation that can be parsed later on.
  7756. * @returns the JSON representation of the texture
  7757. */
  7758. serialize(): any;
  7759. /**
  7760. * Helper function to be called back once a list of texture contains only ready textures.
  7761. * @param textures Define the list of textures to wait for
  7762. * @param callback Define the callback triggered once the entire list will be ready
  7763. */
  7764. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7765. private static _isScene;
  7766. }
  7767. }
  7768. declare module BABYLON {
  7769. /** @hidden */
  7770. export class WebGLDataBuffer extends DataBuffer {
  7771. private _buffer;
  7772. constructor(resource: WebGLBuffer);
  7773. get underlyingResource(): any;
  7774. }
  7775. }
  7776. declare module BABYLON {
  7777. /** @hidden */
  7778. export class WebGLPipelineContext implements IPipelineContext {
  7779. engine: ThinEngine;
  7780. program: Nullable<WebGLProgram>;
  7781. context?: WebGLRenderingContext;
  7782. vertexShader?: WebGLShader;
  7783. fragmentShader?: WebGLShader;
  7784. isParallelCompiled: boolean;
  7785. onCompiled?: () => void;
  7786. transformFeedback?: WebGLTransformFeedback | null;
  7787. vertexCompilationError: Nullable<string>;
  7788. fragmentCompilationError: Nullable<string>;
  7789. programLinkError: Nullable<string>;
  7790. programValidationError: Nullable<string>;
  7791. get isAsync(): boolean;
  7792. get isReady(): boolean;
  7793. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7794. _getVertexShaderCode(): string | null;
  7795. _getFragmentShaderCode(): string | null;
  7796. }
  7797. }
  7798. declare module BABYLON {
  7799. interface ThinEngine {
  7800. /**
  7801. * Create an uniform buffer
  7802. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7803. * @param elements defines the content of the uniform buffer
  7804. * @returns the webGL uniform buffer
  7805. */
  7806. createUniformBuffer(elements: FloatArray): DataBuffer;
  7807. /**
  7808. * Create a dynamic uniform buffer
  7809. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7810. * @param elements defines the content of the uniform buffer
  7811. * @returns the webGL uniform buffer
  7812. */
  7813. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7814. /**
  7815. * Update an existing uniform buffer
  7816. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7817. * @param uniformBuffer defines the target uniform buffer
  7818. * @param elements defines the content to update
  7819. * @param offset defines the offset in the uniform buffer where update should start
  7820. * @param count defines the size of the data to update
  7821. */
  7822. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7823. /**
  7824. * Bind an uniform buffer to the current webGL context
  7825. * @param buffer defines the buffer to bind
  7826. */
  7827. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7828. /**
  7829. * Bind a buffer to the current webGL context at a given location
  7830. * @param buffer defines the buffer to bind
  7831. * @param location defines the index where to bind the buffer
  7832. */
  7833. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7834. /**
  7835. * Bind a specific block at a given index in a specific shader program
  7836. * @param pipelineContext defines the pipeline context to use
  7837. * @param blockName defines the block name
  7838. * @param index defines the index where to bind the block
  7839. */
  7840. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7841. }
  7842. }
  7843. declare module BABYLON {
  7844. /**
  7845. * Uniform buffer objects.
  7846. *
  7847. * Handles blocks of uniform on the GPU.
  7848. *
  7849. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7850. *
  7851. * For more information, please refer to :
  7852. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7853. */
  7854. export class UniformBuffer {
  7855. private _engine;
  7856. private _buffer;
  7857. private _data;
  7858. private _bufferData;
  7859. private _dynamic?;
  7860. private _uniformLocations;
  7861. private _uniformSizes;
  7862. private _uniformLocationPointer;
  7863. private _needSync;
  7864. private _noUBO;
  7865. private _currentEffect;
  7866. /** @hidden */
  7867. _alreadyBound: boolean;
  7868. private static _MAX_UNIFORM_SIZE;
  7869. private static _tempBuffer;
  7870. /**
  7871. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7876. /**
  7877. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7882. /**
  7883. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  7888. /**
  7889. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7894. /**
  7895. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7900. /**
  7901. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7906. /**
  7907. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7912. /**
  7913. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7914. * This is dynamic to allow compat with webgl 1 and 2.
  7915. * You will need to pass the name of the uniform as well as the value.
  7916. */
  7917. updateVector3: (name: string, vector: Vector3) => void;
  7918. /**
  7919. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7920. * This is dynamic to allow compat with webgl 1 and 2.
  7921. * You will need to pass the name of the uniform as well as the value.
  7922. */
  7923. updateVector4: (name: string, vector: Vector4) => void;
  7924. /**
  7925. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7926. * This is dynamic to allow compat with webgl 1 and 2.
  7927. * You will need to pass the name of the uniform as well as the value.
  7928. */
  7929. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7930. /**
  7931. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7932. * This is dynamic to allow compat with webgl 1 and 2.
  7933. * You will need to pass the name of the uniform as well as the value.
  7934. */
  7935. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7936. /**
  7937. * Instantiates a new Uniform buffer objects.
  7938. *
  7939. * Handles blocks of uniform on the GPU.
  7940. *
  7941. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7942. *
  7943. * For more information, please refer to :
  7944. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7945. * @param engine Define the engine the buffer is associated with
  7946. * @param data Define the data contained in the buffer
  7947. * @param dynamic Define if the buffer is updatable
  7948. */
  7949. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7950. /**
  7951. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7952. * or just falling back on setUniformXXX calls.
  7953. */
  7954. get useUbo(): boolean;
  7955. /**
  7956. * Indicates if the WebGL underlying uniform buffer is in sync
  7957. * with the javascript cache data.
  7958. */
  7959. get isSync(): boolean;
  7960. /**
  7961. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7962. * Also, a dynamic UniformBuffer will disable cache verification and always
  7963. * update the underlying WebGL uniform buffer to the GPU.
  7964. * @returns if Dynamic, otherwise false
  7965. */
  7966. isDynamic(): boolean;
  7967. /**
  7968. * The data cache on JS side.
  7969. * @returns the underlying data as a float array
  7970. */
  7971. getData(): Float32Array;
  7972. /**
  7973. * The underlying WebGL Uniform buffer.
  7974. * @returns the webgl buffer
  7975. */
  7976. getBuffer(): Nullable<DataBuffer>;
  7977. /**
  7978. * std140 layout specifies how to align data within an UBO structure.
  7979. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7980. * for specs.
  7981. */
  7982. private _fillAlignment;
  7983. /**
  7984. * Adds an uniform in the buffer.
  7985. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7986. * for the layout to be correct !
  7987. * @param name Name of the uniform, as used in the uniform block in the shader.
  7988. * @param size Data size, or data directly.
  7989. */
  7990. addUniform(name: string, size: number | number[]): void;
  7991. /**
  7992. * Adds a Matrix 4x4 to the uniform buffer.
  7993. * @param name Name of the uniform, as used in the uniform block in the shader.
  7994. * @param mat A 4x4 matrix.
  7995. */
  7996. addMatrix(name: string, mat: Matrix): void;
  7997. /**
  7998. * Adds a vec2 to the uniform buffer.
  7999. * @param name Name of the uniform, as used in the uniform block in the shader.
  8000. * @param x Define the x component value of the vec2
  8001. * @param y Define the y component value of the vec2
  8002. */
  8003. addFloat2(name: string, x: number, y: number): void;
  8004. /**
  8005. * Adds a vec3 to the uniform buffer.
  8006. * @param name Name of the uniform, as used in the uniform block in the shader.
  8007. * @param x Define the x component value of the vec3
  8008. * @param y Define the y component value of the vec3
  8009. * @param z Define the z component value of the vec3
  8010. */
  8011. addFloat3(name: string, x: number, y: number, z: number): void;
  8012. /**
  8013. * Adds a vec3 to the uniform buffer.
  8014. * @param name Name of the uniform, as used in the uniform block in the shader.
  8015. * @param color Define the vec3 from a Color
  8016. */
  8017. addColor3(name: string, color: Color3): void;
  8018. /**
  8019. * Adds a vec4 to the uniform buffer.
  8020. * @param name Name of the uniform, as used in the uniform block in the shader.
  8021. * @param color Define the rgb components from a Color
  8022. * @param alpha Define the a component of the vec4
  8023. */
  8024. addColor4(name: string, color: Color3, alpha: number): void;
  8025. /**
  8026. * Adds a vec3 to the uniform buffer.
  8027. * @param name Name of the uniform, as used in the uniform block in the shader.
  8028. * @param vector Define the vec3 components from a Vector
  8029. */
  8030. addVector3(name: string, vector: Vector3): void;
  8031. /**
  8032. * Adds a Matrix 3x3 to the uniform buffer.
  8033. * @param name Name of the uniform, as used in the uniform block in the shader.
  8034. */
  8035. addMatrix3x3(name: string): void;
  8036. /**
  8037. * Adds a Matrix 2x2 to the uniform buffer.
  8038. * @param name Name of the uniform, as used in the uniform block in the shader.
  8039. */
  8040. addMatrix2x2(name: string): void;
  8041. /**
  8042. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8043. */
  8044. create(): void;
  8045. /** @hidden */
  8046. _rebuild(): void;
  8047. /**
  8048. * Updates the WebGL Uniform Buffer on the GPU.
  8049. * If the `dynamic` flag is set to true, no cache comparison is done.
  8050. * Otherwise, the buffer will be updated only if the cache differs.
  8051. */
  8052. update(): void;
  8053. /**
  8054. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8055. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8056. * @param data Define the flattened data
  8057. * @param size Define the size of the data.
  8058. */
  8059. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8060. private _valueCache;
  8061. private _cacheMatrix;
  8062. private _updateMatrix3x3ForUniform;
  8063. private _updateMatrix3x3ForEffect;
  8064. private _updateMatrix2x2ForEffect;
  8065. private _updateMatrix2x2ForUniform;
  8066. private _updateFloatForEffect;
  8067. private _updateFloatForUniform;
  8068. private _updateFloat2ForEffect;
  8069. private _updateFloat2ForUniform;
  8070. private _updateFloat3ForEffect;
  8071. private _updateFloat3ForUniform;
  8072. private _updateFloat4ForEffect;
  8073. private _updateFloat4ForUniform;
  8074. private _updateMatrixForEffect;
  8075. private _updateMatrixForUniform;
  8076. private _updateVector3ForEffect;
  8077. private _updateVector3ForUniform;
  8078. private _updateVector4ForEffect;
  8079. private _updateVector4ForUniform;
  8080. private _updateColor3ForEffect;
  8081. private _updateColor3ForUniform;
  8082. private _updateColor4ForEffect;
  8083. private _updateColor4ForUniform;
  8084. /**
  8085. * Sets a sampler uniform on the effect.
  8086. * @param name Define the name of the sampler.
  8087. * @param texture Define the texture to set in the sampler
  8088. */
  8089. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8090. /**
  8091. * Directly updates the value of the uniform in the cache AND on the GPU.
  8092. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8093. * @param data Define the flattened data
  8094. */
  8095. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8096. /**
  8097. * Binds this uniform buffer to an effect.
  8098. * @param effect Define the effect to bind the buffer to
  8099. * @param name Name of the uniform block in the shader.
  8100. */
  8101. bindToEffect(effect: Effect, name: string): void;
  8102. /**
  8103. * Disposes the uniform buffer.
  8104. */
  8105. dispose(): void;
  8106. }
  8107. }
  8108. declare module BABYLON {
  8109. /**
  8110. * Manages the defines for the Material
  8111. */
  8112. export class MaterialDefines {
  8113. /** @hidden */
  8114. protected _keys: string[];
  8115. private _isDirty;
  8116. /** @hidden */
  8117. _renderId: number;
  8118. /** @hidden */
  8119. _areLightsDirty: boolean;
  8120. /** @hidden */
  8121. _areLightsDisposed: boolean;
  8122. /** @hidden */
  8123. _areAttributesDirty: boolean;
  8124. /** @hidden */
  8125. _areTexturesDirty: boolean;
  8126. /** @hidden */
  8127. _areFresnelDirty: boolean;
  8128. /** @hidden */
  8129. _areMiscDirty: boolean;
  8130. /** @hidden */
  8131. _arePrePassDirty: boolean;
  8132. /** @hidden */
  8133. _areImageProcessingDirty: boolean;
  8134. /** @hidden */
  8135. _normals: boolean;
  8136. /** @hidden */
  8137. _uvs: boolean;
  8138. /** @hidden */
  8139. _needNormals: boolean;
  8140. /** @hidden */
  8141. _needUVs: boolean;
  8142. [id: string]: any;
  8143. /**
  8144. * Specifies if the material needs to be re-calculated
  8145. */
  8146. get isDirty(): boolean;
  8147. /**
  8148. * Marks the material to indicate that it has been re-calculated
  8149. */
  8150. markAsProcessed(): void;
  8151. /**
  8152. * Marks the material to indicate that it needs to be re-calculated
  8153. */
  8154. markAsUnprocessed(): void;
  8155. /**
  8156. * Marks the material to indicate all of its defines need to be re-calculated
  8157. */
  8158. markAllAsDirty(): void;
  8159. /**
  8160. * Marks the material to indicate that image processing needs to be re-calculated
  8161. */
  8162. markAsImageProcessingDirty(): void;
  8163. /**
  8164. * Marks the material to indicate the lights need to be re-calculated
  8165. * @param disposed Defines whether the light is dirty due to dispose or not
  8166. */
  8167. markAsLightDirty(disposed?: boolean): void;
  8168. /**
  8169. * Marks the attribute state as changed
  8170. */
  8171. markAsAttributesDirty(): void;
  8172. /**
  8173. * Marks the texture state as changed
  8174. */
  8175. markAsTexturesDirty(): void;
  8176. /**
  8177. * Marks the fresnel state as changed
  8178. */
  8179. markAsFresnelDirty(): void;
  8180. /**
  8181. * Marks the misc state as changed
  8182. */
  8183. markAsMiscDirty(): void;
  8184. /**
  8185. * Marks the prepass state as changed
  8186. */
  8187. markAsPrePassDirty(): void;
  8188. /**
  8189. * Rebuilds the material defines
  8190. */
  8191. rebuild(): void;
  8192. /**
  8193. * Specifies if two material defines are equal
  8194. * @param other - A material define instance to compare to
  8195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8196. */
  8197. isEqual(other: MaterialDefines): boolean;
  8198. /**
  8199. * Clones this instance's defines to another instance
  8200. * @param other - material defines to clone values to
  8201. */
  8202. cloneTo(other: MaterialDefines): void;
  8203. /**
  8204. * Resets the material define values
  8205. */
  8206. reset(): void;
  8207. /**
  8208. * Converts the material define values to a string
  8209. * @returns - String of material define information
  8210. */
  8211. toString(): string;
  8212. }
  8213. }
  8214. declare module BABYLON {
  8215. /**
  8216. * Enum that determines the text-wrapping mode to use.
  8217. */
  8218. export enum InspectableType {
  8219. /**
  8220. * Checkbox for booleans
  8221. */
  8222. Checkbox = 0,
  8223. /**
  8224. * Sliders for numbers
  8225. */
  8226. Slider = 1,
  8227. /**
  8228. * Vector3
  8229. */
  8230. Vector3 = 2,
  8231. /**
  8232. * Quaternions
  8233. */
  8234. Quaternion = 3,
  8235. /**
  8236. * Color3
  8237. */
  8238. Color3 = 4,
  8239. /**
  8240. * String
  8241. */
  8242. String = 5
  8243. }
  8244. /**
  8245. * Interface used to define custom inspectable properties.
  8246. * This interface is used by the inspector to display custom property grids
  8247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8248. */
  8249. export interface IInspectable {
  8250. /**
  8251. * Gets the label to display
  8252. */
  8253. label: string;
  8254. /**
  8255. * Gets the name of the property to edit
  8256. */
  8257. propertyName: string;
  8258. /**
  8259. * Gets the type of the editor to use
  8260. */
  8261. type: InspectableType;
  8262. /**
  8263. * Gets the minimum value of the property when using in "slider" mode
  8264. */
  8265. min?: number;
  8266. /**
  8267. * Gets the maximum value of the property when using in "slider" mode
  8268. */
  8269. max?: number;
  8270. /**
  8271. * Gets the setp to use when using in "slider" mode
  8272. */
  8273. step?: number;
  8274. }
  8275. }
  8276. declare module BABYLON {
  8277. /**
  8278. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8279. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8280. * 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.
  8281. */
  8282. export abstract class Light extends Node {
  8283. /**
  8284. * Falloff Default: light is falling off following the material specification:
  8285. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8286. */
  8287. static readonly FALLOFF_DEFAULT: number;
  8288. /**
  8289. * Falloff Physical: light is falling off following the inverse squared distance law.
  8290. */
  8291. static readonly FALLOFF_PHYSICAL: number;
  8292. /**
  8293. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8294. * to enhance interoperability with other engines.
  8295. */
  8296. static readonly FALLOFF_GLTF: number;
  8297. /**
  8298. * Falloff Standard: light is falling off like in the standard material
  8299. * to enhance interoperability with other materials.
  8300. */
  8301. static readonly FALLOFF_STANDARD: number;
  8302. /**
  8303. * If every light affecting the material is in this lightmapMode,
  8304. * material.lightmapTexture adds or multiplies
  8305. * (depends on material.useLightmapAsShadowmap)
  8306. * after every other light calculations.
  8307. */
  8308. static readonly LIGHTMAP_DEFAULT: number;
  8309. /**
  8310. * material.lightmapTexture as only diffuse lighting from this light
  8311. * adds only specular lighting from this light
  8312. * adds dynamic shadows
  8313. */
  8314. static readonly LIGHTMAP_SPECULAR: number;
  8315. /**
  8316. * material.lightmapTexture as only lighting
  8317. * no light calculation from this light
  8318. * only adds dynamic shadows from this light
  8319. */
  8320. static readonly LIGHTMAP_SHADOWSONLY: number;
  8321. /**
  8322. * Each light type uses the default quantity according to its type:
  8323. * point/spot lights use luminous intensity
  8324. * directional lights use illuminance
  8325. */
  8326. static readonly INTENSITYMODE_AUTOMATIC: number;
  8327. /**
  8328. * lumen (lm)
  8329. */
  8330. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8331. /**
  8332. * candela (lm/sr)
  8333. */
  8334. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8335. /**
  8336. * lux (lm/m^2)
  8337. */
  8338. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8339. /**
  8340. * nit (cd/m^2)
  8341. */
  8342. static readonly INTENSITYMODE_LUMINANCE: number;
  8343. /**
  8344. * Light type const id of the point light.
  8345. */
  8346. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8347. /**
  8348. * Light type const id of the directional light.
  8349. */
  8350. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8351. /**
  8352. * Light type const id of the spot light.
  8353. */
  8354. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8355. /**
  8356. * Light type const id of the hemispheric light.
  8357. */
  8358. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8359. /**
  8360. * Diffuse gives the basic color to an object.
  8361. */
  8362. diffuse: Color3;
  8363. /**
  8364. * Specular produces a highlight color on an object.
  8365. * Note: This is note affecting PBR materials.
  8366. */
  8367. specular: Color3;
  8368. /**
  8369. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8370. * falling off base on range or angle.
  8371. * This can be set to any values in Light.FALLOFF_x.
  8372. *
  8373. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8374. * other types of materials.
  8375. */
  8376. falloffType: number;
  8377. /**
  8378. * Strength of the light.
  8379. * Note: By default it is define in the framework own unit.
  8380. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8381. */
  8382. intensity: number;
  8383. private _range;
  8384. protected _inverseSquaredRange: number;
  8385. /**
  8386. * Defines how far from the source the light is impacting in scene units.
  8387. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8388. */
  8389. get range(): number;
  8390. /**
  8391. * Defines how far from the source the light is impacting in scene units.
  8392. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8393. */
  8394. set range(value: number);
  8395. /**
  8396. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8397. * of light.
  8398. */
  8399. private _photometricScale;
  8400. private _intensityMode;
  8401. /**
  8402. * Gets the photometric scale used to interpret the intensity.
  8403. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8404. */
  8405. get intensityMode(): number;
  8406. /**
  8407. * Sets the photometric scale used to interpret the intensity.
  8408. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8409. */
  8410. set intensityMode(value: number);
  8411. private _radius;
  8412. /**
  8413. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8414. */
  8415. get radius(): number;
  8416. /**
  8417. * sets the light radius used by PBR Materials to simulate soft area lights.
  8418. */
  8419. set radius(value: number);
  8420. private _renderPriority;
  8421. /**
  8422. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8423. * exceeding the number allowed of the materials.
  8424. */
  8425. renderPriority: number;
  8426. private _shadowEnabled;
  8427. /**
  8428. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8429. * the current shadow generator.
  8430. */
  8431. get shadowEnabled(): boolean;
  8432. /**
  8433. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8434. * the current shadow generator.
  8435. */
  8436. set shadowEnabled(value: boolean);
  8437. private _includedOnlyMeshes;
  8438. /**
  8439. * Gets the only meshes impacted by this light.
  8440. */
  8441. get includedOnlyMeshes(): AbstractMesh[];
  8442. /**
  8443. * Sets the only meshes impacted by this light.
  8444. */
  8445. set includedOnlyMeshes(value: AbstractMesh[]);
  8446. private _excludedMeshes;
  8447. /**
  8448. * Gets the meshes not impacted by this light.
  8449. */
  8450. get excludedMeshes(): AbstractMesh[];
  8451. /**
  8452. * Sets the meshes not impacted by this light.
  8453. */
  8454. set excludedMeshes(value: AbstractMesh[]);
  8455. private _excludeWithLayerMask;
  8456. /**
  8457. * Gets the layer id use to find what meshes are not impacted by the light.
  8458. * Inactive if 0
  8459. */
  8460. get excludeWithLayerMask(): number;
  8461. /**
  8462. * Sets the layer id use to find what meshes are not impacted by the light.
  8463. * Inactive if 0
  8464. */
  8465. set excludeWithLayerMask(value: number);
  8466. private _includeOnlyWithLayerMask;
  8467. /**
  8468. * Gets the layer id use to find what meshes are impacted by the light.
  8469. * Inactive if 0
  8470. */
  8471. get includeOnlyWithLayerMask(): number;
  8472. /**
  8473. * Sets the layer id use to find what meshes are impacted by the light.
  8474. * Inactive if 0
  8475. */
  8476. set includeOnlyWithLayerMask(value: number);
  8477. private _lightmapMode;
  8478. /**
  8479. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8480. */
  8481. get lightmapMode(): number;
  8482. /**
  8483. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8484. */
  8485. set lightmapMode(value: number);
  8486. /**
  8487. * Shadow generator associted to the light.
  8488. * @hidden Internal use only.
  8489. */
  8490. _shadowGenerator: Nullable<IShadowGenerator>;
  8491. /**
  8492. * @hidden Internal use only.
  8493. */
  8494. _excludedMeshesIds: string[];
  8495. /**
  8496. * @hidden Internal use only.
  8497. */
  8498. _includedOnlyMeshesIds: string[];
  8499. /**
  8500. * The current light unifom buffer.
  8501. * @hidden Internal use only.
  8502. */
  8503. _uniformBuffer: UniformBuffer;
  8504. /** @hidden */
  8505. _renderId: number;
  8506. /**
  8507. * Creates a Light object in the scene.
  8508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8509. * @param name The firendly name of the light
  8510. * @param scene The scene the light belongs too
  8511. */
  8512. constructor(name: string, scene: Scene);
  8513. protected abstract _buildUniformLayout(): void;
  8514. /**
  8515. * Sets the passed Effect "effect" with the Light information.
  8516. * @param effect The effect to update
  8517. * @param lightIndex The index of the light in the effect to update
  8518. * @returns The light
  8519. */
  8520. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8521. /**
  8522. * Sets the passed Effect "effect" with the Light textures.
  8523. * @param effect The effect to update
  8524. * @param lightIndex The index of the light in the effect to update
  8525. * @returns The light
  8526. */
  8527. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8528. /**
  8529. * Binds the lights information from the scene to the effect for the given mesh.
  8530. * @param lightIndex Light index
  8531. * @param scene The scene where the light belongs to
  8532. * @param effect The effect we are binding the data to
  8533. * @param useSpecular Defines if specular is supported
  8534. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8535. */
  8536. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8537. /**
  8538. * Sets the passed Effect "effect" with the Light information.
  8539. * @param effect The effect to update
  8540. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8541. * @returns The light
  8542. */
  8543. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8544. /**
  8545. * Returns the string "Light".
  8546. * @returns the class name
  8547. */
  8548. getClassName(): string;
  8549. /** @hidden */
  8550. readonly _isLight: boolean;
  8551. /**
  8552. * Converts the light information to a readable string for debug purpose.
  8553. * @param fullDetails Supports for multiple levels of logging within scene loading
  8554. * @returns the human readable light info
  8555. */
  8556. toString(fullDetails?: boolean): string;
  8557. /** @hidden */
  8558. protected _syncParentEnabledState(): void;
  8559. /**
  8560. * Set the enabled state of this node.
  8561. * @param value - the new enabled state
  8562. */
  8563. setEnabled(value: boolean): void;
  8564. /**
  8565. * Returns the Light associated shadow generator if any.
  8566. * @return the associated shadow generator.
  8567. */
  8568. getShadowGenerator(): Nullable<IShadowGenerator>;
  8569. /**
  8570. * Returns a Vector3, the absolute light position in the World.
  8571. * @returns the world space position of the light
  8572. */
  8573. getAbsolutePosition(): Vector3;
  8574. /**
  8575. * Specifies if the light will affect the passed mesh.
  8576. * @param mesh The mesh to test against the light
  8577. * @return true the mesh is affected otherwise, false.
  8578. */
  8579. canAffectMesh(mesh: AbstractMesh): boolean;
  8580. /**
  8581. * Sort function to order lights for rendering.
  8582. * @param a First Light object to compare to second.
  8583. * @param b Second Light object to compare first.
  8584. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8585. */
  8586. static CompareLightsPriority(a: Light, b: Light): number;
  8587. /**
  8588. * Releases resources associated with this node.
  8589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8591. */
  8592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8593. /**
  8594. * Returns the light type ID (integer).
  8595. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8596. */
  8597. getTypeID(): number;
  8598. /**
  8599. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8600. * @returns the scaled intensity in intensity mode unit
  8601. */
  8602. getScaledIntensity(): number;
  8603. /**
  8604. * Returns a new Light object, named "name", from the current one.
  8605. * @param name The name of the cloned light
  8606. * @param newParent The parent of this light, if it has one
  8607. * @returns the new created light
  8608. */
  8609. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8610. /**
  8611. * Serializes the current light into a Serialization object.
  8612. * @returns the serialized object.
  8613. */
  8614. serialize(): any;
  8615. /**
  8616. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8617. * This new light is named "name" and added to the passed scene.
  8618. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8619. * @param name The friendly name of the light
  8620. * @param scene The scene the new light will belong to
  8621. * @returns the constructor function
  8622. */
  8623. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8624. /**
  8625. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8626. * @param parsedLight The JSON representation of the light
  8627. * @param scene The scene to create the parsed light in
  8628. * @returns the created light after parsing
  8629. */
  8630. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8631. private _hookArrayForExcluded;
  8632. private _hookArrayForIncludedOnly;
  8633. private _resyncMeshes;
  8634. /**
  8635. * Forces the meshes to update their light related information in their rendering used effects
  8636. * @hidden Internal Use Only
  8637. */
  8638. _markMeshesAsLightDirty(): void;
  8639. /**
  8640. * Recomputes the cached photometric scale if needed.
  8641. */
  8642. private _computePhotometricScale;
  8643. /**
  8644. * Returns the Photometric Scale according to the light type and intensity mode.
  8645. */
  8646. private _getPhotometricScale;
  8647. /**
  8648. * Reorder the light in the scene according to their defined priority.
  8649. * @hidden Internal Use Only
  8650. */
  8651. _reorderLightsInScene(): void;
  8652. /**
  8653. * Prepares the list of defines specific to the light type.
  8654. * @param defines the list of defines
  8655. * @param lightIndex defines the index of the light for the effect
  8656. */
  8657. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /** Defines supported spaces */
  8662. export enum Space {
  8663. /** Local (object) space */
  8664. LOCAL = 0,
  8665. /** World space */
  8666. WORLD = 1,
  8667. /** Bone space */
  8668. BONE = 2
  8669. }
  8670. /** Defines the 3 main axes */
  8671. export class Axis {
  8672. /** X axis */
  8673. static X: Vector3;
  8674. /** Y axis */
  8675. static Y: Vector3;
  8676. /** Z axis */
  8677. static Z: Vector3;
  8678. }
  8679. /**
  8680. * Defines cartesian components.
  8681. */
  8682. export enum Coordinate {
  8683. /** X axis */
  8684. X = 0,
  8685. /** Y axis */
  8686. Y = 1,
  8687. /** Z axis */
  8688. Z = 2
  8689. }
  8690. }
  8691. declare module BABYLON {
  8692. /**
  8693. * Interface describing all the common properties and methods a shadow light needs to implement.
  8694. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8695. * as well as binding the different shadow properties to the effects.
  8696. */
  8697. export interface IShadowLight extends Light {
  8698. /**
  8699. * The light id in the scene (used in scene.findLighById for instance)
  8700. */
  8701. id: string;
  8702. /**
  8703. * The position the shdow will be casted from.
  8704. */
  8705. position: Vector3;
  8706. /**
  8707. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8708. */
  8709. direction: Vector3;
  8710. /**
  8711. * The transformed position. Position of the light in world space taking parenting in account.
  8712. */
  8713. transformedPosition: Vector3;
  8714. /**
  8715. * The transformed direction. Direction of the light in world space taking parenting in account.
  8716. */
  8717. transformedDirection: Vector3;
  8718. /**
  8719. * The friendly name of the light in the scene.
  8720. */
  8721. name: string;
  8722. /**
  8723. * Defines the shadow projection clipping minimum z value.
  8724. */
  8725. shadowMinZ: number;
  8726. /**
  8727. * Defines the shadow projection clipping maximum z value.
  8728. */
  8729. shadowMaxZ: number;
  8730. /**
  8731. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8732. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8733. */
  8734. computeTransformedInformation(): boolean;
  8735. /**
  8736. * Gets the scene the light belongs to.
  8737. * @returns The scene
  8738. */
  8739. getScene(): Scene;
  8740. /**
  8741. * Callback defining a custom Projection Matrix Builder.
  8742. * This can be used to override the default projection matrix computation.
  8743. */
  8744. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8745. /**
  8746. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8747. * @param matrix The materix to updated with the projection information
  8748. * @param viewMatrix The transform matrix of the light
  8749. * @param renderList The list of mesh to render in the map
  8750. * @returns The current light
  8751. */
  8752. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8753. /**
  8754. * Gets the current depth scale used in ESM.
  8755. * @returns The scale
  8756. */
  8757. getDepthScale(): number;
  8758. /**
  8759. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8760. * @returns true if a cube texture needs to be use
  8761. */
  8762. needCube(): boolean;
  8763. /**
  8764. * Detects if the projection matrix requires to be recomputed this frame.
  8765. * @returns true if it requires to be recomputed otherwise, false.
  8766. */
  8767. needProjectionMatrixCompute(): boolean;
  8768. /**
  8769. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8770. */
  8771. forceProjectionMatrixCompute(): void;
  8772. /**
  8773. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8774. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8775. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8776. */
  8777. getShadowDirection(faceIndex?: number): Vector3;
  8778. /**
  8779. * Gets the minZ used for shadow according to both the scene and the light.
  8780. * @param activeCamera The camera we are returning the min for
  8781. * @returns the depth min z
  8782. */
  8783. getDepthMinZ(activeCamera: Camera): number;
  8784. /**
  8785. * Gets the maxZ used for shadow according to both the scene and the light.
  8786. * @param activeCamera The camera we are returning the max for
  8787. * @returns the depth max z
  8788. */
  8789. getDepthMaxZ(activeCamera: Camera): number;
  8790. }
  8791. /**
  8792. * Base implementation IShadowLight
  8793. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8794. */
  8795. export abstract class ShadowLight extends Light implements IShadowLight {
  8796. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8797. protected _position: Vector3;
  8798. protected _setPosition(value: Vector3): void;
  8799. /**
  8800. * Sets the position the shadow will be casted from. Also use as the light position for both
  8801. * point and spot lights.
  8802. */
  8803. get position(): Vector3;
  8804. /**
  8805. * Sets the position the shadow will be casted from. Also use as the light position for both
  8806. * point and spot lights.
  8807. */
  8808. set position(value: Vector3);
  8809. protected _direction: Vector3;
  8810. protected _setDirection(value: Vector3): void;
  8811. /**
  8812. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8813. * Also use as the light direction on spot and directional lights.
  8814. */
  8815. get direction(): Vector3;
  8816. /**
  8817. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8818. * Also use as the light direction on spot and directional lights.
  8819. */
  8820. set direction(value: Vector3);
  8821. protected _shadowMinZ: number;
  8822. /**
  8823. * Gets the shadow projection clipping minimum z value.
  8824. */
  8825. get shadowMinZ(): number;
  8826. /**
  8827. * Sets the shadow projection clipping minimum z value.
  8828. */
  8829. set shadowMinZ(value: number);
  8830. protected _shadowMaxZ: number;
  8831. /**
  8832. * Sets the shadow projection clipping maximum z value.
  8833. */
  8834. get shadowMaxZ(): number;
  8835. /**
  8836. * Gets the shadow projection clipping maximum z value.
  8837. */
  8838. set shadowMaxZ(value: number);
  8839. /**
  8840. * Callback defining a custom Projection Matrix Builder.
  8841. * This can be used to override the default projection matrix computation.
  8842. */
  8843. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8844. /**
  8845. * The transformed position. Position of the light in world space taking parenting in account.
  8846. */
  8847. transformedPosition: Vector3;
  8848. /**
  8849. * The transformed direction. Direction of the light in world space taking parenting in account.
  8850. */
  8851. transformedDirection: Vector3;
  8852. private _needProjectionMatrixCompute;
  8853. /**
  8854. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8855. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8856. */
  8857. computeTransformedInformation(): boolean;
  8858. /**
  8859. * Return the depth scale used for the shadow map.
  8860. * @returns the depth scale.
  8861. */
  8862. getDepthScale(): number;
  8863. /**
  8864. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8865. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8866. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8867. */
  8868. getShadowDirection(faceIndex?: number): Vector3;
  8869. /**
  8870. * Returns the ShadowLight absolute position in the World.
  8871. * @returns the position vector in world space
  8872. */
  8873. getAbsolutePosition(): Vector3;
  8874. /**
  8875. * Sets the ShadowLight direction toward the passed target.
  8876. * @param target The point to target in local space
  8877. * @returns the updated ShadowLight direction
  8878. */
  8879. setDirectionToTarget(target: Vector3): Vector3;
  8880. /**
  8881. * Returns the light rotation in euler definition.
  8882. * @returns the x y z rotation in local space.
  8883. */
  8884. getRotation(): Vector3;
  8885. /**
  8886. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8887. * @returns true if a cube texture needs to be use
  8888. */
  8889. needCube(): boolean;
  8890. /**
  8891. * Detects if the projection matrix requires to be recomputed this frame.
  8892. * @returns true if it requires to be recomputed otherwise, false.
  8893. */
  8894. needProjectionMatrixCompute(): boolean;
  8895. /**
  8896. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8897. */
  8898. forceProjectionMatrixCompute(): void;
  8899. /** @hidden */
  8900. _initCache(): void;
  8901. /** @hidden */
  8902. _isSynchronized(): boolean;
  8903. /**
  8904. * Computes the world matrix of the node
  8905. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8906. * @returns the world matrix
  8907. */
  8908. computeWorldMatrix(force?: boolean): Matrix;
  8909. /**
  8910. * Gets the minZ used for shadow according to both the scene and the light.
  8911. * @param activeCamera The camera we are returning the min for
  8912. * @returns the depth min z
  8913. */
  8914. getDepthMinZ(activeCamera: Camera): number;
  8915. /**
  8916. * Gets the maxZ used for shadow according to both the scene and the light.
  8917. * @param activeCamera The camera we are returning the max for
  8918. * @returns the depth max z
  8919. */
  8920. getDepthMaxZ(activeCamera: Camera): number;
  8921. /**
  8922. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8923. * @param matrix The materix to updated with the projection information
  8924. * @param viewMatrix The transform matrix of the light
  8925. * @param renderList The list of mesh to render in the map
  8926. * @returns The current light
  8927. */
  8928. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8929. }
  8930. }
  8931. declare module BABYLON {
  8932. /**
  8933. * Configuration needed for prepass-capable materials
  8934. */
  8935. export class PrePassConfiguration {
  8936. /**
  8937. * Previous world matrices of meshes carrying this material
  8938. * Used for computing velocity
  8939. */
  8940. previousWorldMatrices: {
  8941. [index: number]: Matrix;
  8942. };
  8943. /**
  8944. * Previous view project matrix
  8945. * Used for computing velocity
  8946. */
  8947. previousViewProjection: Matrix;
  8948. /**
  8949. * Previous bones of meshes carrying this material
  8950. * Used for computing velocity
  8951. */
  8952. previousBones: {
  8953. [index: number]: Float32Array;
  8954. };
  8955. /**
  8956. * Add the required uniforms to the current list.
  8957. * @param uniforms defines the current uniform list.
  8958. */
  8959. static AddUniforms(uniforms: string[]): void;
  8960. /**
  8961. * Add the required samplers to the current list.
  8962. * @param samplers defines the current sampler list.
  8963. */
  8964. static AddSamplers(samplers: string[]): void;
  8965. /**
  8966. * Binds the material data.
  8967. * @param effect defines the effect to update
  8968. * @param scene defines the scene the material belongs to.
  8969. * @param mesh The mesh
  8970. * @param world World matrix of this mesh
  8971. * @param isFrozen Is the material frozen
  8972. */
  8973. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8974. }
  8975. }
  8976. declare module BABYLON {
  8977. /**
  8978. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8979. * This is the base of the follow, arc rotate cameras and Free camera
  8980. * @see https://doc.babylonjs.com/features/cameras
  8981. */
  8982. export class TargetCamera extends Camera {
  8983. private static _RigCamTransformMatrix;
  8984. private static _TargetTransformMatrix;
  8985. private static _TargetFocalPoint;
  8986. private _tmpUpVector;
  8987. private _tmpTargetVector;
  8988. /**
  8989. * Define the current direction the camera is moving to
  8990. */
  8991. cameraDirection: Vector3;
  8992. /**
  8993. * Define the current rotation the camera is rotating to
  8994. */
  8995. cameraRotation: Vector2;
  8996. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8997. ignoreParentScaling: boolean;
  8998. /**
  8999. * When set, the up vector of the camera will be updated by the rotation of the camera
  9000. */
  9001. updateUpVectorFromRotation: boolean;
  9002. private _tmpQuaternion;
  9003. /**
  9004. * Define the current rotation of the camera
  9005. */
  9006. rotation: Vector3;
  9007. /**
  9008. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9009. */
  9010. rotationQuaternion: Quaternion;
  9011. /**
  9012. * Define the current speed of the camera
  9013. */
  9014. speed: number;
  9015. /**
  9016. * Add constraint to the camera to prevent it to move freely in all directions and
  9017. * around all axis.
  9018. */
  9019. noRotationConstraint: boolean;
  9020. /**
  9021. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9022. * panning
  9023. */
  9024. invertRotation: boolean;
  9025. /**
  9026. * Speed multiplier for inverse camera panning
  9027. */
  9028. inverseRotationSpeed: number;
  9029. /**
  9030. * Define the current target of the camera as an object or a position.
  9031. */
  9032. lockedTarget: any;
  9033. /** @hidden */
  9034. _currentTarget: Vector3;
  9035. /** @hidden */
  9036. _initialFocalDistance: number;
  9037. /** @hidden */
  9038. _viewMatrix: Matrix;
  9039. /** @hidden */
  9040. _camMatrix: Matrix;
  9041. /** @hidden */
  9042. _cameraTransformMatrix: Matrix;
  9043. /** @hidden */
  9044. _cameraRotationMatrix: Matrix;
  9045. /** @hidden */
  9046. _referencePoint: Vector3;
  9047. /** @hidden */
  9048. _transformedReferencePoint: Vector3;
  9049. /** @hidden */
  9050. _reset: () => void;
  9051. private _defaultUp;
  9052. /**
  9053. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9054. * This is the base of the follow, arc rotate cameras and Free camera
  9055. * @see https://doc.babylonjs.com/features/cameras
  9056. * @param name Defines the name of the camera in the scene
  9057. * @param position Defines the start position of the camera in the scene
  9058. * @param scene Defines the scene the camera belongs to
  9059. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9060. */
  9061. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9062. /**
  9063. * Gets the position in front of the camera at a given distance.
  9064. * @param distance The distance from the camera we want the position to be
  9065. * @returns the position
  9066. */
  9067. getFrontPosition(distance: number): Vector3;
  9068. /** @hidden */
  9069. _getLockedTargetPosition(): Nullable<Vector3>;
  9070. private _storedPosition;
  9071. private _storedRotation;
  9072. private _storedRotationQuaternion;
  9073. /**
  9074. * Store current camera state of the camera (fov, position, rotation, etc..)
  9075. * @returns the camera
  9076. */
  9077. storeState(): Camera;
  9078. /**
  9079. * Restored camera state. You must call storeState() first
  9080. * @returns whether it was successful or not
  9081. * @hidden
  9082. */
  9083. _restoreStateValues(): boolean;
  9084. /** @hidden */
  9085. _initCache(): void;
  9086. /** @hidden */
  9087. _updateCache(ignoreParentClass?: boolean): void;
  9088. /** @hidden */
  9089. _isSynchronizedViewMatrix(): boolean;
  9090. /** @hidden */
  9091. _computeLocalCameraSpeed(): number;
  9092. /**
  9093. * Defines the target the camera should look at.
  9094. * @param target Defines the new target as a Vector or a mesh
  9095. */
  9096. setTarget(target: Vector3): void;
  9097. /**
  9098. * Defines the target point of the camera.
  9099. * The camera looks towards it form the radius distance.
  9100. */
  9101. get target(): Vector3;
  9102. set target(value: Vector3);
  9103. /**
  9104. * Return the current target position of the camera. This value is expressed in local space.
  9105. * @returns the target position
  9106. */
  9107. getTarget(): Vector3;
  9108. /** @hidden */
  9109. _decideIfNeedsToMove(): boolean;
  9110. /** @hidden */
  9111. _updatePosition(): void;
  9112. /** @hidden */
  9113. _checkInputs(): void;
  9114. protected _updateCameraRotationMatrix(): void;
  9115. /**
  9116. * 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)
  9117. * @returns the current camera
  9118. */
  9119. private _rotateUpVectorWithCameraRotationMatrix;
  9120. private _cachedRotationZ;
  9121. private _cachedQuaternionRotationZ;
  9122. /** @hidden */
  9123. _getViewMatrix(): Matrix;
  9124. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9125. /**
  9126. * @hidden
  9127. */
  9128. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9129. /**
  9130. * @hidden
  9131. */
  9132. _updateRigCameras(): void;
  9133. private _getRigCamPositionAndTarget;
  9134. /**
  9135. * Gets the current object class name.
  9136. * @return the class name
  9137. */
  9138. getClassName(): string;
  9139. }
  9140. }
  9141. declare module BABYLON {
  9142. /**
  9143. * @ignore
  9144. * This is a list of all the different input types that are available in the application.
  9145. * Fo instance: ArcRotateCameraGamepadInput...
  9146. */
  9147. export var CameraInputTypes: {};
  9148. /**
  9149. * This is the contract to implement in order to create a new input class.
  9150. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9151. */
  9152. export interface ICameraInput<TCamera extends Camera> {
  9153. /**
  9154. * Defines the camera the input is attached to.
  9155. */
  9156. camera: Nullable<TCamera>;
  9157. /**
  9158. * Gets the class name of the current intput.
  9159. * @returns the class name
  9160. */
  9161. getClassName(): string;
  9162. /**
  9163. * Get the friendly name associated with the input class.
  9164. * @returns the input friendly name
  9165. */
  9166. getSimpleName(): string;
  9167. /**
  9168. * Attach the input controls to a specific dom element to get the input from.
  9169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9170. */
  9171. attachControl(noPreventDefault?: boolean): void;
  9172. /**
  9173. * Detach the current controls from the specified dom element.
  9174. */
  9175. detachControl(): void;
  9176. /**
  9177. * Update the current camera state depending on the inputs that have been used this frame.
  9178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9179. */
  9180. checkInputs?: () => void;
  9181. }
  9182. /**
  9183. * Represents a map of input types to input instance or input index to input instance.
  9184. */
  9185. export interface CameraInputsMap<TCamera extends Camera> {
  9186. /**
  9187. * Accessor to the input by input type.
  9188. */
  9189. [name: string]: ICameraInput<TCamera>;
  9190. /**
  9191. * Accessor to the input by input index.
  9192. */
  9193. [idx: number]: ICameraInput<TCamera>;
  9194. }
  9195. /**
  9196. * This represents the input manager used within a camera.
  9197. * It helps dealing with all the different kind of input attached to a camera.
  9198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9199. */
  9200. export class CameraInputsManager<TCamera extends Camera> {
  9201. /**
  9202. * Defines the list of inputs attahed to the camera.
  9203. */
  9204. attached: CameraInputsMap<TCamera>;
  9205. /**
  9206. * Defines the dom element the camera is collecting inputs from.
  9207. * This is null if the controls have not been attached.
  9208. */
  9209. attachedToElement: boolean;
  9210. /**
  9211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9212. */
  9213. noPreventDefault: boolean;
  9214. /**
  9215. * Defined the camera the input manager belongs to.
  9216. */
  9217. camera: TCamera;
  9218. /**
  9219. * Update the current camera state depending on the inputs that have been used this frame.
  9220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9221. */
  9222. checkInputs: () => void;
  9223. /**
  9224. * Instantiate a new Camera Input Manager.
  9225. * @param camera Defines the camera the input manager blongs to
  9226. */
  9227. constructor(camera: TCamera);
  9228. /**
  9229. * Add an input method to a camera
  9230. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9231. * @param input camera input method
  9232. */
  9233. add(input: ICameraInput<TCamera>): void;
  9234. /**
  9235. * Remove a specific input method from a camera
  9236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9237. * @param inputToRemove camera input method
  9238. */
  9239. remove(inputToRemove: ICameraInput<TCamera>): void;
  9240. /**
  9241. * Remove a specific input type from a camera
  9242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9243. * @param inputType the type of the input to remove
  9244. */
  9245. removeByType(inputType: string): void;
  9246. private _addCheckInputs;
  9247. /**
  9248. * Attach the input controls to the currently attached dom element to listen the events from.
  9249. * @param input Defines the input to attach
  9250. */
  9251. attachInput(input: ICameraInput<TCamera>): void;
  9252. /**
  9253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9254. * @param element Defines the dom element to collect the events from
  9255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9256. */
  9257. attachElement(noPreventDefault?: boolean): void;
  9258. /**
  9259. * Detach the current manager inputs controls from a specific dom element.
  9260. * @param element Defines the dom element to collect the events from
  9261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9262. */
  9263. detachElement(disconnect?: boolean): void;
  9264. /**
  9265. * Rebuild the dynamic inputCheck function from the current list of
  9266. * defined inputs in the manager.
  9267. */
  9268. rebuildInputCheck(): void;
  9269. /**
  9270. * Remove all attached input methods from a camera
  9271. */
  9272. clear(): void;
  9273. /**
  9274. * Serialize the current input manager attached to a camera.
  9275. * This ensures than once parsed,
  9276. * the input associated to the camera will be identical to the current ones
  9277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9278. */
  9279. serialize(serializedCamera: any): void;
  9280. /**
  9281. * Parses an input manager serialized JSON to restore the previous list of inputs
  9282. * and states associated to a camera.
  9283. * @param parsedCamera Defines the JSON to parse
  9284. */
  9285. parse(parsedCamera: any): void;
  9286. }
  9287. }
  9288. declare module BABYLON {
  9289. /**
  9290. * Gather the list of keyboard event types as constants.
  9291. */
  9292. export class KeyboardEventTypes {
  9293. /**
  9294. * The keydown event is fired when a key becomes active (pressed).
  9295. */
  9296. static readonly KEYDOWN: number;
  9297. /**
  9298. * The keyup event is fired when a key has been released.
  9299. */
  9300. static readonly KEYUP: number;
  9301. }
  9302. /**
  9303. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9304. */
  9305. export class KeyboardInfo {
  9306. /**
  9307. * Defines the type of event (KeyboardEventTypes)
  9308. */
  9309. type: number;
  9310. /**
  9311. * Defines the related dom event
  9312. */
  9313. event: KeyboardEvent;
  9314. /**
  9315. * Instantiates a new keyboard info.
  9316. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9317. * @param type Defines the type of event (KeyboardEventTypes)
  9318. * @param event Defines the related dom event
  9319. */
  9320. constructor(
  9321. /**
  9322. * Defines the type of event (KeyboardEventTypes)
  9323. */
  9324. type: number,
  9325. /**
  9326. * Defines the related dom event
  9327. */
  9328. event: KeyboardEvent);
  9329. }
  9330. /**
  9331. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9332. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9333. */
  9334. export class KeyboardInfoPre extends KeyboardInfo {
  9335. /**
  9336. * Defines the type of event (KeyboardEventTypes)
  9337. */
  9338. type: number;
  9339. /**
  9340. * Defines the related dom event
  9341. */
  9342. event: KeyboardEvent;
  9343. /**
  9344. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9345. */
  9346. skipOnPointerObservable: boolean;
  9347. /**
  9348. * Instantiates a new keyboard pre info.
  9349. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9350. * @param type Defines the type of event (KeyboardEventTypes)
  9351. * @param event Defines the related dom event
  9352. */
  9353. constructor(
  9354. /**
  9355. * Defines the type of event (KeyboardEventTypes)
  9356. */
  9357. type: number,
  9358. /**
  9359. * Defines the related dom event
  9360. */
  9361. event: KeyboardEvent);
  9362. }
  9363. }
  9364. declare module BABYLON {
  9365. /**
  9366. * Manage the keyboard inputs to control the movement of a free camera.
  9367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9368. */
  9369. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9370. /**
  9371. * Defines the camera the input is attached to.
  9372. */
  9373. camera: FreeCamera;
  9374. /**
  9375. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9376. */
  9377. keysUp: number[];
  9378. /**
  9379. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9380. */
  9381. keysUpward: number[];
  9382. /**
  9383. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9384. */
  9385. keysDown: number[];
  9386. /**
  9387. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9388. */
  9389. keysDownward: number[];
  9390. /**
  9391. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9392. */
  9393. keysLeft: number[];
  9394. /**
  9395. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9396. */
  9397. keysRight: number[];
  9398. private _keys;
  9399. private _onCanvasBlurObserver;
  9400. private _onKeyboardObserver;
  9401. private _engine;
  9402. private _scene;
  9403. /**
  9404. * Attach the input controls to a specific dom element to get the input from.
  9405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9406. */
  9407. attachControl(noPreventDefault?: boolean): void;
  9408. /**
  9409. * Detach the current controls from the specified dom element.
  9410. */
  9411. detachControl(): void;
  9412. /**
  9413. * Update the current camera state depending on the inputs that have been used this frame.
  9414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9415. */
  9416. checkInputs(): void;
  9417. /**
  9418. * Gets the class name of the current intput.
  9419. * @returns the class name
  9420. */
  9421. getClassName(): string;
  9422. /** @hidden */
  9423. _onLostFocus(): void;
  9424. /**
  9425. * Get the friendly name associated with the input class.
  9426. * @returns the input friendly name
  9427. */
  9428. getSimpleName(): string;
  9429. }
  9430. }
  9431. declare module BABYLON {
  9432. /**
  9433. * Interface used to define Action
  9434. */
  9435. export interface IAction {
  9436. /**
  9437. * Trigger for the action
  9438. */
  9439. trigger: number;
  9440. /** Options of the trigger */
  9441. triggerOptions: any;
  9442. /**
  9443. * Gets the trigger parameters
  9444. * @returns the trigger parameters
  9445. */
  9446. getTriggerParameter(): any;
  9447. /**
  9448. * Internal only - executes current action event
  9449. * @hidden
  9450. */
  9451. _executeCurrent(evt?: ActionEvent): void;
  9452. /**
  9453. * Serialize placeholder for child classes
  9454. * @param parent of child
  9455. * @returns the serialized object
  9456. */
  9457. serialize(parent: any): any;
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: Nullable<AbstractActionManager>;
  9468. /**
  9469. * Adds action to chain of actions, may be a DoNothingAction
  9470. * @param action defines the next action to execute
  9471. * @returns The action passed in
  9472. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9473. */
  9474. then(action: IAction): IAction;
  9475. }
  9476. /**
  9477. * The action to be carried out following a trigger
  9478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9479. */
  9480. export class Action implements IAction {
  9481. /** the trigger, with or without parameters, for the action */
  9482. triggerOptions: any;
  9483. /**
  9484. * Trigger for the action
  9485. */
  9486. trigger: number;
  9487. /**
  9488. * Internal only - manager for action
  9489. * @hidden
  9490. */
  9491. _actionManager: ActionManager;
  9492. private _nextActiveAction;
  9493. private _child;
  9494. private _condition?;
  9495. private _triggerParameter;
  9496. /**
  9497. * An event triggered prior to action being executed.
  9498. */
  9499. onBeforeExecuteObservable: Observable<Action>;
  9500. /**
  9501. * Creates a new Action
  9502. * @param triggerOptions the trigger, with or without parameters, for the action
  9503. * @param condition an optional determinant of action
  9504. */
  9505. constructor(
  9506. /** the trigger, with or without parameters, for the action */
  9507. triggerOptions: any, condition?: Condition);
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. _prepare(): void;
  9513. /**
  9514. * Gets the trigger parameters
  9515. * @returns the trigger parameters
  9516. */
  9517. getTriggerParameter(): any;
  9518. /**
  9519. * Internal only - executes current action event
  9520. * @hidden
  9521. */
  9522. _executeCurrent(evt?: ActionEvent): void;
  9523. /**
  9524. * Execute placeholder for child classes
  9525. * @param evt optional action event
  9526. */
  9527. execute(evt?: ActionEvent): void;
  9528. /**
  9529. * Skips to next active action
  9530. */
  9531. skipToNextActiveAction(): void;
  9532. /**
  9533. * Adds action to chain of actions, may be a DoNothingAction
  9534. * @param action defines the next action to execute
  9535. * @returns The action passed in
  9536. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9537. */
  9538. then(action: Action): Action;
  9539. /**
  9540. * Internal only
  9541. * @hidden
  9542. */
  9543. _getProperty(propertyPath: string): string;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. _getEffectiveTarget(target: any, propertyPath: string): any;
  9549. /**
  9550. * Serialize placeholder for child classes
  9551. * @param parent of child
  9552. * @returns the serialized object
  9553. */
  9554. serialize(parent: any): any;
  9555. /**
  9556. * Internal only called by serialize
  9557. * @hidden
  9558. */
  9559. protected _serialize(serializedAction: any, parent?: any): any;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. static _SerializeValueAsString: (value: any) => string;
  9565. /**
  9566. * Internal only
  9567. * @hidden
  9568. */
  9569. static _GetTargetProperty: (target: Scene | Node) => {
  9570. name: string;
  9571. targetType: string;
  9572. value: string;
  9573. };
  9574. }
  9575. }
  9576. declare module BABYLON {
  9577. /**
  9578. * A Condition applied to an Action
  9579. */
  9580. export class Condition {
  9581. /**
  9582. * Internal only - manager for action
  9583. * @hidden
  9584. */
  9585. _actionManager: ActionManager;
  9586. /**
  9587. * Internal only
  9588. * @hidden
  9589. */
  9590. _evaluationId: number;
  9591. /**
  9592. * Internal only
  9593. * @hidden
  9594. */
  9595. _currentResult: boolean;
  9596. /**
  9597. * Creates a new Condition
  9598. * @param actionManager the manager of the action the condition is applied to
  9599. */
  9600. constructor(actionManager: ActionManager);
  9601. /**
  9602. * Check if the current condition is valid
  9603. * @returns a boolean
  9604. */
  9605. isValid(): boolean;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. _getProperty(propertyPath: string): string;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. _getEffectiveTarget(target: any, propertyPath: string): any;
  9616. /**
  9617. * Serialize placeholder for child classes
  9618. * @returns the serialized object
  9619. */
  9620. serialize(): any;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. protected _serialize(serializedCondition: any): any;
  9626. }
  9627. /**
  9628. * Defines specific conditional operators as extensions of Condition
  9629. */
  9630. export class ValueCondition extends Condition {
  9631. /** path to specify the property of the target the conditional operator uses */
  9632. propertyPath: string;
  9633. /** the value compared by the conditional operator against the current value of the property */
  9634. value: any;
  9635. /** the conditional operator, default ValueCondition.IsEqual */
  9636. operator: number;
  9637. /**
  9638. * Internal only
  9639. * @hidden
  9640. */
  9641. private static _IsEqual;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private static _IsDifferent;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. private static _IsGreater;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. private static _IsLesser;
  9657. /**
  9658. * returns the number for IsEqual
  9659. */
  9660. static get IsEqual(): number;
  9661. /**
  9662. * Returns the number for IsDifferent
  9663. */
  9664. static get IsDifferent(): number;
  9665. /**
  9666. * Returns the number for IsGreater
  9667. */
  9668. static get IsGreater(): number;
  9669. /**
  9670. * Returns the number for IsLesser
  9671. */
  9672. static get IsLesser(): number;
  9673. /**
  9674. * Internal only The action manager for the condition
  9675. * @hidden
  9676. */
  9677. _actionManager: ActionManager;
  9678. /**
  9679. * Internal only
  9680. * @hidden
  9681. */
  9682. private _target;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. private _effectiveTarget;
  9688. /**
  9689. * Internal only
  9690. * @hidden
  9691. */
  9692. private _property;
  9693. /**
  9694. * Creates a new ValueCondition
  9695. * @param actionManager manager for the action the condition applies to
  9696. * @param target for the action
  9697. * @param propertyPath path to specify the property of the target the conditional operator uses
  9698. * @param value the value compared by the conditional operator against the current value of the property
  9699. * @param operator the conditional operator, default ValueCondition.IsEqual
  9700. */
  9701. constructor(actionManager: ActionManager, target: any,
  9702. /** path to specify the property of the target the conditional operator uses */
  9703. propertyPath: string,
  9704. /** the value compared by the conditional operator against the current value of the property */
  9705. value: any,
  9706. /** the conditional operator, default ValueCondition.IsEqual */
  9707. operator?: number);
  9708. /**
  9709. * Compares the given value with the property value for the specified conditional operator
  9710. * @returns the result of the comparison
  9711. */
  9712. isValid(): boolean;
  9713. /**
  9714. * Serialize the ValueCondition into a JSON compatible object
  9715. * @returns serialization object
  9716. */
  9717. serialize(): any;
  9718. /**
  9719. * Gets the name of the conditional operator for the ValueCondition
  9720. * @param operator the conditional operator
  9721. * @returns the name
  9722. */
  9723. static GetOperatorName(operator: number): string;
  9724. }
  9725. /**
  9726. * Defines a predicate condition as an extension of Condition
  9727. */
  9728. export class PredicateCondition extends Condition {
  9729. /** defines the predicate function used to validate the condition */
  9730. predicate: () => boolean;
  9731. /**
  9732. * Internal only - manager for action
  9733. * @hidden
  9734. */
  9735. _actionManager: ActionManager;
  9736. /**
  9737. * Creates a new PredicateCondition
  9738. * @param actionManager manager for the action the condition applies to
  9739. * @param predicate defines the predicate function used to validate the condition
  9740. */
  9741. constructor(actionManager: ActionManager,
  9742. /** defines the predicate function used to validate the condition */
  9743. predicate: () => boolean);
  9744. /**
  9745. * @returns the validity of the predicate condition
  9746. */
  9747. isValid(): boolean;
  9748. }
  9749. /**
  9750. * Defines a state condition as an extension of Condition
  9751. */
  9752. export class StateCondition extends Condition {
  9753. /** Value to compare with target state */
  9754. value: string;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Internal only
  9762. * @hidden
  9763. */
  9764. private _target;
  9765. /**
  9766. * Creates a new StateCondition
  9767. * @param actionManager manager for the action the condition applies to
  9768. * @param target of the condition
  9769. * @param value to compare with target state
  9770. */
  9771. constructor(actionManager: ActionManager, target: any,
  9772. /** Value to compare with target state */
  9773. value: string);
  9774. /**
  9775. * Gets a boolean indicating if the current condition is met
  9776. * @returns the validity of the state
  9777. */
  9778. isValid(): boolean;
  9779. /**
  9780. * Serialize the StateCondition into a JSON compatible object
  9781. * @returns serialization object
  9782. */
  9783. serialize(): any;
  9784. }
  9785. }
  9786. declare module BABYLON {
  9787. /**
  9788. * This defines an action responsible to toggle a boolean once triggered.
  9789. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9790. */
  9791. export class SwitchBooleanAction extends Action {
  9792. /**
  9793. * The path to the boolean property in the target object
  9794. */
  9795. propertyPath: string;
  9796. private _target;
  9797. private _effectiveTarget;
  9798. private _property;
  9799. /**
  9800. * Instantiate the action
  9801. * @param triggerOptions defines the trigger options
  9802. * @param target defines the object containing the boolean
  9803. * @param propertyPath defines the path to the boolean property in the target object
  9804. * @param condition defines the trigger related conditions
  9805. */
  9806. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9807. /** @hidden */
  9808. _prepare(): void;
  9809. /**
  9810. * Execute the action toggle the boolean value.
  9811. */
  9812. execute(): void;
  9813. /**
  9814. * Serializes the actions and its related information.
  9815. * @param parent defines the object to serialize in
  9816. * @returns the serialized object
  9817. */
  9818. serialize(parent: any): any;
  9819. }
  9820. /**
  9821. * This defines an action responsible to set a the state field of the target
  9822. * to a desired value once triggered.
  9823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9824. */
  9825. export class SetStateAction extends Action {
  9826. /**
  9827. * The value to store in the state field.
  9828. */
  9829. value: string;
  9830. private _target;
  9831. /**
  9832. * Instantiate the action
  9833. * @param triggerOptions defines the trigger options
  9834. * @param target defines the object containing the state property
  9835. * @param value defines the value to store in the state field
  9836. * @param condition defines the trigger related conditions
  9837. */
  9838. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9839. /**
  9840. * Execute the action and store the value on the target state property.
  9841. */
  9842. execute(): void;
  9843. /**
  9844. * Serializes the actions and its related information.
  9845. * @param parent defines the object to serialize in
  9846. * @returns the serialized object
  9847. */
  9848. serialize(parent: any): any;
  9849. }
  9850. /**
  9851. * This defines an action responsible to set a property of the target
  9852. * to a desired value once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class SetValueAction extends Action {
  9856. /**
  9857. * The path of the property to set in the target.
  9858. */
  9859. propertyPath: string;
  9860. /**
  9861. * The value to set in the property
  9862. */
  9863. value: any;
  9864. private _target;
  9865. private _effectiveTarget;
  9866. private _property;
  9867. /**
  9868. * Instantiate the action
  9869. * @param triggerOptions defines the trigger options
  9870. * @param target defines the object containing the property
  9871. * @param propertyPath defines the path of the property to set in the target
  9872. * @param value defines the value to set in the property
  9873. * @param condition defines the trigger related conditions
  9874. */
  9875. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9876. /** @hidden */
  9877. _prepare(): void;
  9878. /**
  9879. * Execute the action and set the targetted property to the desired value.
  9880. */
  9881. execute(): void;
  9882. /**
  9883. * Serializes the actions and its related information.
  9884. * @param parent defines the object to serialize in
  9885. * @returns the serialized object
  9886. */
  9887. serialize(parent: any): any;
  9888. }
  9889. /**
  9890. * This defines an action responsible to increment the target value
  9891. * to a desired value once triggered.
  9892. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9893. */
  9894. export class IncrementValueAction extends Action {
  9895. /**
  9896. * The path of the property to increment in the target.
  9897. */
  9898. propertyPath: string;
  9899. /**
  9900. * The value we should increment the property by.
  9901. */
  9902. value: any;
  9903. private _target;
  9904. private _effectiveTarget;
  9905. private _property;
  9906. /**
  9907. * Instantiate the action
  9908. * @param triggerOptions defines the trigger options
  9909. * @param target defines the object containing the property
  9910. * @param propertyPath defines the path of the property to increment in the target
  9911. * @param value defines the value value we should increment the property by
  9912. * @param condition defines the trigger related conditions
  9913. */
  9914. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9915. /** @hidden */
  9916. _prepare(): void;
  9917. /**
  9918. * Execute the action and increment the target of the value amount.
  9919. */
  9920. execute(): void;
  9921. /**
  9922. * Serializes the actions and its related information.
  9923. * @param parent defines the object to serialize in
  9924. * @returns the serialized object
  9925. */
  9926. serialize(parent: any): any;
  9927. }
  9928. /**
  9929. * This defines an action responsible to start an animation once triggered.
  9930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9931. */
  9932. export class PlayAnimationAction extends Action {
  9933. /**
  9934. * Where the animation should start (animation frame)
  9935. */
  9936. from: number;
  9937. /**
  9938. * Where the animation should stop (animation frame)
  9939. */
  9940. to: number;
  9941. /**
  9942. * Define if the animation should loop or stop after the first play.
  9943. */
  9944. loop?: boolean;
  9945. private _target;
  9946. /**
  9947. * Instantiate the action
  9948. * @param triggerOptions defines the trigger options
  9949. * @param target defines the target animation or animation name
  9950. * @param from defines from where the animation should start (animation frame)
  9951. * @param end defines where the animation should stop (animation frame)
  9952. * @param loop defines if the animation should loop or stop after the first play
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9956. /** @hidden */
  9957. _prepare(): void;
  9958. /**
  9959. * Execute the action and play the animation.
  9960. */
  9961. execute(): void;
  9962. /**
  9963. * Serializes the actions and its related information.
  9964. * @param parent defines the object to serialize in
  9965. * @returns the serialized object
  9966. */
  9967. serialize(parent: any): any;
  9968. }
  9969. /**
  9970. * This defines an action responsible to stop an animation once triggered.
  9971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9972. */
  9973. export class StopAnimationAction extends Action {
  9974. private _target;
  9975. /**
  9976. * Instantiate the action
  9977. * @param triggerOptions defines the trigger options
  9978. * @param target defines the target animation or animation name
  9979. * @param condition defines the trigger related conditions
  9980. */
  9981. constructor(triggerOptions: any, target: any, condition?: Condition);
  9982. /** @hidden */
  9983. _prepare(): void;
  9984. /**
  9985. * Execute the action and stop the animation.
  9986. */
  9987. execute(): void;
  9988. /**
  9989. * Serializes the actions and its related information.
  9990. * @param parent defines the object to serialize in
  9991. * @returns the serialized object
  9992. */
  9993. serialize(parent: any): any;
  9994. }
  9995. /**
  9996. * This defines an action responsible that does nothing once triggered.
  9997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9998. */
  9999. export class DoNothingAction extends Action {
  10000. /**
  10001. * Instantiate the action
  10002. * @param triggerOptions defines the trigger options
  10003. * @param condition defines the trigger related conditions
  10004. */
  10005. constructor(triggerOptions?: any, condition?: Condition);
  10006. /**
  10007. * Execute the action and do nothing.
  10008. */
  10009. execute(): void;
  10010. /**
  10011. * Serializes the actions and its related information.
  10012. * @param parent defines the object to serialize in
  10013. * @returns the serialized object
  10014. */
  10015. serialize(parent: any): any;
  10016. }
  10017. /**
  10018. * This defines an action responsible to trigger several actions once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class CombineAction extends Action {
  10022. /**
  10023. * The list of aggregated animations to run.
  10024. */
  10025. children: Action[];
  10026. /**
  10027. * Instantiate the action
  10028. * @param triggerOptions defines the trigger options
  10029. * @param children defines the list of aggregated animations to run
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10033. /** @hidden */
  10034. _prepare(): void;
  10035. /**
  10036. * Execute the action and executes all the aggregated actions.
  10037. */
  10038. execute(evt: ActionEvent): void;
  10039. /**
  10040. * Serializes the actions and its related information.
  10041. * @param parent defines the object to serialize in
  10042. * @returns the serialized object
  10043. */
  10044. serialize(parent: any): any;
  10045. }
  10046. /**
  10047. * This defines an action responsible to run code (external event) once triggered.
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10049. */
  10050. export class ExecuteCodeAction extends Action {
  10051. /**
  10052. * The callback function to run.
  10053. */
  10054. func: (evt: ActionEvent) => void;
  10055. /**
  10056. * Instantiate the action
  10057. * @param triggerOptions defines the trigger options
  10058. * @param func defines the callback function to run
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10062. /**
  10063. * Execute the action and run the attached code.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. }
  10067. /**
  10068. * This defines an action responsible to set the parent property of the target once triggered.
  10069. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10070. */
  10071. export class SetParentAction extends Action {
  10072. private _parent;
  10073. private _target;
  10074. /**
  10075. * Instantiate the action
  10076. * @param triggerOptions defines the trigger options
  10077. * @param target defines the target containing the parent property
  10078. * @param parent defines from where the animation should start (animation frame)
  10079. * @param condition defines the trigger related conditions
  10080. */
  10081. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10082. /** @hidden */
  10083. _prepare(): void;
  10084. /**
  10085. * Execute the action and set the parent property.
  10086. */
  10087. execute(): void;
  10088. /**
  10089. * Serializes the actions and its related information.
  10090. * @param parent defines the object to serialize in
  10091. * @returns the serialized object
  10092. */
  10093. serialize(parent: any): any;
  10094. }
  10095. }
  10096. declare module BABYLON {
  10097. /**
  10098. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10099. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class ActionManager extends AbstractActionManager {
  10103. /**
  10104. * Nothing
  10105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10106. */
  10107. static readonly NothingTrigger: number;
  10108. /**
  10109. * On pick
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10111. */
  10112. static readonly OnPickTrigger: number;
  10113. /**
  10114. * On left pick
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnLeftPickTrigger: number;
  10118. /**
  10119. * On right pick
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnRightPickTrigger: number;
  10123. /**
  10124. * On center pick
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnCenterPickTrigger: number;
  10128. /**
  10129. * On pick down
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnPickDownTrigger: number;
  10133. /**
  10134. * On double pick
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnDoublePickTrigger: number;
  10138. /**
  10139. * On pick up
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnPickUpTrigger: number;
  10143. /**
  10144. * On pick out.
  10145. * This trigger will only be raised if you also declared a OnPickDown
  10146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10147. */
  10148. static readonly OnPickOutTrigger: number;
  10149. /**
  10150. * On long press
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10152. */
  10153. static readonly OnLongPressTrigger: number;
  10154. /**
  10155. * On pointer over
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly OnPointerOverTrigger: number;
  10159. /**
  10160. * On pointer out
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnPointerOutTrigger: number;
  10164. /**
  10165. * On every frame
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnEveryFrameTrigger: number;
  10169. /**
  10170. * On intersection enter
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnIntersectionEnterTrigger: number;
  10174. /**
  10175. * On intersection exit
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnIntersectionExitTrigger: number;
  10179. /**
  10180. * On key down
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnKeyDownTrigger: number;
  10184. /**
  10185. * On key up
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnKeyUpTrigger: number;
  10189. private _scene;
  10190. /**
  10191. * Creates a new action manager
  10192. * @param scene defines the hosting scene
  10193. */
  10194. constructor(scene: Scene);
  10195. /**
  10196. * Releases all associated resources
  10197. */
  10198. dispose(): void;
  10199. /**
  10200. * Gets hosting scene
  10201. * @returns the hosting scene
  10202. */
  10203. getScene(): Scene;
  10204. /**
  10205. * Does this action manager handles actions of any of the given triggers
  10206. * @param triggers defines the triggers to be tested
  10207. * @return a boolean indicating whether one (or more) of the triggers is handled
  10208. */
  10209. hasSpecificTriggers(triggers: number[]): boolean;
  10210. /**
  10211. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10212. * speed.
  10213. * @param triggerA defines the trigger to be tested
  10214. * @param triggerB defines the trigger to be tested
  10215. * @return a boolean indicating whether one (or more) of the triggers is handled
  10216. */
  10217. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10218. /**
  10219. * Does this action manager handles actions of a given trigger
  10220. * @param trigger defines the trigger to be tested
  10221. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10222. * @return whether the trigger is handled
  10223. */
  10224. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10225. /**
  10226. * Does this action manager has pointer triggers
  10227. */
  10228. get hasPointerTriggers(): boolean;
  10229. /**
  10230. * Does this action manager has pick triggers
  10231. */
  10232. get hasPickTriggers(): boolean;
  10233. /**
  10234. * Registers an action to this action manager
  10235. * @param action defines the action to be registered
  10236. * @return the action amended (prepared) after registration
  10237. */
  10238. registerAction(action: IAction): Nullable<IAction>;
  10239. /**
  10240. * Unregisters an action to this action manager
  10241. * @param action defines the action to be unregistered
  10242. * @return a boolean indicating whether the action has been unregistered
  10243. */
  10244. unregisterAction(action: IAction): Boolean;
  10245. /**
  10246. * Process a specific trigger
  10247. * @param trigger defines the trigger to process
  10248. * @param evt defines the event details to be processed
  10249. */
  10250. processTrigger(trigger: number, evt?: IActionEvent): void;
  10251. /** @hidden */
  10252. _getEffectiveTarget(target: any, propertyPath: string): any;
  10253. /** @hidden */
  10254. _getProperty(propertyPath: string): string;
  10255. /**
  10256. * Serialize this manager to a JSON object
  10257. * @param name defines the property name to store this manager
  10258. * @returns a JSON representation of this manager
  10259. */
  10260. serialize(name: string): any;
  10261. /**
  10262. * Creates a new ActionManager from a JSON data
  10263. * @param parsedActions defines the JSON data to read from
  10264. * @param object defines the hosting mesh
  10265. * @param scene defines the hosting scene
  10266. */
  10267. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10268. /**
  10269. * Get a trigger name by index
  10270. * @param trigger defines the trigger index
  10271. * @returns a trigger name
  10272. */
  10273. static GetTriggerName(trigger: number): string;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Class representing a ray with position and direction
  10279. */
  10280. export class Ray {
  10281. /** origin point */
  10282. origin: Vector3;
  10283. /** direction */
  10284. direction: Vector3;
  10285. /** length of the ray */
  10286. length: number;
  10287. private static readonly _TmpVector3;
  10288. private _tmpRay;
  10289. /**
  10290. * Creates a new ray
  10291. * @param origin origin point
  10292. * @param direction direction
  10293. * @param length length of the ray
  10294. */
  10295. constructor(
  10296. /** origin point */
  10297. origin: Vector3,
  10298. /** direction */
  10299. direction: Vector3,
  10300. /** length of the ray */
  10301. length?: number);
  10302. /**
  10303. * Checks if the ray intersects a box
  10304. * This does not account for the ray lenght by design to improve perfs.
  10305. * @param minimum bound of the box
  10306. * @param maximum bound of the box
  10307. * @param intersectionTreshold extra extend to be added to the box in all direction
  10308. * @returns if the box was hit
  10309. */
  10310. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10311. /**
  10312. * Checks if the ray intersects a box
  10313. * This does not account for the ray lenght by design to improve perfs.
  10314. * @param box the bounding box to check
  10315. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10316. * @returns if the box was hit
  10317. */
  10318. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10319. /**
  10320. * If the ray hits a sphere
  10321. * @param sphere the bounding sphere to check
  10322. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10323. * @returns true if it hits the sphere
  10324. */
  10325. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10326. /**
  10327. * If the ray hits a triange
  10328. * @param vertex0 triangle vertex
  10329. * @param vertex1 triangle vertex
  10330. * @param vertex2 triangle vertex
  10331. * @returns intersection information if hit
  10332. */
  10333. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10334. /**
  10335. * Checks if ray intersects a plane
  10336. * @param plane the plane to check
  10337. * @returns the distance away it was hit
  10338. */
  10339. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10340. /**
  10341. * Calculate the intercept of a ray on a given axis
  10342. * @param axis to check 'x' | 'y' | 'z'
  10343. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10344. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10345. */
  10346. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10347. /**
  10348. * Checks if ray intersects a mesh
  10349. * @param mesh the mesh to check
  10350. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10351. * @returns picking info of the intersecton
  10352. */
  10353. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10354. /**
  10355. * Checks if ray intersects a mesh
  10356. * @param meshes the meshes to check
  10357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10358. * @param results array to store result in
  10359. * @returns Array of picking infos
  10360. */
  10361. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10362. private _comparePickingInfo;
  10363. private static smallnum;
  10364. private static rayl;
  10365. /**
  10366. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10367. * @param sega the first point of the segment to test the intersection against
  10368. * @param segb the second point of the segment to test the intersection against
  10369. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10370. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10371. */
  10372. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10373. /**
  10374. * Update the ray from viewport position
  10375. * @param x position
  10376. * @param y y position
  10377. * @param viewportWidth viewport width
  10378. * @param viewportHeight viewport height
  10379. * @param world world matrix
  10380. * @param view view matrix
  10381. * @param projection projection matrix
  10382. * @returns this ray updated
  10383. */
  10384. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10385. /**
  10386. * Creates a ray with origin and direction of 0,0,0
  10387. * @returns the new ray
  10388. */
  10389. static Zero(): Ray;
  10390. /**
  10391. * Creates a new ray from screen space and viewport
  10392. * @param x position
  10393. * @param y y position
  10394. * @param viewportWidth viewport width
  10395. * @param viewportHeight viewport height
  10396. * @param world world matrix
  10397. * @param view view matrix
  10398. * @param projection projection matrix
  10399. * @returns new ray
  10400. */
  10401. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10402. /**
  10403. * 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
  10404. * transformed to the given world matrix.
  10405. * @param origin The origin point
  10406. * @param end The end point
  10407. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10408. * @returns the new ray
  10409. */
  10410. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10411. /**
  10412. * Transforms a ray by a matrix
  10413. * @param ray ray to transform
  10414. * @param matrix matrix to apply
  10415. * @returns the resulting new ray
  10416. */
  10417. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10418. /**
  10419. * Transforms a ray by a matrix
  10420. * @param ray ray to transform
  10421. * @param matrix matrix to apply
  10422. * @param result ray to store result in
  10423. */
  10424. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10425. /**
  10426. * Unproject a ray from screen space to object space
  10427. * @param sourceX defines the screen space x coordinate to use
  10428. * @param sourceY defines the screen space y coordinate to use
  10429. * @param viewportWidth defines the current width of the viewport
  10430. * @param viewportHeight defines the current height of the viewport
  10431. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10432. * @param view defines the view matrix to use
  10433. * @param projection defines the projection matrix to use
  10434. */
  10435. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10436. }
  10437. /**
  10438. * Type used to define predicate used to select faces when a mesh intersection is detected
  10439. */
  10440. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10441. interface Scene {
  10442. /** @hidden */
  10443. _tempPickingRay: Nullable<Ray>;
  10444. /** @hidden */
  10445. _cachedRayForTransform: Ray;
  10446. /** @hidden */
  10447. _pickWithRayInverseMatrix: Matrix;
  10448. /** @hidden */
  10449. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10450. /** @hidden */
  10451. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10452. /** @hidden */
  10453. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10454. }
  10455. }
  10456. declare module BABYLON {
  10457. /**
  10458. * Groups all the scene component constants in one place to ease maintenance.
  10459. * @hidden
  10460. */
  10461. export class SceneComponentConstants {
  10462. static readonly NAME_EFFECTLAYER: string;
  10463. static readonly NAME_LAYER: string;
  10464. static readonly NAME_LENSFLARESYSTEM: string;
  10465. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10466. static readonly NAME_PARTICLESYSTEM: string;
  10467. static readonly NAME_GAMEPAD: string;
  10468. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10469. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10470. static readonly NAME_PREPASSRENDERER: string;
  10471. static readonly NAME_DEPTHRENDERER: string;
  10472. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10473. static readonly NAME_SPRITE: string;
  10474. static readonly NAME_SUBSURFACE: string;
  10475. static readonly NAME_OUTLINERENDERER: string;
  10476. static readonly NAME_PROCEDURALTEXTURE: string;
  10477. static readonly NAME_SHADOWGENERATOR: string;
  10478. static readonly NAME_OCTREE: string;
  10479. static readonly NAME_PHYSICSENGINE: string;
  10480. static readonly NAME_AUDIO: string;
  10481. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10482. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10483. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10484. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10485. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10486. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10487. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10488. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10489. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10490. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10491. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10492. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10493. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10494. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10495. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10496. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10497. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10498. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10499. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10500. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10501. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10502. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10503. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10504. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10505. static readonly STEP_AFTERRENDER_AUDIO: number;
  10506. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10507. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10508. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10509. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10510. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10511. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10512. static readonly STEP_POINTERMOVE_SPRITE: number;
  10513. static readonly STEP_POINTERDOWN_SPRITE: number;
  10514. static readonly STEP_POINTERUP_SPRITE: number;
  10515. }
  10516. /**
  10517. * This represents a scene component.
  10518. *
  10519. * This is used to decouple the dependency the scene is having on the different workloads like
  10520. * layers, post processes...
  10521. */
  10522. export interface ISceneComponent {
  10523. /**
  10524. * The name of the component. Each component must have a unique name.
  10525. */
  10526. name: string;
  10527. /**
  10528. * The scene the component belongs to.
  10529. */
  10530. scene: Scene;
  10531. /**
  10532. * Register the component to one instance of a scene.
  10533. */
  10534. register(): void;
  10535. /**
  10536. * Rebuilds the elements related to this component in case of
  10537. * context lost for instance.
  10538. */
  10539. rebuild(): void;
  10540. /**
  10541. * Disposes the component and the associated ressources.
  10542. */
  10543. dispose(): void;
  10544. }
  10545. /**
  10546. * This represents a SERIALIZABLE scene component.
  10547. *
  10548. * This extends Scene Component to add Serialization methods on top.
  10549. */
  10550. export interface ISceneSerializableComponent extends ISceneComponent {
  10551. /**
  10552. * Adds all the elements from the container to the scene
  10553. * @param container the container holding the elements
  10554. */
  10555. addFromContainer(container: AbstractScene): void;
  10556. /**
  10557. * Removes all the elements in the container from the scene
  10558. * @param container contains the elements to remove
  10559. * @param dispose if the removed element should be disposed (default: false)
  10560. */
  10561. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10562. /**
  10563. * Serializes the component data to the specified json object
  10564. * @param serializationObject The object to serialize to
  10565. */
  10566. serialize(serializationObject: any): void;
  10567. }
  10568. /**
  10569. * Strong typing of a Mesh related stage step action
  10570. */
  10571. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10572. /**
  10573. * Strong typing of a Evaluate Sub Mesh related stage step action
  10574. */
  10575. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10576. /**
  10577. * Strong typing of a pre active Mesh related stage step action
  10578. */
  10579. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10580. /**
  10581. * Strong typing of a Camera related stage step action
  10582. */
  10583. export type CameraStageAction = (camera: Camera) => void;
  10584. /**
  10585. * Strong typing of a Camera Frame buffer related stage step action
  10586. */
  10587. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10588. /**
  10589. * Strong typing of a Render Target related stage step action
  10590. */
  10591. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10592. /**
  10593. * Strong typing of a RenderingGroup related stage step action
  10594. */
  10595. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10596. /**
  10597. * Strong typing of a Mesh Render related stage step action
  10598. */
  10599. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10600. /**
  10601. * Strong typing of a simple stage step action
  10602. */
  10603. export type SimpleStageAction = () => void;
  10604. /**
  10605. * Strong typing of a render target action.
  10606. */
  10607. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10608. /**
  10609. * Strong typing of a pointer move action.
  10610. */
  10611. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10612. /**
  10613. * Strong typing of a pointer up/down action.
  10614. */
  10615. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10616. /**
  10617. * Representation of a stage in the scene (Basically a list of ordered steps)
  10618. * @hidden
  10619. */
  10620. export class Stage<T extends Function> extends Array<{
  10621. index: number;
  10622. component: ISceneComponent;
  10623. action: T;
  10624. }> {
  10625. /**
  10626. * Hide ctor from the rest of the world.
  10627. * @param items The items to add.
  10628. */
  10629. private constructor();
  10630. /**
  10631. * Creates a new Stage.
  10632. * @returns A new instance of a Stage
  10633. */
  10634. static Create<T extends Function>(): Stage<T>;
  10635. /**
  10636. * Registers a step in an ordered way in the targeted stage.
  10637. * @param index Defines the position to register the step in
  10638. * @param component Defines the component attached to the step
  10639. * @param action Defines the action to launch during the step
  10640. */
  10641. registerStep(index: number, component: ISceneComponent, action: T): void;
  10642. /**
  10643. * Clears all the steps from the stage.
  10644. */
  10645. clear(): void;
  10646. }
  10647. }
  10648. declare module BABYLON {
  10649. interface Scene {
  10650. /** @hidden */
  10651. _pointerOverSprite: Nullable<Sprite>;
  10652. /** @hidden */
  10653. _pickedDownSprite: Nullable<Sprite>;
  10654. /** @hidden */
  10655. _tempSpritePickingRay: Nullable<Ray>;
  10656. /**
  10657. * All of the sprite managers added to this scene
  10658. * @see https://doc.babylonjs.com/babylon101/sprites
  10659. */
  10660. spriteManagers: Array<ISpriteManager>;
  10661. /**
  10662. * An event triggered when sprites rendering is about to start
  10663. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10664. */
  10665. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10666. /**
  10667. * An event triggered when sprites rendering is done
  10668. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10669. */
  10670. onAfterSpritesRenderingObservable: Observable<Scene>;
  10671. /** @hidden */
  10672. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10673. /** Launch a ray to try to pick a sprite in the scene
  10674. * @param x position on screen
  10675. * @param y position on screen
  10676. * @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
  10677. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10678. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10679. * @returns a PickingInfo
  10680. */
  10681. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10682. /** Use the given ray to pick a sprite in the scene
  10683. * @param ray The ray (in world space) to use to pick meshes
  10684. * @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
  10685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10686. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10687. * @returns a PickingInfo
  10688. */
  10689. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10690. /** @hidden */
  10691. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10692. /** Launch a ray to try to pick sprites in the scene
  10693. * @param x position on screen
  10694. * @param y position on screen
  10695. * @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
  10696. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10697. * @returns a PickingInfo array
  10698. */
  10699. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10700. /** Use the given ray to pick sprites in the scene
  10701. * @param ray The ray (in world space) to use to pick meshes
  10702. * @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
  10703. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10704. * @returns a PickingInfo array
  10705. */
  10706. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10707. /**
  10708. * Force the sprite under the pointer
  10709. * @param sprite defines the sprite to use
  10710. */
  10711. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10712. /**
  10713. * Gets the sprite under the pointer
  10714. * @returns a Sprite or null if no sprite is under the pointer
  10715. */
  10716. getPointerOverSprite(): Nullable<Sprite>;
  10717. }
  10718. /**
  10719. * Defines the sprite scene component responsible to manage sprites
  10720. * in a given scene.
  10721. */
  10722. export class SpriteSceneComponent implements ISceneComponent {
  10723. /**
  10724. * The component name helpfull to identify the component in the list of scene components.
  10725. */
  10726. readonly name: string;
  10727. /**
  10728. * The scene the component belongs to.
  10729. */
  10730. scene: Scene;
  10731. /** @hidden */
  10732. private _spritePredicate;
  10733. /**
  10734. * Creates a new instance of the component for the given scene
  10735. * @param scene Defines the scene to register the component in
  10736. */
  10737. constructor(scene: Scene);
  10738. /**
  10739. * Registers the component in a given scene
  10740. */
  10741. register(): void;
  10742. /**
  10743. * Rebuilds the elements related to this component in case of
  10744. * context lost for instance.
  10745. */
  10746. rebuild(): void;
  10747. /**
  10748. * Disposes the component and the associated ressources.
  10749. */
  10750. dispose(): void;
  10751. private _pickSpriteButKeepRay;
  10752. private _pointerMove;
  10753. private _pointerDown;
  10754. private _pointerUp;
  10755. }
  10756. }
  10757. declare module BABYLON {
  10758. /**
  10759. * Class used to provide helper for timing
  10760. */
  10761. export class TimingTools {
  10762. /**
  10763. * Polyfill for setImmediate
  10764. * @param action defines the action to execute after the current execution block
  10765. */
  10766. static SetImmediate(action: () => void): void;
  10767. }
  10768. }
  10769. declare module BABYLON {
  10770. /**
  10771. * Class used to enable instatition of objects by class name
  10772. */
  10773. export class InstantiationTools {
  10774. /**
  10775. * Use this object to register external classes like custom textures or material
  10776. * to allow the laoders to instantiate them
  10777. */
  10778. static RegisteredExternalClasses: {
  10779. [key: string]: Object;
  10780. };
  10781. /**
  10782. * Tries to instantiate a new object from a given class name
  10783. * @param className defines the class name to instantiate
  10784. * @returns the new object or null if the system was not able to do the instantiation
  10785. */
  10786. static Instantiate(className: string): any;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. /**
  10791. * Class used to host copy specific utilities
  10792. */
  10793. export class CopyTools {
  10794. /**
  10795. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10796. * @param texture defines the texture to read pixels from
  10797. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10798. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10799. * @returns The base64 encoded string or null
  10800. */
  10801. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /**
  10806. * Define options used to create a depth texture
  10807. */
  10808. export class DepthTextureCreationOptions {
  10809. /** Specifies whether or not a stencil should be allocated in the texture */
  10810. generateStencil?: boolean;
  10811. /** Specifies whether or not bilinear filtering is enable on the texture */
  10812. bilinearFiltering?: boolean;
  10813. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10814. comparisonFunction?: number;
  10815. /** Specifies if the created texture is a cube texture */
  10816. isCube?: boolean;
  10817. }
  10818. }
  10819. declare module BABYLON {
  10820. interface ThinEngine {
  10821. /**
  10822. * Creates a depth stencil cube texture.
  10823. * This is only available in WebGL 2.
  10824. * @param size The size of face edge in the cube texture.
  10825. * @param options The options defining the cube texture.
  10826. * @returns The cube texture
  10827. */
  10828. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10829. /**
  10830. * Creates a cube texture
  10831. * @param rootUrl defines the url where the files to load is located
  10832. * @param scene defines the current scene
  10833. * @param files defines the list of files to load (1 per face)
  10834. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10835. * @param onLoad defines an optional callback raised when the texture is loaded
  10836. * @param onError defines an optional callback raised if there is an issue to load the texture
  10837. * @param format defines the format of the data
  10838. * @param forcedExtension defines the extension to use to pick the right loader
  10839. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10840. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10841. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10842. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10843. * @param loaderOptions options to be passed to the loader
  10844. * @returns the cube texture as an InternalTexture
  10845. */
  10846. 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;
  10847. /**
  10848. * Creates a cube texture
  10849. * @param rootUrl defines the url where the files to load is located
  10850. * @param scene defines the current scene
  10851. * @param files defines the list of files to load (1 per face)
  10852. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10853. * @param onLoad defines an optional callback raised when the texture is loaded
  10854. * @param onError defines an optional callback raised if there is an issue to load the texture
  10855. * @param format defines the format of the data
  10856. * @param forcedExtension defines the extension to use to pick the right loader
  10857. * @returns the cube texture as an InternalTexture
  10858. */
  10859. 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;
  10860. /**
  10861. * Creates a cube texture
  10862. * @param rootUrl defines the url where the files to load is located
  10863. * @param scene defines the current scene
  10864. * @param files defines the list of files to load (1 per face)
  10865. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10866. * @param onLoad defines an optional callback raised when the texture is loaded
  10867. * @param onError defines an optional callback raised if there is an issue to load the texture
  10868. * @param format defines the format of the data
  10869. * @param forcedExtension defines the extension to use to pick the right loader
  10870. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10873. * @returns the cube texture as an InternalTexture
  10874. */
  10875. 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;
  10876. /** @hidden */
  10877. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10878. /** @hidden */
  10879. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10880. /** @hidden */
  10881. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10882. /** @hidden */
  10883. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10884. /**
  10885. * @hidden
  10886. */
  10887. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10888. }
  10889. }
  10890. declare module BABYLON {
  10891. /**
  10892. * Class for creating a cube texture
  10893. */
  10894. export class CubeTexture extends BaseTexture {
  10895. private _delayedOnLoad;
  10896. /**
  10897. * Observable triggered once the texture has been loaded.
  10898. */
  10899. onLoadObservable: Observable<CubeTexture>;
  10900. /**
  10901. * The url of the texture
  10902. */
  10903. url: string;
  10904. /**
  10905. * Gets or sets the center of the bounding box associated with the cube texture.
  10906. * It must define where the camera used to render the texture was set
  10907. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10908. */
  10909. boundingBoxPosition: Vector3;
  10910. private _boundingBoxSize;
  10911. /**
  10912. * Gets or sets the size of the bounding box associated with the cube texture
  10913. * When defined, the cubemap will switch to local mode
  10914. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10915. * @example https://www.babylonjs-playground.com/#RNASML
  10916. */
  10917. set boundingBoxSize(value: Vector3);
  10918. /**
  10919. * Returns the bounding box size
  10920. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10921. */
  10922. get boundingBoxSize(): Vector3;
  10923. protected _rotationY: number;
  10924. /**
  10925. * Sets texture matrix rotation angle around Y axis in radians.
  10926. */
  10927. set rotationY(value: number);
  10928. /**
  10929. * Gets texture matrix rotation angle around Y axis radians.
  10930. */
  10931. get rotationY(): number;
  10932. /**
  10933. * Are mip maps generated for this texture or not.
  10934. */
  10935. get noMipmap(): boolean;
  10936. private _noMipmap;
  10937. private _files;
  10938. protected _forcedExtension: Nullable<string>;
  10939. private _extensions;
  10940. private _textureMatrix;
  10941. private _format;
  10942. private _createPolynomials;
  10943. private _loaderOptions;
  10944. /**
  10945. * Creates a cube texture from an array of image urls
  10946. * @param files defines an array of image urls
  10947. * @param scene defines the hosting scene
  10948. * @param noMipmap specifies if mip maps are not used
  10949. * @returns a cube texture
  10950. */
  10951. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10952. /**
  10953. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10954. * @param url defines the url of the prefiltered texture
  10955. * @param scene defines the scene the texture is attached to
  10956. * @param forcedExtension defines the extension of the file if different from the url
  10957. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10958. * @return the prefiltered texture
  10959. */
  10960. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10961. /**
  10962. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10963. * as prefiltered data.
  10964. * @param rootUrl defines the url of the texture or the root name of the six images
  10965. * @param null defines the scene or engine the texture is attached to
  10966. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10967. * @param noMipmap defines if mipmaps should be created or not
  10968. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10969. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10970. * @param onError defines a callback triggered in case of error during load
  10971. * @param format defines the internal format to use for the texture once loaded
  10972. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10973. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10974. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10977. * @param loaderOptions options to be passed to the loader
  10978. * @return the cube texture
  10979. */
  10980. 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);
  10981. /**
  10982. * Get the current class name of the texture useful for serialization or dynamic coding.
  10983. * @returns "CubeTexture"
  10984. */
  10985. getClassName(): string;
  10986. /**
  10987. * Update the url (and optional buffer) of this texture if url was null during construction.
  10988. * @param url the url of the texture
  10989. * @param forcedExtension defines the extension to use
  10990. * @param onLoad callback called when the texture is loaded (defaults to null)
  10991. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10992. */
  10993. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10994. /**
  10995. * Delays loading of the cube texture
  10996. * @param forcedExtension defines the extension to use
  10997. */
  10998. delayLoad(forcedExtension?: string): void;
  10999. /**
  11000. * Returns the reflection texture matrix
  11001. * @returns the reflection texture matrix
  11002. */
  11003. getReflectionTextureMatrix(): Matrix;
  11004. /**
  11005. * Sets the reflection texture matrix
  11006. * @param value Reflection texture matrix
  11007. */
  11008. setReflectionTextureMatrix(value: Matrix): void;
  11009. /**
  11010. * Parses text to create a cube texture
  11011. * @param parsedTexture define the serialized text to read from
  11012. * @param scene defines the hosting scene
  11013. * @param rootUrl defines the root url of the cube texture
  11014. * @returns a cube texture
  11015. */
  11016. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11017. /**
  11018. * Makes a clone, or deep copy, of the cube texture
  11019. * @returns a new cube texture
  11020. */
  11021. clone(): CubeTexture;
  11022. }
  11023. }
  11024. declare module BABYLON {
  11025. /**
  11026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11028. * 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;
  11029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11030. */
  11031. export class ColorCurves {
  11032. private _dirty;
  11033. private _tempColor;
  11034. private _globalCurve;
  11035. private _highlightsCurve;
  11036. private _midtonesCurve;
  11037. private _shadowsCurve;
  11038. private _positiveCurve;
  11039. private _negativeCurve;
  11040. private _globalHue;
  11041. private _globalDensity;
  11042. private _globalSaturation;
  11043. private _globalExposure;
  11044. /**
  11045. * Gets the global Hue value.
  11046. * 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).
  11047. */
  11048. get globalHue(): number;
  11049. /**
  11050. * Sets the global Hue value.
  11051. * 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).
  11052. */
  11053. set globalHue(value: number);
  11054. /**
  11055. * Gets the global Density value.
  11056. * 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.
  11057. * Values less than zero provide a filter of opposite hue.
  11058. */
  11059. get globalDensity(): number;
  11060. /**
  11061. * Sets the global Density value.
  11062. * 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.
  11063. * Values less than zero provide a filter of opposite hue.
  11064. */
  11065. set globalDensity(value: number);
  11066. /**
  11067. * Gets the global Saturation value.
  11068. * 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.
  11069. */
  11070. get globalSaturation(): number;
  11071. /**
  11072. * Sets the global Saturation value.
  11073. * 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.
  11074. */
  11075. set globalSaturation(value: number);
  11076. /**
  11077. * Gets the global Exposure value.
  11078. * 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.
  11079. */
  11080. get globalExposure(): number;
  11081. /**
  11082. * Sets the global Exposure value.
  11083. * 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.
  11084. */
  11085. set globalExposure(value: number);
  11086. private _highlightsHue;
  11087. private _highlightsDensity;
  11088. private _highlightsSaturation;
  11089. private _highlightsExposure;
  11090. /**
  11091. * Gets the highlights Hue value.
  11092. * 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).
  11093. */
  11094. get highlightsHue(): number;
  11095. /**
  11096. * Sets the highlights Hue value.
  11097. * 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).
  11098. */
  11099. set highlightsHue(value: number);
  11100. /**
  11101. * Gets the highlights Density value.
  11102. * 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.
  11103. * Values less than zero provide a filter of opposite hue.
  11104. */
  11105. get highlightsDensity(): number;
  11106. /**
  11107. * Sets the highlights Density value.
  11108. * 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.
  11109. * Values less than zero provide a filter of opposite hue.
  11110. */
  11111. set highlightsDensity(value: number);
  11112. /**
  11113. * Gets the highlights Saturation value.
  11114. * 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.
  11115. */
  11116. get highlightsSaturation(): number;
  11117. /**
  11118. * Sets the highlights Saturation value.
  11119. * 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.
  11120. */
  11121. set highlightsSaturation(value: number);
  11122. /**
  11123. * Gets the highlights Exposure value.
  11124. * 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.
  11125. */
  11126. get highlightsExposure(): number;
  11127. /**
  11128. * Sets the highlights Exposure value.
  11129. * 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.
  11130. */
  11131. set highlightsExposure(value: number);
  11132. private _midtonesHue;
  11133. private _midtonesDensity;
  11134. private _midtonesSaturation;
  11135. private _midtonesExposure;
  11136. /**
  11137. * Gets the midtones Hue value.
  11138. * 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).
  11139. */
  11140. get midtonesHue(): number;
  11141. /**
  11142. * Sets the midtones Hue value.
  11143. * 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).
  11144. */
  11145. set midtonesHue(value: number);
  11146. /**
  11147. * Gets the midtones Density value.
  11148. * 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.
  11149. * Values less than zero provide a filter of opposite hue.
  11150. */
  11151. get midtonesDensity(): number;
  11152. /**
  11153. * Sets the midtones Density value.
  11154. * 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.
  11155. * Values less than zero provide a filter of opposite hue.
  11156. */
  11157. set midtonesDensity(value: number);
  11158. /**
  11159. * Gets the midtones Saturation value.
  11160. * 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.
  11161. */
  11162. get midtonesSaturation(): number;
  11163. /**
  11164. * Sets the midtones Saturation value.
  11165. * 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.
  11166. */
  11167. set midtonesSaturation(value: number);
  11168. /**
  11169. * Gets the midtones Exposure value.
  11170. * 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.
  11171. */
  11172. get midtonesExposure(): number;
  11173. /**
  11174. * Sets the midtones Exposure value.
  11175. * 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.
  11176. */
  11177. set midtonesExposure(value: number);
  11178. private _shadowsHue;
  11179. private _shadowsDensity;
  11180. private _shadowsSaturation;
  11181. private _shadowsExposure;
  11182. /**
  11183. * Gets the shadows Hue value.
  11184. * 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).
  11185. */
  11186. get shadowsHue(): number;
  11187. /**
  11188. * Sets the shadows Hue value.
  11189. * 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).
  11190. */
  11191. set shadowsHue(value: number);
  11192. /**
  11193. * Gets the shadows Density value.
  11194. * 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.
  11195. * Values less than zero provide a filter of opposite hue.
  11196. */
  11197. get shadowsDensity(): number;
  11198. /**
  11199. * Sets the shadows Density value.
  11200. * 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.
  11201. * Values less than zero provide a filter of opposite hue.
  11202. */
  11203. set shadowsDensity(value: number);
  11204. /**
  11205. * Gets the shadows Saturation value.
  11206. * 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.
  11207. */
  11208. get shadowsSaturation(): number;
  11209. /**
  11210. * Sets the shadows Saturation value.
  11211. * 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.
  11212. */
  11213. set shadowsSaturation(value: number);
  11214. /**
  11215. * Gets the shadows Exposure value.
  11216. * 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.
  11217. */
  11218. get shadowsExposure(): number;
  11219. /**
  11220. * Sets the shadows Exposure value.
  11221. * 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.
  11222. */
  11223. set shadowsExposure(value: number);
  11224. /**
  11225. * Returns the class name
  11226. * @returns The class name
  11227. */
  11228. getClassName(): string;
  11229. /**
  11230. * Binds the color curves to the shader.
  11231. * @param colorCurves The color curve to bind
  11232. * @param effect The effect to bind to
  11233. * @param positiveUniform The positive uniform shader parameter
  11234. * @param neutralUniform The neutral uniform shader parameter
  11235. * @param negativeUniform The negative uniform shader parameter
  11236. */
  11237. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11238. /**
  11239. * Prepare the list of uniforms associated with the ColorCurves effects.
  11240. * @param uniformsList The list of uniforms used in the effect
  11241. */
  11242. static PrepareUniforms(uniformsList: string[]): void;
  11243. /**
  11244. * Returns color grading data based on a hue, density, saturation and exposure value.
  11245. * @param filterHue The hue of the color filter.
  11246. * @param filterDensity The density of the color filter.
  11247. * @param saturation The saturation.
  11248. * @param exposure The exposure.
  11249. * @param result The result data container.
  11250. */
  11251. private getColorGradingDataToRef;
  11252. /**
  11253. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11254. * @param value The input slider value in range [-100,100].
  11255. * @returns Adjusted value.
  11256. */
  11257. private static applyColorGradingSliderNonlinear;
  11258. /**
  11259. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11260. * @param hue The hue (H) input.
  11261. * @param saturation The saturation (S) input.
  11262. * @param brightness The brightness (B) input.
  11263. * @result An RGBA color represented as Vector4.
  11264. */
  11265. private static fromHSBToRef;
  11266. /**
  11267. * Returns a value clamped between min and max
  11268. * @param value The value to clamp
  11269. * @param min The minimum of value
  11270. * @param max The maximum of value
  11271. * @returns The clamped value.
  11272. */
  11273. private static clamp;
  11274. /**
  11275. * Clones the current color curve instance.
  11276. * @return The cloned curves
  11277. */
  11278. clone(): ColorCurves;
  11279. /**
  11280. * Serializes the current color curve instance to a json representation.
  11281. * @return a JSON representation
  11282. */
  11283. serialize(): any;
  11284. /**
  11285. * Parses the color curve from a json representation.
  11286. * @param source the JSON source to parse
  11287. * @return The parsed curves
  11288. */
  11289. static Parse(source: any): ColorCurves;
  11290. }
  11291. }
  11292. declare module BABYLON {
  11293. /**
  11294. * Interface to follow in your material defines to integrate easily the
  11295. * Image proccessing functions.
  11296. * @hidden
  11297. */
  11298. export interface IImageProcessingConfigurationDefines {
  11299. IMAGEPROCESSING: boolean;
  11300. VIGNETTE: boolean;
  11301. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11302. VIGNETTEBLENDMODEOPAQUE: boolean;
  11303. TONEMAPPING: boolean;
  11304. TONEMAPPING_ACES: boolean;
  11305. CONTRAST: boolean;
  11306. EXPOSURE: boolean;
  11307. COLORCURVES: boolean;
  11308. COLORGRADING: boolean;
  11309. COLORGRADING3D: boolean;
  11310. SAMPLER3DGREENDEPTH: boolean;
  11311. SAMPLER3DBGRMAP: boolean;
  11312. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11313. }
  11314. /**
  11315. * @hidden
  11316. */
  11317. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11318. IMAGEPROCESSING: boolean;
  11319. VIGNETTE: boolean;
  11320. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11321. VIGNETTEBLENDMODEOPAQUE: boolean;
  11322. TONEMAPPING: boolean;
  11323. TONEMAPPING_ACES: boolean;
  11324. CONTRAST: boolean;
  11325. COLORCURVES: boolean;
  11326. COLORGRADING: boolean;
  11327. COLORGRADING3D: boolean;
  11328. SAMPLER3DGREENDEPTH: boolean;
  11329. SAMPLER3DBGRMAP: boolean;
  11330. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11331. EXPOSURE: boolean;
  11332. constructor();
  11333. }
  11334. /**
  11335. * This groups together the common properties used for image processing either in direct forward pass
  11336. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11337. * or not.
  11338. */
  11339. export class ImageProcessingConfiguration {
  11340. /**
  11341. * Default tone mapping applied in BabylonJS.
  11342. */
  11343. static readonly TONEMAPPING_STANDARD: number;
  11344. /**
  11345. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11346. * to other engines rendering to increase portability.
  11347. */
  11348. static readonly TONEMAPPING_ACES: number;
  11349. /**
  11350. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11351. */
  11352. colorCurves: Nullable<ColorCurves>;
  11353. private _colorCurvesEnabled;
  11354. /**
  11355. * Gets wether the color curves effect is enabled.
  11356. */
  11357. get colorCurvesEnabled(): boolean;
  11358. /**
  11359. * Sets wether the color curves effect is enabled.
  11360. */
  11361. set colorCurvesEnabled(value: boolean);
  11362. private _colorGradingTexture;
  11363. /**
  11364. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11365. */
  11366. get colorGradingTexture(): Nullable<BaseTexture>;
  11367. /**
  11368. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11369. */
  11370. set colorGradingTexture(value: Nullable<BaseTexture>);
  11371. private _colorGradingEnabled;
  11372. /**
  11373. * Gets wether the color grading effect is enabled.
  11374. */
  11375. get colorGradingEnabled(): boolean;
  11376. /**
  11377. * Sets wether the color grading effect is enabled.
  11378. */
  11379. set colorGradingEnabled(value: boolean);
  11380. private _colorGradingWithGreenDepth;
  11381. /**
  11382. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11383. */
  11384. get colorGradingWithGreenDepth(): boolean;
  11385. /**
  11386. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11387. */
  11388. set colorGradingWithGreenDepth(value: boolean);
  11389. private _colorGradingBGR;
  11390. /**
  11391. * Gets wether the color grading texture contains BGR values.
  11392. */
  11393. get colorGradingBGR(): boolean;
  11394. /**
  11395. * Sets wether the color grading texture contains BGR values.
  11396. */
  11397. set colorGradingBGR(value: boolean);
  11398. /** @hidden */
  11399. _exposure: number;
  11400. /**
  11401. * Gets the Exposure used in the effect.
  11402. */
  11403. get exposure(): number;
  11404. /**
  11405. * Sets the Exposure used in the effect.
  11406. */
  11407. set exposure(value: number);
  11408. private _toneMappingEnabled;
  11409. /**
  11410. * Gets wether the tone mapping effect is enabled.
  11411. */
  11412. get toneMappingEnabled(): boolean;
  11413. /**
  11414. * Sets wether the tone mapping effect is enabled.
  11415. */
  11416. set toneMappingEnabled(value: boolean);
  11417. private _toneMappingType;
  11418. /**
  11419. * Gets the type of tone mapping effect.
  11420. */
  11421. get toneMappingType(): number;
  11422. /**
  11423. * Sets the type of tone mapping effect used in BabylonJS.
  11424. */
  11425. set toneMappingType(value: number);
  11426. protected _contrast: number;
  11427. /**
  11428. * Gets the contrast used in the effect.
  11429. */
  11430. get contrast(): number;
  11431. /**
  11432. * Sets the contrast used in the effect.
  11433. */
  11434. set contrast(value: number);
  11435. /**
  11436. * Vignette stretch size.
  11437. */
  11438. vignetteStretch: number;
  11439. /**
  11440. * Vignette centre X Offset.
  11441. */
  11442. vignetteCentreX: number;
  11443. /**
  11444. * Vignette centre Y Offset.
  11445. */
  11446. vignetteCentreY: number;
  11447. /**
  11448. * Vignette weight or intensity of the vignette effect.
  11449. */
  11450. vignetteWeight: number;
  11451. /**
  11452. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11453. * if vignetteEnabled is set to true.
  11454. */
  11455. vignetteColor: Color4;
  11456. /**
  11457. * Camera field of view used by the Vignette effect.
  11458. */
  11459. vignetteCameraFov: number;
  11460. private _vignetteBlendMode;
  11461. /**
  11462. * Gets the vignette blend mode allowing different kind of effect.
  11463. */
  11464. get vignetteBlendMode(): number;
  11465. /**
  11466. * Sets the vignette blend mode allowing different kind of effect.
  11467. */
  11468. set vignetteBlendMode(value: number);
  11469. private _vignetteEnabled;
  11470. /**
  11471. * Gets wether the vignette effect is enabled.
  11472. */
  11473. get vignetteEnabled(): boolean;
  11474. /**
  11475. * Sets wether the vignette effect is enabled.
  11476. */
  11477. set vignetteEnabled(value: boolean);
  11478. private _applyByPostProcess;
  11479. /**
  11480. * Gets wether the image processing is applied through a post process or not.
  11481. */
  11482. get applyByPostProcess(): boolean;
  11483. /**
  11484. * Sets wether the image processing is applied through a post process or not.
  11485. */
  11486. set applyByPostProcess(value: boolean);
  11487. private _isEnabled;
  11488. /**
  11489. * Gets wether the image processing is enabled or not.
  11490. */
  11491. get isEnabled(): boolean;
  11492. /**
  11493. * Sets wether the image processing is enabled or not.
  11494. */
  11495. set isEnabled(value: boolean);
  11496. /**
  11497. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11498. */
  11499. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11500. /**
  11501. * Method called each time the image processing information changes requires to recompile the effect.
  11502. */
  11503. protected _updateParameters(): void;
  11504. /**
  11505. * Gets the current class name.
  11506. * @return "ImageProcessingConfiguration"
  11507. */
  11508. getClassName(): string;
  11509. /**
  11510. * Prepare the list of uniforms associated with the Image Processing effects.
  11511. * @param uniforms The list of uniforms used in the effect
  11512. * @param defines the list of defines currently in use
  11513. */
  11514. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11515. /**
  11516. * Prepare the list of samplers associated with the Image Processing effects.
  11517. * @param samplersList The list of uniforms used in the effect
  11518. * @param defines the list of defines currently in use
  11519. */
  11520. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11521. /**
  11522. * Prepare the list of defines associated to the shader.
  11523. * @param defines the list of defines to complete
  11524. * @param forPostProcess Define if we are currently in post process mode or not
  11525. */
  11526. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11527. /**
  11528. * Returns true if all the image processing information are ready.
  11529. * @returns True if ready, otherwise, false
  11530. */
  11531. isReady(): boolean;
  11532. /**
  11533. * Binds the image processing to the shader.
  11534. * @param effect The effect to bind to
  11535. * @param overrideAspectRatio Override the aspect ratio of the effect
  11536. */
  11537. bind(effect: Effect, overrideAspectRatio?: number): void;
  11538. /**
  11539. * Clones the current image processing instance.
  11540. * @return The cloned image processing
  11541. */
  11542. clone(): ImageProcessingConfiguration;
  11543. /**
  11544. * Serializes the current image processing instance to a json representation.
  11545. * @return a JSON representation
  11546. */
  11547. serialize(): any;
  11548. /**
  11549. * Parses the image processing from a json representation.
  11550. * @param source the JSON source to parse
  11551. * @return The parsed image processing
  11552. */
  11553. static Parse(source: any): ImageProcessingConfiguration;
  11554. private static _VIGNETTEMODE_MULTIPLY;
  11555. private static _VIGNETTEMODE_OPAQUE;
  11556. /**
  11557. * Used to apply the vignette as a mix with the pixel color.
  11558. */
  11559. static get VIGNETTEMODE_MULTIPLY(): number;
  11560. /**
  11561. * Used to apply the vignette as a replacement of the pixel color.
  11562. */
  11563. static get VIGNETTEMODE_OPAQUE(): number;
  11564. }
  11565. }
  11566. declare module BABYLON {
  11567. /** @hidden */
  11568. export var postprocessVertexShader: {
  11569. name: string;
  11570. shader: string;
  11571. };
  11572. }
  11573. declare module BABYLON {
  11574. /**
  11575. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11576. */
  11577. export type RenderTargetTextureSize = number | {
  11578. width: number;
  11579. height: number;
  11580. layers?: number;
  11581. };
  11582. interface ThinEngine {
  11583. /**
  11584. * Creates a new render target texture
  11585. * @param size defines the size of the texture
  11586. * @param options defines the options used to create the texture
  11587. * @returns a new render target texture stored in an InternalTexture
  11588. */
  11589. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11590. /**
  11591. * Creates a depth stencil texture.
  11592. * This is only available in WebGL 2 or with the depth texture extension available.
  11593. * @param size The size of face edge in the texture.
  11594. * @param options The options defining the texture.
  11595. * @returns The texture
  11596. */
  11597. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11598. /** @hidden */
  11599. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11600. }
  11601. }
  11602. declare module BABYLON {
  11603. /**
  11604. * Defines the kind of connection point for node based material
  11605. */
  11606. export enum NodeMaterialBlockConnectionPointTypes {
  11607. /** Float */
  11608. Float = 1,
  11609. /** Int */
  11610. Int = 2,
  11611. /** Vector2 */
  11612. Vector2 = 4,
  11613. /** Vector3 */
  11614. Vector3 = 8,
  11615. /** Vector4 */
  11616. Vector4 = 16,
  11617. /** Color3 */
  11618. Color3 = 32,
  11619. /** Color4 */
  11620. Color4 = 64,
  11621. /** Matrix */
  11622. Matrix = 128,
  11623. /** Custom object */
  11624. Object = 256,
  11625. /** Detect type based on connection */
  11626. AutoDetect = 1024,
  11627. /** Output type that will be defined by input type */
  11628. BasedOnInput = 2048
  11629. }
  11630. }
  11631. declare module BABYLON {
  11632. /**
  11633. * Enum used to define the target of a block
  11634. */
  11635. export enum NodeMaterialBlockTargets {
  11636. /** Vertex shader */
  11637. Vertex = 1,
  11638. /** Fragment shader */
  11639. Fragment = 2,
  11640. /** Neutral */
  11641. Neutral = 4,
  11642. /** Vertex and Fragment */
  11643. VertexAndFragment = 3
  11644. }
  11645. }
  11646. declare module BABYLON {
  11647. /**
  11648. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11649. */
  11650. export enum NodeMaterialBlockConnectionPointMode {
  11651. /** Value is an uniform */
  11652. Uniform = 0,
  11653. /** Value is a mesh attribute */
  11654. Attribute = 1,
  11655. /** Value is a varying between vertex and fragment shaders */
  11656. Varying = 2,
  11657. /** Mode is undefined */
  11658. Undefined = 3
  11659. }
  11660. }
  11661. declare module BABYLON {
  11662. /**
  11663. * Enum used to define system values e.g. values automatically provided by the system
  11664. */
  11665. export enum NodeMaterialSystemValues {
  11666. /** World */
  11667. World = 1,
  11668. /** View */
  11669. View = 2,
  11670. /** Projection */
  11671. Projection = 3,
  11672. /** ViewProjection */
  11673. ViewProjection = 4,
  11674. /** WorldView */
  11675. WorldView = 5,
  11676. /** WorldViewProjection */
  11677. WorldViewProjection = 6,
  11678. /** CameraPosition */
  11679. CameraPosition = 7,
  11680. /** Fog Color */
  11681. FogColor = 8,
  11682. /** Delta time */
  11683. DeltaTime = 9
  11684. }
  11685. }
  11686. declare module BABYLON {
  11687. /**
  11688. * Represents a camera frustum
  11689. */
  11690. export class Frustum {
  11691. /**
  11692. * Gets the planes representing the frustum
  11693. * @param transform matrix to be applied to the returned planes
  11694. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11695. */
  11696. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11697. /**
  11698. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11703. /**
  11704. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11709. /**
  11710. * Gets the left frustum plane transformed by the transform matrix
  11711. * @param transform transformation matrix to be applied to the resulting frustum plane
  11712. * @param frustumPlane the resuling frustum plane
  11713. */
  11714. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11715. /**
  11716. * Gets the right frustum plane transformed by the transform matrix
  11717. * @param transform transformation matrix to be applied to the resulting frustum plane
  11718. * @param frustumPlane the resuling frustum plane
  11719. */
  11720. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11721. /**
  11722. * Gets the top frustum plane transformed by the transform matrix
  11723. * @param transform transformation matrix to be applied to the resulting frustum plane
  11724. * @param frustumPlane the resuling frustum plane
  11725. */
  11726. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11727. /**
  11728. * Gets the bottom frustum plane transformed by the transform matrix
  11729. * @param transform transformation matrix to be applied to the resulting frustum plane
  11730. * @param frustumPlane the resuling frustum plane
  11731. */
  11732. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11733. /**
  11734. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11735. * @param transform transformation matrix to be applied to the resulting frustum planes
  11736. * @param frustumPlanes the resuling frustum planes
  11737. */
  11738. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11739. }
  11740. }
  11741. declare module BABYLON {
  11742. /**
  11743. * Contains position and normal vectors for a vertex
  11744. */
  11745. export class PositionNormalVertex {
  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. /**
  11751. * Creates a PositionNormalVertex
  11752. * @param position the position of the vertex (defaut: 0,0,0)
  11753. * @param normal the normal of the vertex (defaut: 0,1,0)
  11754. */
  11755. constructor(
  11756. /** the position of the vertex (defaut: 0,0,0) */
  11757. position?: Vector3,
  11758. /** the normal of the vertex (defaut: 0,1,0) */
  11759. normal?: Vector3);
  11760. /**
  11761. * Clones the PositionNormalVertex
  11762. * @returns the cloned PositionNormalVertex
  11763. */
  11764. clone(): PositionNormalVertex;
  11765. }
  11766. /**
  11767. * Contains position, normal and uv vectors for a vertex
  11768. */
  11769. export class PositionNormalTextureVertex {
  11770. /** the position of the vertex (defaut: 0,0,0) */
  11771. position: Vector3;
  11772. /** the normal of the vertex (defaut: 0,1,0) */
  11773. normal: Vector3;
  11774. /** the uv of the vertex (default: 0,0) */
  11775. uv: Vector2;
  11776. /**
  11777. * Creates a PositionNormalTextureVertex
  11778. * @param position the position of the vertex (defaut: 0,0,0)
  11779. * @param normal the normal of the vertex (defaut: 0,1,0)
  11780. * @param uv the uv of the vertex (default: 0,0)
  11781. */
  11782. constructor(
  11783. /** the position of the vertex (defaut: 0,0,0) */
  11784. position?: Vector3,
  11785. /** the normal of the vertex (defaut: 0,1,0) */
  11786. normal?: Vector3,
  11787. /** the uv of the vertex (default: 0,0) */
  11788. uv?: Vector2);
  11789. /**
  11790. * Clones the PositionNormalTextureVertex
  11791. * @returns the cloned PositionNormalTextureVertex
  11792. */
  11793. clone(): PositionNormalTextureVertex;
  11794. }
  11795. }
  11796. declare module BABYLON {
  11797. /**
  11798. * Enum defining the type of animations supported by InputBlock
  11799. */
  11800. export enum AnimatedInputBlockTypes {
  11801. /** No animation */
  11802. None = 0,
  11803. /** Time based animation. Will only work for floats */
  11804. Time = 1
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * Block used to expose an input value
  11810. */
  11811. export class InputBlock extends NodeMaterialBlock {
  11812. private _mode;
  11813. private _associatedVariableName;
  11814. private _storedValue;
  11815. private _valueCallback;
  11816. private _type;
  11817. private _animationType;
  11818. /** Gets or set a value used to limit the range of float values */
  11819. min: number;
  11820. /** Gets or set a value used to limit the range of float values */
  11821. max: number;
  11822. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11823. isBoolean: boolean;
  11824. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11825. matrixMode: number;
  11826. /** @hidden */
  11827. _systemValue: Nullable<NodeMaterialSystemValues>;
  11828. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11829. isConstant: boolean;
  11830. /** Gets or sets the group to use to display this block in the Inspector */
  11831. groupInInspector: string;
  11832. /** Gets an observable raised when the value is changed */
  11833. onValueChangedObservable: Observable<InputBlock>;
  11834. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  11835. convertToGammaSpace: boolean;
  11836. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  11837. convertToLinearSpace: boolean;
  11838. /**
  11839. * Gets or sets the connection point type (default is float)
  11840. */
  11841. get type(): NodeMaterialBlockConnectionPointTypes;
  11842. /**
  11843. * Creates a new InputBlock
  11844. * @param name defines the block name
  11845. * @param target defines the target of that block (Vertex by default)
  11846. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11847. */
  11848. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11849. /**
  11850. * Validates if a name is a reserve word.
  11851. * @param newName the new name to be given to the node.
  11852. * @returns false if the name is a reserve word, else true.
  11853. */
  11854. validateBlockName(newName: string): boolean;
  11855. /**
  11856. * Gets the output component
  11857. */
  11858. get output(): NodeMaterialConnectionPoint;
  11859. /**
  11860. * Set the source of this connection point to a vertex attribute
  11861. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11862. * @returns the current connection point
  11863. */
  11864. setAsAttribute(attributeName?: string): InputBlock;
  11865. /**
  11866. * Set the source of this connection point to a system value
  11867. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11868. * @returns the current connection point
  11869. */
  11870. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11871. /**
  11872. * Gets or sets the value of that point.
  11873. * Please note that this value will be ignored if valueCallback is defined
  11874. */
  11875. get value(): any;
  11876. set value(value: any);
  11877. /**
  11878. * Gets or sets a callback used to get the value of that point.
  11879. * Please note that setting this value will force the connection point to ignore the value property
  11880. */
  11881. get valueCallback(): () => any;
  11882. set valueCallback(value: () => any);
  11883. /**
  11884. * Gets or sets the associated variable name in the shader
  11885. */
  11886. get associatedVariableName(): string;
  11887. set associatedVariableName(value: string);
  11888. /** Gets or sets the type of animation applied to the input */
  11889. get animationType(): AnimatedInputBlockTypes;
  11890. set animationType(value: AnimatedInputBlockTypes);
  11891. /**
  11892. * Gets a boolean indicating that this connection point not defined yet
  11893. */
  11894. get isUndefined(): boolean;
  11895. /**
  11896. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11897. * In this case the connection point name must be the name of the uniform to use.
  11898. * Can only be set on inputs
  11899. */
  11900. get isUniform(): boolean;
  11901. set isUniform(value: boolean);
  11902. /**
  11903. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11904. * In this case the connection point name must be the name of the attribute to use
  11905. * Can only be set on inputs
  11906. */
  11907. get isAttribute(): boolean;
  11908. set isAttribute(value: boolean);
  11909. /**
  11910. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11911. * Can only be set on exit points
  11912. */
  11913. get isVarying(): boolean;
  11914. set isVarying(value: boolean);
  11915. /**
  11916. * Gets a boolean indicating that the current connection point is a system value
  11917. */
  11918. get isSystemValue(): boolean;
  11919. /**
  11920. * Gets or sets the current well known value or null if not defined as a system value
  11921. */
  11922. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11923. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11924. /**
  11925. * Gets the current class name
  11926. * @returns the class name
  11927. */
  11928. getClassName(): string;
  11929. /**
  11930. * Animate the input if animationType !== None
  11931. * @param scene defines the rendering scene
  11932. */
  11933. animate(scene: Scene): void;
  11934. private _emitDefine;
  11935. initialize(state: NodeMaterialBuildState): void;
  11936. /**
  11937. * Set the input block to its default value (based on its type)
  11938. */
  11939. setDefaultValue(): void;
  11940. private _emitConstant;
  11941. /** @hidden */
  11942. get _noContextSwitch(): boolean;
  11943. private _emit;
  11944. /** @hidden */
  11945. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11946. /** @hidden */
  11947. _transmit(effect: Effect, scene: Scene): void;
  11948. protected _buildBlock(state: NodeMaterialBuildState): void;
  11949. protected _dumpPropertiesCode(): string;
  11950. dispose(): void;
  11951. serialize(): any;
  11952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11953. }
  11954. }
  11955. declare module BABYLON {
  11956. /**
  11957. * Enum used to define the compatibility state between two connection points
  11958. */
  11959. export enum NodeMaterialConnectionPointCompatibilityStates {
  11960. /** Points are compatibles */
  11961. Compatible = 0,
  11962. /** Points are incompatible because of their types */
  11963. TypeIncompatible = 1,
  11964. /** Points are incompatible because of their targets (vertex vs fragment) */
  11965. TargetIncompatible = 2
  11966. }
  11967. /**
  11968. * Defines the direction of a connection point
  11969. */
  11970. export enum NodeMaterialConnectionPointDirection {
  11971. /** Input */
  11972. Input = 0,
  11973. /** Output */
  11974. Output = 1
  11975. }
  11976. /**
  11977. * Defines a connection point for a block
  11978. */
  11979. export class NodeMaterialConnectionPoint {
  11980. /**
  11981. * Checks if two types are equivalent
  11982. * @param type1 type 1 to check
  11983. * @param type2 type 2 to check
  11984. * @returns true if both types are equivalent, else false
  11985. */
  11986. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11987. /** @hidden */
  11988. _ownerBlock: NodeMaterialBlock;
  11989. /** @hidden */
  11990. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11991. private _endpoints;
  11992. private _associatedVariableName;
  11993. private _direction;
  11994. /** @hidden */
  11995. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11996. /** @hidden */
  11997. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11998. /** @hidden */
  11999. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12000. private _type;
  12001. /** @hidden */
  12002. _enforceAssociatedVariableName: boolean;
  12003. /** Gets the direction of the point */
  12004. get direction(): NodeMaterialConnectionPointDirection;
  12005. /** Indicates that this connection point needs dual validation before being connected to another point */
  12006. needDualDirectionValidation: boolean;
  12007. /**
  12008. * Gets or sets the additional types supported by this connection point
  12009. */
  12010. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12011. /**
  12012. * Gets or sets the additional types excluded by this connection point
  12013. */
  12014. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12015. /**
  12016. * Observable triggered when this point is connected
  12017. */
  12018. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12019. /**
  12020. * Gets or sets the associated variable name in the shader
  12021. */
  12022. get associatedVariableName(): string;
  12023. set associatedVariableName(value: string);
  12024. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12025. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12026. /**
  12027. * Gets or sets the connection point type (default is float)
  12028. */
  12029. get type(): NodeMaterialBlockConnectionPointTypes;
  12030. set type(value: NodeMaterialBlockConnectionPointTypes);
  12031. /**
  12032. * Gets or sets the connection point name
  12033. */
  12034. name: string;
  12035. /**
  12036. * Gets or sets the connection point name
  12037. */
  12038. displayName: string;
  12039. /**
  12040. * Gets or sets a boolean indicating that this connection point can be omitted
  12041. */
  12042. isOptional: boolean;
  12043. /**
  12044. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12045. */
  12046. isExposedOnFrame: boolean;
  12047. /**
  12048. * Gets or sets number indicating the position that the port is exposed to on a frame
  12049. */
  12050. exposedPortPosition: number;
  12051. /**
  12052. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12053. */
  12054. define: string;
  12055. /** @hidden */
  12056. _prioritizeVertex: boolean;
  12057. private _target;
  12058. /** Gets or sets the target of that connection point */
  12059. get target(): NodeMaterialBlockTargets;
  12060. set target(value: NodeMaterialBlockTargets);
  12061. /**
  12062. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12063. */
  12064. get isConnected(): boolean;
  12065. /**
  12066. * Gets a boolean indicating that the current point is connected to an input block
  12067. */
  12068. get isConnectedToInputBlock(): boolean;
  12069. /**
  12070. * Gets a the connected input block (if any)
  12071. */
  12072. get connectInputBlock(): Nullable<InputBlock>;
  12073. /** Get the other side of the connection (if any) */
  12074. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12075. /** Get the block that owns this connection point */
  12076. get ownerBlock(): NodeMaterialBlock;
  12077. /** Get the block connected on the other side of this connection (if any) */
  12078. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12079. /** Get the block connected on the endpoints of this connection (if any) */
  12080. get connectedBlocks(): Array<NodeMaterialBlock>;
  12081. /** Gets the list of connected endpoints */
  12082. get endpoints(): NodeMaterialConnectionPoint[];
  12083. /** Gets a boolean indicating if that output point is connected to at least one input */
  12084. get hasEndpoints(): boolean;
  12085. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12086. get isConnectedInVertexShader(): boolean;
  12087. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12088. get isConnectedInFragmentShader(): boolean;
  12089. /**
  12090. * Creates a block suitable to be used as an input for this input point.
  12091. * If null is returned, a block based on the point type will be created.
  12092. * @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
  12093. */
  12094. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12095. /**
  12096. * Creates a new connection point
  12097. * @param name defines the connection point name
  12098. * @param ownerBlock defines the block hosting this connection point
  12099. * @param direction defines the direction of the connection point
  12100. */
  12101. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12102. /**
  12103. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12104. * @returns the class name
  12105. */
  12106. getClassName(): string;
  12107. /**
  12108. * Gets a boolean indicating if the current point can be connected to another point
  12109. * @param connectionPoint defines the other connection point
  12110. * @returns a boolean
  12111. */
  12112. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12113. /**
  12114. * Gets a number indicating if the current point can be connected to another point
  12115. * @param connectionPoint defines the other connection point
  12116. * @returns a number defining the compatibility state
  12117. */
  12118. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12119. /**
  12120. * Connect this point to another connection point
  12121. * @param connectionPoint defines the other connection point
  12122. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12123. * @returns the current connection point
  12124. */
  12125. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12126. /**
  12127. * Disconnect this point from one of his endpoint
  12128. * @param endpoint defines the other connection point
  12129. * @returns the current connection point
  12130. */
  12131. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12132. /**
  12133. * Serializes this point in a JSON representation
  12134. * @param isInput defines if the connection point is an input (default is true)
  12135. * @returns the serialized point object
  12136. */
  12137. serialize(isInput?: boolean): any;
  12138. /**
  12139. * Release resources
  12140. */
  12141. dispose(): void;
  12142. }
  12143. }
  12144. declare module BABYLON {
  12145. /**
  12146. * Enum used to define the material modes
  12147. */
  12148. export enum NodeMaterialModes {
  12149. /** Regular material */
  12150. Material = 0,
  12151. /** For post process */
  12152. PostProcess = 1,
  12153. /** For particle system */
  12154. Particle = 2,
  12155. /** For procedural texture */
  12156. ProceduralTexture = 3
  12157. }
  12158. }
  12159. declare module BABYLON {
  12160. /** @hidden */
  12161. export var helperFunctions: {
  12162. name: string;
  12163. shader: string;
  12164. };
  12165. }
  12166. declare module BABYLON {
  12167. /**
  12168. * Block used to read a texture from a sampler
  12169. */
  12170. export class TextureBlock extends NodeMaterialBlock {
  12171. private _defineName;
  12172. private _linearDefineName;
  12173. private _gammaDefineName;
  12174. private _tempTextureRead;
  12175. private _samplerName;
  12176. private _transformedUVName;
  12177. private _textureTransformName;
  12178. private _textureInfoName;
  12179. private _mainUVName;
  12180. private _mainUVDefineName;
  12181. private _fragmentOnly;
  12182. /**
  12183. * Gets or sets the texture associated with the node
  12184. */
  12185. texture: Nullable<Texture>;
  12186. /**
  12187. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12188. */
  12189. convertToGammaSpace: boolean;
  12190. /**
  12191. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12192. */
  12193. convertToLinearSpace: boolean;
  12194. /**
  12195. * Create a new TextureBlock
  12196. * @param name defines the block name
  12197. */
  12198. constructor(name: string, fragmentOnly?: boolean);
  12199. /**
  12200. * Gets the current class name
  12201. * @returns the class name
  12202. */
  12203. getClassName(): string;
  12204. /**
  12205. * Gets the uv input component
  12206. */
  12207. get uv(): NodeMaterialConnectionPoint;
  12208. /**
  12209. * Gets the rgba output component
  12210. */
  12211. get rgba(): NodeMaterialConnectionPoint;
  12212. /**
  12213. * Gets the rgb output component
  12214. */
  12215. get rgb(): NodeMaterialConnectionPoint;
  12216. /**
  12217. * Gets the r output component
  12218. */
  12219. get r(): NodeMaterialConnectionPoint;
  12220. /**
  12221. * Gets the g output component
  12222. */
  12223. get g(): NodeMaterialConnectionPoint;
  12224. /**
  12225. * Gets the b output component
  12226. */
  12227. get b(): NodeMaterialConnectionPoint;
  12228. /**
  12229. * Gets the a output component
  12230. */
  12231. get a(): NodeMaterialConnectionPoint;
  12232. get target(): NodeMaterialBlockTargets;
  12233. autoConfigure(material: NodeMaterial): void;
  12234. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12236. isReady(): boolean;
  12237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12238. private get _isMixed();
  12239. private _injectVertexCode;
  12240. private _writeTextureRead;
  12241. private _writeOutput;
  12242. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12243. protected _dumpPropertiesCode(): string;
  12244. serialize(): any;
  12245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12246. }
  12247. }
  12248. declare module BABYLON {
  12249. /** @hidden */
  12250. export var reflectionFunction: {
  12251. name: string;
  12252. shader: string;
  12253. };
  12254. }
  12255. declare module BABYLON {
  12256. /**
  12257. * Base block used to read a reflection texture from a sampler
  12258. */
  12259. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12260. /** @hidden */
  12261. _define3DName: string;
  12262. /** @hidden */
  12263. _defineCubicName: string;
  12264. /** @hidden */
  12265. _defineExplicitName: string;
  12266. /** @hidden */
  12267. _defineProjectionName: string;
  12268. /** @hidden */
  12269. _defineLocalCubicName: string;
  12270. /** @hidden */
  12271. _defineSphericalName: string;
  12272. /** @hidden */
  12273. _definePlanarName: string;
  12274. /** @hidden */
  12275. _defineEquirectangularName: string;
  12276. /** @hidden */
  12277. _defineMirroredEquirectangularFixedName: string;
  12278. /** @hidden */
  12279. _defineEquirectangularFixedName: string;
  12280. /** @hidden */
  12281. _defineSkyboxName: string;
  12282. /** @hidden */
  12283. _defineOppositeZ: string;
  12284. /** @hidden */
  12285. _cubeSamplerName: string;
  12286. /** @hidden */
  12287. _2DSamplerName: string;
  12288. protected _positionUVWName: string;
  12289. protected _directionWName: string;
  12290. protected _reflectionVectorName: string;
  12291. /** @hidden */
  12292. _reflectionCoordsName: string;
  12293. /** @hidden */
  12294. _reflectionMatrixName: string;
  12295. protected _reflectionColorName: string;
  12296. /**
  12297. * Gets or sets the texture associated with the node
  12298. */
  12299. texture: Nullable<BaseTexture>;
  12300. /**
  12301. * Create a new ReflectionTextureBaseBlock
  12302. * @param name defines the block name
  12303. */
  12304. constructor(name: string);
  12305. /**
  12306. * Gets the current class name
  12307. * @returns the class name
  12308. */
  12309. getClassName(): string;
  12310. /**
  12311. * Gets the world position input component
  12312. */
  12313. abstract get position(): NodeMaterialConnectionPoint;
  12314. /**
  12315. * Gets the world position input component
  12316. */
  12317. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12318. /**
  12319. * Gets the world normal input component
  12320. */
  12321. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12322. /**
  12323. * Gets the world input component
  12324. */
  12325. abstract get world(): NodeMaterialConnectionPoint;
  12326. /**
  12327. * Gets the camera (or eye) position component
  12328. */
  12329. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12330. /**
  12331. * Gets the view input component
  12332. */
  12333. abstract get view(): NodeMaterialConnectionPoint;
  12334. protected _getTexture(): Nullable<BaseTexture>;
  12335. autoConfigure(material: NodeMaterial): void;
  12336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12337. isReady(): boolean;
  12338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12339. /**
  12340. * Gets the code to inject in the vertex shader
  12341. * @param state current state of the node material building
  12342. * @returns the shader code
  12343. */
  12344. handleVertexSide(state: NodeMaterialBuildState): string;
  12345. /**
  12346. * Handles the inits for the fragment code path
  12347. * @param state node material build state
  12348. */
  12349. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12350. /**
  12351. * Generates the reflection coords code for the fragment code path
  12352. * @param worldNormalVarName name of the world normal variable
  12353. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12354. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12355. * @returns the shader code
  12356. */
  12357. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12358. /**
  12359. * Generates the reflection color code for the fragment code path
  12360. * @param lodVarName name of the lod variable
  12361. * @param swizzleLookupTexture swizzle to use for the final color variable
  12362. * @returns the shader code
  12363. */
  12364. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12365. /**
  12366. * Generates the code corresponding to the connected output points
  12367. * @param state node material build state
  12368. * @param varName name of the variable to output
  12369. * @returns the shader code
  12370. */
  12371. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12372. protected _buildBlock(state: NodeMaterialBuildState): this;
  12373. protected _dumpPropertiesCode(): string;
  12374. serialize(): any;
  12375. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12376. }
  12377. }
  12378. declare module BABYLON {
  12379. /**
  12380. * Defines a connection point to be used for points with a custom object type
  12381. */
  12382. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12383. private _blockType;
  12384. private _blockName;
  12385. private _nameForCheking?;
  12386. /**
  12387. * Creates a new connection point
  12388. * @param name defines the connection point name
  12389. * @param ownerBlock defines the block hosting this connection point
  12390. * @param direction defines the direction of the connection point
  12391. */
  12392. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12393. /**
  12394. * Gets a number indicating if the current point can be connected to another point
  12395. * @param connectionPoint defines the other connection point
  12396. * @returns a number defining the compatibility state
  12397. */
  12398. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12399. /**
  12400. * Creates a block suitable to be used as an input for this input point.
  12401. * If null is returned, a block based on the point type will be created.
  12402. * @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
  12403. */
  12404. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12405. }
  12406. }
  12407. declare module BABYLON {
  12408. /**
  12409. * Enum defining the type of properties that can be edited in the property pages in the NME
  12410. */
  12411. export enum PropertyTypeForEdition {
  12412. /** property is a boolean */
  12413. Boolean = 0,
  12414. /** property is a float */
  12415. Float = 1,
  12416. /** property is a Vector2 */
  12417. Vector2 = 2,
  12418. /** property is a list of values */
  12419. List = 3
  12420. }
  12421. /**
  12422. * Interface that defines an option in a variable of type list
  12423. */
  12424. export interface IEditablePropertyListOption {
  12425. /** label of the option */
  12426. "label": string;
  12427. /** value of the option */
  12428. "value": number;
  12429. }
  12430. /**
  12431. * Interface that defines the options available for an editable property
  12432. */
  12433. export interface IEditablePropertyOption {
  12434. /** min value */
  12435. "min"?: number;
  12436. /** max value */
  12437. "max"?: number;
  12438. /** notifiers: indicates which actions to take when the property is changed */
  12439. "notifiers"?: {
  12440. /** the material should be rebuilt */
  12441. "rebuild"?: boolean;
  12442. /** the preview should be updated */
  12443. "update"?: boolean;
  12444. };
  12445. /** list of the options for a variable of type list */
  12446. "options"?: IEditablePropertyListOption[];
  12447. }
  12448. /**
  12449. * Interface that describes an editable property
  12450. */
  12451. export interface IPropertyDescriptionForEdition {
  12452. /** name of the property */
  12453. "propertyName": string;
  12454. /** display name of the property */
  12455. "displayName": string;
  12456. /** type of the property */
  12457. "type": PropertyTypeForEdition;
  12458. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12459. "groupName": string;
  12460. /** options for the property */
  12461. "options": IEditablePropertyOption;
  12462. }
  12463. /**
  12464. * Decorator that flags a property in a node material block as being editable
  12465. */
  12466. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12467. }
  12468. declare module BABYLON {
  12469. /**
  12470. * Block used to implement the refraction part of the sub surface module of the PBR material
  12471. */
  12472. export class RefractionBlock extends NodeMaterialBlock {
  12473. /** @hidden */
  12474. _define3DName: string;
  12475. /** @hidden */
  12476. _refractionMatrixName: string;
  12477. /** @hidden */
  12478. _defineLODRefractionAlpha: string;
  12479. /** @hidden */
  12480. _defineLinearSpecularRefraction: string;
  12481. /** @hidden */
  12482. _defineOppositeZ: string;
  12483. /** @hidden */
  12484. _cubeSamplerName: string;
  12485. /** @hidden */
  12486. _2DSamplerName: string;
  12487. /** @hidden */
  12488. _vRefractionMicrosurfaceInfosName: string;
  12489. /** @hidden */
  12490. _vRefractionInfosName: string;
  12491. /** @hidden */
  12492. _vRefractionFilteringInfoName: string;
  12493. private _scene;
  12494. /**
  12495. * The properties below are set by the main PBR block prior to calling methods of this class.
  12496. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12497. * It's less burden on the user side in the editor part.
  12498. */
  12499. /** @hidden */
  12500. viewConnectionPoint: NodeMaterialConnectionPoint;
  12501. /** @hidden */
  12502. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12503. /**
  12504. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12505. * Materials half opaque for instance using refraction could benefit from this control.
  12506. */
  12507. linkRefractionWithTransparency: boolean;
  12508. /**
  12509. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12510. */
  12511. invertRefractionY: boolean;
  12512. /**
  12513. * Gets or sets the texture associated with the node
  12514. */
  12515. texture: Nullable<BaseTexture>;
  12516. /**
  12517. * Create a new RefractionBlock
  12518. * @param name defines the block name
  12519. */
  12520. constructor(name: string);
  12521. /**
  12522. * Gets the current class name
  12523. * @returns the class name
  12524. */
  12525. getClassName(): string;
  12526. /**
  12527. * Gets the intensity input component
  12528. */
  12529. get intensity(): NodeMaterialConnectionPoint;
  12530. /**
  12531. * Gets the tint at distance input component
  12532. */
  12533. get tintAtDistance(): NodeMaterialConnectionPoint;
  12534. /**
  12535. * Gets the view input component
  12536. */
  12537. get view(): NodeMaterialConnectionPoint;
  12538. /**
  12539. * Gets the refraction object output component
  12540. */
  12541. get refraction(): NodeMaterialConnectionPoint;
  12542. /**
  12543. * Returns true if the block has a texture
  12544. */
  12545. get hasTexture(): boolean;
  12546. protected _getTexture(): Nullable<BaseTexture>;
  12547. autoConfigure(material: NodeMaterial): void;
  12548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12549. isReady(): boolean;
  12550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12551. /**
  12552. * Gets the main code of the block (fragment side)
  12553. * @param state current state of the node material building
  12554. * @returns the shader code
  12555. */
  12556. getCode(state: NodeMaterialBuildState): string;
  12557. protected _buildBlock(state: NodeMaterialBuildState): this;
  12558. protected _dumpPropertiesCode(): string;
  12559. serialize(): any;
  12560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12561. }
  12562. }
  12563. declare module BABYLON {
  12564. /**
  12565. * Base block used as input for post process
  12566. */
  12567. export class CurrentScreenBlock extends NodeMaterialBlock {
  12568. private _samplerName;
  12569. private _linearDefineName;
  12570. private _gammaDefineName;
  12571. private _mainUVName;
  12572. private _tempTextureRead;
  12573. /**
  12574. * Gets or sets the texture associated with the node
  12575. */
  12576. texture: Nullable<BaseTexture>;
  12577. /**
  12578. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12579. */
  12580. convertToGammaSpace: boolean;
  12581. /**
  12582. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12583. */
  12584. convertToLinearSpace: boolean;
  12585. /**
  12586. * Create a new CurrentScreenBlock
  12587. * @param name defines the block name
  12588. */
  12589. constructor(name: string);
  12590. /**
  12591. * Gets the current class name
  12592. * @returns the class name
  12593. */
  12594. getClassName(): string;
  12595. /**
  12596. * Gets the uv input component
  12597. */
  12598. get uv(): NodeMaterialConnectionPoint;
  12599. /**
  12600. * Gets the rgba output component
  12601. */
  12602. get rgba(): NodeMaterialConnectionPoint;
  12603. /**
  12604. * Gets the rgb output component
  12605. */
  12606. get rgb(): NodeMaterialConnectionPoint;
  12607. /**
  12608. * Gets the r output component
  12609. */
  12610. get r(): NodeMaterialConnectionPoint;
  12611. /**
  12612. * Gets the g output component
  12613. */
  12614. get g(): NodeMaterialConnectionPoint;
  12615. /**
  12616. * Gets the b output component
  12617. */
  12618. get b(): NodeMaterialConnectionPoint;
  12619. /**
  12620. * Gets the a output component
  12621. */
  12622. get a(): NodeMaterialConnectionPoint;
  12623. /**
  12624. * Initialize the block and prepare the context for build
  12625. * @param state defines the state that will be used for the build
  12626. */
  12627. initialize(state: NodeMaterialBuildState): void;
  12628. get target(): NodeMaterialBlockTargets;
  12629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12630. isReady(): boolean;
  12631. private _injectVertexCode;
  12632. private _writeTextureRead;
  12633. private _writeOutput;
  12634. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12635. serialize(): any;
  12636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12637. }
  12638. }
  12639. declare module BABYLON {
  12640. /**
  12641. * Base block used for the particle texture
  12642. */
  12643. export class ParticleTextureBlock extends NodeMaterialBlock {
  12644. private _samplerName;
  12645. private _linearDefineName;
  12646. private _gammaDefineName;
  12647. private _tempTextureRead;
  12648. /**
  12649. * Gets or sets the texture associated with the node
  12650. */
  12651. texture: Nullable<BaseTexture>;
  12652. /**
  12653. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12654. */
  12655. convertToGammaSpace: boolean;
  12656. /**
  12657. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12658. */
  12659. convertToLinearSpace: boolean;
  12660. /**
  12661. * Create a new ParticleTextureBlock
  12662. * @param name defines the block name
  12663. */
  12664. constructor(name: string);
  12665. /**
  12666. * Gets the current class name
  12667. * @returns the class name
  12668. */
  12669. getClassName(): string;
  12670. /**
  12671. * Gets the uv input component
  12672. */
  12673. get uv(): NodeMaterialConnectionPoint;
  12674. /**
  12675. * Gets the rgba output component
  12676. */
  12677. get rgba(): NodeMaterialConnectionPoint;
  12678. /**
  12679. * Gets the rgb output component
  12680. */
  12681. get rgb(): NodeMaterialConnectionPoint;
  12682. /**
  12683. * Gets the r output component
  12684. */
  12685. get r(): NodeMaterialConnectionPoint;
  12686. /**
  12687. * Gets the g output component
  12688. */
  12689. get g(): NodeMaterialConnectionPoint;
  12690. /**
  12691. * Gets the b output component
  12692. */
  12693. get b(): NodeMaterialConnectionPoint;
  12694. /**
  12695. * Gets the a output component
  12696. */
  12697. get a(): NodeMaterialConnectionPoint;
  12698. /**
  12699. * Initialize the block and prepare the context for build
  12700. * @param state defines the state that will be used for the build
  12701. */
  12702. initialize(state: NodeMaterialBuildState): void;
  12703. autoConfigure(material: NodeMaterial): void;
  12704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12705. isReady(): boolean;
  12706. private _writeOutput;
  12707. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12708. serialize(): any;
  12709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12710. }
  12711. }
  12712. declare module BABYLON {
  12713. /**
  12714. * Class used to store shared data between 2 NodeMaterialBuildState
  12715. */
  12716. export class NodeMaterialBuildStateSharedData {
  12717. /**
  12718. * Gets the list of emitted varyings
  12719. */
  12720. temps: string[];
  12721. /**
  12722. * Gets the list of emitted varyings
  12723. */
  12724. varyings: string[];
  12725. /**
  12726. * Gets the varying declaration string
  12727. */
  12728. varyingDeclaration: string;
  12729. /**
  12730. * Input blocks
  12731. */
  12732. inputBlocks: InputBlock[];
  12733. /**
  12734. * Input blocks
  12735. */
  12736. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12737. /**
  12738. * Bindable blocks (Blocks that need to set data to the effect)
  12739. */
  12740. bindableBlocks: NodeMaterialBlock[];
  12741. /**
  12742. * List of blocks that can provide a compilation fallback
  12743. */
  12744. blocksWithFallbacks: NodeMaterialBlock[];
  12745. /**
  12746. * List of blocks that can provide a define update
  12747. */
  12748. blocksWithDefines: NodeMaterialBlock[];
  12749. /**
  12750. * List of blocks that can provide a repeatable content
  12751. */
  12752. repeatableContentBlocks: NodeMaterialBlock[];
  12753. /**
  12754. * List of blocks that can provide a dynamic list of uniforms
  12755. */
  12756. dynamicUniformBlocks: NodeMaterialBlock[];
  12757. /**
  12758. * List of blocks that can block the isReady function for the material
  12759. */
  12760. blockingBlocks: NodeMaterialBlock[];
  12761. /**
  12762. * Gets the list of animated inputs
  12763. */
  12764. animatedInputs: InputBlock[];
  12765. /**
  12766. * Build Id used to avoid multiple recompilations
  12767. */
  12768. buildId: number;
  12769. /** List of emitted variables */
  12770. variableNames: {
  12771. [key: string]: number;
  12772. };
  12773. /** List of emitted defines */
  12774. defineNames: {
  12775. [key: string]: number;
  12776. };
  12777. /** Should emit comments? */
  12778. emitComments: boolean;
  12779. /** Emit build activity */
  12780. verbose: boolean;
  12781. /** Gets or sets the hosting scene */
  12782. scene: Scene;
  12783. /**
  12784. * Gets the compilation hints emitted at compilation time
  12785. */
  12786. hints: {
  12787. needWorldViewMatrix: boolean;
  12788. needWorldViewProjectionMatrix: boolean;
  12789. needAlphaBlending: boolean;
  12790. needAlphaTesting: boolean;
  12791. };
  12792. /**
  12793. * List of compilation checks
  12794. */
  12795. checks: {
  12796. emitVertex: boolean;
  12797. emitFragment: boolean;
  12798. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12799. };
  12800. /**
  12801. * Is vertex program allowed to be empty?
  12802. */
  12803. allowEmptyVertexProgram: boolean;
  12804. /** Creates a new shared data */
  12805. constructor();
  12806. /**
  12807. * Emits console errors and exceptions if there is a failing check
  12808. */
  12809. emitErrors(): void;
  12810. }
  12811. }
  12812. declare module BABYLON {
  12813. /**
  12814. * Class used to store node based material build state
  12815. */
  12816. export class NodeMaterialBuildState {
  12817. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12818. supportUniformBuffers: boolean;
  12819. /**
  12820. * Gets the list of emitted attributes
  12821. */
  12822. attributes: string[];
  12823. /**
  12824. * Gets the list of emitted uniforms
  12825. */
  12826. uniforms: string[];
  12827. /**
  12828. * Gets the list of emitted constants
  12829. */
  12830. constants: string[];
  12831. /**
  12832. * Gets the list of emitted samplers
  12833. */
  12834. samplers: string[];
  12835. /**
  12836. * Gets the list of emitted functions
  12837. */
  12838. functions: {
  12839. [key: string]: string;
  12840. };
  12841. /**
  12842. * Gets the list of emitted extensions
  12843. */
  12844. extensions: {
  12845. [key: string]: string;
  12846. };
  12847. /**
  12848. * Gets the target of the compilation state
  12849. */
  12850. target: NodeMaterialBlockTargets;
  12851. /**
  12852. * Gets the list of emitted counters
  12853. */
  12854. counters: {
  12855. [key: string]: number;
  12856. };
  12857. /**
  12858. * Shared data between multiple NodeMaterialBuildState instances
  12859. */
  12860. sharedData: NodeMaterialBuildStateSharedData;
  12861. /** @hidden */
  12862. _vertexState: NodeMaterialBuildState;
  12863. /** @hidden */
  12864. _attributeDeclaration: string;
  12865. /** @hidden */
  12866. _uniformDeclaration: string;
  12867. /** @hidden */
  12868. _constantDeclaration: string;
  12869. /** @hidden */
  12870. _samplerDeclaration: string;
  12871. /** @hidden */
  12872. _varyingTransfer: string;
  12873. /** @hidden */
  12874. _injectAtEnd: string;
  12875. private _repeatableContentAnchorIndex;
  12876. /** @hidden */
  12877. _builtCompilationString: string;
  12878. /**
  12879. * Gets the emitted compilation strings
  12880. */
  12881. compilationString: string;
  12882. /**
  12883. * Finalize the compilation strings
  12884. * @param state defines the current compilation state
  12885. */
  12886. finalize(state: NodeMaterialBuildState): void;
  12887. /** @hidden */
  12888. get _repeatableContentAnchor(): string;
  12889. /** @hidden */
  12890. _getFreeVariableName(prefix: string): string;
  12891. /** @hidden */
  12892. _getFreeDefineName(prefix: string): string;
  12893. /** @hidden */
  12894. _excludeVariableName(name: string): void;
  12895. /** @hidden */
  12896. _emit2DSampler(name: string): void;
  12897. /** @hidden */
  12898. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12899. /** @hidden */
  12900. _emitExtension(name: string, extension: string, define?: string): void;
  12901. /** @hidden */
  12902. _emitFunction(name: string, code: string, comments: string): void;
  12903. /** @hidden */
  12904. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12905. replaceStrings?: {
  12906. search: RegExp;
  12907. replace: string;
  12908. }[];
  12909. repeatKey?: string;
  12910. }): string;
  12911. /** @hidden */
  12912. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12913. repeatKey?: string;
  12914. removeAttributes?: boolean;
  12915. removeUniforms?: boolean;
  12916. removeVaryings?: boolean;
  12917. removeIfDef?: boolean;
  12918. replaceStrings?: {
  12919. search: RegExp;
  12920. replace: string;
  12921. }[];
  12922. }, storeKey?: string): void;
  12923. /** @hidden */
  12924. _registerTempVariable(name: string): boolean;
  12925. /** @hidden */
  12926. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12927. /** @hidden */
  12928. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12929. /** @hidden */
  12930. _emitFloat(value: number): string;
  12931. }
  12932. }
  12933. declare module BABYLON {
  12934. /**
  12935. * Helper class used to generate session unique ID
  12936. */
  12937. export class UniqueIdGenerator {
  12938. private static _UniqueIdCounter;
  12939. /**
  12940. * Gets an unique (relatively to the current scene) Id
  12941. */
  12942. static get UniqueId(): number;
  12943. }
  12944. }
  12945. declare module BABYLON {
  12946. /**
  12947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12949. */
  12950. export class EffectFallbacks implements IEffectFallbacks {
  12951. private _defines;
  12952. private _currentRank;
  12953. private _maxRank;
  12954. private _mesh;
  12955. /**
  12956. * Removes the fallback from the bound mesh.
  12957. */
  12958. unBindMesh(): void;
  12959. /**
  12960. * Adds a fallback on the specified property.
  12961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12962. * @param define The name of the define in the shader
  12963. */
  12964. addFallback(rank: number, define: string): void;
  12965. /**
  12966. * Sets the mesh to use CPU skinning when needing to fallback.
  12967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12968. * @param mesh The mesh to use the fallbacks.
  12969. */
  12970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12971. /**
  12972. * Checks to see if more fallbacks are still availible.
  12973. */
  12974. get hasMoreFallbacks(): boolean;
  12975. /**
  12976. * Removes the defines that should be removed when falling back.
  12977. * @param currentDefines defines the current define statements for the shader.
  12978. * @param effect defines the current effect we try to compile
  12979. * @returns The resulting defines with defines of the current rank removed.
  12980. */
  12981. reduce(currentDefines: string, effect: Effect): string;
  12982. }
  12983. }
  12984. declare module BABYLON {
  12985. /**
  12986. * Defines a block that can be used inside a node based material
  12987. */
  12988. export class NodeMaterialBlock {
  12989. private _buildId;
  12990. private _buildTarget;
  12991. private _target;
  12992. private _isFinalMerger;
  12993. private _isInput;
  12994. private _name;
  12995. protected _isUnique: boolean;
  12996. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  12997. inputsAreExclusive: boolean;
  12998. /** @hidden */
  12999. _codeVariableName: string;
  13000. /** @hidden */
  13001. _inputs: NodeMaterialConnectionPoint[];
  13002. /** @hidden */
  13003. _outputs: NodeMaterialConnectionPoint[];
  13004. /** @hidden */
  13005. _preparationId: number;
  13006. /**
  13007. * Gets the name of the block
  13008. */
  13009. get name(): string;
  13010. /**
  13011. * Sets the name of the block. Will check if the name is valid.
  13012. */
  13013. set name(newName: string);
  13014. /**
  13015. * Gets or sets the unique id of the node
  13016. */
  13017. uniqueId: number;
  13018. /**
  13019. * Gets or sets the comments associated with this block
  13020. */
  13021. comments: string;
  13022. /**
  13023. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13024. */
  13025. get isUnique(): boolean;
  13026. /**
  13027. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13028. */
  13029. get isFinalMerger(): boolean;
  13030. /**
  13031. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13032. */
  13033. get isInput(): boolean;
  13034. /**
  13035. * Gets or sets the build Id
  13036. */
  13037. get buildId(): number;
  13038. set buildId(value: number);
  13039. /**
  13040. * Gets or sets the target of the block
  13041. */
  13042. get target(): NodeMaterialBlockTargets;
  13043. set target(value: NodeMaterialBlockTargets);
  13044. /**
  13045. * Gets the list of input points
  13046. */
  13047. get inputs(): NodeMaterialConnectionPoint[];
  13048. /** Gets the list of output points */
  13049. get outputs(): NodeMaterialConnectionPoint[];
  13050. /**
  13051. * Find an input by its name
  13052. * @param name defines the name of the input to look for
  13053. * @returns the input or null if not found
  13054. */
  13055. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13056. /**
  13057. * Find an output by its name
  13058. * @param name defines the name of the outputto look for
  13059. * @returns the output or null if not found
  13060. */
  13061. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13062. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13063. visibleInInspector: boolean;
  13064. /**
  13065. * Creates a new NodeMaterialBlock
  13066. * @param name defines the block name
  13067. * @param target defines the target of that block (Vertex by default)
  13068. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13069. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13070. */
  13071. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13072. /**
  13073. * Initialize the block and prepare the context for build
  13074. * @param state defines the state that will be used for the build
  13075. */
  13076. initialize(state: NodeMaterialBuildState): void;
  13077. /**
  13078. * Bind data to effect. Will only be called for blocks with isBindable === true
  13079. * @param effect defines the effect to bind data to
  13080. * @param nodeMaterial defines the hosting NodeMaterial
  13081. * @param mesh defines the mesh that will be rendered
  13082. * @param subMesh defines the submesh that will be rendered
  13083. */
  13084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13085. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13086. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13087. protected _writeFloat(value: number): string;
  13088. /**
  13089. * Gets the current class name e.g. "NodeMaterialBlock"
  13090. * @returns the class name
  13091. */
  13092. getClassName(): string;
  13093. /**
  13094. * Register a new input. Must be called inside a block constructor
  13095. * @param name defines the connection point name
  13096. * @param type defines the connection point type
  13097. * @param isOptional defines a boolean indicating that this input can be omitted
  13098. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13099. * @param point an already created connection point. If not provided, create a new one
  13100. * @returns the current block
  13101. */
  13102. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13103. /**
  13104. * Register a new output. Must be called inside a block constructor
  13105. * @param name defines the connection point name
  13106. * @param type defines the connection point type
  13107. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13108. * @param point an already created connection point. If not provided, create a new one
  13109. * @returns the current block
  13110. */
  13111. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13112. /**
  13113. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13114. * @param forOutput defines an optional connection point to check compatibility with
  13115. * @returns the first available input or null
  13116. */
  13117. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13118. /**
  13119. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13120. * @param forBlock defines an optional block to check compatibility with
  13121. * @returns the first available input or null
  13122. */
  13123. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13124. /**
  13125. * Gets the sibling of the given output
  13126. * @param current defines the current output
  13127. * @returns the next output in the list or null
  13128. */
  13129. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13130. /**
  13131. * Connect current block with another block
  13132. * @param other defines the block to connect with
  13133. * @param options define the various options to help pick the right connections
  13134. * @returns the current block
  13135. */
  13136. connectTo(other: NodeMaterialBlock, options?: {
  13137. input?: string;
  13138. output?: string;
  13139. outputSwizzle?: string;
  13140. }): this | undefined;
  13141. protected _buildBlock(state: NodeMaterialBuildState): void;
  13142. /**
  13143. * Add uniforms, samplers and uniform buffers at compilation time
  13144. * @param state defines the state to update
  13145. * @param nodeMaterial defines the node material requesting the update
  13146. * @param defines defines the material defines to update
  13147. * @param uniformBuffers defines the list of uniform buffer names
  13148. */
  13149. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13150. /**
  13151. * Add potential fallbacks if shader compilation fails
  13152. * @param mesh defines the mesh to be rendered
  13153. * @param fallbacks defines the current prioritized list of fallbacks
  13154. */
  13155. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13156. /**
  13157. * Initialize defines for shader compilation
  13158. * @param mesh defines the mesh to be rendered
  13159. * @param nodeMaterial defines the node material requesting the update
  13160. * @param defines defines the material defines to update
  13161. * @param useInstances specifies that instances should be used
  13162. */
  13163. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13164. /**
  13165. * Update defines for shader compilation
  13166. * @param mesh defines the mesh to be rendered
  13167. * @param nodeMaterial defines the node material requesting the update
  13168. * @param defines defines the material defines to update
  13169. * @param useInstances specifies that instances should be used
  13170. * @param subMesh defines which submesh to render
  13171. */
  13172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13173. /**
  13174. * Lets the block try to connect some inputs automatically
  13175. * @param material defines the hosting NodeMaterial
  13176. */
  13177. autoConfigure(material: NodeMaterial): void;
  13178. /**
  13179. * Function called when a block is declared as repeatable content generator
  13180. * @param vertexShaderState defines the current compilation state for the vertex shader
  13181. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13182. * @param mesh defines the mesh to be rendered
  13183. * @param defines defines the material defines to update
  13184. */
  13185. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13186. /**
  13187. * Checks if the block is ready
  13188. * @param mesh defines the mesh to be rendered
  13189. * @param nodeMaterial defines the node material requesting the update
  13190. * @param defines defines the material defines to update
  13191. * @param useInstances specifies that instances should be used
  13192. * @returns true if the block is ready
  13193. */
  13194. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13195. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13196. private _processBuild;
  13197. /**
  13198. * Validates the new name for the block node.
  13199. * @param newName the new name to be given to the node.
  13200. * @returns false if the name is a reserve word, else true.
  13201. */
  13202. validateBlockName(newName: string): boolean;
  13203. /**
  13204. * Compile the current node and generate the shader code
  13205. * @param state defines the current compilation state (uniforms, samplers, current string)
  13206. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13207. * @returns true if already built
  13208. */
  13209. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13210. protected _inputRename(name: string): string;
  13211. protected _outputRename(name: string): string;
  13212. protected _dumpPropertiesCode(): string;
  13213. /** @hidden */
  13214. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13215. /** @hidden */
  13216. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13217. /**
  13218. * Clone the current block to a new identical block
  13219. * @param scene defines the hosting scene
  13220. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13221. * @returns a copy of the current block
  13222. */
  13223. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13224. /**
  13225. * Serializes this block in a JSON representation
  13226. * @returns the serialized block object
  13227. */
  13228. serialize(): any;
  13229. /** @hidden */
  13230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13231. private _deserializePortDisplayNamesAndExposedOnFrame;
  13232. /**
  13233. * Release resources
  13234. */
  13235. dispose(): void;
  13236. }
  13237. }
  13238. declare module BABYLON {
  13239. /**
  13240. * Base class of materials working in push mode in babylon JS
  13241. * @hidden
  13242. */
  13243. export class PushMaterial extends Material {
  13244. protected _activeEffect: Effect;
  13245. protected _normalMatrix: Matrix;
  13246. constructor(name: string, scene: Scene);
  13247. getEffect(): Effect;
  13248. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13249. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13250. /**
  13251. * Binds the given world matrix to the active effect
  13252. *
  13253. * @param world the matrix to bind
  13254. */
  13255. bindOnlyWorldMatrix(world: Matrix): void;
  13256. /**
  13257. * Binds the given normal matrix to the active effect
  13258. *
  13259. * @param normalMatrix the matrix to bind
  13260. */
  13261. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13262. bind(world: Matrix, mesh?: Mesh): void;
  13263. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13264. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13265. }
  13266. }
  13267. declare module BABYLON {
  13268. /**
  13269. * Root class for all node material optimizers
  13270. */
  13271. export class NodeMaterialOptimizer {
  13272. /**
  13273. * Function used to optimize a NodeMaterial graph
  13274. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13275. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13276. */
  13277. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13278. }
  13279. }
  13280. declare module BABYLON {
  13281. /**
  13282. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13283. */
  13284. export class TransformBlock extends NodeMaterialBlock {
  13285. /**
  13286. * Defines the value to use to complement W value to transform it to a Vector4
  13287. */
  13288. complementW: number;
  13289. /**
  13290. * Defines the value to use to complement z value to transform it to a Vector4
  13291. */
  13292. complementZ: number;
  13293. /**
  13294. * Creates a new TransformBlock
  13295. * @param name defines the block name
  13296. */
  13297. constructor(name: string);
  13298. /**
  13299. * Gets the current class name
  13300. * @returns the class name
  13301. */
  13302. getClassName(): string;
  13303. /**
  13304. * Gets the vector input
  13305. */
  13306. get vector(): NodeMaterialConnectionPoint;
  13307. /**
  13308. * Gets the output component
  13309. */
  13310. get output(): NodeMaterialConnectionPoint;
  13311. /**
  13312. * Gets the xyz output component
  13313. */
  13314. get xyz(): NodeMaterialConnectionPoint;
  13315. /**
  13316. * Gets the matrix transform input
  13317. */
  13318. get transform(): NodeMaterialConnectionPoint;
  13319. protected _buildBlock(state: NodeMaterialBuildState): this;
  13320. /**
  13321. * Update defines for shader compilation
  13322. * @param mesh defines the mesh to be rendered
  13323. * @param nodeMaterial defines the node material requesting the update
  13324. * @param defines defines the material defines to update
  13325. * @param useInstances specifies that instances should be used
  13326. * @param subMesh defines which submesh to render
  13327. */
  13328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13329. serialize(): any;
  13330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13331. protected _dumpPropertiesCode(): string;
  13332. }
  13333. }
  13334. declare module BABYLON {
  13335. /**
  13336. * Block used to output the vertex position
  13337. */
  13338. export class VertexOutputBlock extends NodeMaterialBlock {
  13339. /**
  13340. * Creates a new VertexOutputBlock
  13341. * @param name defines the block name
  13342. */
  13343. constructor(name: string);
  13344. /**
  13345. * Gets the current class name
  13346. * @returns the class name
  13347. */
  13348. getClassName(): string;
  13349. /**
  13350. * Gets the vector input component
  13351. */
  13352. get vector(): NodeMaterialConnectionPoint;
  13353. protected _buildBlock(state: NodeMaterialBuildState): this;
  13354. }
  13355. }
  13356. declare module BABYLON {
  13357. /**
  13358. * Block used to output the final color
  13359. */
  13360. export class FragmentOutputBlock extends NodeMaterialBlock {
  13361. /**
  13362. * Create a new FragmentOutputBlock
  13363. * @param name defines the block name
  13364. */
  13365. constructor(name: string);
  13366. /**
  13367. * Gets the current class name
  13368. * @returns the class name
  13369. */
  13370. getClassName(): string;
  13371. /**
  13372. * Gets the rgba input component
  13373. */
  13374. get rgba(): NodeMaterialConnectionPoint;
  13375. /**
  13376. * Gets the rgb input component
  13377. */
  13378. get rgb(): NodeMaterialConnectionPoint;
  13379. /**
  13380. * Gets the a input component
  13381. */
  13382. get a(): NodeMaterialConnectionPoint;
  13383. protected _buildBlock(state: NodeMaterialBuildState): this;
  13384. }
  13385. }
  13386. declare module BABYLON {
  13387. /**
  13388. * Block used for the particle ramp gradient section
  13389. */
  13390. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13391. /**
  13392. * Create a new ParticleRampGradientBlock
  13393. * @param name defines the block name
  13394. */
  13395. constructor(name: string);
  13396. /**
  13397. * Gets the current class name
  13398. * @returns the class name
  13399. */
  13400. getClassName(): string;
  13401. /**
  13402. * Gets the color input component
  13403. */
  13404. get color(): NodeMaterialConnectionPoint;
  13405. /**
  13406. * Gets the rampColor output component
  13407. */
  13408. get rampColor(): NodeMaterialConnectionPoint;
  13409. /**
  13410. * Initialize the block and prepare the context for build
  13411. * @param state defines the state that will be used for the build
  13412. */
  13413. initialize(state: NodeMaterialBuildState): void;
  13414. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13415. }
  13416. }
  13417. declare module BABYLON {
  13418. /**
  13419. * Block used for the particle blend multiply section
  13420. */
  13421. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13422. /**
  13423. * Create a new ParticleBlendMultiplyBlock
  13424. * @param name defines the block name
  13425. */
  13426. constructor(name: string);
  13427. /**
  13428. * Gets the current class name
  13429. * @returns the class name
  13430. */
  13431. getClassName(): string;
  13432. /**
  13433. * Gets the color input component
  13434. */
  13435. get color(): NodeMaterialConnectionPoint;
  13436. /**
  13437. * Gets the alphaTexture input component
  13438. */
  13439. get alphaTexture(): NodeMaterialConnectionPoint;
  13440. /**
  13441. * Gets the alphaColor input component
  13442. */
  13443. get alphaColor(): NodeMaterialConnectionPoint;
  13444. /**
  13445. * Gets the blendColor output component
  13446. */
  13447. get blendColor(): NodeMaterialConnectionPoint;
  13448. /**
  13449. * Initialize the block and prepare the context for build
  13450. * @param state defines the state that will be used for the build
  13451. */
  13452. initialize(state: NodeMaterialBuildState): void;
  13453. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13454. }
  13455. }
  13456. declare module BABYLON {
  13457. /**
  13458. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13459. */
  13460. export class VectorMergerBlock extends NodeMaterialBlock {
  13461. /**
  13462. * Create a new VectorMergerBlock
  13463. * @param name defines the block name
  13464. */
  13465. constructor(name: string);
  13466. /**
  13467. * Gets the current class name
  13468. * @returns the class name
  13469. */
  13470. getClassName(): string;
  13471. /**
  13472. * Gets the xyz component (input)
  13473. */
  13474. get xyzIn(): NodeMaterialConnectionPoint;
  13475. /**
  13476. * Gets the xy component (input)
  13477. */
  13478. get xyIn(): NodeMaterialConnectionPoint;
  13479. /**
  13480. * Gets the x component (input)
  13481. */
  13482. get x(): NodeMaterialConnectionPoint;
  13483. /**
  13484. * Gets the y component (input)
  13485. */
  13486. get y(): NodeMaterialConnectionPoint;
  13487. /**
  13488. * Gets the z component (input)
  13489. */
  13490. get z(): NodeMaterialConnectionPoint;
  13491. /**
  13492. * Gets the w component (input)
  13493. */
  13494. get w(): NodeMaterialConnectionPoint;
  13495. /**
  13496. * Gets the xyzw component (output)
  13497. */
  13498. get xyzw(): NodeMaterialConnectionPoint;
  13499. /**
  13500. * Gets the xyz component (output)
  13501. */
  13502. get xyzOut(): NodeMaterialConnectionPoint;
  13503. /**
  13504. * Gets the xy component (output)
  13505. */
  13506. get xyOut(): NodeMaterialConnectionPoint;
  13507. /**
  13508. * Gets the xy component (output)
  13509. * @deprecated Please use xyOut instead.
  13510. */
  13511. get xy(): NodeMaterialConnectionPoint;
  13512. /**
  13513. * Gets the xyz component (output)
  13514. * @deprecated Please use xyzOut instead.
  13515. */
  13516. get xyz(): NodeMaterialConnectionPoint;
  13517. protected _buildBlock(state: NodeMaterialBuildState): this;
  13518. }
  13519. }
  13520. declare module BABYLON {
  13521. /**
  13522. * Block used to remap a float from a range to a new one
  13523. */
  13524. export class RemapBlock extends NodeMaterialBlock {
  13525. /**
  13526. * Gets or sets the source range
  13527. */
  13528. sourceRange: Vector2;
  13529. /**
  13530. * Gets or sets the target range
  13531. */
  13532. targetRange: Vector2;
  13533. /**
  13534. * Creates a new RemapBlock
  13535. * @param name defines the block name
  13536. */
  13537. constructor(name: string);
  13538. /**
  13539. * Gets the current class name
  13540. * @returns the class name
  13541. */
  13542. getClassName(): string;
  13543. /**
  13544. * Gets the input component
  13545. */
  13546. get input(): NodeMaterialConnectionPoint;
  13547. /**
  13548. * Gets the source min input component
  13549. */
  13550. get sourceMin(): NodeMaterialConnectionPoint;
  13551. /**
  13552. * Gets the source max input component
  13553. */
  13554. get sourceMax(): NodeMaterialConnectionPoint;
  13555. /**
  13556. * Gets the target min input component
  13557. */
  13558. get targetMin(): NodeMaterialConnectionPoint;
  13559. /**
  13560. * Gets the target max input component
  13561. */
  13562. get targetMax(): NodeMaterialConnectionPoint;
  13563. /**
  13564. * Gets the output component
  13565. */
  13566. get output(): NodeMaterialConnectionPoint;
  13567. protected _buildBlock(state: NodeMaterialBuildState): this;
  13568. protected _dumpPropertiesCode(): string;
  13569. serialize(): any;
  13570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13571. }
  13572. }
  13573. declare module BABYLON {
  13574. /**
  13575. * Block used to multiply 2 values
  13576. */
  13577. export class MultiplyBlock extends NodeMaterialBlock {
  13578. /**
  13579. * Creates a new MultiplyBlock
  13580. * @param name defines the block name
  13581. */
  13582. constructor(name: string);
  13583. /**
  13584. * Gets the current class name
  13585. * @returns the class name
  13586. */
  13587. getClassName(): string;
  13588. /**
  13589. * Gets the left operand input component
  13590. */
  13591. get left(): NodeMaterialConnectionPoint;
  13592. /**
  13593. * Gets the right operand input component
  13594. */
  13595. get right(): NodeMaterialConnectionPoint;
  13596. /**
  13597. * Gets the output component
  13598. */
  13599. get output(): NodeMaterialConnectionPoint;
  13600. protected _buildBlock(state: NodeMaterialBuildState): this;
  13601. }
  13602. }
  13603. declare module BABYLON {
  13604. /** Interface used by value gradients (color, factor, ...) */
  13605. export interface IValueGradient {
  13606. /**
  13607. * Gets or sets the gradient value (between 0 and 1)
  13608. */
  13609. gradient: number;
  13610. }
  13611. /** Class used to store color4 gradient */
  13612. export class ColorGradient implements IValueGradient {
  13613. /**
  13614. * Gets or sets the gradient value (between 0 and 1)
  13615. */
  13616. gradient: number;
  13617. /**
  13618. * Gets or sets first associated color
  13619. */
  13620. color1: Color4;
  13621. /**
  13622. * Gets or sets second associated color
  13623. */
  13624. color2?: Color4 | undefined;
  13625. /**
  13626. * Creates a new color4 gradient
  13627. * @param gradient gets or sets the gradient value (between 0 and 1)
  13628. * @param color1 gets or sets first associated color
  13629. * @param color2 gets or sets first second color
  13630. */
  13631. constructor(
  13632. /**
  13633. * Gets or sets the gradient value (between 0 and 1)
  13634. */
  13635. gradient: number,
  13636. /**
  13637. * Gets or sets first associated color
  13638. */
  13639. color1: Color4,
  13640. /**
  13641. * Gets or sets second associated color
  13642. */
  13643. color2?: Color4 | undefined);
  13644. /**
  13645. * Will get a color picked randomly between color1 and color2.
  13646. * If color2 is undefined then color1 will be used
  13647. * @param result defines the target Color4 to store the result in
  13648. */
  13649. getColorToRef(result: Color4): void;
  13650. }
  13651. /** Class used to store color 3 gradient */
  13652. export class Color3Gradient implements IValueGradient {
  13653. /**
  13654. * Gets or sets the gradient value (between 0 and 1)
  13655. */
  13656. gradient: number;
  13657. /**
  13658. * Gets or sets the associated color
  13659. */
  13660. color: Color3;
  13661. /**
  13662. * Creates a new color3 gradient
  13663. * @param gradient gets or sets the gradient value (between 0 and 1)
  13664. * @param color gets or sets associated color
  13665. */
  13666. constructor(
  13667. /**
  13668. * Gets or sets the gradient value (between 0 and 1)
  13669. */
  13670. gradient: number,
  13671. /**
  13672. * Gets or sets the associated color
  13673. */
  13674. color: Color3);
  13675. }
  13676. /** Class used to store factor gradient */
  13677. export class FactorGradient implements IValueGradient {
  13678. /**
  13679. * Gets or sets the gradient value (between 0 and 1)
  13680. */
  13681. gradient: number;
  13682. /**
  13683. * Gets or sets first associated factor
  13684. */
  13685. factor1: number;
  13686. /**
  13687. * Gets or sets second associated factor
  13688. */
  13689. factor2?: number | undefined;
  13690. /**
  13691. * Creates a new factor gradient
  13692. * @param gradient gets or sets the gradient value (between 0 and 1)
  13693. * @param factor1 gets or sets first associated factor
  13694. * @param factor2 gets or sets second associated factor
  13695. */
  13696. constructor(
  13697. /**
  13698. * Gets or sets the gradient value (between 0 and 1)
  13699. */
  13700. gradient: number,
  13701. /**
  13702. * Gets or sets first associated factor
  13703. */
  13704. factor1: number,
  13705. /**
  13706. * Gets or sets second associated factor
  13707. */
  13708. factor2?: number | undefined);
  13709. /**
  13710. * Will get a number picked randomly between factor1 and factor2.
  13711. * If factor2 is undefined then factor1 will be used
  13712. * @returns the picked number
  13713. */
  13714. getFactor(): number;
  13715. }
  13716. /**
  13717. * Helper used to simplify some generic gradient tasks
  13718. */
  13719. export class GradientHelper {
  13720. /**
  13721. * Gets the current gradient from an array of IValueGradient
  13722. * @param ratio defines the current ratio to get
  13723. * @param gradients defines the array of IValueGradient
  13724. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13725. */
  13726. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13727. }
  13728. }
  13729. declare module BABYLON {
  13730. interface ThinEngine {
  13731. /**
  13732. * Creates a raw texture
  13733. * @param data defines the data to store in the texture
  13734. * @param width defines the width of the texture
  13735. * @param height defines the height of the texture
  13736. * @param format defines the format of the data
  13737. * @param generateMipMaps defines if the engine should generate the mip levels
  13738. * @param invertY defines if data must be stored with Y axis inverted
  13739. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13740. * @param compression defines the compression used (null by default)
  13741. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13742. * @returns the raw texture inside an InternalTexture
  13743. */
  13744. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13745. /**
  13746. * Update a raw texture
  13747. * @param texture defines the texture to update
  13748. * @param data defines the data to store in the texture
  13749. * @param format defines the format of the data
  13750. * @param invertY defines if data must be stored with Y axis inverted
  13751. */
  13752. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13753. /**
  13754. * Update a raw texture
  13755. * @param texture defines the texture to update
  13756. * @param data defines the data to store in the texture
  13757. * @param format defines the format of the data
  13758. * @param invertY defines if data must be stored with Y axis inverted
  13759. * @param compression defines the compression used (null by default)
  13760. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13761. */
  13762. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13763. /**
  13764. * Creates a new raw cube texture
  13765. * @param data defines the array of data to use to create each face
  13766. * @param size defines the size of the textures
  13767. * @param format defines the format of the data
  13768. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13769. * @param generateMipMaps defines if the engine should generate the mip levels
  13770. * @param invertY defines if data must be stored with Y axis inverted
  13771. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13772. * @param compression defines the compression used (null by default)
  13773. * @returns the cube texture as an InternalTexture
  13774. */
  13775. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13776. /**
  13777. * Update a raw cube texture
  13778. * @param texture defines the texture to udpdate
  13779. * @param data defines the data to store
  13780. * @param format defines the data format
  13781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13782. * @param invertY defines if data must be stored with Y axis inverted
  13783. */
  13784. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13785. /**
  13786. * Update a raw cube texture
  13787. * @param texture defines the texture to udpdate
  13788. * @param data defines the data to store
  13789. * @param format defines the data format
  13790. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13791. * @param invertY defines if data must be stored with Y axis inverted
  13792. * @param compression defines the compression used (null by default)
  13793. */
  13794. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13795. /**
  13796. * Update a raw cube texture
  13797. * @param texture defines the texture to udpdate
  13798. * @param data defines the data to store
  13799. * @param format defines the data format
  13800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13801. * @param invertY defines if data must be stored with Y axis inverted
  13802. * @param compression defines the compression used (null by default)
  13803. * @param level defines which level of the texture to update
  13804. */
  13805. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13806. /**
  13807. * Creates a new raw cube texture from a specified url
  13808. * @param url defines the url where the data is located
  13809. * @param scene defines the current scene
  13810. * @param size defines the size of the textures
  13811. * @param format defines the format of the data
  13812. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13813. * @param noMipmap defines if the engine should avoid generating the mip levels
  13814. * @param callback defines a callback used to extract texture data from loaded data
  13815. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13816. * @param onLoad defines a callback called when texture is loaded
  13817. * @param onError defines a callback called if there is an error
  13818. * @returns the cube texture as an InternalTexture
  13819. */
  13820. 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;
  13821. /**
  13822. * Creates a new raw cube texture from a specified url
  13823. * @param url defines the url where the data is located
  13824. * @param scene defines the current scene
  13825. * @param size defines the size of the textures
  13826. * @param format defines the format of the data
  13827. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13828. * @param noMipmap defines if the engine should avoid generating the mip levels
  13829. * @param callback defines a callback used to extract texture data from loaded data
  13830. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13831. * @param onLoad defines a callback called when texture is loaded
  13832. * @param onError defines a callback called if there is an error
  13833. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13834. * @param invertY defines if data must be stored with Y axis inverted
  13835. * @returns the cube texture as an InternalTexture
  13836. */
  13837. 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;
  13838. /**
  13839. * Creates a new raw 3D texture
  13840. * @param data defines the data used to create the texture
  13841. * @param width defines the width of the texture
  13842. * @param height defines the height of the texture
  13843. * @param depth defines the depth of the texture
  13844. * @param format defines the format of the texture
  13845. * @param generateMipMaps defines if the engine must generate mip levels
  13846. * @param invertY defines if data must be stored with Y axis inverted
  13847. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13848. * @param compression defines the compressed used (can be null)
  13849. * @param textureType defines the compressed used (can be null)
  13850. * @returns a new raw 3D texture (stored in an InternalTexture)
  13851. */
  13852. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13853. /**
  13854. * Update a raw 3D texture
  13855. * @param texture defines the texture to update
  13856. * @param data defines the data to store
  13857. * @param format defines the data format
  13858. * @param invertY defines if data must be stored with Y axis inverted
  13859. */
  13860. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13861. /**
  13862. * Update a raw 3D texture
  13863. * @param texture defines the texture to update
  13864. * @param data defines the data to store
  13865. * @param format defines the data format
  13866. * @param invertY defines if data must be stored with Y axis inverted
  13867. * @param compression defines the used compression (can be null)
  13868. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13869. */
  13870. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13871. /**
  13872. * Creates a new raw 2D array texture
  13873. * @param data defines the data used to create the texture
  13874. * @param width defines the width of the texture
  13875. * @param height defines the height of the texture
  13876. * @param depth defines the number of layers of the texture
  13877. * @param format defines the format of the texture
  13878. * @param generateMipMaps defines if the engine must generate mip levels
  13879. * @param invertY defines if data must be stored with Y axis inverted
  13880. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13881. * @param compression defines the compressed used (can be null)
  13882. * @param textureType defines the compressed used (can be null)
  13883. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13884. */
  13885. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13886. /**
  13887. * Update a raw 2D array texture
  13888. * @param texture defines the texture to update
  13889. * @param data defines the data to store
  13890. * @param format defines the data format
  13891. * @param invertY defines if data must be stored with Y axis inverted
  13892. */
  13893. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13894. /**
  13895. * Update a raw 2D array texture
  13896. * @param texture defines the texture to update
  13897. * @param data defines the data to store
  13898. * @param format defines the data format
  13899. * @param invertY defines if data must be stored with Y axis inverted
  13900. * @param compression defines the used compression (can be null)
  13901. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13902. */
  13903. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13904. }
  13905. }
  13906. declare module BABYLON {
  13907. /**
  13908. * Raw texture can help creating a texture directly from an array of data.
  13909. * This can be super useful if you either get the data from an uncompressed source or
  13910. * if you wish to create your texture pixel by pixel.
  13911. */
  13912. export class RawTexture extends Texture {
  13913. /**
  13914. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13915. */
  13916. format: number;
  13917. /**
  13918. * Instantiates a new RawTexture.
  13919. * Raw texture can help creating a texture directly from an array of data.
  13920. * This can be super useful if you either get the data from an uncompressed source or
  13921. * if you wish to create your texture pixel by pixel.
  13922. * @param data define the array of data to use to create the texture
  13923. * @param width define the width of the texture
  13924. * @param height define the height of the texture
  13925. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13926. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13927. * @param generateMipMaps define whether mip maps should be generated or not
  13928. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13929. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13930. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13931. */
  13932. constructor(data: ArrayBufferView, width: number, height: number,
  13933. /**
  13934. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13935. */
  13936. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13937. /**
  13938. * Updates the texture underlying data.
  13939. * @param data Define the new data of the texture
  13940. */
  13941. update(data: ArrayBufferView): void;
  13942. /**
  13943. * Creates a luminance 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 luminance texture
  13952. */
  13953. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13954. /**
  13955. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  13964. */
  13965. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13966. /**
  13967. * Creates an alpha texture from some data.
  13968. * @param data Define the texture data
  13969. * @param width Define the width of the texture
  13970. * @param height Define the height of the texture
  13971. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13972. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13973. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13974. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13975. * @returns the alpha texture
  13976. */
  13977. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13978. /**
  13979. * Creates a RGB texture from some data.
  13980. * @param data Define the texture data
  13981. * @param width Define the width of the texture
  13982. * @param height Define the height of the texture
  13983. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13988. * @returns the RGB alpha texture
  13989. */
  13990. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13991. /**
  13992. * Creates a RGBA texture from some data.
  13993. * @param data Define the texture data
  13994. * @param width Define the width of the texture
  13995. * @param height Define the height of the texture
  13996. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13997. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13998. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13999. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14000. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14001. * @returns the RGBA texture
  14002. */
  14003. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14004. /**
  14005. * Creates a R texture from some data.
  14006. * @param data Define the texture data
  14007. * @param width Define the width of the texture
  14008. * @param height Define the height of the texture
  14009. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14010. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14011. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14012. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14013. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14014. * @returns the R texture
  14015. */
  14016. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14017. }
  14018. }
  14019. declare module BABYLON {
  14020. interface ThinEngine {
  14021. /**
  14022. * Update a dynamic index buffer
  14023. * @param indexBuffer defines the target index buffer
  14024. * @param indices defines the data to update
  14025. * @param offset defines the offset in the target index buffer where update should start
  14026. */
  14027. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14028. /**
  14029. * Updates a dynamic vertex buffer.
  14030. * @param vertexBuffer the vertex buffer to update
  14031. * @param data the data used to update the vertex buffer
  14032. * @param byteOffset the byte offset of the data
  14033. * @param byteLength the byte length of the data
  14034. */
  14035. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14036. }
  14037. }
  14038. declare module BABYLON {
  14039. interface AbstractScene {
  14040. /**
  14041. * The list of procedural textures added to the scene
  14042. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14043. */
  14044. proceduralTextures: Array<ProceduralTexture>;
  14045. }
  14046. /**
  14047. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14048. * in a given scene.
  14049. */
  14050. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14051. /**
  14052. * The component name helpfull to identify the component in the list of scene components.
  14053. */
  14054. readonly name: string;
  14055. /**
  14056. * The scene the component belongs to.
  14057. */
  14058. scene: Scene;
  14059. /**
  14060. * Creates a new instance of the component for the given scene
  14061. * @param scene Defines the scene to register the component in
  14062. */
  14063. constructor(scene: Scene);
  14064. /**
  14065. * Registers the component in a given scene
  14066. */
  14067. register(): void;
  14068. /**
  14069. * Rebuilds the elements related to this component in case of
  14070. * context lost for instance.
  14071. */
  14072. rebuild(): void;
  14073. /**
  14074. * Disposes the component and the associated ressources.
  14075. */
  14076. dispose(): void;
  14077. private _beforeClear;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. interface ThinEngine {
  14082. /**
  14083. * Creates a new render target cube texture
  14084. * @param size defines the size of the texture
  14085. * @param options defines the options used to create the texture
  14086. * @returns a new render target cube texture stored in an InternalTexture
  14087. */
  14088. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14089. }
  14090. }
  14091. declare module BABYLON {
  14092. /** @hidden */
  14093. export var proceduralVertexShader: {
  14094. name: string;
  14095. shader: string;
  14096. };
  14097. }
  14098. declare module BABYLON {
  14099. /**
  14100. * 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.
  14101. * This is the base class of any Procedural texture and contains most of the shareable code.
  14102. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14103. */
  14104. export class ProceduralTexture extends Texture {
  14105. /**
  14106. * Define if the texture is enabled or not (disabled texture will not render)
  14107. */
  14108. isEnabled: boolean;
  14109. /**
  14110. * Define if the texture must be cleared before rendering (default is true)
  14111. */
  14112. autoClear: boolean;
  14113. /**
  14114. * Callback called when the texture is generated
  14115. */
  14116. onGenerated: () => void;
  14117. /**
  14118. * Event raised when the texture is generated
  14119. */
  14120. onGeneratedObservable: Observable<ProceduralTexture>;
  14121. /**
  14122. * Event raised before the texture is generated
  14123. */
  14124. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14125. /**
  14126. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14127. */
  14128. nodeMaterialSource: Nullable<NodeMaterial>;
  14129. /** @hidden */
  14130. _generateMipMaps: boolean;
  14131. /** @hidden **/
  14132. _effect: Effect;
  14133. /** @hidden */
  14134. _textures: {
  14135. [key: string]: Texture;
  14136. };
  14137. /** @hidden */
  14138. protected _fallbackTexture: Nullable<Texture>;
  14139. private _size;
  14140. private _currentRefreshId;
  14141. private _frameId;
  14142. private _refreshRate;
  14143. private _vertexBuffers;
  14144. private _indexBuffer;
  14145. private _uniforms;
  14146. private _samplers;
  14147. private _fragment;
  14148. private _floats;
  14149. private _ints;
  14150. private _floatsArrays;
  14151. private _colors3;
  14152. private _colors4;
  14153. private _vectors2;
  14154. private _vectors3;
  14155. private _matrices;
  14156. private _fallbackTextureUsed;
  14157. private _fullEngine;
  14158. private _cachedDefines;
  14159. private _contentUpdateId;
  14160. private _contentData;
  14161. /**
  14162. * Instantiates a new procedural texture.
  14163. * 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.
  14164. * This is the base class of any Procedural texture and contains most of the shareable code.
  14165. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14166. * @param name Define the name of the texture
  14167. * @param size Define the size of the texture to create
  14168. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14169. * @param scene Define the scene the texture belongs to
  14170. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14171. * @param generateMipMaps Define if the texture should creates mip maps or not
  14172. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14173. * @param textureType The FBO internal texture type
  14174. */
  14175. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14176. /**
  14177. * The effect that is created when initializing the post process.
  14178. * @returns The created effect corresponding the the postprocess.
  14179. */
  14180. getEffect(): Effect;
  14181. /**
  14182. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14183. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14184. */
  14185. getContent(): Nullable<ArrayBufferView>;
  14186. private _createIndexBuffer;
  14187. /** @hidden */
  14188. _rebuild(): void;
  14189. /**
  14190. * Resets the texture in order to recreate its associated resources.
  14191. * This can be called in case of context loss
  14192. */
  14193. reset(): void;
  14194. protected _getDefines(): string;
  14195. /**
  14196. * Is the texture ready to be used ? (rendered at least once)
  14197. * @returns true if ready, otherwise, false.
  14198. */
  14199. isReady(): boolean;
  14200. /**
  14201. * Resets the refresh counter of the texture and start bak from scratch.
  14202. * Could be useful to regenerate the texture if it is setup to render only once.
  14203. */
  14204. resetRefreshCounter(): void;
  14205. /**
  14206. * Set the fragment shader to use in order to render the texture.
  14207. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14208. */
  14209. setFragment(fragment: any): void;
  14210. /**
  14211. * Define the refresh rate of the texture or the rendering frequency.
  14212. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14213. */
  14214. get refreshRate(): number;
  14215. set refreshRate(value: number);
  14216. /** @hidden */
  14217. _shouldRender(): boolean;
  14218. /**
  14219. * Get the size the texture is rendering at.
  14220. * @returns the size (on cube texture it is always squared)
  14221. */
  14222. getRenderSize(): RenderTargetTextureSize;
  14223. /**
  14224. * Resize the texture to new value.
  14225. * @param size Define the new size the texture should have
  14226. * @param generateMipMaps Define whether the new texture should create mip maps
  14227. */
  14228. resize(size: number, generateMipMaps: boolean): void;
  14229. private _checkUniform;
  14230. /**
  14231. * Set a texture in the shader program used to render.
  14232. * @param name Define the name of the uniform samplers as defined in the shader
  14233. * @param texture Define the texture to bind to this sampler
  14234. * @return the texture itself allowing "fluent" like uniform updates
  14235. */
  14236. setTexture(name: string, texture: Texture): ProceduralTexture;
  14237. /**
  14238. * Set a float in the shader.
  14239. * @param name Define the name of the uniform as defined in the shader
  14240. * @param value Define the value to give to the uniform
  14241. * @return the texture itself allowing "fluent" like uniform updates
  14242. */
  14243. setFloat(name: string, value: number): ProceduralTexture;
  14244. /**
  14245. * Set a int in the shader.
  14246. * @param name Define the name of the uniform as defined in the shader
  14247. * @param value Define the value to give to the uniform
  14248. * @return the texture itself allowing "fluent" like uniform updates
  14249. */
  14250. setInt(name: string, value: number): ProceduralTexture;
  14251. /**
  14252. * Set an array of floats in the shader.
  14253. * @param name Define the name of the uniform as defined in the shader
  14254. * @param value Define the value to give to the uniform
  14255. * @return the texture itself allowing "fluent" like uniform updates
  14256. */
  14257. setFloats(name: string, value: number[]): ProceduralTexture;
  14258. /**
  14259. * Set a vec3 in the shader from a Color3.
  14260. * @param name Define the name of the uniform as defined in the shader
  14261. * @param value Define the value to give to the uniform
  14262. * @return the texture itself allowing "fluent" like uniform updates
  14263. */
  14264. setColor3(name: string, value: Color3): ProceduralTexture;
  14265. /**
  14266. * Set a vec4 in the shader from a Color4.
  14267. * @param name Define the name of the uniform as defined in the shader
  14268. * @param value Define the value to give to the uniform
  14269. * @return the texture itself allowing "fluent" like uniform updates
  14270. */
  14271. setColor4(name: string, value: Color4): ProceduralTexture;
  14272. /**
  14273. * Set a vec2 in the shader from a Vector2.
  14274. * @param name Define the name of the uniform as defined in the shader
  14275. * @param value Define the value to give to the uniform
  14276. * @return the texture itself allowing "fluent" like uniform updates
  14277. */
  14278. setVector2(name: string, value: Vector2): ProceduralTexture;
  14279. /**
  14280. * Set a vec3 in the shader from a Vector3.
  14281. * @param name Define the name of the uniform as defined in the shader
  14282. * @param value Define the value to give to the uniform
  14283. * @return the texture itself allowing "fluent" like uniform updates
  14284. */
  14285. setVector3(name: string, value: Vector3): ProceduralTexture;
  14286. /**
  14287. * Set a mat4 in the shader from a MAtrix.
  14288. * @param name Define the name of the uniform as defined in the shader
  14289. * @param value Define the value to give to the uniform
  14290. * @return the texture itself allowing "fluent" like uniform updates
  14291. */
  14292. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14293. /**
  14294. * Render the texture to its associated render target.
  14295. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14296. */
  14297. render(useCameraPostProcess?: boolean): void;
  14298. /**
  14299. * Clone the texture.
  14300. * @returns the cloned texture
  14301. */
  14302. clone(): ProceduralTexture;
  14303. /**
  14304. * Dispose the texture and release its asoociated resources.
  14305. */
  14306. dispose(): void;
  14307. }
  14308. }
  14309. declare module BABYLON {
  14310. /**
  14311. * This represents the base class for particle system in Babylon.
  14312. * 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.
  14313. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14314. * @example https://doc.babylonjs.com/babylon101/particles
  14315. */
  14316. export class BaseParticleSystem {
  14317. /**
  14318. * Source color is added to the destination color without alpha affecting the result
  14319. */
  14320. static BLENDMODE_ONEONE: number;
  14321. /**
  14322. * Blend current color and particle color using particle’s alpha
  14323. */
  14324. static BLENDMODE_STANDARD: number;
  14325. /**
  14326. * Add current color and particle color multiplied by particle’s alpha
  14327. */
  14328. static BLENDMODE_ADD: number;
  14329. /**
  14330. * Multiply current color with particle color
  14331. */
  14332. static BLENDMODE_MULTIPLY: number;
  14333. /**
  14334. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14335. */
  14336. static BLENDMODE_MULTIPLYADD: number;
  14337. /**
  14338. * List of animations used by the particle system.
  14339. */
  14340. animations: Animation[];
  14341. /**
  14342. * Gets or sets the unique id of the particle system
  14343. */
  14344. uniqueId: number;
  14345. /**
  14346. * The id of the Particle system.
  14347. */
  14348. id: string;
  14349. /**
  14350. * The friendly name of the Particle system.
  14351. */
  14352. name: string;
  14353. /**
  14354. * Snippet ID if the particle system was created from the snippet server
  14355. */
  14356. snippetId: string;
  14357. /**
  14358. * The rendering group used by the Particle system to chose when to render.
  14359. */
  14360. renderingGroupId: number;
  14361. /**
  14362. * The emitter represents the Mesh or position we are attaching the particle system to.
  14363. */
  14364. emitter: Nullable<AbstractMesh | Vector3>;
  14365. /**
  14366. * The maximum number of particles to emit per frame
  14367. */
  14368. emitRate: number;
  14369. /**
  14370. * If you want to launch only a few particles at once, that can be done, as well.
  14371. */
  14372. manualEmitCount: number;
  14373. /**
  14374. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14375. */
  14376. updateSpeed: number;
  14377. /**
  14378. * The amount of time the particle system is running (depends of the overall update speed).
  14379. */
  14380. targetStopDuration: number;
  14381. /**
  14382. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14383. */
  14384. disposeOnStop: boolean;
  14385. /**
  14386. * Minimum power of emitting particles.
  14387. */
  14388. minEmitPower: number;
  14389. /**
  14390. * Maximum power of emitting particles.
  14391. */
  14392. maxEmitPower: number;
  14393. /**
  14394. * Minimum life time of emitting particles.
  14395. */
  14396. minLifeTime: number;
  14397. /**
  14398. * Maximum life time of emitting particles.
  14399. */
  14400. maxLifeTime: number;
  14401. /**
  14402. * Minimum Size of emitting particles.
  14403. */
  14404. minSize: number;
  14405. /**
  14406. * Maximum Size of emitting particles.
  14407. */
  14408. maxSize: number;
  14409. /**
  14410. * Minimum scale of emitting particles on X axis.
  14411. */
  14412. minScaleX: number;
  14413. /**
  14414. * Maximum scale of emitting particles on X axis.
  14415. */
  14416. maxScaleX: number;
  14417. /**
  14418. * Minimum scale of emitting particles on Y axis.
  14419. */
  14420. minScaleY: number;
  14421. /**
  14422. * Maximum scale of emitting particles on Y axis.
  14423. */
  14424. maxScaleY: number;
  14425. /**
  14426. * Gets or sets the minimal initial rotation in radians.
  14427. */
  14428. minInitialRotation: number;
  14429. /**
  14430. * Gets or sets the maximal initial rotation in radians.
  14431. */
  14432. maxInitialRotation: number;
  14433. /**
  14434. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14435. */
  14436. minAngularSpeed: number;
  14437. /**
  14438. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14439. */
  14440. maxAngularSpeed: number;
  14441. /**
  14442. * The texture used to render each particle. (this can be a spritesheet)
  14443. */
  14444. particleTexture: Nullable<BaseTexture>;
  14445. /**
  14446. * The layer mask we are rendering the particles through.
  14447. */
  14448. layerMask: number;
  14449. /**
  14450. * This can help using your own shader to render the particle system.
  14451. * The according effect will be created
  14452. */
  14453. customShader: any;
  14454. /**
  14455. * By default particle system starts as soon as they are created. This prevents the
  14456. * automatic start to happen and let you decide when to start emitting particles.
  14457. */
  14458. preventAutoStart: boolean;
  14459. private _noiseTexture;
  14460. /**
  14461. * Gets or sets a texture used to add random noise to particle positions
  14462. */
  14463. get noiseTexture(): Nullable<ProceduralTexture>;
  14464. set noiseTexture(value: Nullable<ProceduralTexture>);
  14465. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14466. noiseStrength: Vector3;
  14467. /**
  14468. * Callback triggered when the particle animation is ending.
  14469. */
  14470. onAnimationEnd: Nullable<() => void>;
  14471. /**
  14472. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14473. */
  14474. blendMode: number;
  14475. /**
  14476. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14477. * to override the particles.
  14478. */
  14479. forceDepthWrite: boolean;
  14480. /** 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 */
  14481. preWarmCycles: number;
  14482. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14483. preWarmStepOffset: number;
  14484. /**
  14485. * 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)
  14486. */
  14487. spriteCellChangeSpeed: number;
  14488. /**
  14489. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14490. */
  14491. startSpriteCellID: number;
  14492. /**
  14493. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14494. */
  14495. endSpriteCellID: number;
  14496. /**
  14497. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14498. */
  14499. spriteCellWidth: number;
  14500. /**
  14501. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14502. */
  14503. spriteCellHeight: number;
  14504. /**
  14505. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14506. */
  14507. spriteRandomStartCell: boolean;
  14508. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14509. translationPivot: Vector2;
  14510. /** @hidden */
  14511. protected _isAnimationSheetEnabled: boolean;
  14512. /**
  14513. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14514. */
  14515. beginAnimationOnStart: boolean;
  14516. /**
  14517. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14518. */
  14519. beginAnimationFrom: number;
  14520. /**
  14521. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14522. */
  14523. beginAnimationTo: number;
  14524. /**
  14525. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14526. */
  14527. beginAnimationLoop: boolean;
  14528. /**
  14529. * Gets or sets a world offset applied to all particles
  14530. */
  14531. worldOffset: Vector3;
  14532. /**
  14533. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14534. */
  14535. get isAnimationSheetEnabled(): boolean;
  14536. set isAnimationSheetEnabled(value: boolean);
  14537. /**
  14538. * Get hosting scene
  14539. * @returns the scene
  14540. */
  14541. getScene(): Nullable<Scene>;
  14542. /**
  14543. * You can use gravity if you want to give an orientation to your particles.
  14544. */
  14545. gravity: Vector3;
  14546. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14547. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14548. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14549. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14550. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14551. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14552. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14553. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14554. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14555. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14556. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14557. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14558. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14559. /**
  14560. * Defines the delay in milliseconds before starting the system (0 by default)
  14561. */
  14562. startDelay: number;
  14563. /**
  14564. * Gets the current list of drag gradients.
  14565. * You must use addDragGradient and removeDragGradient to udpate this list
  14566. * @returns the list of drag gradients
  14567. */
  14568. getDragGradients(): Nullable<Array<FactorGradient>>;
  14569. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14570. limitVelocityDamping: number;
  14571. /**
  14572. * Gets the current list of limit velocity gradients.
  14573. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14574. * @returns the list of limit velocity gradients
  14575. */
  14576. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14577. /**
  14578. * Gets the current list of color gradients.
  14579. * You must use addColorGradient and removeColorGradient to udpate this list
  14580. * @returns the list of color gradients
  14581. */
  14582. getColorGradients(): Nullable<Array<ColorGradient>>;
  14583. /**
  14584. * Gets the current list of size gradients.
  14585. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14586. * @returns the list of size gradients
  14587. */
  14588. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14589. /**
  14590. * Gets the current list of color remap gradients.
  14591. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14592. * @returns the list of color remap gradients
  14593. */
  14594. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14595. /**
  14596. * Gets the current list of alpha remap gradients.
  14597. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14598. * @returns the list of alpha remap gradients
  14599. */
  14600. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14601. /**
  14602. * Gets the current list of life time gradients.
  14603. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14604. * @returns the list of life time gradients
  14605. */
  14606. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14607. /**
  14608. * Gets the current list of angular speed gradients.
  14609. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14610. * @returns the list of angular speed gradients
  14611. */
  14612. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14613. /**
  14614. * Gets the current list of velocity gradients.
  14615. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14616. * @returns the list of velocity gradients
  14617. */
  14618. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14619. /**
  14620. * Gets the current list of start size gradients.
  14621. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14622. * @returns the list of start size gradients
  14623. */
  14624. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14625. /**
  14626. * Gets the current list of emit rate gradients.
  14627. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14628. * @returns the list of emit rate gradients
  14629. */
  14630. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14631. /**
  14632. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14633. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14634. */
  14635. get direction1(): Vector3;
  14636. set direction1(value: Vector3);
  14637. /**
  14638. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14639. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14640. */
  14641. get direction2(): Vector3;
  14642. set direction2(value: Vector3);
  14643. /**
  14644. * 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.
  14645. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14646. */
  14647. get minEmitBox(): Vector3;
  14648. set minEmitBox(value: Vector3);
  14649. /**
  14650. * 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.
  14651. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14652. */
  14653. get maxEmitBox(): Vector3;
  14654. set maxEmitBox(value: Vector3);
  14655. /**
  14656. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14657. */
  14658. color1: Color4;
  14659. /**
  14660. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14661. */
  14662. color2: Color4;
  14663. /**
  14664. * Color the particle will have at the end of its lifetime
  14665. */
  14666. colorDead: Color4;
  14667. /**
  14668. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14669. */
  14670. textureMask: Color4;
  14671. /**
  14672. * The particle emitter type defines the emitter used by the particle system.
  14673. * It can be for example box, sphere, or cone...
  14674. */
  14675. particleEmitterType: IParticleEmitterType;
  14676. /** @hidden */
  14677. _isSubEmitter: boolean;
  14678. /**
  14679. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14680. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14681. */
  14682. billboardMode: number;
  14683. protected _isBillboardBased: boolean;
  14684. /**
  14685. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14686. */
  14687. get isBillboardBased(): boolean;
  14688. set isBillboardBased(value: boolean);
  14689. /**
  14690. * The scene the particle system belongs to.
  14691. */
  14692. protected _scene: Nullable<Scene>;
  14693. /**
  14694. * The engine the particle system belongs to.
  14695. */
  14696. protected _engine: ThinEngine;
  14697. /**
  14698. * Local cache of defines for image processing.
  14699. */
  14700. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14701. /**
  14702. * Default configuration related to image processing available in the standard Material.
  14703. */
  14704. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14705. /**
  14706. * Gets the image processing configuration used either in this material.
  14707. */
  14708. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14709. /**
  14710. * Sets the Default image processing configuration used either in the this material.
  14711. *
  14712. * If sets to null, the scene one is in use.
  14713. */
  14714. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14715. /**
  14716. * Attaches a new image processing configuration to the Standard Material.
  14717. * @param configuration
  14718. */
  14719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14720. /** @hidden */
  14721. protected _reset(): void;
  14722. /** @hidden */
  14723. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14724. /**
  14725. * Instantiates a particle system.
  14726. * 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.
  14727. * @param name The name of the particle system
  14728. */
  14729. constructor(name: string);
  14730. /**
  14731. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14734. * @returns the emitter
  14735. */
  14736. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14737. /**
  14738. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14739. * @param radius The radius of the hemisphere to emit from
  14740. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14741. * @returns the emitter
  14742. */
  14743. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14744. /**
  14745. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14746. * @param radius The radius of the sphere to emit from
  14747. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14748. * @returns the emitter
  14749. */
  14750. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14751. /**
  14752. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14753. * @param radius The radius of the sphere to emit from
  14754. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14755. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14756. * @returns the emitter
  14757. */
  14758. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14759. /**
  14760. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14761. * @param radius The radius of the emission cylinder
  14762. * @param height The height of the emission cylinder
  14763. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14764. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14765. * @returns the emitter
  14766. */
  14767. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14768. /**
  14769. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14770. * @param radius The radius of the cylinder to emit from
  14771. * @param height The height of the emission cylinder
  14772. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14773. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14774. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14775. * @returns the emitter
  14776. */
  14777. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14778. /**
  14779. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14780. * @param radius The radius of the cone to emit from
  14781. * @param angle The base angle of the cone
  14782. * @returns the emitter
  14783. */
  14784. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14785. /**
  14786. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14789. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14790. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14791. * @returns the emitter
  14792. */
  14793. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14794. }
  14795. }
  14796. declare module BABYLON {
  14797. /**
  14798. * Type of sub emitter
  14799. */
  14800. export enum SubEmitterType {
  14801. /**
  14802. * Attached to the particle over it's lifetime
  14803. */
  14804. ATTACHED = 0,
  14805. /**
  14806. * Created when the particle dies
  14807. */
  14808. END = 1
  14809. }
  14810. /**
  14811. * Sub emitter class used to emit particles from an existing particle
  14812. */
  14813. export class SubEmitter {
  14814. /**
  14815. * the particle system to be used by the sub emitter
  14816. */
  14817. particleSystem: ParticleSystem;
  14818. /**
  14819. * Type of the submitter (Default: END)
  14820. */
  14821. type: SubEmitterType;
  14822. /**
  14823. * 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)
  14824. * Note: This only is supported when using an emitter of type Mesh
  14825. */
  14826. inheritDirection: boolean;
  14827. /**
  14828. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14829. */
  14830. inheritedVelocityAmount: number;
  14831. /**
  14832. * Creates a sub emitter
  14833. * @param particleSystem the particle system to be used by the sub emitter
  14834. */
  14835. constructor(
  14836. /**
  14837. * the particle system to be used by the sub emitter
  14838. */
  14839. particleSystem: ParticleSystem);
  14840. /**
  14841. * Clones the sub emitter
  14842. * @returns the cloned sub emitter
  14843. */
  14844. clone(): SubEmitter;
  14845. /**
  14846. * Serialize current object to a JSON object
  14847. * @returns the serialized object
  14848. */
  14849. serialize(): any;
  14850. /** @hidden */
  14851. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14852. /**
  14853. * Creates a new SubEmitter from a serialized JSON version
  14854. * @param serializationObject defines the JSON object to read from
  14855. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14856. * @param rootUrl defines the rootUrl for data loading
  14857. * @returns a new SubEmitter
  14858. */
  14859. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14860. /** Release associated resources */
  14861. dispose(): void;
  14862. }
  14863. }
  14864. declare module BABYLON {
  14865. /** @hidden */
  14866. export var clipPlaneFragmentDeclaration: {
  14867. name: string;
  14868. shader: string;
  14869. };
  14870. }
  14871. declare module BABYLON {
  14872. /** @hidden */
  14873. export var imageProcessingDeclaration: {
  14874. name: string;
  14875. shader: string;
  14876. };
  14877. }
  14878. declare module BABYLON {
  14879. /** @hidden */
  14880. export var imageProcessingFunctions: {
  14881. name: string;
  14882. shader: string;
  14883. };
  14884. }
  14885. declare module BABYLON {
  14886. /** @hidden */
  14887. export var clipPlaneFragment: {
  14888. name: string;
  14889. shader: string;
  14890. };
  14891. }
  14892. declare module BABYLON {
  14893. /** @hidden */
  14894. export var particlesPixelShader: {
  14895. name: string;
  14896. shader: string;
  14897. };
  14898. }
  14899. declare module BABYLON {
  14900. /** @hidden */
  14901. export var clipPlaneVertexDeclaration: {
  14902. name: string;
  14903. shader: string;
  14904. };
  14905. }
  14906. declare module BABYLON {
  14907. /** @hidden */
  14908. export var clipPlaneVertex: {
  14909. name: string;
  14910. shader: string;
  14911. };
  14912. }
  14913. declare module BABYLON {
  14914. /** @hidden */
  14915. export var particlesVertexShader: {
  14916. name: string;
  14917. shader: string;
  14918. };
  14919. }
  14920. declare module BABYLON {
  14921. /**
  14922. * Interface used to define entities containing multiple clip planes
  14923. */
  14924. export interface IClipPlanesHolder {
  14925. /**
  14926. * Gets or sets the active clipplane 1
  14927. */
  14928. clipPlane: Nullable<Plane>;
  14929. /**
  14930. * Gets or sets the active clipplane 2
  14931. */
  14932. clipPlane2: Nullable<Plane>;
  14933. /**
  14934. * Gets or sets the active clipplane 3
  14935. */
  14936. clipPlane3: Nullable<Plane>;
  14937. /**
  14938. * Gets or sets the active clipplane 4
  14939. */
  14940. clipPlane4: Nullable<Plane>;
  14941. /**
  14942. * Gets or sets the active clipplane 5
  14943. */
  14944. clipPlane5: Nullable<Plane>;
  14945. /**
  14946. * Gets or sets the active clipplane 6
  14947. */
  14948. clipPlane6: Nullable<Plane>;
  14949. }
  14950. }
  14951. declare module BABYLON {
  14952. /**
  14953. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14954. *
  14955. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14956. *
  14957. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14958. */
  14959. export class ThinMaterialHelper {
  14960. /**
  14961. * Binds the clip plane information from the holder to the effect.
  14962. * @param effect The effect we are binding the data to
  14963. * @param holder The entity containing the clip plane information
  14964. */
  14965. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14966. }
  14967. }
  14968. declare module BABYLON {
  14969. interface ThinEngine {
  14970. /**
  14971. * Sets alpha constants used by some alpha blending modes
  14972. * @param r defines the red component
  14973. * @param g defines the green component
  14974. * @param b defines the blue component
  14975. * @param a defines the alpha component
  14976. */
  14977. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14978. /**
  14979. * Sets the current alpha mode
  14980. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14981. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14982. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14983. */
  14984. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14985. /**
  14986. * Gets the current alpha mode
  14987. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14988. * @returns the current alpha mode
  14989. */
  14990. getAlphaMode(): number;
  14991. /**
  14992. * Sets the current alpha equation
  14993. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14994. */
  14995. setAlphaEquation(equation: number): void;
  14996. /**
  14997. * Gets the current alpha equation.
  14998. * @returns the current alpha equation
  14999. */
  15000. getAlphaEquation(): number;
  15001. }
  15002. }
  15003. declare module BABYLON {
  15004. /**
  15005. * This represents a particle system in Babylon.
  15006. * 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.
  15007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15008. * @example https://doc.babylonjs.com/babylon101/particles
  15009. */
  15010. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15011. /**
  15012. * Billboard mode will only apply to Y axis
  15013. */
  15014. static readonly BILLBOARDMODE_Y: number;
  15015. /**
  15016. * Billboard mode will apply to all axes
  15017. */
  15018. static readonly BILLBOARDMODE_ALL: number;
  15019. /**
  15020. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15021. */
  15022. static readonly BILLBOARDMODE_STRETCHED: number;
  15023. /**
  15024. * This function can be defined to provide custom update for active particles.
  15025. * This function will be called instead of regular update (age, position, color, etc.).
  15026. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15027. */
  15028. updateFunction: (particles: Particle[]) => void;
  15029. private _emitterWorldMatrix;
  15030. /**
  15031. * This function can be defined to specify initial direction for every new particle.
  15032. * It by default use the emitterType defined function
  15033. */
  15034. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15035. /**
  15036. * This function can be defined to specify initial position for every new particle.
  15037. * It by default use the emitterType defined function
  15038. */
  15039. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15040. /**
  15041. * @hidden
  15042. */
  15043. _inheritedVelocityOffset: Vector3;
  15044. /**
  15045. * An event triggered when the system is disposed
  15046. */
  15047. onDisposeObservable: Observable<IParticleSystem>;
  15048. /**
  15049. * An event triggered when the system is stopped
  15050. */
  15051. onStoppedObservable: Observable<IParticleSystem>;
  15052. private _onDisposeObserver;
  15053. /**
  15054. * Sets a callback that will be triggered when the system is disposed
  15055. */
  15056. set onDispose(callback: () => void);
  15057. private _particles;
  15058. private _epsilon;
  15059. private _capacity;
  15060. private _stockParticles;
  15061. private _newPartsExcess;
  15062. private _vertexData;
  15063. private _vertexBuffer;
  15064. private _vertexBuffers;
  15065. private _spriteBuffer;
  15066. private _indexBuffer;
  15067. private _effect;
  15068. private _customEffect;
  15069. private _cachedDefines;
  15070. private _scaledColorStep;
  15071. private _colorDiff;
  15072. private _scaledDirection;
  15073. private _scaledGravity;
  15074. private _currentRenderId;
  15075. private _alive;
  15076. private _useInstancing;
  15077. private _vertexArrayObject;
  15078. private _started;
  15079. private _stopped;
  15080. private _actualFrame;
  15081. private _scaledUpdateSpeed;
  15082. private _vertexBufferSize;
  15083. /** @hidden */
  15084. _currentEmitRateGradient: Nullable<FactorGradient>;
  15085. /** @hidden */
  15086. _currentEmitRate1: number;
  15087. /** @hidden */
  15088. _currentEmitRate2: number;
  15089. /** @hidden */
  15090. _currentStartSizeGradient: Nullable<FactorGradient>;
  15091. /** @hidden */
  15092. _currentStartSize1: number;
  15093. /** @hidden */
  15094. _currentStartSize2: number;
  15095. private readonly _rawTextureWidth;
  15096. private _rampGradientsTexture;
  15097. private _useRampGradients;
  15098. /** Gets or sets a matrix to use to compute projection */
  15099. defaultProjectionMatrix: Matrix;
  15100. /** Gets or sets a matrix to use to compute view */
  15101. defaultViewMatrix: Matrix;
  15102. /** Gets or sets a boolean indicating that ramp gradients must be used
  15103. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15104. */
  15105. get useRampGradients(): boolean;
  15106. set useRampGradients(value: boolean);
  15107. /**
  15108. * 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.
  15109. * 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: [])
  15110. */
  15111. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15112. private _subEmitters;
  15113. /**
  15114. * @hidden
  15115. * If the particle systems emitter should be disposed when the particle system is disposed
  15116. */
  15117. _disposeEmitterOnDispose: boolean;
  15118. /**
  15119. * The current active Sub-systems, this property is used by the root particle system only.
  15120. */
  15121. activeSubSystems: Array<ParticleSystem>;
  15122. /**
  15123. * Specifies if the particles are updated in emitter local space or world space
  15124. */
  15125. isLocal: boolean;
  15126. private _rootParticleSystem;
  15127. /**
  15128. * Gets the current list of active particles
  15129. */
  15130. get particles(): Particle[];
  15131. /**
  15132. * Gets the number of particles active at the same time.
  15133. * @returns The number of active particles.
  15134. */
  15135. getActiveCount(): number;
  15136. /**
  15137. * Returns the string "ParticleSystem"
  15138. * @returns a string containing the class name
  15139. */
  15140. getClassName(): string;
  15141. /**
  15142. * Gets a boolean indicating that the system is stopping
  15143. * @returns true if the system is currently stopping
  15144. */
  15145. isStopping(): boolean;
  15146. /**
  15147. * Gets the custom effect used to render the particles
  15148. * @param blendMode Blend mode for which the effect should be retrieved
  15149. * @returns The effect
  15150. */
  15151. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15152. /**
  15153. * Sets the custom effect used to render the particles
  15154. * @param effect The effect to set
  15155. * @param blendMode Blend mode for which the effect should be set
  15156. */
  15157. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15158. /** @hidden */
  15159. private _onBeforeDrawParticlesObservable;
  15160. /**
  15161. * Observable that will be called just before the particles are drawn
  15162. */
  15163. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15164. /**
  15165. * Gets the name of the particle vertex shader
  15166. */
  15167. get vertexShaderName(): string;
  15168. /**
  15169. * Instantiates a particle system.
  15170. * 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.
  15171. * @param name The name of the particle system
  15172. * @param capacity The max number of particles alive at the same time
  15173. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15174. * @param customEffect a custom effect used to change the way particles are rendered by default
  15175. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15176. * @param epsilon Offset used to render the particles
  15177. */
  15178. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15179. private _addFactorGradient;
  15180. private _removeFactorGradient;
  15181. /**
  15182. * Adds a new life time gradient
  15183. * @param gradient defines the gradient to use (between 0 and 1)
  15184. * @param factor defines the life time factor to affect to the specified gradient
  15185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15186. * @returns the current particle system
  15187. */
  15188. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15189. /**
  15190. * Remove a specific life time gradient
  15191. * @param gradient defines the gradient to remove
  15192. * @returns the current particle system
  15193. */
  15194. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15195. /**
  15196. * Adds a new size gradient
  15197. * @param gradient defines the gradient to use (between 0 and 1)
  15198. * @param factor defines the size factor to affect to the specified gradient
  15199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15200. * @returns the current particle system
  15201. */
  15202. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15203. /**
  15204. * Remove a specific size gradient
  15205. * @param gradient defines the gradient to remove
  15206. * @returns the current particle system
  15207. */
  15208. removeSizeGradient(gradient: number): IParticleSystem;
  15209. /**
  15210. * Adds a new color remap gradient
  15211. * @param gradient defines the gradient to use (between 0 and 1)
  15212. * @param min defines the color remap minimal range
  15213. * @param max defines the color remap maximal range
  15214. * @returns the current particle system
  15215. */
  15216. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15217. /**
  15218. * Remove a specific color remap gradient
  15219. * @param gradient defines the gradient to remove
  15220. * @returns the current particle system
  15221. */
  15222. removeColorRemapGradient(gradient: number): IParticleSystem;
  15223. /**
  15224. * Adds a new alpha remap gradient
  15225. * @param gradient defines the gradient to use (between 0 and 1)
  15226. * @param min defines the alpha remap minimal range
  15227. * @param max defines the alpha remap maximal range
  15228. * @returns the current particle system
  15229. */
  15230. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15231. /**
  15232. * Remove a specific alpha remap gradient
  15233. * @param gradient defines the gradient to remove
  15234. * @returns the current particle system
  15235. */
  15236. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15237. /**
  15238. * Adds a new angular speed gradient
  15239. * @param gradient defines the gradient to use (between 0 and 1)
  15240. * @param factor defines the angular speed to affect to the specified gradient
  15241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15242. * @returns the current particle system
  15243. */
  15244. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15245. /**
  15246. * Remove a specific angular speed gradient
  15247. * @param gradient defines the gradient to remove
  15248. * @returns the current particle system
  15249. */
  15250. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15251. /**
  15252. * Adds a new velocity gradient
  15253. * @param gradient defines the gradient to use (between 0 and 1)
  15254. * @param factor defines the velocity to affect to the specified gradient
  15255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15256. * @returns the current particle system
  15257. */
  15258. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15259. /**
  15260. * Remove a specific velocity gradient
  15261. * @param gradient defines the gradient to remove
  15262. * @returns the current particle system
  15263. */
  15264. removeVelocityGradient(gradient: number): IParticleSystem;
  15265. /**
  15266. * Adds a new limit velocity gradient
  15267. * @param gradient defines the gradient to use (between 0 and 1)
  15268. * @param factor defines the limit velocity value to affect to the specified gradient
  15269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15270. * @returns the current particle system
  15271. */
  15272. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15273. /**
  15274. * Remove a specific limit velocity gradient
  15275. * @param gradient defines the gradient to remove
  15276. * @returns the current particle system
  15277. */
  15278. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15279. /**
  15280. * Adds a new drag gradient
  15281. * @param gradient defines the gradient to use (between 0 and 1)
  15282. * @param factor defines the drag value to affect to the specified gradient
  15283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15284. * @returns the current particle system
  15285. */
  15286. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15287. /**
  15288. * Remove a specific drag gradient
  15289. * @param gradient defines the gradient to remove
  15290. * @returns the current particle system
  15291. */
  15292. removeDragGradient(gradient: number): IParticleSystem;
  15293. /**
  15294. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15295. * @param gradient defines the gradient to use (between 0 and 1)
  15296. * @param factor defines the emit rate value to affect to the specified gradient
  15297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15298. * @returns the current particle system
  15299. */
  15300. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15301. /**
  15302. * Remove a specific emit rate gradient
  15303. * @param gradient defines the gradient to remove
  15304. * @returns the current particle system
  15305. */
  15306. removeEmitRateGradient(gradient: number): IParticleSystem;
  15307. /**
  15308. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15309. * @param gradient defines the gradient to use (between 0 and 1)
  15310. * @param factor defines the start size value to affect to the specified gradient
  15311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15312. * @returns the current particle system
  15313. */
  15314. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15315. /**
  15316. * Remove a specific start size gradient
  15317. * @param gradient defines the gradient to remove
  15318. * @returns the current particle system
  15319. */
  15320. removeStartSizeGradient(gradient: number): IParticleSystem;
  15321. private _createRampGradientTexture;
  15322. /**
  15323. * Gets the current list of ramp gradients.
  15324. * You must use addRampGradient and removeRampGradient to udpate this list
  15325. * @returns the list of ramp gradients
  15326. */
  15327. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15328. /** Force the system to rebuild all gradients that need to be resync */
  15329. forceRefreshGradients(): void;
  15330. private _syncRampGradientTexture;
  15331. /**
  15332. * Adds a new ramp gradient used to remap particle colors
  15333. * @param gradient defines the gradient to use (between 0 and 1)
  15334. * @param color defines the color to affect to the specified gradient
  15335. * @returns the current particle system
  15336. */
  15337. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15338. /**
  15339. * Remove a specific ramp gradient
  15340. * @param gradient defines the gradient to remove
  15341. * @returns the current particle system
  15342. */
  15343. removeRampGradient(gradient: number): ParticleSystem;
  15344. /**
  15345. * Adds a new color gradient
  15346. * @param gradient defines the gradient to use (between 0 and 1)
  15347. * @param color1 defines the color to affect to the specified gradient
  15348. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15349. * @returns this particle system
  15350. */
  15351. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15352. /**
  15353. * Remove a specific color gradient
  15354. * @param gradient defines the gradient to remove
  15355. * @returns this particle system
  15356. */
  15357. removeColorGradient(gradient: number): IParticleSystem;
  15358. private _fetchR;
  15359. protected _reset(): void;
  15360. private _resetEffect;
  15361. private _createVertexBuffers;
  15362. private _createIndexBuffer;
  15363. /**
  15364. * Gets the maximum number of particles active at the same time.
  15365. * @returns The max number of active particles.
  15366. */
  15367. getCapacity(): number;
  15368. /**
  15369. * Gets whether there are still active particles in the system.
  15370. * @returns True if it is alive, otherwise false.
  15371. */
  15372. isAlive(): boolean;
  15373. /**
  15374. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15375. * @returns True if it has been started, otherwise false.
  15376. */
  15377. isStarted(): boolean;
  15378. private _prepareSubEmitterInternalArray;
  15379. /**
  15380. * Starts the particle system and begins to emit
  15381. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15382. */
  15383. start(delay?: number): void;
  15384. /**
  15385. * Stops the particle system.
  15386. * @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.
  15387. */
  15388. stop(stopSubEmitters?: boolean): void;
  15389. /**
  15390. * Remove all active particles
  15391. */
  15392. reset(): void;
  15393. /**
  15394. * @hidden (for internal use only)
  15395. */
  15396. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15397. /**
  15398. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15399. * Its lifetime will start back at 0.
  15400. */
  15401. recycleParticle: (particle: Particle) => void;
  15402. private _stopSubEmitters;
  15403. private _createParticle;
  15404. private _removeFromRoot;
  15405. private _emitFromParticle;
  15406. private _update;
  15407. /** @hidden */
  15408. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15409. /** @hidden */
  15410. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15411. /**
  15412. * Fill the defines array according to the current settings of the particle system
  15413. * @param defines Array to be updated
  15414. * @param blendMode blend mode to take into account when updating the array
  15415. */
  15416. fillDefines(defines: Array<string>, blendMode: number): void;
  15417. /**
  15418. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15419. * @param uniforms Uniforms array to fill
  15420. * @param attributes Attributes array to fill
  15421. * @param samplers Samplers array to fill
  15422. */
  15423. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15424. /** @hidden */
  15425. private _getEffect;
  15426. /**
  15427. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15428. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15429. */
  15430. animate(preWarmOnly?: boolean): void;
  15431. private _appendParticleVertices;
  15432. /**
  15433. * Rebuilds the particle system.
  15434. */
  15435. rebuild(): void;
  15436. /**
  15437. * Is this system ready to be used/rendered
  15438. * @return true if the system is ready
  15439. */
  15440. isReady(): boolean;
  15441. private _render;
  15442. /**
  15443. * Renders the particle system in its current state.
  15444. * @returns the current number of particles
  15445. */
  15446. render(): number;
  15447. /**
  15448. * Disposes the particle system and free the associated resources
  15449. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15450. */
  15451. dispose(disposeTexture?: boolean): void;
  15452. /**
  15453. * Clones the particle system.
  15454. * @param name The name of the cloned object
  15455. * @param newEmitter The new emitter to use
  15456. * @returns the cloned particle system
  15457. */
  15458. clone(name: string, newEmitter: any): ParticleSystem;
  15459. /**
  15460. * Serializes the particle system to a JSON object
  15461. * @param serializeTexture defines if the texture must be serialized as well
  15462. * @returns the JSON object
  15463. */
  15464. serialize(serializeTexture?: boolean): any;
  15465. /** @hidden */
  15466. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15467. /** @hidden */
  15468. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15469. /**
  15470. * Parses a JSON object to create a particle system.
  15471. * @param parsedParticleSystem The JSON object to parse
  15472. * @param sceneOrEngine The scene or the engine to create the particle system in
  15473. * @param rootUrl The root url to use to load external dependencies like texture
  15474. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15475. * @returns the Parsed particle system
  15476. */
  15477. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15478. }
  15479. }
  15480. declare module BABYLON {
  15481. /**
  15482. * A particle represents one of the element emitted by a particle system.
  15483. * This is mainly define by its coordinates, direction, velocity and age.
  15484. */
  15485. export class Particle {
  15486. /**
  15487. * The particle system the particle belongs to.
  15488. */
  15489. particleSystem: ParticleSystem;
  15490. private static _Count;
  15491. /**
  15492. * Unique ID of the particle
  15493. */
  15494. id: number;
  15495. /**
  15496. * The world position of the particle in the scene.
  15497. */
  15498. position: Vector3;
  15499. /**
  15500. * The world direction of the particle in the scene.
  15501. */
  15502. direction: Vector3;
  15503. /**
  15504. * The color of the particle.
  15505. */
  15506. color: Color4;
  15507. /**
  15508. * The color change of the particle per step.
  15509. */
  15510. colorStep: Color4;
  15511. /**
  15512. * Defines how long will the life of the particle be.
  15513. */
  15514. lifeTime: number;
  15515. /**
  15516. * The current age of the particle.
  15517. */
  15518. age: number;
  15519. /**
  15520. * The current size of the particle.
  15521. */
  15522. size: number;
  15523. /**
  15524. * The current scale of the particle.
  15525. */
  15526. scale: Vector2;
  15527. /**
  15528. * The current angle of the particle.
  15529. */
  15530. angle: number;
  15531. /**
  15532. * Defines how fast is the angle changing.
  15533. */
  15534. angularSpeed: number;
  15535. /**
  15536. * Defines the cell index used by the particle to be rendered from a sprite.
  15537. */
  15538. cellIndex: number;
  15539. /**
  15540. * The information required to support color remapping
  15541. */
  15542. remapData: Vector4;
  15543. /** @hidden */
  15544. _randomCellOffset?: number;
  15545. /** @hidden */
  15546. _initialDirection: Nullable<Vector3>;
  15547. /** @hidden */
  15548. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15549. /** @hidden */
  15550. _initialStartSpriteCellID: number;
  15551. /** @hidden */
  15552. _initialEndSpriteCellID: number;
  15553. /** @hidden */
  15554. _currentColorGradient: Nullable<ColorGradient>;
  15555. /** @hidden */
  15556. _currentColor1: Color4;
  15557. /** @hidden */
  15558. _currentColor2: Color4;
  15559. /** @hidden */
  15560. _currentSizeGradient: Nullable<FactorGradient>;
  15561. /** @hidden */
  15562. _currentSize1: number;
  15563. /** @hidden */
  15564. _currentSize2: number;
  15565. /** @hidden */
  15566. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15567. /** @hidden */
  15568. _currentAngularSpeed1: number;
  15569. /** @hidden */
  15570. _currentAngularSpeed2: number;
  15571. /** @hidden */
  15572. _currentVelocityGradient: Nullable<FactorGradient>;
  15573. /** @hidden */
  15574. _currentVelocity1: number;
  15575. /** @hidden */
  15576. _currentVelocity2: number;
  15577. /** @hidden */
  15578. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15579. /** @hidden */
  15580. _currentLimitVelocity1: number;
  15581. /** @hidden */
  15582. _currentLimitVelocity2: number;
  15583. /** @hidden */
  15584. _currentDragGradient: Nullable<FactorGradient>;
  15585. /** @hidden */
  15586. _currentDrag1: number;
  15587. /** @hidden */
  15588. _currentDrag2: number;
  15589. /** @hidden */
  15590. _randomNoiseCoordinates1: Vector3;
  15591. /** @hidden */
  15592. _randomNoiseCoordinates2: Vector3;
  15593. /** @hidden */
  15594. _localPosition?: Vector3;
  15595. /**
  15596. * Creates a new instance Particle
  15597. * @param particleSystem the particle system the particle belongs to
  15598. */
  15599. constructor(
  15600. /**
  15601. * The particle system the particle belongs to.
  15602. */
  15603. particleSystem: ParticleSystem);
  15604. private updateCellInfoFromSystem;
  15605. /**
  15606. * Defines how the sprite cell index is updated for the particle
  15607. */
  15608. updateCellIndex(): void;
  15609. /** @hidden */
  15610. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15611. /** @hidden */
  15612. _inheritParticleInfoToSubEmitters(): void;
  15613. /** @hidden */
  15614. _reset(): void;
  15615. /**
  15616. * Copy the properties of particle to another one.
  15617. * @param other the particle to copy the information to.
  15618. */
  15619. copyTo(other: Particle): void;
  15620. }
  15621. }
  15622. declare module BABYLON {
  15623. /**
  15624. * Particle emitter represents a volume emitting particles.
  15625. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15626. */
  15627. export interface IParticleEmitterType {
  15628. /**
  15629. * Called by the particle System when the direction is computed for the created particle.
  15630. * @param worldMatrix is the world matrix of the particle system
  15631. * @param directionToUpdate is the direction vector to update with the result
  15632. * @param particle is the particle we are computed the direction for
  15633. * @param isLocal defines if the direction should be set in local space
  15634. */
  15635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15636. /**
  15637. * Called by the particle System when the position is computed for the created particle.
  15638. * @param worldMatrix is the world matrix of the particle system
  15639. * @param positionToUpdate is the position vector to update with the result
  15640. * @param particle is the particle we are computed the position for
  15641. * @param isLocal defines if the position should be set in local space
  15642. */
  15643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15644. /**
  15645. * Clones the current emitter and returns a copy of it
  15646. * @returns the new emitter
  15647. */
  15648. clone(): IParticleEmitterType;
  15649. /**
  15650. * Called by the GPUParticleSystem to setup the update shader
  15651. * @param effect defines the update shader
  15652. */
  15653. applyToShader(effect: Effect): void;
  15654. /**
  15655. * Returns a string to use to update the GPU particles update shader
  15656. * @returns the effect defines string
  15657. */
  15658. getEffectDefines(): string;
  15659. /**
  15660. * Returns a string representing the class name
  15661. * @returns a string containing the class name
  15662. */
  15663. getClassName(): string;
  15664. /**
  15665. * Serializes the particle system to a JSON object.
  15666. * @returns the JSON object
  15667. */
  15668. serialize(): any;
  15669. /**
  15670. * Parse properties from a JSON object
  15671. * @param serializationObject defines the JSON object
  15672. * @param scene defines the hosting scene
  15673. */
  15674. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /**
  15679. * Particle emitter emitting particles from the inside of a box.
  15680. * It emits the particles randomly between 2 given directions.
  15681. */
  15682. export class BoxParticleEmitter implements IParticleEmitterType {
  15683. /**
  15684. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15685. */
  15686. direction1: Vector3;
  15687. /**
  15688. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15689. */
  15690. direction2: Vector3;
  15691. /**
  15692. * 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.
  15693. */
  15694. minEmitBox: Vector3;
  15695. /**
  15696. * 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.
  15697. */
  15698. maxEmitBox: Vector3;
  15699. /**
  15700. * Creates a new instance BoxParticleEmitter
  15701. */
  15702. constructor();
  15703. /**
  15704. * Called by the particle System when the direction is computed for the created particle.
  15705. * @param worldMatrix is the world matrix of the particle system
  15706. * @param directionToUpdate is the direction vector to update with the result
  15707. * @param particle is the particle we are computed the direction for
  15708. * @param isLocal defines if the direction should be set in local space
  15709. */
  15710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15711. /**
  15712. * Called by the particle System when the position is computed for the created particle.
  15713. * @param worldMatrix is the world matrix of the particle system
  15714. * @param positionToUpdate is the position vector to update with the result
  15715. * @param particle is the particle we are computed the position for
  15716. * @param isLocal defines if the position should be set in local space
  15717. */
  15718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15719. /**
  15720. * Clones the current emitter and returns a copy of it
  15721. * @returns the new emitter
  15722. */
  15723. clone(): BoxParticleEmitter;
  15724. /**
  15725. * Called by the GPUParticleSystem to setup the update shader
  15726. * @param effect defines the update shader
  15727. */
  15728. applyToShader(effect: Effect): void;
  15729. /**
  15730. * Returns a string to use to update the GPU particles update shader
  15731. * @returns a string containng the defines string
  15732. */
  15733. getEffectDefines(): string;
  15734. /**
  15735. * Returns the string "BoxParticleEmitter"
  15736. * @returns a string containing the class name
  15737. */
  15738. getClassName(): string;
  15739. /**
  15740. * Serializes the particle system to a JSON object.
  15741. * @returns the JSON object
  15742. */
  15743. serialize(): any;
  15744. /**
  15745. * Parse properties from a JSON object
  15746. * @param serializationObject defines the JSON object
  15747. */
  15748. parse(serializationObject: any): void;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. /**
  15753. * Particle emitter emitting particles from the inside of a cone.
  15754. * It emits the particles alongside the cone volume from the base to the particle.
  15755. * The emission direction might be randomized.
  15756. */
  15757. export class ConeParticleEmitter implements IParticleEmitterType {
  15758. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15759. directionRandomizer: number;
  15760. private _radius;
  15761. private _angle;
  15762. private _height;
  15763. /**
  15764. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15765. */
  15766. radiusRange: number;
  15767. /**
  15768. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15769. */
  15770. heightRange: number;
  15771. /**
  15772. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15773. */
  15774. emitFromSpawnPointOnly: boolean;
  15775. /**
  15776. * Gets or sets the radius of the emission cone
  15777. */
  15778. get radius(): number;
  15779. set radius(value: number);
  15780. /**
  15781. * Gets or sets the angle of the emission cone
  15782. */
  15783. get angle(): number;
  15784. set angle(value: number);
  15785. private _buildHeight;
  15786. /**
  15787. * Creates a new instance ConeParticleEmitter
  15788. * @param radius the radius of the emission cone (1 by default)
  15789. * @param angle the cone base angle (PI by default)
  15790. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15791. */
  15792. constructor(radius?: number, angle?: number,
  15793. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15794. directionRandomizer?: number);
  15795. /**
  15796. * Called by the particle System when the direction is computed for the created particle.
  15797. * @param worldMatrix is the world matrix of the particle system
  15798. * @param directionToUpdate is the direction vector to update with the result
  15799. * @param particle is the particle we are computed the direction for
  15800. * @param isLocal defines if the direction should be set in local space
  15801. */
  15802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15803. /**
  15804. * Called by the particle System when the position is computed for the created particle.
  15805. * @param worldMatrix is the world matrix of the particle system
  15806. * @param positionToUpdate is the position vector to update with the result
  15807. * @param particle is the particle we are computed the position for
  15808. * @param isLocal defines if the position should be set in local space
  15809. */
  15810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15811. /**
  15812. * Clones the current emitter and returns a copy of it
  15813. * @returns the new emitter
  15814. */
  15815. clone(): ConeParticleEmitter;
  15816. /**
  15817. * Called by the GPUParticleSystem to setup the update shader
  15818. * @param effect defines the update shader
  15819. */
  15820. applyToShader(effect: Effect): void;
  15821. /**
  15822. * Returns a string to use to update the GPU particles update shader
  15823. * @returns a string containng the defines string
  15824. */
  15825. getEffectDefines(): string;
  15826. /**
  15827. * Returns the string "ConeParticleEmitter"
  15828. * @returns a string containing the class name
  15829. */
  15830. getClassName(): string;
  15831. /**
  15832. * Serializes the particle system to a JSON object.
  15833. * @returns the JSON object
  15834. */
  15835. serialize(): any;
  15836. /**
  15837. * Parse properties from a JSON object
  15838. * @param serializationObject defines the JSON object
  15839. */
  15840. parse(serializationObject: any): void;
  15841. }
  15842. }
  15843. declare module BABYLON {
  15844. /**
  15845. * Particle emitter emitting particles from the inside of a cylinder.
  15846. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15847. */
  15848. export class CylinderParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance CylinderParticleEmitter
  15867. * @param radius the radius of the emission cylinder (1 by default)
  15868. * @param height the height of the emission cylinder (1 by default)
  15869. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15870. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15871. */
  15872. constructor(
  15873. /**
  15874. * The radius of the emission cylinder.
  15875. */
  15876. radius?: number,
  15877. /**
  15878. * The height of the emission cylinder.
  15879. */
  15880. height?: number,
  15881. /**
  15882. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15883. */
  15884. radiusRange?: number,
  15885. /**
  15886. * How much to randomize the particle direction [0-1].
  15887. */
  15888. directionRandomizer?: number);
  15889. /**
  15890. * Called by the particle System when the direction is computed for the created particle.
  15891. * @param worldMatrix is the world matrix of the particle system
  15892. * @param directionToUpdate is the direction vector to update with the result
  15893. * @param particle is the particle we are computed the direction for
  15894. * @param isLocal defines if the direction should be set in local space
  15895. */
  15896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15897. /**
  15898. * Called by the particle System when the position is computed for the created particle.
  15899. * @param worldMatrix is the world matrix of the particle system
  15900. * @param positionToUpdate is the position vector to update with the result
  15901. * @param particle is the particle we are computed the position for
  15902. * @param isLocal defines if the position should be set in local space
  15903. */
  15904. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15905. /**
  15906. * Clones the current emitter and returns a copy of it
  15907. * @returns the new emitter
  15908. */
  15909. clone(): CylinderParticleEmitter;
  15910. /**
  15911. * Called by the GPUParticleSystem to setup the update shader
  15912. * @param effect defines the update shader
  15913. */
  15914. applyToShader(effect: Effect): void;
  15915. /**
  15916. * Returns a string to use to update the GPU particles update shader
  15917. * @returns a string containng the defines string
  15918. */
  15919. getEffectDefines(): string;
  15920. /**
  15921. * Returns the string "CylinderParticleEmitter"
  15922. * @returns a string containing the class name
  15923. */
  15924. getClassName(): string;
  15925. /**
  15926. * Serializes the particle system to a JSON object.
  15927. * @returns the JSON object
  15928. */
  15929. serialize(): any;
  15930. /**
  15931. * Parse properties from a JSON object
  15932. * @param serializationObject defines the JSON object
  15933. */
  15934. parse(serializationObject: any): void;
  15935. }
  15936. /**
  15937. * Particle emitter emitting particles from the inside of a cylinder.
  15938. * It emits the particles randomly between two vectors.
  15939. */
  15940. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15941. /**
  15942. * The min limit of the emission direction.
  15943. */
  15944. direction1: Vector3;
  15945. /**
  15946. * The max limit of the emission direction.
  15947. */
  15948. direction2: Vector3;
  15949. /**
  15950. * Creates a new instance CylinderDirectedParticleEmitter
  15951. * @param radius the radius of the emission cylinder (1 by default)
  15952. * @param height the height of the emission cylinder (1 by default)
  15953. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15954. * @param direction1 the min limit of the emission direction (up vector by default)
  15955. * @param direction2 the max limit of the emission direction (up vector by default)
  15956. */
  15957. constructor(radius?: number, height?: number, radiusRange?: number,
  15958. /**
  15959. * The min limit of the emission direction.
  15960. */
  15961. direction1?: Vector3,
  15962. /**
  15963. * The max limit of the emission direction.
  15964. */
  15965. direction2?: Vector3);
  15966. /**
  15967. * Called by the particle System when the direction is computed for the created particle.
  15968. * @param worldMatrix is the world matrix of the particle system
  15969. * @param directionToUpdate is the direction vector to update with the result
  15970. * @param particle is the particle we are computed the direction for
  15971. */
  15972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15973. /**
  15974. * Clones the current emitter and returns a copy of it
  15975. * @returns the new emitter
  15976. */
  15977. clone(): CylinderDirectedParticleEmitter;
  15978. /**
  15979. * Called by the GPUParticleSystem to setup the update shader
  15980. * @param effect defines the update shader
  15981. */
  15982. applyToShader(effect: Effect): void;
  15983. /**
  15984. * Returns a string to use to update the GPU particles update shader
  15985. * @returns a string containng the defines string
  15986. */
  15987. getEffectDefines(): string;
  15988. /**
  15989. * Returns the string "CylinderDirectedParticleEmitter"
  15990. * @returns a string containing the class name
  15991. */
  15992. getClassName(): string;
  15993. /**
  15994. * Serializes the particle system to a JSON object.
  15995. * @returns the JSON object
  15996. */
  15997. serialize(): any;
  15998. /**
  15999. * Parse properties from a JSON object
  16000. * @param serializationObject defines the JSON object
  16001. */
  16002. parse(serializationObject: any): void;
  16003. }
  16004. }
  16005. declare module BABYLON {
  16006. /**
  16007. * Particle emitter emitting particles from the inside of a hemisphere.
  16008. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16009. */
  16010. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16011. /**
  16012. * The radius of the emission hemisphere.
  16013. */
  16014. radius: number;
  16015. /**
  16016. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16017. */
  16018. radiusRange: number;
  16019. /**
  16020. * How much to randomize the particle direction [0-1].
  16021. */
  16022. directionRandomizer: number;
  16023. /**
  16024. * Creates a new instance HemisphericParticleEmitter
  16025. * @param radius the radius of the emission hemisphere (1 by default)
  16026. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16027. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16028. */
  16029. constructor(
  16030. /**
  16031. * The radius of the emission hemisphere.
  16032. */
  16033. radius?: number,
  16034. /**
  16035. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16036. */
  16037. radiusRange?: number,
  16038. /**
  16039. * How much to randomize the particle direction [0-1].
  16040. */
  16041. directionRandomizer?: number);
  16042. /**
  16043. * Called by the particle System when the direction is computed for the created particle.
  16044. * @param worldMatrix is the world matrix of the particle system
  16045. * @param directionToUpdate is the direction vector to update with the result
  16046. * @param particle is the particle we are computed the direction for
  16047. * @param isLocal defines if the direction should be set in local space
  16048. */
  16049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16050. /**
  16051. * Called by the particle System when the position is computed for the created particle.
  16052. * @param worldMatrix is the world matrix of the particle system
  16053. * @param positionToUpdate is the position vector to update with the result
  16054. * @param particle is the particle we are computed the position for
  16055. * @param isLocal defines if the position should be set in local space
  16056. */
  16057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16058. /**
  16059. * Clones the current emitter and returns a copy of it
  16060. * @returns the new emitter
  16061. */
  16062. clone(): HemisphericParticleEmitter;
  16063. /**
  16064. * Called by the GPUParticleSystem to setup the update shader
  16065. * @param effect defines the update shader
  16066. */
  16067. applyToShader(effect: Effect): void;
  16068. /**
  16069. * Returns a string to use to update the GPU particles update shader
  16070. * @returns a string containng the defines string
  16071. */
  16072. getEffectDefines(): string;
  16073. /**
  16074. * Returns the string "HemisphericParticleEmitter"
  16075. * @returns a string containing the class name
  16076. */
  16077. getClassName(): string;
  16078. /**
  16079. * Serializes the particle system to a JSON object.
  16080. * @returns the JSON object
  16081. */
  16082. serialize(): any;
  16083. /**
  16084. * Parse properties from a JSON object
  16085. * @param serializationObject defines the JSON object
  16086. */
  16087. parse(serializationObject: any): void;
  16088. }
  16089. }
  16090. declare module BABYLON {
  16091. /**
  16092. * Particle emitter emitting particles from a point.
  16093. * It emits the particles randomly between 2 given directions.
  16094. */
  16095. export class PointParticleEmitter implements IParticleEmitterType {
  16096. /**
  16097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16098. */
  16099. direction1: Vector3;
  16100. /**
  16101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16102. */
  16103. direction2: Vector3;
  16104. /**
  16105. * Creates a new instance PointParticleEmitter
  16106. */
  16107. constructor();
  16108. /**
  16109. * Called by the particle System when the direction is computed for the created particle.
  16110. * @param worldMatrix is the world matrix of the particle system
  16111. * @param directionToUpdate is the direction vector to update with the result
  16112. * @param particle is the particle we are computed the direction for
  16113. * @param isLocal defines if the direction should be set in local space
  16114. */
  16115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16116. /**
  16117. * Called by the particle System when the position is computed for the created particle.
  16118. * @param worldMatrix is the world matrix of the particle system
  16119. * @param positionToUpdate is the position vector to update with the result
  16120. * @param particle is the particle we are computed the position for
  16121. * @param isLocal defines if the position should be set in local space
  16122. */
  16123. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16124. /**
  16125. * Clones the current emitter and returns a copy of it
  16126. * @returns the new emitter
  16127. */
  16128. clone(): PointParticleEmitter;
  16129. /**
  16130. * Called by the GPUParticleSystem to setup the update shader
  16131. * @param effect defines the update shader
  16132. */
  16133. applyToShader(effect: Effect): void;
  16134. /**
  16135. * Returns a string to use to update the GPU particles update shader
  16136. * @returns a string containng the defines string
  16137. */
  16138. getEffectDefines(): string;
  16139. /**
  16140. * Returns the string "PointParticleEmitter"
  16141. * @returns a string containing the class name
  16142. */
  16143. getClassName(): string;
  16144. /**
  16145. * Serializes the particle system to a JSON object.
  16146. * @returns the JSON object
  16147. */
  16148. serialize(): any;
  16149. /**
  16150. * Parse properties from a JSON object
  16151. * @param serializationObject defines the JSON object
  16152. */
  16153. parse(serializationObject: any): void;
  16154. }
  16155. }
  16156. declare module BABYLON {
  16157. /**
  16158. * Particle emitter emitting particles from the inside of a sphere.
  16159. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16160. */
  16161. export class SphereParticleEmitter implements IParticleEmitterType {
  16162. /**
  16163. * The radius of the emission sphere.
  16164. */
  16165. radius: number;
  16166. /**
  16167. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16168. */
  16169. radiusRange: number;
  16170. /**
  16171. * How much to randomize the particle direction [0-1].
  16172. */
  16173. directionRandomizer: number;
  16174. /**
  16175. * Creates a new instance SphereParticleEmitter
  16176. * @param radius the radius of the emission sphere (1 by default)
  16177. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16178. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16179. */
  16180. constructor(
  16181. /**
  16182. * The radius of the emission sphere.
  16183. */
  16184. radius?: number,
  16185. /**
  16186. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16187. */
  16188. radiusRange?: number,
  16189. /**
  16190. * How much to randomize the particle direction [0-1].
  16191. */
  16192. directionRandomizer?: number);
  16193. /**
  16194. * Called by the particle System when the direction is computed for the created particle.
  16195. * @param worldMatrix is the world matrix of the particle system
  16196. * @param directionToUpdate is the direction vector to update with the result
  16197. * @param particle is the particle we are computed the direction for
  16198. * @param isLocal defines if the direction should be set in local space
  16199. */
  16200. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16201. /**
  16202. * Called by the particle System when the position is computed for the created particle.
  16203. * @param worldMatrix is the world matrix of the particle system
  16204. * @param positionToUpdate is the position vector to update with the result
  16205. * @param particle is the particle we are computed the position for
  16206. * @param isLocal defines if the position should be set in local space
  16207. */
  16208. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16209. /**
  16210. * Clones the current emitter and returns a copy of it
  16211. * @returns the new emitter
  16212. */
  16213. clone(): SphereParticleEmitter;
  16214. /**
  16215. * Called by the GPUParticleSystem to setup the update shader
  16216. * @param effect defines the update shader
  16217. */
  16218. applyToShader(effect: Effect): void;
  16219. /**
  16220. * Returns a string to use to update the GPU particles update shader
  16221. * @returns a string containng the defines string
  16222. */
  16223. getEffectDefines(): string;
  16224. /**
  16225. * Returns the string "SphereParticleEmitter"
  16226. * @returns a string containing the class name
  16227. */
  16228. getClassName(): string;
  16229. /**
  16230. * Serializes the particle system to a JSON object.
  16231. * @returns the JSON object
  16232. */
  16233. serialize(): any;
  16234. /**
  16235. * Parse properties from a JSON object
  16236. * @param serializationObject defines the JSON object
  16237. */
  16238. parse(serializationObject: any): void;
  16239. }
  16240. /**
  16241. * Particle emitter emitting particles from the inside of a sphere.
  16242. * It emits the particles randomly between two vectors.
  16243. */
  16244. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16245. /**
  16246. * The min limit of the emission direction.
  16247. */
  16248. direction1: Vector3;
  16249. /**
  16250. * The max limit of the emission direction.
  16251. */
  16252. direction2: Vector3;
  16253. /**
  16254. * Creates a new instance SphereDirectedParticleEmitter
  16255. * @param radius the radius of the emission sphere (1 by default)
  16256. * @param direction1 the min limit of the emission direction (up vector by default)
  16257. * @param direction2 the max limit of the emission direction (up vector by default)
  16258. */
  16259. constructor(radius?: number,
  16260. /**
  16261. * The min limit of the emission direction.
  16262. */
  16263. direction1?: Vector3,
  16264. /**
  16265. * The max limit of the emission direction.
  16266. */
  16267. direction2?: Vector3);
  16268. /**
  16269. * Called by the particle System when the direction is computed for the created particle.
  16270. * @param worldMatrix is the world matrix of the particle system
  16271. * @param directionToUpdate is the direction vector to update with the result
  16272. * @param particle is the particle we are computed the direction for
  16273. */
  16274. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16275. /**
  16276. * Clones the current emitter and returns a copy of it
  16277. * @returns the new emitter
  16278. */
  16279. clone(): SphereDirectedParticleEmitter;
  16280. /**
  16281. * Called by the GPUParticleSystem to setup the update shader
  16282. * @param effect defines the update shader
  16283. */
  16284. applyToShader(effect: Effect): void;
  16285. /**
  16286. * Returns a string to use to update the GPU particles update shader
  16287. * @returns a string containng the defines string
  16288. */
  16289. getEffectDefines(): string;
  16290. /**
  16291. * Returns the string "SphereDirectedParticleEmitter"
  16292. * @returns a string containing the class name
  16293. */
  16294. getClassName(): string;
  16295. /**
  16296. * Serializes the particle system to a JSON object.
  16297. * @returns the JSON object
  16298. */
  16299. serialize(): any;
  16300. /**
  16301. * Parse properties from a JSON object
  16302. * @param serializationObject defines the JSON object
  16303. */
  16304. parse(serializationObject: any): void;
  16305. }
  16306. }
  16307. declare module BABYLON {
  16308. /**
  16309. * Particle emitter emitting particles from a custom list of positions.
  16310. */
  16311. export class CustomParticleEmitter implements IParticleEmitterType {
  16312. /**
  16313. * Gets or sets the position generator that will create the inital position of each particle.
  16314. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16315. */
  16316. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16317. /**
  16318. * Gets or sets the destination generator that will create the final destination of each particle.
  16319. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16320. */
  16321. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16322. /**
  16323. * Creates a new instance CustomParticleEmitter
  16324. */
  16325. constructor();
  16326. /**
  16327. * Called by the particle System when the direction is computed for the created particle.
  16328. * @param worldMatrix is the world matrix of the particle system
  16329. * @param directionToUpdate is the direction vector to update with the result
  16330. * @param particle is the particle we are computed the direction for
  16331. * @param isLocal defines if the direction should be set in local space
  16332. */
  16333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16334. /**
  16335. * Called by the particle System when the position is computed for the created particle.
  16336. * @param worldMatrix is the world matrix of the particle system
  16337. * @param positionToUpdate is the position vector to update with the result
  16338. * @param particle is the particle we are computed the position for
  16339. * @param isLocal defines if the position should be set in local space
  16340. */
  16341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16342. /**
  16343. * Clones the current emitter and returns a copy of it
  16344. * @returns the new emitter
  16345. */
  16346. clone(): CustomParticleEmitter;
  16347. /**
  16348. * Called by the GPUParticleSystem to setup the update shader
  16349. * @param effect defines the update shader
  16350. */
  16351. applyToShader(effect: Effect): void;
  16352. /**
  16353. * Returns a string to use to update the GPU particles update shader
  16354. * @returns a string containng the defines string
  16355. */
  16356. getEffectDefines(): string;
  16357. /**
  16358. * Returns the string "PointParticleEmitter"
  16359. * @returns a string containing the class name
  16360. */
  16361. getClassName(): string;
  16362. /**
  16363. * Serializes the particle system to a JSON object.
  16364. * @returns the JSON object
  16365. */
  16366. serialize(): any;
  16367. /**
  16368. * Parse properties from a JSON object
  16369. * @param serializationObject defines the JSON object
  16370. */
  16371. parse(serializationObject: any): void;
  16372. }
  16373. }
  16374. declare module BABYLON {
  16375. /**
  16376. * Particle emitter emitting particles from the inside of a box.
  16377. * It emits the particles randomly between 2 given directions.
  16378. */
  16379. export class MeshParticleEmitter implements IParticleEmitterType {
  16380. private _indices;
  16381. private _positions;
  16382. private _normals;
  16383. private _storedNormal;
  16384. private _mesh;
  16385. /**
  16386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16387. */
  16388. direction1: Vector3;
  16389. /**
  16390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16391. */
  16392. direction2: Vector3;
  16393. /**
  16394. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16395. */
  16396. useMeshNormalsForDirection: boolean;
  16397. /** Defines the mesh to use as source */
  16398. get mesh(): Nullable<AbstractMesh>;
  16399. set mesh(value: Nullable<AbstractMesh>);
  16400. /**
  16401. * Creates a new instance MeshParticleEmitter
  16402. * @param mesh defines the mesh to use as source
  16403. */
  16404. constructor(mesh?: Nullable<AbstractMesh>);
  16405. /**
  16406. * Called by the particle System when the direction is computed for the created particle.
  16407. * @param worldMatrix is the world matrix of the particle system
  16408. * @param directionToUpdate is the direction vector to update with the result
  16409. * @param particle is the particle we are computed the direction for
  16410. * @param isLocal defines if the direction should be set in local space
  16411. */
  16412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16413. /**
  16414. * Called by the particle System when the position is computed for the created particle.
  16415. * @param worldMatrix is the world matrix of the particle system
  16416. * @param positionToUpdate is the position vector to update with the result
  16417. * @param particle is the particle we are computed the position for
  16418. * @param isLocal defines if the position should be set in local space
  16419. */
  16420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16421. /**
  16422. * Clones the current emitter and returns a copy of it
  16423. * @returns the new emitter
  16424. */
  16425. clone(): MeshParticleEmitter;
  16426. /**
  16427. * Called by the GPUParticleSystem to setup the update shader
  16428. * @param effect defines the update shader
  16429. */
  16430. applyToShader(effect: Effect): void;
  16431. /**
  16432. * Returns a string to use to update the GPU particles update shader
  16433. * @returns a string containng the defines string
  16434. */
  16435. getEffectDefines(): string;
  16436. /**
  16437. * Returns the string "BoxParticleEmitter"
  16438. * @returns a string containing the class name
  16439. */
  16440. getClassName(): string;
  16441. /**
  16442. * Serializes the particle system to a JSON object.
  16443. * @returns the JSON object
  16444. */
  16445. serialize(): any;
  16446. /**
  16447. * Parse properties from a JSON object
  16448. * @param serializationObject defines the JSON object
  16449. * @param scene defines the hosting scene
  16450. */
  16451. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16452. }
  16453. }
  16454. declare module BABYLON {
  16455. /**
  16456. * Interface representing a particle system in Babylon.js.
  16457. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16458. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16459. */
  16460. export interface IParticleSystem {
  16461. /**
  16462. * List of animations used by the particle system.
  16463. */
  16464. animations: Animation[];
  16465. /**
  16466. * The id of the Particle system.
  16467. */
  16468. id: string;
  16469. /**
  16470. * The name of the Particle system.
  16471. */
  16472. name: string;
  16473. /**
  16474. * The emitter represents the Mesh or position we are attaching the particle system to.
  16475. */
  16476. emitter: Nullable<AbstractMesh | Vector3>;
  16477. /**
  16478. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16479. */
  16480. isBillboardBased: boolean;
  16481. /**
  16482. * The rendering group used by the Particle system to chose when to render.
  16483. */
  16484. renderingGroupId: number;
  16485. /**
  16486. * The layer mask we are rendering the particles through.
  16487. */
  16488. layerMask: number;
  16489. /**
  16490. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16491. */
  16492. updateSpeed: number;
  16493. /**
  16494. * The amount of time the particle system is running (depends of the overall update speed).
  16495. */
  16496. targetStopDuration: number;
  16497. /**
  16498. * The texture used to render each particle. (this can be a spritesheet)
  16499. */
  16500. particleTexture: Nullable<BaseTexture>;
  16501. /**
  16502. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16503. */
  16504. blendMode: number;
  16505. /**
  16506. * Minimum life time of emitting particles.
  16507. */
  16508. minLifeTime: number;
  16509. /**
  16510. * Maximum life time of emitting particles.
  16511. */
  16512. maxLifeTime: number;
  16513. /**
  16514. * Minimum Size of emitting particles.
  16515. */
  16516. minSize: number;
  16517. /**
  16518. * Maximum Size of emitting particles.
  16519. */
  16520. maxSize: number;
  16521. /**
  16522. * Minimum scale of emitting particles on X axis.
  16523. */
  16524. minScaleX: number;
  16525. /**
  16526. * Maximum scale of emitting particles on X axis.
  16527. */
  16528. maxScaleX: number;
  16529. /**
  16530. * Minimum scale of emitting particles on Y axis.
  16531. */
  16532. minScaleY: number;
  16533. /**
  16534. * Maximum scale of emitting particles on Y axis.
  16535. */
  16536. maxScaleY: number;
  16537. /**
  16538. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16539. */
  16540. color1: Color4;
  16541. /**
  16542. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16543. */
  16544. color2: Color4;
  16545. /**
  16546. * Color the particle will have at the end of its lifetime.
  16547. */
  16548. colorDead: Color4;
  16549. /**
  16550. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16551. */
  16552. emitRate: number;
  16553. /**
  16554. * You can use gravity if you want to give an orientation to your particles.
  16555. */
  16556. gravity: Vector3;
  16557. /**
  16558. * Minimum power of emitting particles.
  16559. */
  16560. minEmitPower: number;
  16561. /**
  16562. * Maximum power of emitting particles.
  16563. */
  16564. maxEmitPower: number;
  16565. /**
  16566. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16567. */
  16568. minAngularSpeed: number;
  16569. /**
  16570. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16571. */
  16572. maxAngularSpeed: number;
  16573. /**
  16574. * Gets or sets the minimal initial rotation in radians.
  16575. */
  16576. minInitialRotation: number;
  16577. /**
  16578. * Gets or sets the maximal initial rotation in radians.
  16579. */
  16580. maxInitialRotation: number;
  16581. /**
  16582. * The particle emitter type defines the emitter used by the particle system.
  16583. * It can be for example box, sphere, or cone...
  16584. */
  16585. particleEmitterType: Nullable<IParticleEmitterType>;
  16586. /**
  16587. * Defines the delay in milliseconds before starting the system (0 by default)
  16588. */
  16589. startDelay: number;
  16590. /**
  16591. * 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
  16592. */
  16593. preWarmCycles: number;
  16594. /**
  16595. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16596. */
  16597. preWarmStepOffset: number;
  16598. /**
  16599. * 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)
  16600. */
  16601. spriteCellChangeSpeed: number;
  16602. /**
  16603. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16604. */
  16605. startSpriteCellID: number;
  16606. /**
  16607. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16608. */
  16609. endSpriteCellID: number;
  16610. /**
  16611. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16612. */
  16613. spriteCellWidth: number;
  16614. /**
  16615. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16616. */
  16617. spriteCellHeight: number;
  16618. /**
  16619. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16620. */
  16621. spriteRandomStartCell: boolean;
  16622. /**
  16623. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16624. */
  16625. isAnimationSheetEnabled: boolean;
  16626. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16627. translationPivot: Vector2;
  16628. /**
  16629. * Gets or sets a texture used to add random noise to particle positions
  16630. */
  16631. noiseTexture: Nullable<BaseTexture>;
  16632. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16633. noiseStrength: Vector3;
  16634. /**
  16635. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16636. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16637. */
  16638. billboardMode: number;
  16639. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16640. limitVelocityDamping: number;
  16641. /**
  16642. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16643. */
  16644. beginAnimationOnStart: boolean;
  16645. /**
  16646. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16647. */
  16648. beginAnimationFrom: number;
  16649. /**
  16650. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16651. */
  16652. beginAnimationTo: number;
  16653. /**
  16654. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16655. */
  16656. beginAnimationLoop: boolean;
  16657. /**
  16658. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16659. */
  16660. disposeOnStop: boolean;
  16661. /**
  16662. * Specifies if the particles are updated in emitter local space or world space
  16663. */
  16664. isLocal: boolean;
  16665. /** Snippet ID if the particle system was created from the snippet server */
  16666. snippetId: string;
  16667. /** Gets or sets a matrix to use to compute projection */
  16668. defaultProjectionMatrix: Matrix;
  16669. /**
  16670. * Gets the maximum number of particles active at the same time.
  16671. * @returns The max number of active particles.
  16672. */
  16673. getCapacity(): number;
  16674. /**
  16675. * Gets the number of particles active at the same time.
  16676. * @returns The number of active particles.
  16677. */
  16678. getActiveCount(): number;
  16679. /**
  16680. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16681. * @returns True if it has been started, otherwise false.
  16682. */
  16683. isStarted(): boolean;
  16684. /**
  16685. * Animates the particle system for this frame.
  16686. */
  16687. animate(): void;
  16688. /**
  16689. * Renders the particle system in its current state.
  16690. * @returns the current number of particles
  16691. */
  16692. render(): number;
  16693. /**
  16694. * Dispose the particle system and frees its associated resources.
  16695. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16696. */
  16697. dispose(disposeTexture?: boolean): void;
  16698. /**
  16699. * An event triggered when the system is disposed
  16700. */
  16701. onDisposeObservable: Observable<IParticleSystem>;
  16702. /**
  16703. * An event triggered when the system is stopped
  16704. */
  16705. onStoppedObservable: Observable<IParticleSystem>;
  16706. /**
  16707. * Clones the particle system.
  16708. * @param name The name of the cloned object
  16709. * @param newEmitter The new emitter to use
  16710. * @returns the cloned particle system
  16711. */
  16712. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16713. /**
  16714. * Serializes the particle system to a JSON object
  16715. * @param serializeTexture defines if the texture must be serialized as well
  16716. * @returns the JSON object
  16717. */
  16718. serialize(serializeTexture: boolean): any;
  16719. /**
  16720. * Rebuild the particle system
  16721. */
  16722. rebuild(): void;
  16723. /** Force the system to rebuild all gradients that need to be resync */
  16724. forceRefreshGradients(): void;
  16725. /**
  16726. * Starts the particle system and begins to emit
  16727. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16728. */
  16729. start(delay?: number): void;
  16730. /**
  16731. * Stops the particle system.
  16732. */
  16733. stop(): void;
  16734. /**
  16735. * Remove all active particles
  16736. */
  16737. reset(): void;
  16738. /**
  16739. * Gets a boolean indicating that the system is stopping
  16740. * @returns true if the system is currently stopping
  16741. */
  16742. isStopping(): boolean;
  16743. /**
  16744. * Is this system ready to be used/rendered
  16745. * @return true if the system is ready
  16746. */
  16747. isReady(): boolean;
  16748. /**
  16749. * Returns the string "ParticleSystem"
  16750. * @returns a string containing the class name
  16751. */
  16752. getClassName(): string;
  16753. /**
  16754. * Gets the custom effect used to render the particles
  16755. * @param blendMode Blend mode for which the effect should be retrieved
  16756. * @returns The effect
  16757. */
  16758. getCustomEffect(blendMode: number): Nullable<Effect>;
  16759. /**
  16760. * Sets the custom effect used to render the particles
  16761. * @param effect The effect to set
  16762. * @param blendMode Blend mode for which the effect should be set
  16763. */
  16764. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16765. /**
  16766. * Fill the defines array according to the current settings of the particle system
  16767. * @param defines Array to be updated
  16768. * @param blendMode blend mode to take into account when updating the array
  16769. */
  16770. fillDefines(defines: Array<string>, blendMode: number): void;
  16771. /**
  16772. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16773. * @param uniforms Uniforms array to fill
  16774. * @param attributes Attributes array to fill
  16775. * @param samplers Samplers array to fill
  16776. */
  16777. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16778. /**
  16779. * Observable that will be called just before the particles are drawn
  16780. */
  16781. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16782. /**
  16783. * Gets the name of the particle vertex shader
  16784. */
  16785. vertexShaderName: string;
  16786. /**
  16787. * Adds a new color gradient
  16788. * @param gradient defines the gradient to use (between 0 and 1)
  16789. * @param color1 defines the color to affect to the specified gradient
  16790. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16791. * @returns the current particle system
  16792. */
  16793. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16794. /**
  16795. * Remove a specific color gradient
  16796. * @param gradient defines the gradient to remove
  16797. * @returns the current particle system
  16798. */
  16799. removeColorGradient(gradient: number): IParticleSystem;
  16800. /**
  16801. * Adds a new size gradient
  16802. * @param gradient defines the gradient to use (between 0 and 1)
  16803. * @param factor defines the size factor to affect to the specified gradient
  16804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16805. * @returns the current particle system
  16806. */
  16807. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16808. /**
  16809. * Remove a specific size gradient
  16810. * @param gradient defines the gradient to remove
  16811. * @returns the current particle system
  16812. */
  16813. removeSizeGradient(gradient: number): IParticleSystem;
  16814. /**
  16815. * Gets the current list of color gradients.
  16816. * You must use addColorGradient and removeColorGradient to udpate this list
  16817. * @returns the list of color gradients
  16818. */
  16819. getColorGradients(): Nullable<Array<ColorGradient>>;
  16820. /**
  16821. * Gets the current list of size gradients.
  16822. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16823. * @returns the list of size gradients
  16824. */
  16825. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16826. /**
  16827. * Gets the current list of angular speed gradients.
  16828. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16829. * @returns the list of angular speed gradients
  16830. */
  16831. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16832. /**
  16833. * Adds a new angular speed gradient
  16834. * @param gradient defines the gradient to use (between 0 and 1)
  16835. * @param factor defines the angular speed to affect to the specified gradient
  16836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16837. * @returns the current particle system
  16838. */
  16839. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16840. /**
  16841. * Remove a specific angular speed gradient
  16842. * @param gradient defines the gradient to remove
  16843. * @returns the current particle system
  16844. */
  16845. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16846. /**
  16847. * Gets the current list of velocity gradients.
  16848. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16849. * @returns the list of velocity gradients
  16850. */
  16851. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16852. /**
  16853. * Adds a new velocity gradient
  16854. * @param gradient defines the gradient to use (between 0 and 1)
  16855. * @param factor defines the velocity to affect to the specified gradient
  16856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16857. * @returns the current particle system
  16858. */
  16859. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16860. /**
  16861. * Remove a specific velocity gradient
  16862. * @param gradient defines the gradient to remove
  16863. * @returns the current particle system
  16864. */
  16865. removeVelocityGradient(gradient: number): IParticleSystem;
  16866. /**
  16867. * Gets the current list of limit velocity gradients.
  16868. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16869. * @returns the list of limit velocity gradients
  16870. */
  16871. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16872. /**
  16873. * Adds a new limit velocity gradient
  16874. * @param gradient defines the gradient to use (between 0 and 1)
  16875. * @param factor defines the limit velocity to affect to the specified gradient
  16876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16877. * @returns the current particle system
  16878. */
  16879. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16880. /**
  16881. * Remove a specific limit velocity gradient
  16882. * @param gradient defines the gradient to remove
  16883. * @returns the current particle system
  16884. */
  16885. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16886. /**
  16887. * Adds a new drag gradient
  16888. * @param gradient defines the gradient to use (between 0 and 1)
  16889. * @param factor defines the drag to affect to the specified gradient
  16890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16891. * @returns the current particle system
  16892. */
  16893. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16894. /**
  16895. * Remove a specific drag gradient
  16896. * @param gradient defines the gradient to remove
  16897. * @returns the current particle system
  16898. */
  16899. removeDragGradient(gradient: number): IParticleSystem;
  16900. /**
  16901. * Gets the current list of drag gradients.
  16902. * You must use addDragGradient and removeDragGradient to udpate this list
  16903. * @returns the list of drag gradients
  16904. */
  16905. getDragGradients(): Nullable<Array<FactorGradient>>;
  16906. /**
  16907. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16908. * @param gradient defines the gradient to use (between 0 and 1)
  16909. * @param factor defines the emit rate to affect to the specified gradient
  16910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16911. * @returns the current particle system
  16912. */
  16913. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16914. /**
  16915. * Remove a specific emit rate gradient
  16916. * @param gradient defines the gradient to remove
  16917. * @returns the current particle system
  16918. */
  16919. removeEmitRateGradient(gradient: number): IParticleSystem;
  16920. /**
  16921. * Gets the current list of emit rate gradients.
  16922. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16923. * @returns the list of emit rate gradients
  16924. */
  16925. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16926. /**
  16927. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16928. * @param gradient defines the gradient to use (between 0 and 1)
  16929. * @param factor defines the start size to affect to the specified gradient
  16930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16931. * @returns the current particle system
  16932. */
  16933. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16934. /**
  16935. * Remove a specific start size gradient
  16936. * @param gradient defines the gradient to remove
  16937. * @returns the current particle system
  16938. */
  16939. removeStartSizeGradient(gradient: number): IParticleSystem;
  16940. /**
  16941. * Gets the current list of start size gradients.
  16942. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16943. * @returns the list of start size gradients
  16944. */
  16945. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16946. /**
  16947. * Adds a new life time gradient
  16948. * @param gradient defines the gradient to use (between 0 and 1)
  16949. * @param factor defines the life time factor to affect to the specified gradient
  16950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16951. * @returns the current particle system
  16952. */
  16953. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16954. /**
  16955. * Remove a specific life time gradient
  16956. * @param gradient defines the gradient to remove
  16957. * @returns the current particle system
  16958. */
  16959. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16960. /**
  16961. * Gets the current list of life time gradients.
  16962. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16963. * @returns the list of life time gradients
  16964. */
  16965. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16966. /**
  16967. * Gets the current list of color gradients.
  16968. * You must use addColorGradient and removeColorGradient to udpate this list
  16969. * @returns the list of color gradients
  16970. */
  16971. getColorGradients(): Nullable<Array<ColorGradient>>;
  16972. /**
  16973. * Adds a new ramp gradient used to remap particle colors
  16974. * @param gradient defines the gradient to use (between 0 and 1)
  16975. * @param color defines the color to affect to the specified gradient
  16976. * @returns the current particle system
  16977. */
  16978. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16979. /**
  16980. * Gets the current list of ramp gradients.
  16981. * You must use addRampGradient and removeRampGradient to udpate this list
  16982. * @returns the list of ramp gradients
  16983. */
  16984. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16985. /** Gets or sets a boolean indicating that ramp gradients must be used
  16986. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16987. */
  16988. useRampGradients: boolean;
  16989. /**
  16990. * Adds a new color remap gradient
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param min defines the color remap minimal range
  16993. * @param max defines the color remap maximal range
  16994. * @returns the current particle system
  16995. */
  16996. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16997. /**
  16998. * Gets the current list of color remap gradients.
  16999. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17000. * @returns the list of color remap gradients
  17001. */
  17002. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17003. /**
  17004. * Adds a new alpha remap gradient
  17005. * @param gradient defines the gradient to use (between 0 and 1)
  17006. * @param min defines the alpha remap minimal range
  17007. * @param max defines the alpha remap maximal range
  17008. * @returns the current particle system
  17009. */
  17010. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17011. /**
  17012. * Gets the current list of alpha remap gradients.
  17013. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17014. * @returns the list of alpha remap gradients
  17015. */
  17016. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17017. /**
  17018. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17019. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17020. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17021. * @returns the emitter
  17022. */
  17023. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17024. /**
  17025. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17026. * @param radius The radius of the hemisphere to emit from
  17027. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17028. * @returns the emitter
  17029. */
  17030. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17031. /**
  17032. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17033. * @param radius The radius of the sphere to emit from
  17034. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17035. * @returns the emitter
  17036. */
  17037. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17038. /**
  17039. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17040. * @param radius The radius of the sphere to emit from
  17041. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17042. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17043. * @returns the emitter
  17044. */
  17045. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17046. /**
  17047. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17048. * @param radius The radius of the emission cylinder
  17049. * @param height The height of the emission cylinder
  17050. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17051. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17052. * @returns the emitter
  17053. */
  17054. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17055. /**
  17056. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17057. * @param radius The radius of the cylinder to emit from
  17058. * @param height The height of the emission cylinder
  17059. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17060. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17061. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17062. * @returns the emitter
  17063. */
  17064. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17065. /**
  17066. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17067. * @param radius The radius of the cone to emit from
  17068. * @param angle The base angle of the cone
  17069. * @returns the emitter
  17070. */
  17071. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17072. /**
  17073. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17074. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17075. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17076. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17077. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17078. * @returns the emitter
  17079. */
  17080. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17081. /**
  17082. * Get hosting scene
  17083. * @returns the scene
  17084. */
  17085. getScene(): Nullable<Scene>;
  17086. }
  17087. }
  17088. declare module BABYLON {
  17089. /**
  17090. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17091. */
  17092. export class ColorSplitterBlock extends NodeMaterialBlock {
  17093. /**
  17094. * Create a new ColorSplitterBlock
  17095. * @param name defines the block name
  17096. */
  17097. constructor(name: string);
  17098. /**
  17099. * Gets the current class name
  17100. * @returns the class name
  17101. */
  17102. getClassName(): string;
  17103. /**
  17104. * Gets the rgba component (input)
  17105. */
  17106. get rgba(): NodeMaterialConnectionPoint;
  17107. /**
  17108. * Gets the rgb component (input)
  17109. */
  17110. get rgbIn(): NodeMaterialConnectionPoint;
  17111. /**
  17112. * Gets the rgb component (output)
  17113. */
  17114. get rgbOut(): NodeMaterialConnectionPoint;
  17115. /**
  17116. * Gets the r component (output)
  17117. */
  17118. get r(): NodeMaterialConnectionPoint;
  17119. /**
  17120. * Gets the g component (output)
  17121. */
  17122. get g(): NodeMaterialConnectionPoint;
  17123. /**
  17124. * Gets the b component (output)
  17125. */
  17126. get b(): NodeMaterialConnectionPoint;
  17127. /**
  17128. * Gets the a component (output)
  17129. */
  17130. get a(): NodeMaterialConnectionPoint;
  17131. protected _inputRename(name: string): string;
  17132. protected _outputRename(name: string): string;
  17133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17134. }
  17135. }
  17136. declare module BABYLON {
  17137. /**
  17138. * Operations supported by the Trigonometry block
  17139. */
  17140. export enum TrigonometryBlockOperations {
  17141. /** Cos */
  17142. Cos = 0,
  17143. /** Sin */
  17144. Sin = 1,
  17145. /** Abs */
  17146. Abs = 2,
  17147. /** Exp */
  17148. Exp = 3,
  17149. /** Exp2 */
  17150. Exp2 = 4,
  17151. /** Round */
  17152. Round = 5,
  17153. /** Floor */
  17154. Floor = 6,
  17155. /** Ceiling */
  17156. Ceiling = 7,
  17157. /** Square root */
  17158. Sqrt = 8,
  17159. /** Log */
  17160. Log = 9,
  17161. /** Tangent */
  17162. Tan = 10,
  17163. /** Arc tangent */
  17164. ArcTan = 11,
  17165. /** Arc cosinus */
  17166. ArcCos = 12,
  17167. /** Arc sinus */
  17168. ArcSin = 13,
  17169. /** Fraction */
  17170. Fract = 14,
  17171. /** Sign */
  17172. Sign = 15,
  17173. /** To radians (from degrees) */
  17174. Radians = 16,
  17175. /** To degrees (from radians) */
  17176. Degrees = 17
  17177. }
  17178. /**
  17179. * Block used to apply trigonometry operation to floats
  17180. */
  17181. export class TrigonometryBlock extends NodeMaterialBlock {
  17182. /**
  17183. * Gets or sets the operation applied by the block
  17184. */
  17185. operation: TrigonometryBlockOperations;
  17186. /**
  17187. * Creates a new TrigonometryBlock
  17188. * @param name defines the block name
  17189. */
  17190. constructor(name: string);
  17191. /**
  17192. * Gets the current class name
  17193. * @returns the class name
  17194. */
  17195. getClassName(): string;
  17196. /**
  17197. * Gets the input component
  17198. */
  17199. get input(): NodeMaterialConnectionPoint;
  17200. /**
  17201. * Gets the output component
  17202. */
  17203. get output(): NodeMaterialConnectionPoint;
  17204. protected _buildBlock(state: NodeMaterialBuildState): this;
  17205. serialize(): any;
  17206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17207. protected _dumpPropertiesCode(): string;
  17208. }
  17209. }
  17210. declare module BABYLON {
  17211. /**
  17212. * Interface used to configure the node material editor
  17213. */
  17214. export interface INodeMaterialEditorOptions {
  17215. /** Define the URl to load node editor script */
  17216. editorURL?: string;
  17217. }
  17218. /** @hidden */
  17219. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17220. NORMAL: boolean;
  17221. TANGENT: boolean;
  17222. UV1: boolean;
  17223. /** BONES */
  17224. NUM_BONE_INFLUENCERS: number;
  17225. BonesPerMesh: number;
  17226. BONETEXTURE: boolean;
  17227. /** MORPH TARGETS */
  17228. MORPHTARGETS: boolean;
  17229. MORPHTARGETS_NORMAL: boolean;
  17230. MORPHTARGETS_TANGENT: boolean;
  17231. MORPHTARGETS_UV: boolean;
  17232. NUM_MORPH_INFLUENCERS: number;
  17233. /** IMAGE PROCESSING */
  17234. IMAGEPROCESSING: boolean;
  17235. VIGNETTE: boolean;
  17236. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17237. VIGNETTEBLENDMODEOPAQUE: boolean;
  17238. TONEMAPPING: boolean;
  17239. TONEMAPPING_ACES: boolean;
  17240. CONTRAST: boolean;
  17241. EXPOSURE: boolean;
  17242. COLORCURVES: boolean;
  17243. COLORGRADING: boolean;
  17244. COLORGRADING3D: boolean;
  17245. SAMPLER3DGREENDEPTH: boolean;
  17246. SAMPLER3DBGRMAP: boolean;
  17247. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17248. /** MISC. */
  17249. BUMPDIRECTUV: number;
  17250. constructor();
  17251. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17252. }
  17253. /**
  17254. * Class used to configure NodeMaterial
  17255. */
  17256. export interface INodeMaterialOptions {
  17257. /**
  17258. * Defines if blocks should emit comments
  17259. */
  17260. emitComments: boolean;
  17261. }
  17262. /**
  17263. * Class used to create a node based material built by assembling shader blocks
  17264. */
  17265. export class NodeMaterial extends PushMaterial {
  17266. private static _BuildIdGenerator;
  17267. private _options;
  17268. private _vertexCompilationState;
  17269. private _fragmentCompilationState;
  17270. private _sharedData;
  17271. private _buildId;
  17272. private _buildWasSuccessful;
  17273. private _cachedWorldViewMatrix;
  17274. private _cachedWorldViewProjectionMatrix;
  17275. private _optimizers;
  17276. private _animationFrame;
  17277. /** Define the Url to load node editor script */
  17278. static EditorURL: string;
  17279. /** Define the Url to load snippets */
  17280. static SnippetUrl: string;
  17281. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17282. static IgnoreTexturesAtLoadTime: boolean;
  17283. private BJSNODEMATERIALEDITOR;
  17284. /** Get the inspector from bundle or global */
  17285. private _getGlobalNodeMaterialEditor;
  17286. /**
  17287. * Snippet ID if the material was created from the snippet server
  17288. */
  17289. snippetId: string;
  17290. /**
  17291. * Gets or sets data used by visual editor
  17292. * @see https://nme.babylonjs.com
  17293. */
  17294. editorData: any;
  17295. /**
  17296. * 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)
  17297. */
  17298. ignoreAlpha: boolean;
  17299. /**
  17300. * Defines the maximum number of lights that can be used in the material
  17301. */
  17302. maxSimultaneousLights: number;
  17303. /**
  17304. * Observable raised when the material is built
  17305. */
  17306. onBuildObservable: Observable<NodeMaterial>;
  17307. /**
  17308. * Gets or sets the root nodes of the material vertex shader
  17309. */
  17310. _vertexOutputNodes: NodeMaterialBlock[];
  17311. /**
  17312. * Gets or sets the root nodes of the material fragment (pixel) shader
  17313. */
  17314. _fragmentOutputNodes: NodeMaterialBlock[];
  17315. /** Gets or sets options to control the node material overall behavior */
  17316. get options(): INodeMaterialOptions;
  17317. set options(options: INodeMaterialOptions);
  17318. /**
  17319. * Default configuration related to image processing available in the standard Material.
  17320. */
  17321. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17322. /**
  17323. * Gets the image processing configuration used either in this material.
  17324. */
  17325. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17326. /**
  17327. * Sets the Default image processing configuration used either in the this material.
  17328. *
  17329. * If sets to null, the scene one is in use.
  17330. */
  17331. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17332. /**
  17333. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17334. */
  17335. attachedBlocks: NodeMaterialBlock[];
  17336. /**
  17337. * Specifies the mode of the node material
  17338. * @hidden
  17339. */
  17340. _mode: NodeMaterialModes;
  17341. /**
  17342. * Gets the mode property
  17343. */
  17344. get mode(): NodeMaterialModes;
  17345. /**
  17346. * A free comment about the material
  17347. */
  17348. comment: string;
  17349. /**
  17350. * Create a new node based material
  17351. * @param name defines the material name
  17352. * @param scene defines the hosting scene
  17353. * @param options defines creation option
  17354. */
  17355. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17356. /**
  17357. * Gets the current class name of the material e.g. "NodeMaterial"
  17358. * @returns the class name
  17359. */
  17360. getClassName(): string;
  17361. /**
  17362. * Keep track of the image processing observer to allow dispose and replace.
  17363. */
  17364. private _imageProcessingObserver;
  17365. /**
  17366. * Attaches a new image processing configuration to the Standard Material.
  17367. * @param configuration
  17368. */
  17369. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17370. /**
  17371. * Get a block by its name
  17372. * @param name defines the name of the block to retrieve
  17373. * @returns the required block or null if not found
  17374. */
  17375. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17376. /**
  17377. * Get a block by its name
  17378. * @param predicate defines the predicate used to find the good candidate
  17379. * @returns the required block or null if not found
  17380. */
  17381. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17382. /**
  17383. * Get an input block by its name
  17384. * @param predicate defines the predicate used to find the good candidate
  17385. * @returns the required input block or null if not found
  17386. */
  17387. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17388. /**
  17389. * Gets the list of input blocks attached to this material
  17390. * @returns an array of InputBlocks
  17391. */
  17392. getInputBlocks(): InputBlock[];
  17393. /**
  17394. * Adds a new optimizer to the list of optimizers
  17395. * @param optimizer defines the optimizers to add
  17396. * @returns the current material
  17397. */
  17398. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17399. /**
  17400. * Remove an optimizer from the list of optimizers
  17401. * @param optimizer defines the optimizers to remove
  17402. * @returns the current material
  17403. */
  17404. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17405. /**
  17406. * Add a new block to the list of output nodes
  17407. * @param node defines the node to add
  17408. * @returns the current material
  17409. */
  17410. addOutputNode(node: NodeMaterialBlock): this;
  17411. /**
  17412. * Remove a block from the list of root nodes
  17413. * @param node defines the node to remove
  17414. * @returns the current material
  17415. */
  17416. removeOutputNode(node: NodeMaterialBlock): this;
  17417. private _addVertexOutputNode;
  17418. private _removeVertexOutputNode;
  17419. private _addFragmentOutputNode;
  17420. private _removeFragmentOutputNode;
  17421. /**
  17422. * Specifies if the material will require alpha blending
  17423. * @returns a boolean specifying if alpha blending is needed
  17424. */
  17425. needAlphaBlending(): boolean;
  17426. /**
  17427. * Specifies if this material should be rendered in alpha test mode
  17428. * @returns a boolean specifying if an alpha test is needed.
  17429. */
  17430. needAlphaTesting(): boolean;
  17431. private _initializeBlock;
  17432. private _resetDualBlocks;
  17433. /**
  17434. * Remove a block from the current node material
  17435. * @param block defines the block to remove
  17436. */
  17437. removeBlock(block: NodeMaterialBlock): void;
  17438. /**
  17439. * Build the material and generates the inner effect
  17440. * @param verbose defines if the build should log activity
  17441. */
  17442. build(verbose?: boolean): void;
  17443. /**
  17444. * Runs an otpimization phase to try to improve the shader code
  17445. */
  17446. optimize(): void;
  17447. private _prepareDefinesForAttributes;
  17448. /**
  17449. * Create a post process from the material
  17450. * @param camera The camera to apply the render pass to.
  17451. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17453. * @param engine The engine which the post process will be applied. (default: current engine)
  17454. * @param reusable If the post process can be reused on the same frame. (default: false)
  17455. * @param textureType Type of textures used when performing the post process. (default: 0)
  17456. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17457. * @returns the post process created
  17458. */
  17459. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17460. /**
  17461. * Create the post process effect from the material
  17462. * @param postProcess The post process to create the effect for
  17463. */
  17464. createEffectForPostProcess(postProcess: PostProcess): void;
  17465. private _createEffectForPostProcess;
  17466. /**
  17467. * Create a new procedural texture based on this node material
  17468. * @param size defines the size of the texture
  17469. * @param scene defines the hosting scene
  17470. * @returns the new procedural texture attached to this node material
  17471. */
  17472. createProceduralTexture(size: number | {
  17473. width: number;
  17474. height: number;
  17475. layers?: number;
  17476. }, scene: Scene): Nullable<ProceduralTexture>;
  17477. private _createEffectForParticles;
  17478. private _checkInternals;
  17479. /**
  17480. * Create the effect to be used as the custom effect for a particle system
  17481. * @param particleSystem Particle system to create the effect for
  17482. * @param onCompiled defines a function to call when the effect creation is successful
  17483. * @param onError defines a function to call when the effect creation has failed
  17484. */
  17485. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17486. private _processDefines;
  17487. /**
  17488. * Get if the submesh is ready to be used and all its information available.
  17489. * Child classes can use it to update shaders
  17490. * @param mesh defines the mesh to check
  17491. * @param subMesh defines which submesh to check
  17492. * @param useInstances specifies that instances should be used
  17493. * @returns a boolean indicating that the submesh is ready or not
  17494. */
  17495. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17496. /**
  17497. * Get a string representing the shaders built by the current node graph
  17498. */
  17499. get compiledShaders(): string;
  17500. /**
  17501. * Binds the world matrix to the material
  17502. * @param world defines the world transformation matrix
  17503. */
  17504. bindOnlyWorldMatrix(world: Matrix): void;
  17505. /**
  17506. * Binds the submesh to this material by preparing the effect and shader to draw
  17507. * @param world defines the world transformation matrix
  17508. * @param mesh defines the mesh containing the submesh
  17509. * @param subMesh defines the submesh to bind the material to
  17510. */
  17511. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17512. /**
  17513. * Gets the active textures from the material
  17514. * @returns an array of textures
  17515. */
  17516. getActiveTextures(): BaseTexture[];
  17517. /**
  17518. * Gets the list of texture blocks
  17519. * @returns an array of texture blocks
  17520. */
  17521. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17522. /**
  17523. * Specifies if the material uses a texture
  17524. * @param texture defines the texture to check against the material
  17525. * @returns a boolean specifying if the material uses the texture
  17526. */
  17527. hasTexture(texture: BaseTexture): boolean;
  17528. /**
  17529. * Disposes the material
  17530. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17531. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17532. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17533. */
  17534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17535. /** Creates the node editor window. */
  17536. private _createNodeEditor;
  17537. /**
  17538. * Launch the node material editor
  17539. * @param config Define the configuration of the editor
  17540. * @return a promise fulfilled when the node editor is visible
  17541. */
  17542. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17543. /**
  17544. * Clear the current material
  17545. */
  17546. clear(): void;
  17547. /**
  17548. * Clear the current material and set it to a default state
  17549. */
  17550. setToDefault(): void;
  17551. /**
  17552. * Clear the current material and set it to a default state for post process
  17553. */
  17554. setToDefaultPostProcess(): void;
  17555. /**
  17556. * Clear the current material and set it to a default state for procedural texture
  17557. */
  17558. setToDefaultProceduralTexture(): void;
  17559. /**
  17560. * Clear the current material and set it to a default state for particle
  17561. */
  17562. setToDefaultParticle(): void;
  17563. /**
  17564. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17565. * @param url defines the url to load from
  17566. * @returns a promise that will fullfil when the material is fully loaded
  17567. */
  17568. loadAsync(url: string): Promise<void>;
  17569. private _gatherBlocks;
  17570. /**
  17571. * Generate a string containing the code declaration required to create an equivalent of this material
  17572. * @returns a string
  17573. */
  17574. generateCode(): string;
  17575. /**
  17576. * Serializes this material in a JSON representation
  17577. * @returns the serialized material object
  17578. */
  17579. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17580. private _restoreConnections;
  17581. /**
  17582. * Clear the current graph and load a new one from a serialization object
  17583. * @param source defines the JSON representation of the material
  17584. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17585. * @param merge defines whether or not the source must be merged or replace the current content
  17586. */
  17587. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17588. /**
  17589. * Makes a duplicate of the current material.
  17590. * @param name - name to use for the new material.
  17591. */
  17592. clone(name: string): NodeMaterial;
  17593. /**
  17594. * Creates a node material from parsed material data
  17595. * @param source defines the JSON representation of the material
  17596. * @param scene defines the hosting scene
  17597. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17598. * @returns a new node material
  17599. */
  17600. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17601. /**
  17602. * Creates a node material from a snippet saved in a remote file
  17603. * @param name defines the name of the material to create
  17604. * @param url defines the url to load from
  17605. * @param scene defines the hosting scene
  17606. * @returns a promise that will resolve to the new node material
  17607. */
  17608. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17609. /**
  17610. * Creates a node material from a snippet saved by the node material editor
  17611. * @param snippetId defines the snippet to load
  17612. * @param scene defines the hosting scene
  17613. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17614. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17615. * @returns a promise that will resolve to the new node material
  17616. */
  17617. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17618. /**
  17619. * Creates a new node material set to default basic configuration
  17620. * @param name defines the name of the material
  17621. * @param scene defines the hosting scene
  17622. * @returns a new NodeMaterial
  17623. */
  17624. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17625. }
  17626. }
  17627. declare module BABYLON {
  17628. interface ThinEngine {
  17629. /**
  17630. * Unbind a list of render target textures from the webGL context
  17631. * This is used only when drawBuffer extension or webGL2 are active
  17632. * @param textures defines the render target textures to unbind
  17633. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17634. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17635. */
  17636. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17637. /**
  17638. * Create a multi render target texture
  17639. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17640. * @param size defines the size of the texture
  17641. * @param options defines the creation options
  17642. * @returns the cube texture as an InternalTexture
  17643. */
  17644. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17645. /**
  17646. * Update the sample count for a given multiple render target texture
  17647. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17648. * @param textures defines the textures to update
  17649. * @param samples defines the sample count to set
  17650. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17651. */
  17652. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17653. /**
  17654. * Select a subsets of attachments to draw to.
  17655. * @param attachments gl attachments
  17656. */
  17657. bindAttachments(attachments: number[]): void;
  17658. /**
  17659. * Creates a layout object to draw/clear on specific textures in a MRT
  17660. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17661. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17662. */
  17663. buildTextureLayout(textureStatus: boolean[]): number[];
  17664. /**
  17665. * Restores the webgl state to only draw on the main color attachment
  17666. */
  17667. restoreSingleAttachment(): void;
  17668. }
  17669. }
  17670. declare module BABYLON {
  17671. /**
  17672. * Creation options of the multi render target texture.
  17673. */
  17674. export interface IMultiRenderTargetOptions {
  17675. /**
  17676. * Define if the texture needs to create mip maps after render.
  17677. */
  17678. generateMipMaps?: boolean;
  17679. /**
  17680. * Define the types of all the draw buffers we want to create
  17681. */
  17682. types?: number[];
  17683. /**
  17684. * Define the sampling modes of all the draw buffers we want to create
  17685. */
  17686. samplingModes?: number[];
  17687. /**
  17688. * Define if a depth buffer is required
  17689. */
  17690. generateDepthBuffer?: boolean;
  17691. /**
  17692. * Define if a stencil buffer is required
  17693. */
  17694. generateStencilBuffer?: boolean;
  17695. /**
  17696. * Define if a depth texture is required instead of a depth buffer
  17697. */
  17698. generateDepthTexture?: boolean;
  17699. /**
  17700. * Define the number of desired draw buffers
  17701. */
  17702. textureCount?: number;
  17703. /**
  17704. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17705. */
  17706. doNotChangeAspectRatio?: boolean;
  17707. /**
  17708. * Define the default type of the buffers we are creating
  17709. */
  17710. defaultType?: number;
  17711. }
  17712. /**
  17713. * A multi render target, like a render target provides the ability to render to a texture.
  17714. * Unlike the render target, it can render to several draw buffers in one draw.
  17715. * This is specially interesting in deferred rendering or for any effects requiring more than
  17716. * just one color from a single pass.
  17717. */
  17718. export class MultiRenderTarget extends RenderTargetTexture {
  17719. private _internalTextures;
  17720. private _textures;
  17721. private _multiRenderTargetOptions;
  17722. private _count;
  17723. /**
  17724. * Get if draw buffers are currently supported by the used hardware and browser.
  17725. */
  17726. get isSupported(): boolean;
  17727. /**
  17728. * Get the list of textures generated by the multi render target.
  17729. */
  17730. get textures(): Texture[];
  17731. /**
  17732. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17733. */
  17734. get count(): number;
  17735. /**
  17736. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17737. */
  17738. get depthTexture(): Texture;
  17739. /**
  17740. * Set the wrapping mode on U of all the textures we are rendering to.
  17741. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17742. */
  17743. set wrapU(wrap: number);
  17744. /**
  17745. * Set the wrapping mode on V of all the textures we are rendering to.
  17746. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17747. */
  17748. set wrapV(wrap: number);
  17749. /**
  17750. * Instantiate a new multi render target texture.
  17751. * A multi render target, like a render target provides the ability to render to a texture.
  17752. * Unlike the render target, it can render to several draw buffers in one draw.
  17753. * This is specially interesting in deferred rendering or for any effects requiring more than
  17754. * just one color from a single pass.
  17755. * @param name Define the name of the texture
  17756. * @param size Define the size of the buffers to render to
  17757. * @param count Define the number of target we are rendering into
  17758. * @param scene Define the scene the texture belongs to
  17759. * @param options Define the options used to create the multi render target
  17760. */
  17761. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17762. private _initTypes;
  17763. /** @hidden */
  17764. _rebuild(forceFullRebuild?: boolean): void;
  17765. private _createInternalTextures;
  17766. private _createTextures;
  17767. /**
  17768. * Replaces a texture within the MRT.
  17769. * @param texture The new texture to insert in the MRT
  17770. * @param index The index of the texture to replace
  17771. */
  17772. replaceTexture(texture: Texture, index: number): void;
  17773. /**
  17774. * Define the number of samples used if MSAA is enabled.
  17775. */
  17776. get samples(): number;
  17777. set samples(value: number);
  17778. /**
  17779. * Resize all the textures in the multi render target.
  17780. * Be careful as it will recreate all the data in the new texture.
  17781. * @param size Define the new size
  17782. */
  17783. resize(size: any): void;
  17784. /**
  17785. * Changes the number of render targets in this MRT
  17786. * Be careful as it will recreate all the data in the new texture.
  17787. * @param count new texture count
  17788. * @param options Specifies texture types and sampling modes for new textures
  17789. */
  17790. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17791. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17792. /**
  17793. * Dispose the render targets and their associated resources
  17794. */
  17795. dispose(): void;
  17796. /**
  17797. * Release all the underlying texture used as draw buffers.
  17798. */
  17799. releaseInternalTextures(): void;
  17800. }
  17801. }
  17802. declare module BABYLON {
  17803. /** @hidden */
  17804. export var imageProcessingPixelShader: {
  17805. name: string;
  17806. shader: string;
  17807. };
  17808. }
  17809. declare module BABYLON {
  17810. /**
  17811. * ImageProcessingPostProcess
  17812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17813. */
  17814. export class ImageProcessingPostProcess extends PostProcess {
  17815. /**
  17816. * Default configuration related to image processing available in the PBR Material.
  17817. */
  17818. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17819. /**
  17820. * Gets the image processing configuration used either in this material.
  17821. */
  17822. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17823. /**
  17824. * Sets the Default image processing configuration used either in the this material.
  17825. *
  17826. * If sets to null, the scene one is in use.
  17827. */
  17828. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17829. /**
  17830. * Keep track of the image processing observer to allow dispose and replace.
  17831. */
  17832. private _imageProcessingObserver;
  17833. /**
  17834. * Attaches a new image processing configuration to the PBR Material.
  17835. * @param configuration
  17836. */
  17837. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17838. /**
  17839. * If the post process is supported.
  17840. */
  17841. get isSupported(): boolean;
  17842. /**
  17843. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17844. */
  17845. get colorCurves(): Nullable<ColorCurves>;
  17846. /**
  17847. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17848. */
  17849. set colorCurves(value: Nullable<ColorCurves>);
  17850. /**
  17851. * Gets wether the color curves effect is enabled.
  17852. */
  17853. get colorCurvesEnabled(): boolean;
  17854. /**
  17855. * Sets wether the color curves effect is enabled.
  17856. */
  17857. set colorCurvesEnabled(value: boolean);
  17858. /**
  17859. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17860. */
  17861. get colorGradingTexture(): Nullable<BaseTexture>;
  17862. /**
  17863. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17864. */
  17865. set colorGradingTexture(value: Nullable<BaseTexture>);
  17866. /**
  17867. * Gets wether the color grading effect is enabled.
  17868. */
  17869. get colorGradingEnabled(): boolean;
  17870. /**
  17871. * Gets wether the color grading effect is enabled.
  17872. */
  17873. set colorGradingEnabled(value: boolean);
  17874. /**
  17875. * Gets exposure used in the effect.
  17876. */
  17877. get exposure(): number;
  17878. /**
  17879. * Sets exposure used in the effect.
  17880. */
  17881. set exposure(value: number);
  17882. /**
  17883. * Gets wether tonemapping is enabled or not.
  17884. */
  17885. get toneMappingEnabled(): boolean;
  17886. /**
  17887. * Sets wether tonemapping is enabled or not
  17888. */
  17889. set toneMappingEnabled(value: boolean);
  17890. /**
  17891. * Gets the type of tone mapping effect.
  17892. */
  17893. get toneMappingType(): number;
  17894. /**
  17895. * Sets the type of tone mapping effect.
  17896. */
  17897. set toneMappingType(value: number);
  17898. /**
  17899. * Gets contrast used in the effect.
  17900. */
  17901. get contrast(): number;
  17902. /**
  17903. * Sets contrast used in the effect.
  17904. */
  17905. set contrast(value: number);
  17906. /**
  17907. * Gets Vignette stretch size.
  17908. */
  17909. get vignetteStretch(): number;
  17910. /**
  17911. * Sets Vignette stretch size.
  17912. */
  17913. set vignetteStretch(value: number);
  17914. /**
  17915. * Gets Vignette centre X Offset.
  17916. */
  17917. get vignetteCentreX(): number;
  17918. /**
  17919. * Sets Vignette centre X Offset.
  17920. */
  17921. set vignetteCentreX(value: number);
  17922. /**
  17923. * Gets Vignette centre Y Offset.
  17924. */
  17925. get vignetteCentreY(): number;
  17926. /**
  17927. * Sets Vignette centre Y Offset.
  17928. */
  17929. set vignetteCentreY(value: number);
  17930. /**
  17931. * Gets Vignette weight or intensity of the vignette effect.
  17932. */
  17933. get vignetteWeight(): number;
  17934. /**
  17935. * Sets Vignette weight or intensity of the vignette effect.
  17936. */
  17937. set vignetteWeight(value: number);
  17938. /**
  17939. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17940. * if vignetteEnabled is set to true.
  17941. */
  17942. get vignetteColor(): Color4;
  17943. /**
  17944. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17945. * if vignetteEnabled is set to true.
  17946. */
  17947. set vignetteColor(value: Color4);
  17948. /**
  17949. * Gets Camera field of view used by the Vignette effect.
  17950. */
  17951. get vignetteCameraFov(): number;
  17952. /**
  17953. * Sets Camera field of view used by the Vignette effect.
  17954. */
  17955. set vignetteCameraFov(value: number);
  17956. /**
  17957. * Gets the vignette blend mode allowing different kind of effect.
  17958. */
  17959. get vignetteBlendMode(): number;
  17960. /**
  17961. * Sets the vignette blend mode allowing different kind of effect.
  17962. */
  17963. set vignetteBlendMode(value: number);
  17964. /**
  17965. * Gets wether the vignette effect is enabled.
  17966. */
  17967. get vignetteEnabled(): boolean;
  17968. /**
  17969. * Sets wether the vignette effect is enabled.
  17970. */
  17971. set vignetteEnabled(value: boolean);
  17972. private _fromLinearSpace;
  17973. /**
  17974. * Gets wether the input of the processing is in Gamma or Linear Space.
  17975. */
  17976. get fromLinearSpace(): boolean;
  17977. /**
  17978. * Sets wether the input of the processing is in Gamma or Linear Space.
  17979. */
  17980. set fromLinearSpace(value: boolean);
  17981. /**
  17982. * Defines cache preventing GC.
  17983. */
  17984. private _defines;
  17985. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17986. /**
  17987. * "ImageProcessingPostProcess"
  17988. * @returns "ImageProcessingPostProcess"
  17989. */
  17990. getClassName(): string;
  17991. /**
  17992. * @hidden
  17993. */
  17994. _updateParameters(): void;
  17995. dispose(camera?: Camera): void;
  17996. }
  17997. }
  17998. declare module BABYLON {
  17999. /**
  18000. * Interface for defining prepass effects in the prepass post-process pipeline
  18001. */
  18002. export interface PrePassEffectConfiguration {
  18003. /**
  18004. * Name of the effect
  18005. */
  18006. name: string;
  18007. /**
  18008. * Post process to attach for this effect
  18009. */
  18010. postProcess?: PostProcess;
  18011. /**
  18012. * Textures required in the MRT
  18013. */
  18014. texturesRequired: number[];
  18015. /**
  18016. * Is the effect enabled
  18017. */
  18018. enabled: boolean;
  18019. /**
  18020. * Disposes the effect configuration
  18021. */
  18022. dispose?: () => void;
  18023. /**
  18024. * Creates the associated post process
  18025. */
  18026. createPostProcess?: () => PostProcess;
  18027. }
  18028. }
  18029. declare module BABYLON {
  18030. /**
  18031. * Options to be used when creating a FresnelParameters.
  18032. */
  18033. export type IFresnelParametersCreationOptions = {
  18034. /**
  18035. * Define the color used on edges (grazing angle)
  18036. */
  18037. leftColor?: Color3;
  18038. /**
  18039. * Define the color used on center
  18040. */
  18041. rightColor?: Color3;
  18042. /**
  18043. * Define bias applied to computed fresnel term
  18044. */
  18045. bias?: number;
  18046. /**
  18047. * Defined the power exponent applied to fresnel term
  18048. */
  18049. power?: number;
  18050. /**
  18051. * Define if the fresnel effect is enable or not.
  18052. */
  18053. isEnabled?: boolean;
  18054. };
  18055. /**
  18056. * Serialized format for FresnelParameters.
  18057. */
  18058. export type IFresnelParametersSerialized = {
  18059. /**
  18060. * Define the color used on edges (grazing angle) [as an array]
  18061. */
  18062. leftColor: number[];
  18063. /**
  18064. * Define the color used on center [as an array]
  18065. */
  18066. rightColor: number[];
  18067. /**
  18068. * Define bias applied to computed fresnel term
  18069. */
  18070. bias: number;
  18071. /**
  18072. * Defined the power exponent applied to fresnel term
  18073. */
  18074. power?: number;
  18075. /**
  18076. * Define if the fresnel effect is enable or not.
  18077. */
  18078. isEnabled: boolean;
  18079. };
  18080. /**
  18081. * This represents all the required information to add a fresnel effect on a material:
  18082. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18083. */
  18084. export class FresnelParameters {
  18085. private _isEnabled;
  18086. /**
  18087. * Define if the fresnel effect is enable or not.
  18088. */
  18089. get isEnabled(): boolean;
  18090. set isEnabled(value: boolean);
  18091. /**
  18092. * Define the color used on edges (grazing angle)
  18093. */
  18094. leftColor: Color3;
  18095. /**
  18096. * Define the color used on center
  18097. */
  18098. rightColor: Color3;
  18099. /**
  18100. * Define bias applied to computed fresnel term
  18101. */
  18102. bias: number;
  18103. /**
  18104. * Defined the power exponent applied to fresnel term
  18105. */
  18106. power: number;
  18107. /**
  18108. * Creates a new FresnelParameters object.
  18109. *
  18110. * @param options provide your own settings to optionally to override defaults
  18111. */
  18112. constructor(options?: IFresnelParametersCreationOptions);
  18113. /**
  18114. * Clones the current fresnel and its valuues
  18115. * @returns a clone fresnel configuration
  18116. */
  18117. clone(): FresnelParameters;
  18118. /**
  18119. * Determines equality between FresnelParameters objects
  18120. * @param otherFresnelParameters defines the second operand
  18121. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18122. */
  18123. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18124. /**
  18125. * Serializes the current fresnel parameters to a JSON representation.
  18126. * @return the JSON serialization
  18127. */
  18128. serialize(): IFresnelParametersSerialized;
  18129. /**
  18130. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18131. * @param parsedFresnelParameters Define the JSON representation
  18132. * @returns the parsed parameters
  18133. */
  18134. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18135. }
  18136. }
  18137. declare module BABYLON {
  18138. /**
  18139. * This groups all the flags used to control the materials channel.
  18140. */
  18141. export class MaterialFlags {
  18142. private static _DiffuseTextureEnabled;
  18143. /**
  18144. * Are diffuse textures enabled in the application.
  18145. */
  18146. static get DiffuseTextureEnabled(): boolean;
  18147. static set DiffuseTextureEnabled(value: boolean);
  18148. private static _DetailTextureEnabled;
  18149. /**
  18150. * Are detail textures enabled in the application.
  18151. */
  18152. static get DetailTextureEnabled(): boolean;
  18153. static set DetailTextureEnabled(value: boolean);
  18154. private static _AmbientTextureEnabled;
  18155. /**
  18156. * Are ambient textures enabled in the application.
  18157. */
  18158. static get AmbientTextureEnabled(): boolean;
  18159. static set AmbientTextureEnabled(value: boolean);
  18160. private static _OpacityTextureEnabled;
  18161. /**
  18162. * Are opacity textures enabled in the application.
  18163. */
  18164. static get OpacityTextureEnabled(): boolean;
  18165. static set OpacityTextureEnabled(value: boolean);
  18166. private static _ReflectionTextureEnabled;
  18167. /**
  18168. * Are reflection textures enabled in the application.
  18169. */
  18170. static get ReflectionTextureEnabled(): boolean;
  18171. static set ReflectionTextureEnabled(value: boolean);
  18172. private static _EmissiveTextureEnabled;
  18173. /**
  18174. * Are emissive textures enabled in the application.
  18175. */
  18176. static get EmissiveTextureEnabled(): boolean;
  18177. static set EmissiveTextureEnabled(value: boolean);
  18178. private static _SpecularTextureEnabled;
  18179. /**
  18180. * Are specular textures enabled in the application.
  18181. */
  18182. static get SpecularTextureEnabled(): boolean;
  18183. static set SpecularTextureEnabled(value: boolean);
  18184. private static _BumpTextureEnabled;
  18185. /**
  18186. * Are bump textures enabled in the application.
  18187. */
  18188. static get BumpTextureEnabled(): boolean;
  18189. static set BumpTextureEnabled(value: boolean);
  18190. private static _LightmapTextureEnabled;
  18191. /**
  18192. * Are lightmap textures enabled in the application.
  18193. */
  18194. static get LightmapTextureEnabled(): boolean;
  18195. static set LightmapTextureEnabled(value: boolean);
  18196. private static _RefractionTextureEnabled;
  18197. /**
  18198. * Are refraction textures enabled in the application.
  18199. */
  18200. static get RefractionTextureEnabled(): boolean;
  18201. static set RefractionTextureEnabled(value: boolean);
  18202. private static _ColorGradingTextureEnabled;
  18203. /**
  18204. * Are color grading textures enabled in the application.
  18205. */
  18206. static get ColorGradingTextureEnabled(): boolean;
  18207. static set ColorGradingTextureEnabled(value: boolean);
  18208. private static _FresnelEnabled;
  18209. /**
  18210. * Are fresnels enabled in the application.
  18211. */
  18212. static get FresnelEnabled(): boolean;
  18213. static set FresnelEnabled(value: boolean);
  18214. private static _ClearCoatTextureEnabled;
  18215. /**
  18216. * Are clear coat textures enabled in the application.
  18217. */
  18218. static get ClearCoatTextureEnabled(): boolean;
  18219. static set ClearCoatTextureEnabled(value: boolean);
  18220. private static _ClearCoatBumpTextureEnabled;
  18221. /**
  18222. * Are clear coat bump textures enabled in the application.
  18223. */
  18224. static get ClearCoatBumpTextureEnabled(): boolean;
  18225. static set ClearCoatBumpTextureEnabled(value: boolean);
  18226. private static _ClearCoatTintTextureEnabled;
  18227. /**
  18228. * Are clear coat tint textures enabled in the application.
  18229. */
  18230. static get ClearCoatTintTextureEnabled(): boolean;
  18231. static set ClearCoatTintTextureEnabled(value: boolean);
  18232. private static _SheenTextureEnabled;
  18233. /**
  18234. * Are sheen textures enabled in the application.
  18235. */
  18236. static get SheenTextureEnabled(): boolean;
  18237. static set SheenTextureEnabled(value: boolean);
  18238. private static _AnisotropicTextureEnabled;
  18239. /**
  18240. * Are anisotropic textures enabled in the application.
  18241. */
  18242. static get AnisotropicTextureEnabled(): boolean;
  18243. static set AnisotropicTextureEnabled(value: boolean);
  18244. private static _ThicknessTextureEnabled;
  18245. /**
  18246. * Are thickness textures enabled in the application.
  18247. */
  18248. static get ThicknessTextureEnabled(): boolean;
  18249. static set ThicknessTextureEnabled(value: boolean);
  18250. }
  18251. }
  18252. declare module BABYLON {
  18253. /** @hidden */
  18254. export var defaultFragmentDeclaration: {
  18255. name: string;
  18256. shader: string;
  18257. };
  18258. }
  18259. declare module BABYLON {
  18260. /** @hidden */
  18261. export var defaultUboDeclaration: {
  18262. name: string;
  18263. shader: string;
  18264. };
  18265. }
  18266. declare module BABYLON {
  18267. /** @hidden */
  18268. export var prePassDeclaration: {
  18269. name: string;
  18270. shader: string;
  18271. };
  18272. }
  18273. declare module BABYLON {
  18274. /** @hidden */
  18275. export var lightFragmentDeclaration: {
  18276. name: string;
  18277. shader: string;
  18278. };
  18279. }
  18280. declare module BABYLON {
  18281. /** @hidden */
  18282. export var lightUboDeclaration: {
  18283. name: string;
  18284. shader: string;
  18285. };
  18286. }
  18287. declare module BABYLON {
  18288. /** @hidden */
  18289. export var lightsFragmentFunctions: {
  18290. name: string;
  18291. shader: string;
  18292. };
  18293. }
  18294. declare module BABYLON {
  18295. /** @hidden */
  18296. export var shadowsFragmentFunctions: {
  18297. name: string;
  18298. shader: string;
  18299. };
  18300. }
  18301. declare module BABYLON {
  18302. /** @hidden */
  18303. export var fresnelFunction: {
  18304. name: string;
  18305. shader: string;
  18306. };
  18307. }
  18308. declare module BABYLON {
  18309. /** @hidden */
  18310. export var bumpFragmentMainFunctions: {
  18311. name: string;
  18312. shader: string;
  18313. };
  18314. }
  18315. declare module BABYLON {
  18316. /** @hidden */
  18317. export var bumpFragmentFunctions: {
  18318. name: string;
  18319. shader: string;
  18320. };
  18321. }
  18322. declare module BABYLON {
  18323. /** @hidden */
  18324. export var logDepthDeclaration: {
  18325. name: string;
  18326. shader: string;
  18327. };
  18328. }
  18329. declare module BABYLON {
  18330. /** @hidden */
  18331. export var fogFragmentDeclaration: {
  18332. name: string;
  18333. shader: string;
  18334. };
  18335. }
  18336. declare module BABYLON {
  18337. /** @hidden */
  18338. export var bumpFragment: {
  18339. name: string;
  18340. shader: string;
  18341. };
  18342. }
  18343. declare module BABYLON {
  18344. /** @hidden */
  18345. export var depthPrePass: {
  18346. name: string;
  18347. shader: string;
  18348. };
  18349. }
  18350. declare module BABYLON {
  18351. /** @hidden */
  18352. export var lightFragment: {
  18353. name: string;
  18354. shader: string;
  18355. };
  18356. }
  18357. declare module BABYLON {
  18358. /** @hidden */
  18359. export var logDepthFragment: {
  18360. name: string;
  18361. shader: string;
  18362. };
  18363. }
  18364. declare module BABYLON {
  18365. /** @hidden */
  18366. export var fogFragment: {
  18367. name: string;
  18368. shader: string;
  18369. };
  18370. }
  18371. declare module BABYLON {
  18372. /** @hidden */
  18373. export var defaultPixelShader: {
  18374. name: string;
  18375. shader: string;
  18376. };
  18377. }
  18378. declare module BABYLON {
  18379. /** @hidden */
  18380. export var defaultVertexDeclaration: {
  18381. name: string;
  18382. shader: string;
  18383. };
  18384. }
  18385. declare module BABYLON {
  18386. /** @hidden */
  18387. export var bonesDeclaration: {
  18388. name: string;
  18389. shader: string;
  18390. };
  18391. }
  18392. declare module BABYLON {
  18393. /** @hidden */
  18394. export var instancesDeclaration: {
  18395. name: string;
  18396. shader: string;
  18397. };
  18398. }
  18399. declare module BABYLON {
  18400. /** @hidden */
  18401. export var prePassVertexDeclaration: {
  18402. name: string;
  18403. shader: string;
  18404. };
  18405. }
  18406. declare module BABYLON {
  18407. /** @hidden */
  18408. export var bumpVertexDeclaration: {
  18409. name: string;
  18410. shader: string;
  18411. };
  18412. }
  18413. declare module BABYLON {
  18414. /** @hidden */
  18415. export var fogVertexDeclaration: {
  18416. name: string;
  18417. shader: string;
  18418. };
  18419. }
  18420. declare module BABYLON {
  18421. /** @hidden */
  18422. export var morphTargetsVertexGlobalDeclaration: {
  18423. name: string;
  18424. shader: string;
  18425. };
  18426. }
  18427. declare module BABYLON {
  18428. /** @hidden */
  18429. export var morphTargetsVertexDeclaration: {
  18430. name: string;
  18431. shader: string;
  18432. };
  18433. }
  18434. declare module BABYLON {
  18435. /** @hidden */
  18436. export var morphTargetsVertex: {
  18437. name: string;
  18438. shader: string;
  18439. };
  18440. }
  18441. declare module BABYLON {
  18442. /** @hidden */
  18443. export var instancesVertex: {
  18444. name: string;
  18445. shader: string;
  18446. };
  18447. }
  18448. declare module BABYLON {
  18449. /** @hidden */
  18450. export var bonesVertex: {
  18451. name: string;
  18452. shader: string;
  18453. };
  18454. }
  18455. declare module BABYLON {
  18456. /** @hidden */
  18457. export var prePassVertex: {
  18458. name: string;
  18459. shader: string;
  18460. };
  18461. }
  18462. declare module BABYLON {
  18463. /** @hidden */
  18464. export var bumpVertex: {
  18465. name: string;
  18466. shader: string;
  18467. };
  18468. }
  18469. declare module BABYLON {
  18470. /** @hidden */
  18471. export var fogVertex: {
  18472. name: string;
  18473. shader: string;
  18474. };
  18475. }
  18476. declare module BABYLON {
  18477. /** @hidden */
  18478. export var shadowsVertex: {
  18479. name: string;
  18480. shader: string;
  18481. };
  18482. }
  18483. declare module BABYLON {
  18484. /** @hidden */
  18485. export var pointCloudVertex: {
  18486. name: string;
  18487. shader: string;
  18488. };
  18489. }
  18490. declare module BABYLON {
  18491. /** @hidden */
  18492. export var logDepthVertex: {
  18493. name: string;
  18494. shader: string;
  18495. };
  18496. }
  18497. declare module BABYLON {
  18498. /** @hidden */
  18499. export var defaultVertexShader: {
  18500. name: string;
  18501. shader: string;
  18502. };
  18503. }
  18504. declare module BABYLON {
  18505. /**
  18506. * @hidden
  18507. */
  18508. export interface IMaterialDetailMapDefines {
  18509. DETAIL: boolean;
  18510. DETAILDIRECTUV: number;
  18511. DETAIL_NORMALBLENDMETHOD: number;
  18512. /** @hidden */
  18513. _areTexturesDirty: boolean;
  18514. }
  18515. /**
  18516. * Define the code related to the detail map parameters of a material
  18517. *
  18518. * Inspired from:
  18519. * 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
  18520. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18521. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18522. */
  18523. export class DetailMapConfiguration {
  18524. private _texture;
  18525. /**
  18526. * The detail texture of the material.
  18527. */
  18528. texture: Nullable<BaseTexture>;
  18529. /**
  18530. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18531. * Bigger values mean stronger blending
  18532. */
  18533. diffuseBlendLevel: number;
  18534. /**
  18535. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18536. * Bigger values mean stronger blending. Only used with PBR materials
  18537. */
  18538. roughnessBlendLevel: number;
  18539. /**
  18540. * Defines how strong the bump effect from the detail map is
  18541. * Bigger values mean stronger effect
  18542. */
  18543. bumpLevel: number;
  18544. private _normalBlendMethod;
  18545. /**
  18546. * The method used to blend the bump and detail normals together
  18547. */
  18548. normalBlendMethod: number;
  18549. private _isEnabled;
  18550. /**
  18551. * Enable or disable the detail map on this material
  18552. */
  18553. isEnabled: boolean;
  18554. /** @hidden */
  18555. private _internalMarkAllSubMeshesAsTexturesDirty;
  18556. /** @hidden */
  18557. _markAllSubMeshesAsTexturesDirty(): void;
  18558. /**
  18559. * Instantiate a new detail map
  18560. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18561. */
  18562. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18563. /**
  18564. * Gets whether the submesh is ready to be used or not.
  18565. * @param defines the list of "defines" to update.
  18566. * @param scene defines the scene the material belongs to.
  18567. * @returns - boolean indicating that the submesh is ready or not.
  18568. */
  18569. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18570. /**
  18571. * Update the defines for detail map usage
  18572. * @param defines the list of "defines" to update.
  18573. * @param scene defines the scene the material belongs to.
  18574. */
  18575. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18576. /**
  18577. * Binds the material data.
  18578. * @param uniformBuffer defines the Uniform buffer to fill in.
  18579. * @param scene defines the scene the material belongs to.
  18580. * @param isFrozen defines whether the material is frozen or not.
  18581. */
  18582. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18583. /**
  18584. * Checks to see if a texture is used in the material.
  18585. * @param texture - Base texture to use.
  18586. * @returns - Boolean specifying if a texture is used in the material.
  18587. */
  18588. hasTexture(texture: BaseTexture): boolean;
  18589. /**
  18590. * Returns an array of the actively used textures.
  18591. * @param activeTextures Array of BaseTextures
  18592. */
  18593. getActiveTextures(activeTextures: BaseTexture[]): void;
  18594. /**
  18595. * Returns the animatable textures.
  18596. * @param animatables Array of animatable textures.
  18597. */
  18598. getAnimatables(animatables: IAnimatable[]): void;
  18599. /**
  18600. * Disposes the resources of the material.
  18601. * @param forceDisposeTextures - Forces the disposal of all textures.
  18602. */
  18603. dispose(forceDisposeTextures?: boolean): void;
  18604. /**
  18605. * Get the current class name useful for serialization or dynamic coding.
  18606. * @returns "DetailMap"
  18607. */
  18608. getClassName(): string;
  18609. /**
  18610. * Add the required uniforms to the current list.
  18611. * @param uniforms defines the current uniform list.
  18612. */
  18613. static AddUniforms(uniforms: string[]): void;
  18614. /**
  18615. * Add the required samplers to the current list.
  18616. * @param samplers defines the current sampler list.
  18617. */
  18618. static AddSamplers(samplers: string[]): void;
  18619. /**
  18620. * Add the required uniforms to the current buffer.
  18621. * @param uniformBuffer defines the current uniform buffer.
  18622. */
  18623. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18624. /**
  18625. * Makes a duplicate of the current instance into another one.
  18626. * @param detailMap define the instance where to copy the info
  18627. */
  18628. copyTo(detailMap: DetailMapConfiguration): void;
  18629. /**
  18630. * Serializes this detail map instance
  18631. * @returns - An object with the serialized instance.
  18632. */
  18633. serialize(): any;
  18634. /**
  18635. * Parses a detail map setting from a serialized object.
  18636. * @param source - Serialized object.
  18637. * @param scene Defines the scene we are parsing for
  18638. * @param rootUrl Defines the rootUrl to load from
  18639. */
  18640. parse(source: any, scene: Scene, rootUrl: string): void;
  18641. }
  18642. }
  18643. declare module BABYLON {
  18644. /** @hidden */
  18645. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18646. MAINUV1: boolean;
  18647. MAINUV2: boolean;
  18648. DIFFUSE: boolean;
  18649. DIFFUSEDIRECTUV: number;
  18650. DETAIL: boolean;
  18651. DETAILDIRECTUV: number;
  18652. DETAIL_NORMALBLENDMETHOD: number;
  18653. AMBIENT: boolean;
  18654. AMBIENTDIRECTUV: number;
  18655. OPACITY: boolean;
  18656. OPACITYDIRECTUV: number;
  18657. OPACITYRGB: boolean;
  18658. REFLECTION: boolean;
  18659. EMISSIVE: boolean;
  18660. EMISSIVEDIRECTUV: number;
  18661. SPECULAR: boolean;
  18662. SPECULARDIRECTUV: number;
  18663. BUMP: boolean;
  18664. BUMPDIRECTUV: number;
  18665. PARALLAX: boolean;
  18666. PARALLAXOCCLUSION: boolean;
  18667. SPECULAROVERALPHA: boolean;
  18668. CLIPPLANE: boolean;
  18669. CLIPPLANE2: boolean;
  18670. CLIPPLANE3: boolean;
  18671. CLIPPLANE4: boolean;
  18672. CLIPPLANE5: boolean;
  18673. CLIPPLANE6: boolean;
  18674. ALPHATEST: boolean;
  18675. DEPTHPREPASS: boolean;
  18676. ALPHAFROMDIFFUSE: boolean;
  18677. POINTSIZE: boolean;
  18678. FOG: boolean;
  18679. SPECULARTERM: boolean;
  18680. DIFFUSEFRESNEL: boolean;
  18681. OPACITYFRESNEL: boolean;
  18682. REFLECTIONFRESNEL: boolean;
  18683. REFRACTIONFRESNEL: boolean;
  18684. EMISSIVEFRESNEL: boolean;
  18685. FRESNEL: boolean;
  18686. NORMAL: boolean;
  18687. UV1: boolean;
  18688. UV2: boolean;
  18689. VERTEXCOLOR: boolean;
  18690. VERTEXALPHA: boolean;
  18691. NUM_BONE_INFLUENCERS: number;
  18692. BonesPerMesh: number;
  18693. BONETEXTURE: boolean;
  18694. BONES_VELOCITY_ENABLED: boolean;
  18695. INSTANCES: boolean;
  18696. THIN_INSTANCES: boolean;
  18697. GLOSSINESS: boolean;
  18698. ROUGHNESS: boolean;
  18699. EMISSIVEASILLUMINATION: boolean;
  18700. LINKEMISSIVEWITHDIFFUSE: boolean;
  18701. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18702. LIGHTMAP: boolean;
  18703. LIGHTMAPDIRECTUV: number;
  18704. OBJECTSPACE_NORMALMAP: boolean;
  18705. USELIGHTMAPASSHADOWMAP: boolean;
  18706. REFLECTIONMAP_3D: boolean;
  18707. REFLECTIONMAP_SPHERICAL: boolean;
  18708. REFLECTIONMAP_PLANAR: boolean;
  18709. REFLECTIONMAP_CUBIC: boolean;
  18710. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18711. REFLECTIONMAP_PROJECTION: boolean;
  18712. REFLECTIONMAP_SKYBOX: boolean;
  18713. REFLECTIONMAP_EXPLICIT: boolean;
  18714. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18715. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18716. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18717. INVERTCUBICMAP: boolean;
  18718. LOGARITHMICDEPTH: boolean;
  18719. REFRACTION: boolean;
  18720. REFRACTIONMAP_3D: boolean;
  18721. REFLECTIONOVERALPHA: boolean;
  18722. TWOSIDEDLIGHTING: boolean;
  18723. SHADOWFLOAT: boolean;
  18724. MORPHTARGETS: boolean;
  18725. MORPHTARGETS_NORMAL: boolean;
  18726. MORPHTARGETS_TANGENT: boolean;
  18727. MORPHTARGETS_UV: boolean;
  18728. NUM_MORPH_INFLUENCERS: number;
  18729. NONUNIFORMSCALING: boolean;
  18730. PREMULTIPLYALPHA: boolean;
  18731. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18732. ALPHABLEND: boolean;
  18733. PREPASS: boolean;
  18734. PREPASS_IRRADIANCE: boolean;
  18735. PREPASS_IRRADIANCE_INDEX: number;
  18736. PREPASS_ALBEDO: boolean;
  18737. PREPASS_ALBEDO_INDEX: number;
  18738. PREPASS_DEPTHNORMAL: boolean;
  18739. PREPASS_DEPTHNORMAL_INDEX: number;
  18740. PREPASS_POSITION: boolean;
  18741. PREPASS_POSITION_INDEX: number;
  18742. PREPASS_VELOCITY: boolean;
  18743. PREPASS_VELOCITY_INDEX: number;
  18744. PREPASS_REFLECTIVITY: boolean;
  18745. PREPASS_REFLECTIVITY_INDEX: number;
  18746. SCENE_MRT_COUNT: number;
  18747. RGBDLIGHTMAP: boolean;
  18748. RGBDREFLECTION: boolean;
  18749. RGBDREFRACTION: boolean;
  18750. IMAGEPROCESSING: boolean;
  18751. VIGNETTE: boolean;
  18752. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18753. VIGNETTEBLENDMODEOPAQUE: boolean;
  18754. TONEMAPPING: boolean;
  18755. TONEMAPPING_ACES: boolean;
  18756. CONTRAST: boolean;
  18757. COLORCURVES: boolean;
  18758. COLORGRADING: boolean;
  18759. COLORGRADING3D: boolean;
  18760. SAMPLER3DGREENDEPTH: boolean;
  18761. SAMPLER3DBGRMAP: boolean;
  18762. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18763. MULTIVIEW: boolean;
  18764. /**
  18765. * If the reflection texture on this material is in linear color space
  18766. * @hidden
  18767. */
  18768. IS_REFLECTION_LINEAR: boolean;
  18769. /**
  18770. * If the refraction texture on this material is in linear color space
  18771. * @hidden
  18772. */
  18773. IS_REFRACTION_LINEAR: boolean;
  18774. EXPOSURE: boolean;
  18775. constructor();
  18776. setReflectionMode(modeToEnable: string): void;
  18777. }
  18778. /**
  18779. * This is the default material used in Babylon. It is the best trade off between quality
  18780. * and performances.
  18781. * @see https://doc.babylonjs.com/babylon101/materials
  18782. */
  18783. export class StandardMaterial extends PushMaterial {
  18784. private _diffuseTexture;
  18785. /**
  18786. * The basic texture of the material as viewed under a light.
  18787. */
  18788. diffuseTexture: Nullable<BaseTexture>;
  18789. private _ambientTexture;
  18790. /**
  18791. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18792. */
  18793. ambientTexture: Nullable<BaseTexture>;
  18794. private _opacityTexture;
  18795. /**
  18796. * Define the transparency of the material from a texture.
  18797. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18798. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18799. */
  18800. opacityTexture: Nullable<BaseTexture>;
  18801. private _reflectionTexture;
  18802. /**
  18803. * Define the texture used to display the reflection.
  18804. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18805. */
  18806. reflectionTexture: Nullable<BaseTexture>;
  18807. private _emissiveTexture;
  18808. /**
  18809. * Define texture of the material as if self lit.
  18810. * This will be mixed in the final result even in the absence of light.
  18811. */
  18812. emissiveTexture: Nullable<BaseTexture>;
  18813. private _specularTexture;
  18814. /**
  18815. * Define how the color and intensity of the highlight given by the light in the material.
  18816. */
  18817. specularTexture: Nullable<BaseTexture>;
  18818. private _bumpTexture;
  18819. /**
  18820. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18821. * 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.
  18822. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18823. */
  18824. bumpTexture: Nullable<BaseTexture>;
  18825. private _lightmapTexture;
  18826. /**
  18827. * Complex lighting can be computationally expensive to compute at runtime.
  18828. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18829. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18830. */
  18831. lightmapTexture: Nullable<BaseTexture>;
  18832. private _refractionTexture;
  18833. /**
  18834. * Define the texture used to display the refraction.
  18835. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18836. */
  18837. refractionTexture: Nullable<BaseTexture>;
  18838. /**
  18839. * The color of the material lit by the environmental background lighting.
  18840. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18841. */
  18842. ambientColor: Color3;
  18843. /**
  18844. * The basic color of the material as viewed under a light.
  18845. */
  18846. diffuseColor: Color3;
  18847. /**
  18848. * Define how the color and intensity of the highlight given by the light in the material.
  18849. */
  18850. specularColor: Color3;
  18851. /**
  18852. * Define the color of the material as if self lit.
  18853. * This will be mixed in the final result even in the absence of light.
  18854. */
  18855. emissiveColor: Color3;
  18856. /**
  18857. * Defines how sharp are the highlights in the material.
  18858. * The bigger the value the sharper giving a more glossy feeling to the result.
  18859. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18860. */
  18861. specularPower: number;
  18862. private _useAlphaFromDiffuseTexture;
  18863. /**
  18864. * Does the transparency come from the diffuse texture alpha channel.
  18865. */
  18866. useAlphaFromDiffuseTexture: boolean;
  18867. private _useEmissiveAsIllumination;
  18868. /**
  18869. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18870. */
  18871. useEmissiveAsIllumination: boolean;
  18872. private _linkEmissiveWithDiffuse;
  18873. /**
  18874. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18875. * the emissive level when the final color is close to one.
  18876. */
  18877. linkEmissiveWithDiffuse: boolean;
  18878. private _useSpecularOverAlpha;
  18879. /**
  18880. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18881. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18882. */
  18883. useSpecularOverAlpha: boolean;
  18884. private _useReflectionOverAlpha;
  18885. /**
  18886. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18887. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18888. */
  18889. useReflectionOverAlpha: boolean;
  18890. private _disableLighting;
  18891. /**
  18892. * Does lights from the scene impacts this material.
  18893. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18894. */
  18895. disableLighting: boolean;
  18896. private _useObjectSpaceNormalMap;
  18897. /**
  18898. * Allows using an object space normal map (instead of tangent space).
  18899. */
  18900. useObjectSpaceNormalMap: boolean;
  18901. private _useParallax;
  18902. /**
  18903. * Is parallax enabled or not.
  18904. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18905. */
  18906. useParallax: boolean;
  18907. private _useParallaxOcclusion;
  18908. /**
  18909. * Is parallax occlusion enabled or not.
  18910. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18911. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18912. */
  18913. useParallaxOcclusion: boolean;
  18914. /**
  18915. * 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.
  18916. */
  18917. parallaxScaleBias: number;
  18918. private _roughness;
  18919. /**
  18920. * Helps to define how blurry the reflections should appears in the material.
  18921. */
  18922. roughness: number;
  18923. /**
  18924. * In case of refraction, define the value of the index of refraction.
  18925. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18926. */
  18927. indexOfRefraction: number;
  18928. /**
  18929. * Invert the refraction texture alongside the y axis.
  18930. * It can be useful with procedural textures or probe for instance.
  18931. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18932. */
  18933. invertRefractionY: boolean;
  18934. /**
  18935. * Defines the alpha limits in alpha test mode.
  18936. */
  18937. alphaCutOff: number;
  18938. private _useLightmapAsShadowmap;
  18939. /**
  18940. * In case of light mapping, define whether the map contains light or shadow informations.
  18941. */
  18942. useLightmapAsShadowmap: boolean;
  18943. private _diffuseFresnelParameters;
  18944. /**
  18945. * Define the diffuse fresnel parameters of the material.
  18946. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18947. */
  18948. diffuseFresnelParameters: FresnelParameters;
  18949. private _opacityFresnelParameters;
  18950. /**
  18951. * Define the opacity fresnel parameters of the material.
  18952. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18953. */
  18954. opacityFresnelParameters: FresnelParameters;
  18955. private _reflectionFresnelParameters;
  18956. /**
  18957. * Define the reflection fresnel parameters of the material.
  18958. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18959. */
  18960. reflectionFresnelParameters: FresnelParameters;
  18961. private _refractionFresnelParameters;
  18962. /**
  18963. * Define the refraction fresnel parameters of the material.
  18964. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18965. */
  18966. refractionFresnelParameters: FresnelParameters;
  18967. private _emissiveFresnelParameters;
  18968. /**
  18969. * Define the emissive fresnel parameters of the material.
  18970. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18971. */
  18972. emissiveFresnelParameters: FresnelParameters;
  18973. private _useReflectionFresnelFromSpecular;
  18974. /**
  18975. * If true automatically deducts the fresnels values from the material specularity.
  18976. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18977. */
  18978. useReflectionFresnelFromSpecular: boolean;
  18979. private _useGlossinessFromSpecularMapAlpha;
  18980. /**
  18981. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18982. */
  18983. useGlossinessFromSpecularMapAlpha: boolean;
  18984. private _maxSimultaneousLights;
  18985. /**
  18986. * Defines the maximum number of lights that can be used in the material
  18987. */
  18988. maxSimultaneousLights: number;
  18989. private _invertNormalMapX;
  18990. /**
  18991. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18992. */
  18993. invertNormalMapX: boolean;
  18994. private _invertNormalMapY;
  18995. /**
  18996. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18997. */
  18998. invertNormalMapY: boolean;
  18999. private _twoSidedLighting;
  19000. /**
  19001. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19002. */
  19003. twoSidedLighting: boolean;
  19004. /**
  19005. * Default configuration related to image processing available in the standard Material.
  19006. */
  19007. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19008. /**
  19009. * Gets the image processing configuration used either in this material.
  19010. */
  19011. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19012. /**
  19013. * Sets the Default image processing configuration used either in the this material.
  19014. *
  19015. * If sets to null, the scene one is in use.
  19016. */
  19017. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19018. /**
  19019. * Keep track of the image processing observer to allow dispose and replace.
  19020. */
  19021. private _imageProcessingObserver;
  19022. /**
  19023. * Attaches a new image processing configuration to the Standard Material.
  19024. * @param configuration
  19025. */
  19026. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19027. /**
  19028. * Defines additionnal PrePass parameters for the material.
  19029. */
  19030. readonly prePassConfiguration: PrePassConfiguration;
  19031. /**
  19032. * Gets wether the color curves effect is enabled.
  19033. */
  19034. get cameraColorCurvesEnabled(): boolean;
  19035. /**
  19036. * Sets wether the color curves effect is enabled.
  19037. */
  19038. set cameraColorCurvesEnabled(value: boolean);
  19039. /**
  19040. * Gets wether the color grading effect is enabled.
  19041. */
  19042. get cameraColorGradingEnabled(): boolean;
  19043. /**
  19044. * Gets wether the color grading effect is enabled.
  19045. */
  19046. set cameraColorGradingEnabled(value: boolean);
  19047. /**
  19048. * Gets wether tonemapping is enabled or not.
  19049. */
  19050. get cameraToneMappingEnabled(): boolean;
  19051. /**
  19052. * Sets wether tonemapping is enabled or not
  19053. */
  19054. set cameraToneMappingEnabled(value: boolean);
  19055. /**
  19056. * The camera exposure used on this material.
  19057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19058. * This corresponds to a photographic exposure.
  19059. */
  19060. get cameraExposure(): number;
  19061. /**
  19062. * The camera exposure used on this material.
  19063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19064. * This corresponds to a photographic exposure.
  19065. */
  19066. set cameraExposure(value: number);
  19067. /**
  19068. * Gets The camera contrast used on this material.
  19069. */
  19070. get cameraContrast(): number;
  19071. /**
  19072. * Sets The camera contrast used on this material.
  19073. */
  19074. set cameraContrast(value: number);
  19075. /**
  19076. * Gets the Color Grading 2D Lookup Texture.
  19077. */
  19078. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19079. /**
  19080. * Sets the Color Grading 2D Lookup Texture.
  19081. */
  19082. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19083. /**
  19084. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19085. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19086. * 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;
  19087. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19088. */
  19089. get cameraColorCurves(): Nullable<ColorCurves>;
  19090. /**
  19091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19093. * 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;
  19094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19095. */
  19096. set cameraColorCurves(value: Nullable<ColorCurves>);
  19097. /**
  19098. * Can this material render to several textures at once
  19099. */
  19100. get canRenderToMRT(): boolean;
  19101. /**
  19102. * Defines the detail map parameters for the material.
  19103. */
  19104. readonly detailMap: DetailMapConfiguration;
  19105. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19106. protected _worldViewProjectionMatrix: Matrix;
  19107. protected _globalAmbientColor: Color3;
  19108. protected _useLogarithmicDepth: boolean;
  19109. protected _rebuildInParallel: boolean;
  19110. /**
  19111. * Instantiates a new standard material.
  19112. * This is the default material used in Babylon. It is the best trade off between quality
  19113. * and performances.
  19114. * @see https://doc.babylonjs.com/babylon101/materials
  19115. * @param name Define the name of the material in the scene
  19116. * @param scene Define the scene the material belong to
  19117. */
  19118. constructor(name: string, scene: Scene);
  19119. /**
  19120. * Gets a boolean indicating that current material needs to register RTT
  19121. */
  19122. get hasRenderTargetTextures(): boolean;
  19123. /**
  19124. * Gets the current class name of the material e.g. "StandardMaterial"
  19125. * Mainly use in serialization.
  19126. * @returns the class name
  19127. */
  19128. getClassName(): string;
  19129. /**
  19130. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19131. * You can try switching to logarithmic depth.
  19132. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19133. */
  19134. get useLogarithmicDepth(): boolean;
  19135. set useLogarithmicDepth(value: boolean);
  19136. /**
  19137. * Specifies if the material will require alpha blending
  19138. * @returns a boolean specifying if alpha blending is needed
  19139. */
  19140. needAlphaBlending(): boolean;
  19141. /**
  19142. * Specifies if this material should be rendered in alpha test mode
  19143. * @returns a boolean specifying if an alpha test is needed.
  19144. */
  19145. needAlphaTesting(): boolean;
  19146. /**
  19147. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19148. */
  19149. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19150. /**
  19151. * Specifies whether or not there is a usable alpha channel for transparency.
  19152. */
  19153. protected _hasAlphaChannel(): boolean;
  19154. /**
  19155. * Get the texture used for alpha test purpose.
  19156. * @returns the diffuse texture in case of the standard material.
  19157. */
  19158. getAlphaTestTexture(): Nullable<BaseTexture>;
  19159. /**
  19160. * Get if the submesh is ready to be used and all its information available.
  19161. * Child classes can use it to update shaders
  19162. * @param mesh defines the mesh to check
  19163. * @param subMesh defines which submesh to check
  19164. * @param useInstances specifies that instances should be used
  19165. * @returns a boolean indicating that the submesh is ready or not
  19166. */
  19167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19168. /**
  19169. * Builds the material UBO layouts.
  19170. * Used internally during the effect preparation.
  19171. */
  19172. buildUniformLayout(): void;
  19173. /**
  19174. * Unbinds the material from the mesh
  19175. */
  19176. unbind(): void;
  19177. /**
  19178. * Binds the submesh to this material by preparing the effect and shader to draw
  19179. * @param world defines the world transformation matrix
  19180. * @param mesh defines the mesh containing the submesh
  19181. * @param subMesh defines the submesh to bind the material to
  19182. */
  19183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19184. /**
  19185. * Get the list of animatables in the material.
  19186. * @returns the list of animatables object used in the material
  19187. */
  19188. getAnimatables(): IAnimatable[];
  19189. /**
  19190. * Gets the active textures from the material
  19191. * @returns an array of textures
  19192. */
  19193. getActiveTextures(): BaseTexture[];
  19194. /**
  19195. * Specifies if the material uses a texture
  19196. * @param texture defines the texture to check against the material
  19197. * @returns a boolean specifying if the material uses the texture
  19198. */
  19199. hasTexture(texture: BaseTexture): boolean;
  19200. /**
  19201. * Disposes the material
  19202. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19203. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19204. */
  19205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19206. /**
  19207. * Makes a duplicate of the material, and gives it a new name
  19208. * @param name defines the new name for the duplicated material
  19209. * @returns the cloned material
  19210. */
  19211. clone(name: string): StandardMaterial;
  19212. /**
  19213. * Serializes this material in a JSON representation
  19214. * @returns the serialized material object
  19215. */
  19216. serialize(): any;
  19217. /**
  19218. * Creates a standard material from parsed material data
  19219. * @param source defines the JSON representation of the material
  19220. * @param scene defines the hosting scene
  19221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19222. * @returns a new standard material
  19223. */
  19224. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19225. /**
  19226. * Are diffuse textures enabled in the application.
  19227. */
  19228. static get DiffuseTextureEnabled(): boolean;
  19229. static set DiffuseTextureEnabled(value: boolean);
  19230. /**
  19231. * Are detail textures enabled in the application.
  19232. */
  19233. static get DetailTextureEnabled(): boolean;
  19234. static set DetailTextureEnabled(value: boolean);
  19235. /**
  19236. * Are ambient textures enabled in the application.
  19237. */
  19238. static get AmbientTextureEnabled(): boolean;
  19239. static set AmbientTextureEnabled(value: boolean);
  19240. /**
  19241. * Are opacity textures enabled in the application.
  19242. */
  19243. static get OpacityTextureEnabled(): boolean;
  19244. static set OpacityTextureEnabled(value: boolean);
  19245. /**
  19246. * Are reflection textures enabled in the application.
  19247. */
  19248. static get ReflectionTextureEnabled(): boolean;
  19249. static set ReflectionTextureEnabled(value: boolean);
  19250. /**
  19251. * Are emissive textures enabled in the application.
  19252. */
  19253. static get EmissiveTextureEnabled(): boolean;
  19254. static set EmissiveTextureEnabled(value: boolean);
  19255. /**
  19256. * Are specular textures enabled in the application.
  19257. */
  19258. static get SpecularTextureEnabled(): boolean;
  19259. static set SpecularTextureEnabled(value: boolean);
  19260. /**
  19261. * Are bump textures enabled in the application.
  19262. */
  19263. static get BumpTextureEnabled(): boolean;
  19264. static set BumpTextureEnabled(value: boolean);
  19265. /**
  19266. * Are lightmap textures enabled in the application.
  19267. */
  19268. static get LightmapTextureEnabled(): boolean;
  19269. static set LightmapTextureEnabled(value: boolean);
  19270. /**
  19271. * Are refraction textures enabled in the application.
  19272. */
  19273. static get RefractionTextureEnabled(): boolean;
  19274. static set RefractionTextureEnabled(value: boolean);
  19275. /**
  19276. * Are color grading textures enabled in the application.
  19277. */
  19278. static get ColorGradingTextureEnabled(): boolean;
  19279. static set ColorGradingTextureEnabled(value: boolean);
  19280. /**
  19281. * Are fresnels enabled in the application.
  19282. */
  19283. static get FresnelEnabled(): boolean;
  19284. static set FresnelEnabled(value: boolean);
  19285. }
  19286. }
  19287. declare module BABYLON {
  19288. /** @hidden */
  19289. export var rgbdDecodePixelShader: {
  19290. name: string;
  19291. shader: string;
  19292. };
  19293. }
  19294. declare module BABYLON {
  19295. /**
  19296. * Class used to host RGBD texture specific utilities
  19297. */
  19298. export class RGBDTextureTools {
  19299. /**
  19300. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19301. * @param texture the texture to expand.
  19302. */
  19303. static ExpandRGBDTexture(texture: Texture): void;
  19304. }
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * Class used to host texture specific utilities
  19309. */
  19310. export class BRDFTextureTools {
  19311. /**
  19312. * Prevents texture cache collision
  19313. */
  19314. private static _instanceNumber;
  19315. /**
  19316. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19317. * @param scene defines the hosting scene
  19318. * @returns the environment BRDF texture
  19319. */
  19320. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19321. private static _environmentBRDFBase64Texture;
  19322. }
  19323. }
  19324. declare module BABYLON {
  19325. /**
  19326. * @hidden
  19327. */
  19328. export interface IMaterialClearCoatDefines {
  19329. CLEARCOAT: boolean;
  19330. CLEARCOAT_DEFAULTIOR: boolean;
  19331. CLEARCOAT_TEXTURE: boolean;
  19332. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19333. CLEARCOAT_TEXTUREDIRECTUV: number;
  19334. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19335. CLEARCOAT_BUMP: boolean;
  19336. CLEARCOAT_BUMPDIRECTUV: number;
  19337. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19338. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19339. CLEARCOAT_REMAP_F0: boolean;
  19340. CLEARCOAT_TINT: boolean;
  19341. CLEARCOAT_TINT_TEXTURE: boolean;
  19342. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19343. /** @hidden */
  19344. _areTexturesDirty: boolean;
  19345. }
  19346. /**
  19347. * Define the code related to the clear coat parameters of the pbr material.
  19348. */
  19349. export class PBRClearCoatConfiguration {
  19350. /**
  19351. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19352. * The default fits with a polyurethane material.
  19353. * @hidden
  19354. */
  19355. static readonly _DefaultIndexOfRefraction: number;
  19356. private _isEnabled;
  19357. /**
  19358. * Defines if the clear coat is enabled in the material.
  19359. */
  19360. isEnabled: boolean;
  19361. /**
  19362. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19363. */
  19364. intensity: number;
  19365. /**
  19366. * Defines the clear coat layer roughness.
  19367. */
  19368. roughness: number;
  19369. private _indexOfRefraction;
  19370. /**
  19371. * Defines the index of refraction of the clear coat.
  19372. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19373. * The default fits with a polyurethane material.
  19374. * Changing the default value is more performance intensive.
  19375. */
  19376. indexOfRefraction: number;
  19377. private _texture;
  19378. /**
  19379. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19380. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19381. * if textureRoughness is not empty, else no texture roughness is used
  19382. */
  19383. texture: Nullable<BaseTexture>;
  19384. private _useRoughnessFromMainTexture;
  19385. /**
  19386. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19387. * If false, the green channel from textureRoughness is used for roughness
  19388. */
  19389. useRoughnessFromMainTexture: boolean;
  19390. private _textureRoughness;
  19391. /**
  19392. * Stores the clear coat roughness in a texture (green channel)
  19393. * Not used if useRoughnessFromMainTexture is true
  19394. */
  19395. textureRoughness: Nullable<BaseTexture>;
  19396. private _remapF0OnInterfaceChange;
  19397. /**
  19398. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19399. */
  19400. remapF0OnInterfaceChange: boolean;
  19401. private _bumpTexture;
  19402. /**
  19403. * Define the clear coat specific bump texture.
  19404. */
  19405. bumpTexture: Nullable<BaseTexture>;
  19406. private _isTintEnabled;
  19407. /**
  19408. * Defines if the clear coat tint is enabled in the material.
  19409. */
  19410. isTintEnabled: boolean;
  19411. /**
  19412. * Defines the clear coat tint of the material.
  19413. * This is only use if tint is enabled
  19414. */
  19415. tintColor: Color3;
  19416. /**
  19417. * Defines the distance at which the tint color should be found in the
  19418. * clear coat media.
  19419. * This is only use if tint is enabled
  19420. */
  19421. tintColorAtDistance: number;
  19422. /**
  19423. * Defines the clear coat layer thickness.
  19424. * This is only use if tint is enabled
  19425. */
  19426. tintThickness: number;
  19427. private _tintTexture;
  19428. /**
  19429. * Stores the clear tint values in a texture.
  19430. * rgb is tint
  19431. * a is a thickness factor
  19432. */
  19433. tintTexture: Nullable<BaseTexture>;
  19434. /** @hidden */
  19435. private _internalMarkAllSubMeshesAsTexturesDirty;
  19436. /** @hidden */
  19437. _markAllSubMeshesAsTexturesDirty(): void;
  19438. /**
  19439. * Instantiate a new istance of clear coat configuration.
  19440. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19441. */
  19442. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19443. /**
  19444. * Gets wehter the submesh is ready to be used or not.
  19445. * @param defines the list of "defines" to update.
  19446. * @param scene defines the scene the material belongs to.
  19447. * @param engine defines the engine the material belongs to.
  19448. * @param disableBumpMap defines wether the material disables bump or not.
  19449. * @returns - boolean indicating that the submesh is ready or not.
  19450. */
  19451. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19452. /**
  19453. * Checks to see if a texture is used in the material.
  19454. * @param defines the list of "defines" to update.
  19455. * @param scene defines the scene to the material belongs to.
  19456. */
  19457. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19458. /**
  19459. * Binds the material data.
  19460. * @param uniformBuffer defines the Uniform buffer to fill in.
  19461. * @param scene defines the scene the material belongs to.
  19462. * @param engine defines the engine the material belongs to.
  19463. * @param disableBumpMap defines wether the material disables bump or not.
  19464. * @param isFrozen defines wether the material is frozen or not.
  19465. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19466. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19467. * @param subMesh the submesh to bind data for
  19468. */
  19469. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19470. /**
  19471. * Checks to see if a texture is used in the material.
  19472. * @param texture - Base texture to use.
  19473. * @returns - Boolean specifying if a texture is used in the material.
  19474. */
  19475. hasTexture(texture: BaseTexture): boolean;
  19476. /**
  19477. * Returns an array of the actively used textures.
  19478. * @param activeTextures Array of BaseTextures
  19479. */
  19480. getActiveTextures(activeTextures: BaseTexture[]): void;
  19481. /**
  19482. * Returns the animatable textures.
  19483. * @param animatables Array of animatable textures.
  19484. */
  19485. getAnimatables(animatables: IAnimatable[]): void;
  19486. /**
  19487. * Disposes the resources of the material.
  19488. * @param forceDisposeTextures - Forces the disposal of all textures.
  19489. */
  19490. dispose(forceDisposeTextures?: boolean): void;
  19491. /**
  19492. * Get the current class name of the texture useful for serialization or dynamic coding.
  19493. * @returns "PBRClearCoatConfiguration"
  19494. */
  19495. getClassName(): string;
  19496. /**
  19497. * Add fallbacks to the effect fallbacks list.
  19498. * @param defines defines the Base texture to use.
  19499. * @param fallbacks defines the current fallback list.
  19500. * @param currentRank defines the current fallback rank.
  19501. * @returns the new fallback rank.
  19502. */
  19503. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19504. /**
  19505. * Add the required uniforms to the current list.
  19506. * @param uniforms defines the current uniform list.
  19507. */
  19508. static AddUniforms(uniforms: string[]): void;
  19509. /**
  19510. * Add the required samplers to the current list.
  19511. * @param samplers defines the current sampler list.
  19512. */
  19513. static AddSamplers(samplers: string[]): void;
  19514. /**
  19515. * Add the required uniforms to the current buffer.
  19516. * @param uniformBuffer defines the current uniform buffer.
  19517. */
  19518. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19519. /**
  19520. * Makes a duplicate of the current configuration into another one.
  19521. * @param clearCoatConfiguration define the config where to copy the info
  19522. */
  19523. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19524. /**
  19525. * Serializes this clear coat configuration.
  19526. * @returns - An object with the serialized config.
  19527. */
  19528. serialize(): any;
  19529. /**
  19530. * Parses a anisotropy Configuration from a serialized object.
  19531. * @param source - Serialized object.
  19532. * @param scene Defines the scene we are parsing for
  19533. * @param rootUrl Defines the rootUrl to load from
  19534. */
  19535. parse(source: any, scene: Scene, rootUrl: string): void;
  19536. }
  19537. }
  19538. declare module BABYLON {
  19539. /**
  19540. * @hidden
  19541. */
  19542. export interface IMaterialAnisotropicDefines {
  19543. ANISOTROPIC: boolean;
  19544. ANISOTROPIC_TEXTURE: boolean;
  19545. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19546. MAINUV1: boolean;
  19547. _areTexturesDirty: boolean;
  19548. _needUVs: boolean;
  19549. }
  19550. /**
  19551. * Define the code related to the anisotropic parameters of the pbr material.
  19552. */
  19553. export class PBRAnisotropicConfiguration {
  19554. private _isEnabled;
  19555. /**
  19556. * Defines if the anisotropy is enabled in the material.
  19557. */
  19558. isEnabled: boolean;
  19559. /**
  19560. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19561. */
  19562. intensity: number;
  19563. /**
  19564. * Defines if the effect is along the tangents, bitangents or in between.
  19565. * By default, the effect is "strectching" the highlights along the tangents.
  19566. */
  19567. direction: Vector2;
  19568. private _texture;
  19569. /**
  19570. * Stores the anisotropy values in a texture.
  19571. * rg is direction (like normal from -1 to 1)
  19572. * b is a intensity
  19573. */
  19574. texture: Nullable<BaseTexture>;
  19575. /** @hidden */
  19576. private _internalMarkAllSubMeshesAsTexturesDirty;
  19577. /** @hidden */
  19578. _markAllSubMeshesAsTexturesDirty(): void;
  19579. /**
  19580. * Instantiate a new istance of anisotropy configuration.
  19581. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19582. */
  19583. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19584. /**
  19585. * Specifies that the submesh is ready to be used.
  19586. * @param defines the list of "defines" to update.
  19587. * @param scene defines the scene the material belongs to.
  19588. * @returns - boolean indicating that the submesh is ready or not.
  19589. */
  19590. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19591. /**
  19592. * Checks to see if a texture is used in the material.
  19593. * @param defines the list of "defines" to update.
  19594. * @param mesh the mesh we are preparing the defines for.
  19595. * @param scene defines the scene the material belongs to.
  19596. */
  19597. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19598. /**
  19599. * Binds the material data.
  19600. * @param uniformBuffer defines the Uniform buffer to fill in.
  19601. * @param scene defines the scene the material belongs to.
  19602. * @param isFrozen defines wether the material is frozen or not.
  19603. */
  19604. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19605. /**
  19606. * Checks to see if a texture is used in the material.
  19607. * @param texture - Base texture to use.
  19608. * @returns - Boolean specifying if a texture is used in the material.
  19609. */
  19610. hasTexture(texture: BaseTexture): boolean;
  19611. /**
  19612. * Returns an array of the actively used textures.
  19613. * @param activeTextures Array of BaseTextures
  19614. */
  19615. getActiveTextures(activeTextures: BaseTexture[]): void;
  19616. /**
  19617. * Returns the animatable textures.
  19618. * @param animatables Array of animatable textures.
  19619. */
  19620. getAnimatables(animatables: IAnimatable[]): void;
  19621. /**
  19622. * Disposes the resources of the material.
  19623. * @param forceDisposeTextures - Forces the disposal of all textures.
  19624. */
  19625. dispose(forceDisposeTextures?: boolean): void;
  19626. /**
  19627. * Get the current class name of the texture useful for serialization or dynamic coding.
  19628. * @returns "PBRAnisotropicConfiguration"
  19629. */
  19630. getClassName(): string;
  19631. /**
  19632. * Add fallbacks to the effect fallbacks list.
  19633. * @param defines defines the Base texture to use.
  19634. * @param fallbacks defines the current fallback list.
  19635. * @param currentRank defines the current fallback rank.
  19636. * @returns the new fallback rank.
  19637. */
  19638. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19639. /**
  19640. * Add the required uniforms to the current list.
  19641. * @param uniforms defines the current uniform list.
  19642. */
  19643. static AddUniforms(uniforms: string[]): void;
  19644. /**
  19645. * Add the required uniforms to the current buffer.
  19646. * @param uniformBuffer defines the current uniform buffer.
  19647. */
  19648. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19649. /**
  19650. * Add the required samplers to the current list.
  19651. * @param samplers defines the current sampler list.
  19652. */
  19653. static AddSamplers(samplers: string[]): void;
  19654. /**
  19655. * Makes a duplicate of the current configuration into another one.
  19656. * @param anisotropicConfiguration define the config where to copy the info
  19657. */
  19658. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19659. /**
  19660. * Serializes this anisotropy configuration.
  19661. * @returns - An object with the serialized config.
  19662. */
  19663. serialize(): any;
  19664. /**
  19665. * Parses a anisotropy Configuration from a serialized object.
  19666. * @param source - Serialized object.
  19667. * @param scene Defines the scene we are parsing for
  19668. * @param rootUrl Defines the rootUrl to load from
  19669. */
  19670. parse(source: any, scene: Scene, rootUrl: string): void;
  19671. }
  19672. }
  19673. declare module BABYLON {
  19674. /**
  19675. * @hidden
  19676. */
  19677. export interface IMaterialBRDFDefines {
  19678. BRDF_V_HEIGHT_CORRELATED: boolean;
  19679. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19680. SPHERICAL_HARMONICS: boolean;
  19681. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19682. /** @hidden */
  19683. _areMiscDirty: boolean;
  19684. }
  19685. /**
  19686. * Define the code related to the BRDF parameters of the pbr material.
  19687. */
  19688. export class PBRBRDFConfiguration {
  19689. /**
  19690. * Default value used for the energy conservation.
  19691. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19692. */
  19693. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19694. /**
  19695. * Default value used for the Smith Visibility Height Correlated mode.
  19696. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19697. */
  19698. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19699. /**
  19700. * Default value used for the IBL diffuse part.
  19701. * This can help switching back to the polynomials mode globally which is a tiny bit
  19702. * less GPU intensive at the drawback of a lower quality.
  19703. */
  19704. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19705. /**
  19706. * Default value used for activating energy conservation for the specular workflow.
  19707. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19708. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19709. */
  19710. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19711. private _useEnergyConservation;
  19712. /**
  19713. * Defines if the material uses energy conservation.
  19714. */
  19715. useEnergyConservation: boolean;
  19716. private _useSmithVisibilityHeightCorrelated;
  19717. /**
  19718. * LEGACY Mode set to false
  19719. * Defines if the material uses height smith correlated visibility term.
  19720. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19721. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19722. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19723. * Not relying on height correlated will also disable energy conservation.
  19724. */
  19725. useSmithVisibilityHeightCorrelated: boolean;
  19726. private _useSphericalHarmonics;
  19727. /**
  19728. * LEGACY Mode set to false
  19729. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19730. * diffuse part of the IBL.
  19731. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19732. * to the ground truth.
  19733. */
  19734. useSphericalHarmonics: boolean;
  19735. private _useSpecularGlossinessInputEnergyConservation;
  19736. /**
  19737. * Defines if the material uses energy conservation, when the specular workflow is active.
  19738. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19739. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19740. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19741. */
  19742. useSpecularGlossinessInputEnergyConservation: boolean;
  19743. /** @hidden */
  19744. private _internalMarkAllSubMeshesAsMiscDirty;
  19745. /** @hidden */
  19746. _markAllSubMeshesAsMiscDirty(): void;
  19747. /**
  19748. * Instantiate a new istance of clear coat configuration.
  19749. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19750. */
  19751. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19752. /**
  19753. * Checks to see if a texture is used in the material.
  19754. * @param defines the list of "defines" to update.
  19755. */
  19756. prepareDefines(defines: IMaterialBRDFDefines): void;
  19757. /**
  19758. * Get the current class name of the texture useful for serialization or dynamic coding.
  19759. * @returns "PBRClearCoatConfiguration"
  19760. */
  19761. getClassName(): string;
  19762. /**
  19763. * Makes a duplicate of the current configuration into another one.
  19764. * @param brdfConfiguration define the config where to copy the info
  19765. */
  19766. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19767. /**
  19768. * Serializes this BRDF configuration.
  19769. * @returns - An object with the serialized config.
  19770. */
  19771. serialize(): any;
  19772. /**
  19773. * Parses a anisotropy Configuration from a serialized object.
  19774. * @param source - Serialized object.
  19775. * @param scene Defines the scene we are parsing for
  19776. * @param rootUrl Defines the rootUrl to load from
  19777. */
  19778. parse(source: any, scene: Scene, rootUrl: string): void;
  19779. }
  19780. }
  19781. declare module BABYLON {
  19782. /**
  19783. * @hidden
  19784. */
  19785. export interface IMaterialSheenDefines {
  19786. SHEEN: boolean;
  19787. SHEEN_TEXTURE: boolean;
  19788. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19789. SHEEN_TEXTUREDIRECTUV: number;
  19790. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19791. SHEEN_LINKWITHALBEDO: boolean;
  19792. SHEEN_ROUGHNESS: boolean;
  19793. SHEEN_ALBEDOSCALING: boolean;
  19794. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19795. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19796. /** @hidden */
  19797. _areTexturesDirty: boolean;
  19798. }
  19799. /**
  19800. * Define the code related to the Sheen parameters of the pbr material.
  19801. */
  19802. export class PBRSheenConfiguration {
  19803. private _isEnabled;
  19804. /**
  19805. * Defines if the material uses sheen.
  19806. */
  19807. isEnabled: boolean;
  19808. private _linkSheenWithAlbedo;
  19809. /**
  19810. * Defines if the sheen is linked to the sheen color.
  19811. */
  19812. linkSheenWithAlbedo: boolean;
  19813. /**
  19814. * Defines the sheen intensity.
  19815. */
  19816. intensity: number;
  19817. /**
  19818. * Defines the sheen color.
  19819. */
  19820. color: Color3;
  19821. private _texture;
  19822. /**
  19823. * Stores the sheen tint values in a texture.
  19824. * rgb is tint
  19825. * 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)
  19826. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19827. */
  19828. texture: Nullable<BaseTexture>;
  19829. private _useRoughnessFromMainTexture;
  19830. /**
  19831. * Indicates that the alpha channel of the texture property will be used for roughness.
  19832. * Has no effect if the roughness (and texture!) property is not defined
  19833. */
  19834. useRoughnessFromMainTexture: boolean;
  19835. private _roughness;
  19836. /**
  19837. * Defines the sheen roughness.
  19838. * It is not taken into account if linkSheenWithAlbedo is true.
  19839. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19840. */
  19841. roughness: Nullable<number>;
  19842. private _textureRoughness;
  19843. /**
  19844. * Stores the sheen roughness in a texture.
  19845. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19846. */
  19847. textureRoughness: Nullable<BaseTexture>;
  19848. private _albedoScaling;
  19849. /**
  19850. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19851. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19852. * making it easier to setup and tweak the effect
  19853. */
  19854. albedoScaling: boolean;
  19855. /** @hidden */
  19856. private _internalMarkAllSubMeshesAsTexturesDirty;
  19857. /** @hidden */
  19858. _markAllSubMeshesAsTexturesDirty(): void;
  19859. /**
  19860. * Instantiate a new istance of clear coat configuration.
  19861. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19862. */
  19863. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19864. /**
  19865. * Specifies that the submesh is ready to be used.
  19866. * @param defines the list of "defines" to update.
  19867. * @param scene defines the scene the material belongs to.
  19868. * @returns - boolean indicating that the submesh is ready or not.
  19869. */
  19870. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19871. /**
  19872. * Checks to see if a texture is used in the material.
  19873. * @param defines the list of "defines" to update.
  19874. * @param scene defines the scene the material belongs to.
  19875. */
  19876. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19877. /**
  19878. * Binds the material data.
  19879. * @param uniformBuffer defines the Uniform buffer to fill in.
  19880. * @param scene defines the scene the material belongs to.
  19881. * @param isFrozen defines wether the material is frozen or not.
  19882. * @param subMesh the submesh to bind data for
  19883. */
  19884. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19885. /**
  19886. * Checks to see if a texture is used in the material.
  19887. * @param texture - Base texture to use.
  19888. * @returns - Boolean specifying if a texture is used in the material.
  19889. */
  19890. hasTexture(texture: BaseTexture): boolean;
  19891. /**
  19892. * Returns an array of the actively used textures.
  19893. * @param activeTextures Array of BaseTextures
  19894. */
  19895. getActiveTextures(activeTextures: BaseTexture[]): void;
  19896. /**
  19897. * Returns the animatable textures.
  19898. * @param animatables Array of animatable textures.
  19899. */
  19900. getAnimatables(animatables: IAnimatable[]): void;
  19901. /**
  19902. * Disposes the resources of the material.
  19903. * @param forceDisposeTextures - Forces the disposal of all textures.
  19904. */
  19905. dispose(forceDisposeTextures?: boolean): void;
  19906. /**
  19907. * Get the current class name of the texture useful for serialization or dynamic coding.
  19908. * @returns "PBRSheenConfiguration"
  19909. */
  19910. getClassName(): string;
  19911. /**
  19912. * Add fallbacks to the effect fallbacks list.
  19913. * @param defines defines the Base texture to use.
  19914. * @param fallbacks defines the current fallback list.
  19915. * @param currentRank defines the current fallback rank.
  19916. * @returns the new fallback rank.
  19917. */
  19918. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19919. /**
  19920. * Add the required uniforms to the current list.
  19921. * @param uniforms defines the current uniform list.
  19922. */
  19923. static AddUniforms(uniforms: string[]): void;
  19924. /**
  19925. * Add the required uniforms to the current buffer.
  19926. * @param uniformBuffer defines the current uniform buffer.
  19927. */
  19928. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19929. /**
  19930. * Add the required samplers to the current list.
  19931. * @param samplers defines the current sampler list.
  19932. */
  19933. static AddSamplers(samplers: string[]): void;
  19934. /**
  19935. * Makes a duplicate of the current configuration into another one.
  19936. * @param sheenConfiguration define the config where to copy the info
  19937. */
  19938. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19939. /**
  19940. * Serializes this BRDF configuration.
  19941. * @returns - An object with the serialized config.
  19942. */
  19943. serialize(): any;
  19944. /**
  19945. * Parses a anisotropy Configuration from a serialized object.
  19946. * @param source - Serialized object.
  19947. * @param scene Defines the scene we are parsing for
  19948. * @param rootUrl Defines the rootUrl to load from
  19949. */
  19950. parse(source: any, scene: Scene, rootUrl: string): void;
  19951. }
  19952. }
  19953. declare module BABYLON {
  19954. /**
  19955. * @hidden
  19956. */
  19957. export interface IMaterialSubSurfaceDefines {
  19958. SUBSURFACE: boolean;
  19959. SS_REFRACTION: boolean;
  19960. SS_TRANSLUCENCY: boolean;
  19961. SS_SCATTERING: boolean;
  19962. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19963. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19964. SS_REFRACTIONMAP_3D: boolean;
  19965. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19966. SS_LODINREFRACTIONALPHA: boolean;
  19967. SS_GAMMAREFRACTION: boolean;
  19968. SS_RGBDREFRACTION: boolean;
  19969. SS_LINEARSPECULARREFRACTION: boolean;
  19970. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19971. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19972. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19973. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19974. /** @hidden */
  19975. _areTexturesDirty: boolean;
  19976. }
  19977. /**
  19978. * Define the code related to the sub surface parameters of the pbr material.
  19979. */
  19980. export class PBRSubSurfaceConfiguration {
  19981. private _isRefractionEnabled;
  19982. /**
  19983. * Defines if the refraction is enabled in the material.
  19984. */
  19985. isRefractionEnabled: boolean;
  19986. private _isTranslucencyEnabled;
  19987. /**
  19988. * Defines if the translucency is enabled in the material.
  19989. */
  19990. isTranslucencyEnabled: boolean;
  19991. private _isScatteringEnabled;
  19992. /**
  19993. * Defines if the sub surface scattering is enabled in the material.
  19994. */
  19995. isScatteringEnabled: boolean;
  19996. private _scatteringDiffusionProfileIndex;
  19997. /**
  19998. * Diffusion profile for subsurface scattering.
  19999. * Useful for better scattering in the skins or foliages.
  20000. */
  20001. get scatteringDiffusionProfile(): Nullable<Color3>;
  20002. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20003. /**
  20004. * Defines the refraction intensity of the material.
  20005. * The refraction when enabled replaces the Diffuse part of the material.
  20006. * The intensity helps transitionning between diffuse and refraction.
  20007. */
  20008. refractionIntensity: number;
  20009. /**
  20010. * Defines the translucency intensity of the material.
  20011. * When translucency has been enabled, this defines how much of the "translucency"
  20012. * is addded to the diffuse part of the material.
  20013. */
  20014. translucencyIntensity: number;
  20015. /**
  20016. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20017. */
  20018. useAlbedoToTintRefraction: boolean;
  20019. private _thicknessTexture;
  20020. /**
  20021. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20022. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20023. * 0 would mean minimumThickness
  20024. * 1 would mean maximumThickness
  20025. * The other channels might be use as a mask to vary the different effects intensity.
  20026. */
  20027. thicknessTexture: Nullable<BaseTexture>;
  20028. private _refractionTexture;
  20029. /**
  20030. * Defines the texture to use for refraction.
  20031. */
  20032. refractionTexture: Nullable<BaseTexture>;
  20033. private _indexOfRefraction;
  20034. /**
  20035. * Index of refraction of the material base layer.
  20036. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20037. *
  20038. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20039. *
  20040. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20041. */
  20042. indexOfRefraction: number;
  20043. private _volumeIndexOfRefraction;
  20044. /**
  20045. * Index of refraction of the material's volume.
  20046. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20047. *
  20048. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20049. * the volume will use the same IOR as the surface.
  20050. */
  20051. get volumeIndexOfRefraction(): number;
  20052. set volumeIndexOfRefraction(value: number);
  20053. private _invertRefractionY;
  20054. /**
  20055. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20056. */
  20057. invertRefractionY: boolean;
  20058. private _linkRefractionWithTransparency;
  20059. /**
  20060. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20061. * Materials half opaque for instance using refraction could benefit from this control.
  20062. */
  20063. linkRefractionWithTransparency: boolean;
  20064. /**
  20065. * Defines the minimum thickness stored in the thickness map.
  20066. * If no thickness map is defined, this value will be used to simulate thickness.
  20067. */
  20068. minimumThickness: number;
  20069. /**
  20070. * Defines the maximum thickness stored in the thickness map.
  20071. */
  20072. maximumThickness: number;
  20073. /**
  20074. * Defines the volume tint of the material.
  20075. * This is used for both translucency and scattering.
  20076. */
  20077. tintColor: Color3;
  20078. /**
  20079. * Defines the distance at which the tint color should be found in the media.
  20080. * This is used for refraction only.
  20081. */
  20082. tintColorAtDistance: number;
  20083. /**
  20084. * Defines how far each channel transmit through the media.
  20085. * It is defined as a color to simplify it selection.
  20086. */
  20087. diffusionDistance: Color3;
  20088. private _useMaskFromThicknessTexture;
  20089. /**
  20090. * Stores the intensity of the different subsurface effects in the thickness texture.
  20091. * * the green channel is the translucency intensity.
  20092. * * the blue channel is the scattering intensity.
  20093. * * the alpha channel is the refraction intensity.
  20094. */
  20095. useMaskFromThicknessTexture: boolean;
  20096. private _scene;
  20097. private _useMaskFromThicknessTextureGltf;
  20098. /**
  20099. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20100. * matches the channel-packing that is used by glTF.
  20101. * * the red channel is the transmission/translucency intensity.
  20102. * * the green channel is the thickness.
  20103. */
  20104. useMaskFromThicknessTextureGltf: boolean;
  20105. /** @hidden */
  20106. private _internalMarkAllSubMeshesAsTexturesDirty;
  20107. private _internalMarkScenePrePassDirty;
  20108. /** @hidden */
  20109. _markAllSubMeshesAsTexturesDirty(): void;
  20110. /** @hidden */
  20111. _markScenePrePassDirty(): void;
  20112. /**
  20113. * Instantiate a new istance of sub surface configuration.
  20114. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20115. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20116. * @param scene The scene
  20117. */
  20118. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20119. /**
  20120. * Gets wehter the submesh is ready to be used or not.
  20121. * @param defines the list of "defines" to update.
  20122. * @param scene defines the scene the material belongs to.
  20123. * @returns - boolean indicating that the submesh is ready or not.
  20124. */
  20125. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20126. /**
  20127. * Checks to see if a texture is used in the material.
  20128. * @param defines the list of "defines" to update.
  20129. * @param scene defines the scene to the material belongs to.
  20130. */
  20131. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20132. /**
  20133. * Binds the material data.
  20134. * @param uniformBuffer defines the Uniform buffer to fill in.
  20135. * @param scene defines the scene the material belongs to.
  20136. * @param engine defines the engine the material belongs to.
  20137. * @param isFrozen defines whether the material is frozen or not.
  20138. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20139. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20140. */
  20141. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20142. /**
  20143. * Unbinds the material from the mesh.
  20144. * @param activeEffect defines the effect that should be unbound from.
  20145. * @returns true if unbound, otherwise false
  20146. */
  20147. unbind(activeEffect: Effect): boolean;
  20148. /**
  20149. * Returns the texture used for refraction or null if none is used.
  20150. * @param scene defines the scene the material belongs to.
  20151. * @returns - Refraction texture if present. If no refraction texture and refraction
  20152. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20153. */
  20154. private _getRefractionTexture;
  20155. /**
  20156. * Returns true if alpha blending should be disabled.
  20157. */
  20158. get disableAlphaBlending(): boolean;
  20159. /**
  20160. * Fills the list of render target textures.
  20161. * @param renderTargets the list of render targets to update
  20162. */
  20163. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20164. /**
  20165. * Checks to see if a texture is used in the material.
  20166. * @param texture - Base texture to use.
  20167. * @returns - Boolean specifying if a texture is used in the material.
  20168. */
  20169. hasTexture(texture: BaseTexture): boolean;
  20170. /**
  20171. * Gets a boolean indicating that current material needs to register RTT
  20172. * @returns true if this uses a render target otherwise false.
  20173. */
  20174. hasRenderTargetTextures(): boolean;
  20175. /**
  20176. * Returns an array of the actively used textures.
  20177. * @param activeTextures Array of BaseTextures
  20178. */
  20179. getActiveTextures(activeTextures: BaseTexture[]): void;
  20180. /**
  20181. * Returns the animatable textures.
  20182. * @param animatables Array of animatable textures.
  20183. */
  20184. getAnimatables(animatables: IAnimatable[]): void;
  20185. /**
  20186. * Disposes the resources of the material.
  20187. * @param forceDisposeTextures - Forces the disposal of all textures.
  20188. */
  20189. dispose(forceDisposeTextures?: boolean): void;
  20190. /**
  20191. * Get the current class name of the texture useful for serialization or dynamic coding.
  20192. * @returns "PBRSubSurfaceConfiguration"
  20193. */
  20194. getClassName(): string;
  20195. /**
  20196. * Add fallbacks to the effect fallbacks list.
  20197. * @param defines defines the Base texture to use.
  20198. * @param fallbacks defines the current fallback list.
  20199. * @param currentRank defines the current fallback rank.
  20200. * @returns the new fallback rank.
  20201. */
  20202. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20203. /**
  20204. * Add the required uniforms to the current list.
  20205. * @param uniforms defines the current uniform list.
  20206. */
  20207. static AddUniforms(uniforms: string[]): void;
  20208. /**
  20209. * Add the required samplers to the current list.
  20210. * @param samplers defines the current sampler list.
  20211. */
  20212. static AddSamplers(samplers: string[]): void;
  20213. /**
  20214. * Add the required uniforms to the current buffer.
  20215. * @param uniformBuffer defines the current uniform buffer.
  20216. */
  20217. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20218. /**
  20219. * Makes a duplicate of the current configuration into another one.
  20220. * @param configuration define the config where to copy the info
  20221. */
  20222. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20223. /**
  20224. * Serializes this Sub Surface configuration.
  20225. * @returns - An object with the serialized config.
  20226. */
  20227. serialize(): any;
  20228. /**
  20229. * Parses a anisotropy Configuration from a serialized object.
  20230. * @param source - Serialized object.
  20231. * @param scene Defines the scene we are parsing for
  20232. * @param rootUrl Defines the rootUrl to load from
  20233. */
  20234. parse(source: any, scene: Scene, rootUrl: string): void;
  20235. }
  20236. }
  20237. declare module BABYLON {
  20238. /**
  20239. * Class representing spherical harmonics coefficients to the 3rd degree
  20240. */
  20241. export class SphericalHarmonics {
  20242. /**
  20243. * Defines whether or not the harmonics have been prescaled for rendering.
  20244. */
  20245. preScaled: boolean;
  20246. /**
  20247. * The l0,0 coefficients of the spherical harmonics
  20248. */
  20249. l00: Vector3;
  20250. /**
  20251. * The l1,-1 coefficients of the spherical harmonics
  20252. */
  20253. l1_1: Vector3;
  20254. /**
  20255. * The l1,0 coefficients of the spherical harmonics
  20256. */
  20257. l10: Vector3;
  20258. /**
  20259. * The l1,1 coefficients of the spherical harmonics
  20260. */
  20261. l11: Vector3;
  20262. /**
  20263. * The l2,-2 coefficients of the spherical harmonics
  20264. */
  20265. l2_2: Vector3;
  20266. /**
  20267. * The l2,-1 coefficients of the spherical harmonics
  20268. */
  20269. l2_1: Vector3;
  20270. /**
  20271. * The l2,0 coefficients of the spherical harmonics
  20272. */
  20273. l20: Vector3;
  20274. /**
  20275. * The l2,1 coefficients of the spherical harmonics
  20276. */
  20277. l21: Vector3;
  20278. /**
  20279. * The l2,2 coefficients of the spherical harmonics
  20280. */
  20281. l22: Vector3;
  20282. /**
  20283. * Adds a light to the spherical harmonics
  20284. * @param direction the direction of the light
  20285. * @param color the color of the light
  20286. * @param deltaSolidAngle the delta solid angle of the light
  20287. */
  20288. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20289. /**
  20290. * Scales the spherical harmonics by the given amount
  20291. * @param scale the amount to scale
  20292. */
  20293. scaleInPlace(scale: number): void;
  20294. /**
  20295. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20296. *
  20297. * ```
  20298. * E_lm = A_l * L_lm
  20299. * ```
  20300. *
  20301. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20302. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20303. * the scaling factors are given in equation 9.
  20304. */
  20305. convertIncidentRadianceToIrradiance(): void;
  20306. /**
  20307. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20308. *
  20309. * ```
  20310. * L = (1/pi) * E * rho
  20311. * ```
  20312. *
  20313. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20314. */
  20315. convertIrradianceToLambertianRadiance(): void;
  20316. /**
  20317. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20318. * required operations at run time.
  20319. *
  20320. * This is simply done by scaling back the SH with Ylm constants parameter.
  20321. * The trigonometric part being applied by the shader at run time.
  20322. */
  20323. preScaleForRendering(): void;
  20324. /**
  20325. * Constructs a spherical harmonics from an array.
  20326. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20327. * @returns the spherical harmonics
  20328. */
  20329. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20330. /**
  20331. * Gets the spherical harmonics from polynomial
  20332. * @param polynomial the spherical polynomial
  20333. * @returns the spherical harmonics
  20334. */
  20335. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20336. }
  20337. /**
  20338. * Class representing spherical polynomial coefficients to the 3rd degree
  20339. */
  20340. export class SphericalPolynomial {
  20341. private _harmonics;
  20342. /**
  20343. * The spherical harmonics used to create the polynomials.
  20344. */
  20345. get preScaledHarmonics(): SphericalHarmonics;
  20346. /**
  20347. * The x coefficients of the spherical polynomial
  20348. */
  20349. x: Vector3;
  20350. /**
  20351. * The y coefficients of the spherical polynomial
  20352. */
  20353. y: Vector3;
  20354. /**
  20355. * The z coefficients of the spherical polynomial
  20356. */
  20357. z: Vector3;
  20358. /**
  20359. * The xx coefficients of the spherical polynomial
  20360. */
  20361. xx: Vector3;
  20362. /**
  20363. * The yy coefficients of the spherical polynomial
  20364. */
  20365. yy: Vector3;
  20366. /**
  20367. * The zz coefficients of the spherical polynomial
  20368. */
  20369. zz: Vector3;
  20370. /**
  20371. * The xy coefficients of the spherical polynomial
  20372. */
  20373. xy: Vector3;
  20374. /**
  20375. * The yz coefficients of the spherical polynomial
  20376. */
  20377. yz: Vector3;
  20378. /**
  20379. * The zx coefficients of the spherical polynomial
  20380. */
  20381. zx: Vector3;
  20382. /**
  20383. * Adds an ambient color to the spherical polynomial
  20384. * @param color the color to add
  20385. */
  20386. addAmbient(color: Color3): void;
  20387. /**
  20388. * Scales the spherical polynomial by the given amount
  20389. * @param scale the amount to scale
  20390. */
  20391. scaleInPlace(scale: number): void;
  20392. /**
  20393. * Gets the spherical polynomial from harmonics
  20394. * @param harmonics the spherical harmonics
  20395. * @returns the spherical polynomial
  20396. */
  20397. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20398. /**
  20399. * Constructs a spherical polynomial from an array.
  20400. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20401. * @returns the spherical polynomial
  20402. */
  20403. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20404. }
  20405. }
  20406. declare module BABYLON {
  20407. /**
  20408. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20409. */
  20410. export interface CubeMapInfo {
  20411. /**
  20412. * The pixel array for the front face.
  20413. * This is stored in format, left to right, up to down format.
  20414. */
  20415. front: Nullable<ArrayBufferView>;
  20416. /**
  20417. * The pixel array for the back face.
  20418. * This is stored in format, left to right, up to down format.
  20419. */
  20420. back: Nullable<ArrayBufferView>;
  20421. /**
  20422. * The pixel array for the left face.
  20423. * This is stored in format, left to right, up to down format.
  20424. */
  20425. left: Nullable<ArrayBufferView>;
  20426. /**
  20427. * The pixel array for the right face.
  20428. * This is stored in format, left to right, up to down format.
  20429. */
  20430. right: Nullable<ArrayBufferView>;
  20431. /**
  20432. * The pixel array for the up face.
  20433. * This is stored in format, left to right, up to down format.
  20434. */
  20435. up: Nullable<ArrayBufferView>;
  20436. /**
  20437. * The pixel array for the down face.
  20438. * This is stored in format, left to right, up to down format.
  20439. */
  20440. down: Nullable<ArrayBufferView>;
  20441. /**
  20442. * The size of the cubemap stored.
  20443. *
  20444. * Each faces will be size * size pixels.
  20445. */
  20446. size: number;
  20447. /**
  20448. * The format of the texture.
  20449. *
  20450. * RGBA, RGB.
  20451. */
  20452. format: number;
  20453. /**
  20454. * The type of the texture data.
  20455. *
  20456. * UNSIGNED_INT, FLOAT.
  20457. */
  20458. type: number;
  20459. /**
  20460. * Specifies whether the texture is in gamma space.
  20461. */
  20462. gammaSpace: boolean;
  20463. }
  20464. /**
  20465. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20466. */
  20467. export class PanoramaToCubeMapTools {
  20468. private static FACE_LEFT;
  20469. private static FACE_RIGHT;
  20470. private static FACE_FRONT;
  20471. private static FACE_BACK;
  20472. private static FACE_DOWN;
  20473. private static FACE_UP;
  20474. /**
  20475. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20476. *
  20477. * @param float32Array The source data.
  20478. * @param inputWidth The width of the input panorama.
  20479. * @param inputHeight The height of the input panorama.
  20480. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20481. * @return The cubemap data
  20482. */
  20483. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20484. private static CreateCubemapTexture;
  20485. private static CalcProjectionSpherical;
  20486. }
  20487. }
  20488. declare module BABYLON {
  20489. /**
  20490. * Helper class dealing with the extraction of spherical polynomial dataArray
  20491. * from a cube map.
  20492. */
  20493. export class CubeMapToSphericalPolynomialTools {
  20494. private static FileFaces;
  20495. /**
  20496. * Converts a texture to the according Spherical Polynomial data.
  20497. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20498. *
  20499. * @param texture The texture to extract the information from.
  20500. * @return The Spherical Polynomial data.
  20501. */
  20502. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20503. /**
  20504. * Converts a cubemap to the according Spherical Polynomial data.
  20505. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20506. *
  20507. * @param cubeInfo The Cube map to extract the information from.
  20508. * @return The Spherical Polynomial data.
  20509. */
  20510. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20511. }
  20512. }
  20513. declare module BABYLON {
  20514. interface BaseTexture {
  20515. /**
  20516. * Get the polynomial representation of the texture data.
  20517. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20518. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20519. */
  20520. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20521. }
  20522. }
  20523. declare module BABYLON {
  20524. /** @hidden */
  20525. export var pbrFragmentDeclaration: {
  20526. name: string;
  20527. shader: string;
  20528. };
  20529. }
  20530. declare module BABYLON {
  20531. /** @hidden */
  20532. export var pbrUboDeclaration: {
  20533. name: string;
  20534. shader: string;
  20535. };
  20536. }
  20537. declare module BABYLON {
  20538. /** @hidden */
  20539. export var pbrFragmentExtraDeclaration: {
  20540. name: string;
  20541. shader: string;
  20542. };
  20543. }
  20544. declare module BABYLON {
  20545. /** @hidden */
  20546. export var pbrFragmentSamplersDeclaration: {
  20547. name: string;
  20548. shader: string;
  20549. };
  20550. }
  20551. declare module BABYLON {
  20552. /** @hidden */
  20553. export var subSurfaceScatteringFunctions: {
  20554. name: string;
  20555. shader: string;
  20556. };
  20557. }
  20558. declare module BABYLON {
  20559. /** @hidden */
  20560. export var importanceSampling: {
  20561. name: string;
  20562. shader: string;
  20563. };
  20564. }
  20565. declare module BABYLON {
  20566. /** @hidden */
  20567. export var pbrHelperFunctions: {
  20568. name: string;
  20569. shader: string;
  20570. };
  20571. }
  20572. declare module BABYLON {
  20573. /** @hidden */
  20574. export var harmonicsFunctions: {
  20575. name: string;
  20576. shader: string;
  20577. };
  20578. }
  20579. declare module BABYLON {
  20580. /** @hidden */
  20581. export var pbrDirectLightingSetupFunctions: {
  20582. name: string;
  20583. shader: string;
  20584. };
  20585. }
  20586. declare module BABYLON {
  20587. /** @hidden */
  20588. export var pbrDirectLightingFalloffFunctions: {
  20589. name: string;
  20590. shader: string;
  20591. };
  20592. }
  20593. declare module BABYLON {
  20594. /** @hidden */
  20595. export var pbrBRDFFunctions: {
  20596. name: string;
  20597. shader: string;
  20598. };
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var hdrFilteringFunctions: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /** @hidden */
  20609. export var pbrDirectLightingFunctions: {
  20610. name: string;
  20611. shader: string;
  20612. };
  20613. }
  20614. declare module BABYLON {
  20615. /** @hidden */
  20616. export var pbrIBLFunctions: {
  20617. name: string;
  20618. shader: string;
  20619. };
  20620. }
  20621. declare module BABYLON {
  20622. /** @hidden */
  20623. export var pbrBlockAlbedoOpacity: {
  20624. name: string;
  20625. shader: string;
  20626. };
  20627. }
  20628. declare module BABYLON {
  20629. /** @hidden */
  20630. export var pbrBlockReflectivity: {
  20631. name: string;
  20632. shader: string;
  20633. };
  20634. }
  20635. declare module BABYLON {
  20636. /** @hidden */
  20637. export var pbrBlockAmbientOcclusion: {
  20638. name: string;
  20639. shader: string;
  20640. };
  20641. }
  20642. declare module BABYLON {
  20643. /** @hidden */
  20644. export var pbrBlockAlphaFresnel: {
  20645. name: string;
  20646. shader: string;
  20647. };
  20648. }
  20649. declare module BABYLON {
  20650. /** @hidden */
  20651. export var pbrBlockAnisotropic: {
  20652. name: string;
  20653. shader: string;
  20654. };
  20655. }
  20656. declare module BABYLON {
  20657. /** @hidden */
  20658. export var pbrBlockReflection: {
  20659. name: string;
  20660. shader: string;
  20661. };
  20662. }
  20663. declare module BABYLON {
  20664. /** @hidden */
  20665. export var pbrBlockSheen: {
  20666. name: string;
  20667. shader: string;
  20668. };
  20669. }
  20670. declare module BABYLON {
  20671. /** @hidden */
  20672. export var pbrBlockClearcoat: {
  20673. name: string;
  20674. shader: string;
  20675. };
  20676. }
  20677. declare module BABYLON {
  20678. /** @hidden */
  20679. export var pbrBlockSubSurface: {
  20680. name: string;
  20681. shader: string;
  20682. };
  20683. }
  20684. declare module BABYLON {
  20685. /** @hidden */
  20686. export var pbrBlockNormalGeometric: {
  20687. name: string;
  20688. shader: string;
  20689. };
  20690. }
  20691. declare module BABYLON {
  20692. /** @hidden */
  20693. export var pbrBlockNormalFinal: {
  20694. name: string;
  20695. shader: string;
  20696. };
  20697. }
  20698. declare module BABYLON {
  20699. /** @hidden */
  20700. export var pbrBlockLightmapInit: {
  20701. name: string;
  20702. shader: string;
  20703. };
  20704. }
  20705. declare module BABYLON {
  20706. /** @hidden */
  20707. export var pbrBlockGeometryInfo: {
  20708. name: string;
  20709. shader: string;
  20710. };
  20711. }
  20712. declare module BABYLON {
  20713. /** @hidden */
  20714. export var pbrBlockReflectance0: {
  20715. name: string;
  20716. shader: string;
  20717. };
  20718. }
  20719. declare module BABYLON {
  20720. /** @hidden */
  20721. export var pbrBlockReflectance: {
  20722. name: string;
  20723. shader: string;
  20724. };
  20725. }
  20726. declare module BABYLON {
  20727. /** @hidden */
  20728. export var pbrBlockDirectLighting: {
  20729. name: string;
  20730. shader: string;
  20731. };
  20732. }
  20733. declare module BABYLON {
  20734. /** @hidden */
  20735. export var pbrBlockFinalLitComponents: {
  20736. name: string;
  20737. shader: string;
  20738. };
  20739. }
  20740. declare module BABYLON {
  20741. /** @hidden */
  20742. export var pbrBlockFinalUnlitComponents: {
  20743. name: string;
  20744. shader: string;
  20745. };
  20746. }
  20747. declare module BABYLON {
  20748. /** @hidden */
  20749. export var pbrBlockFinalColorComposition: {
  20750. name: string;
  20751. shader: string;
  20752. };
  20753. }
  20754. declare module BABYLON {
  20755. /** @hidden */
  20756. export var pbrBlockImageProcessing: {
  20757. name: string;
  20758. shader: string;
  20759. };
  20760. }
  20761. declare module BABYLON {
  20762. /** @hidden */
  20763. export var pbrDebug: {
  20764. name: string;
  20765. shader: string;
  20766. };
  20767. }
  20768. declare module BABYLON {
  20769. /** @hidden */
  20770. export var pbrPixelShader: {
  20771. name: string;
  20772. shader: string;
  20773. };
  20774. }
  20775. declare module BABYLON {
  20776. /** @hidden */
  20777. export var pbrVertexDeclaration: {
  20778. name: string;
  20779. shader: string;
  20780. };
  20781. }
  20782. declare module BABYLON {
  20783. /** @hidden */
  20784. export var pbrVertexShader: {
  20785. name: string;
  20786. shader: string;
  20787. };
  20788. }
  20789. declare module BABYLON {
  20790. /**
  20791. * Manages the defines for the PBR Material.
  20792. * @hidden
  20793. */
  20794. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20795. PBR: boolean;
  20796. NUM_SAMPLES: string;
  20797. REALTIME_FILTERING: boolean;
  20798. MAINUV1: boolean;
  20799. MAINUV2: boolean;
  20800. UV1: boolean;
  20801. UV2: boolean;
  20802. ALBEDO: boolean;
  20803. GAMMAALBEDO: boolean;
  20804. ALBEDODIRECTUV: number;
  20805. VERTEXCOLOR: boolean;
  20806. DETAIL: boolean;
  20807. DETAILDIRECTUV: number;
  20808. DETAIL_NORMALBLENDMETHOD: number;
  20809. AMBIENT: boolean;
  20810. AMBIENTDIRECTUV: number;
  20811. AMBIENTINGRAYSCALE: boolean;
  20812. OPACITY: boolean;
  20813. VERTEXALPHA: boolean;
  20814. OPACITYDIRECTUV: number;
  20815. OPACITYRGB: boolean;
  20816. ALPHATEST: boolean;
  20817. DEPTHPREPASS: boolean;
  20818. ALPHABLEND: boolean;
  20819. ALPHAFROMALBEDO: boolean;
  20820. ALPHATESTVALUE: string;
  20821. SPECULAROVERALPHA: boolean;
  20822. RADIANCEOVERALPHA: boolean;
  20823. ALPHAFRESNEL: boolean;
  20824. LINEARALPHAFRESNEL: boolean;
  20825. PREMULTIPLYALPHA: boolean;
  20826. EMISSIVE: boolean;
  20827. EMISSIVEDIRECTUV: number;
  20828. REFLECTIVITY: boolean;
  20829. REFLECTIVITYDIRECTUV: number;
  20830. SPECULARTERM: boolean;
  20831. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20832. MICROSURFACEAUTOMATIC: boolean;
  20833. LODBASEDMICROSFURACE: boolean;
  20834. MICROSURFACEMAP: boolean;
  20835. MICROSURFACEMAPDIRECTUV: number;
  20836. METALLICWORKFLOW: boolean;
  20837. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20838. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20839. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20840. AOSTOREINMETALMAPRED: boolean;
  20841. METALLIC_REFLECTANCE: boolean;
  20842. METALLIC_REFLECTANCEDIRECTUV: number;
  20843. ENVIRONMENTBRDF: boolean;
  20844. ENVIRONMENTBRDF_RGBD: boolean;
  20845. NORMAL: boolean;
  20846. TANGENT: boolean;
  20847. BUMP: boolean;
  20848. BUMPDIRECTUV: number;
  20849. OBJECTSPACE_NORMALMAP: boolean;
  20850. PARALLAX: boolean;
  20851. PARALLAXOCCLUSION: boolean;
  20852. NORMALXYSCALE: boolean;
  20853. LIGHTMAP: boolean;
  20854. LIGHTMAPDIRECTUV: number;
  20855. USELIGHTMAPASSHADOWMAP: boolean;
  20856. GAMMALIGHTMAP: boolean;
  20857. RGBDLIGHTMAP: boolean;
  20858. REFLECTION: boolean;
  20859. REFLECTIONMAP_3D: boolean;
  20860. REFLECTIONMAP_SPHERICAL: boolean;
  20861. REFLECTIONMAP_PLANAR: boolean;
  20862. REFLECTIONMAP_CUBIC: boolean;
  20863. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20864. REFLECTIONMAP_PROJECTION: boolean;
  20865. REFLECTIONMAP_SKYBOX: boolean;
  20866. REFLECTIONMAP_EXPLICIT: boolean;
  20867. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20868. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20869. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20870. INVERTCUBICMAP: boolean;
  20871. USESPHERICALFROMREFLECTIONMAP: boolean;
  20872. USEIRRADIANCEMAP: boolean;
  20873. SPHERICAL_HARMONICS: boolean;
  20874. USESPHERICALINVERTEX: boolean;
  20875. REFLECTIONMAP_OPPOSITEZ: boolean;
  20876. LODINREFLECTIONALPHA: boolean;
  20877. GAMMAREFLECTION: boolean;
  20878. RGBDREFLECTION: boolean;
  20879. LINEARSPECULARREFLECTION: boolean;
  20880. RADIANCEOCCLUSION: boolean;
  20881. HORIZONOCCLUSION: boolean;
  20882. INSTANCES: boolean;
  20883. THIN_INSTANCES: boolean;
  20884. PREPASS: boolean;
  20885. PREPASS_IRRADIANCE: boolean;
  20886. PREPASS_IRRADIANCE_INDEX: number;
  20887. PREPASS_ALBEDO: boolean;
  20888. PREPASS_ALBEDO_INDEX: number;
  20889. PREPASS_DEPTHNORMAL: boolean;
  20890. PREPASS_DEPTHNORMAL_INDEX: number;
  20891. PREPASS_POSITION: boolean;
  20892. PREPASS_POSITION_INDEX: number;
  20893. PREPASS_VELOCITY: boolean;
  20894. PREPASS_VELOCITY_INDEX: number;
  20895. PREPASS_REFLECTIVITY: boolean;
  20896. PREPASS_REFLECTIVITY_INDEX: number;
  20897. SCENE_MRT_COUNT: number;
  20898. NUM_BONE_INFLUENCERS: number;
  20899. BonesPerMesh: number;
  20900. BONETEXTURE: boolean;
  20901. BONES_VELOCITY_ENABLED: boolean;
  20902. NONUNIFORMSCALING: boolean;
  20903. MORPHTARGETS: boolean;
  20904. MORPHTARGETS_NORMAL: boolean;
  20905. MORPHTARGETS_TANGENT: boolean;
  20906. MORPHTARGETS_UV: boolean;
  20907. NUM_MORPH_INFLUENCERS: number;
  20908. IMAGEPROCESSING: boolean;
  20909. VIGNETTE: boolean;
  20910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20911. VIGNETTEBLENDMODEOPAQUE: boolean;
  20912. TONEMAPPING: boolean;
  20913. TONEMAPPING_ACES: boolean;
  20914. CONTRAST: boolean;
  20915. COLORCURVES: boolean;
  20916. COLORGRADING: boolean;
  20917. COLORGRADING3D: boolean;
  20918. SAMPLER3DGREENDEPTH: boolean;
  20919. SAMPLER3DBGRMAP: boolean;
  20920. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20921. EXPOSURE: boolean;
  20922. MULTIVIEW: boolean;
  20923. USEPHYSICALLIGHTFALLOFF: boolean;
  20924. USEGLTFLIGHTFALLOFF: boolean;
  20925. TWOSIDEDLIGHTING: boolean;
  20926. SHADOWFLOAT: boolean;
  20927. CLIPPLANE: boolean;
  20928. CLIPPLANE2: boolean;
  20929. CLIPPLANE3: boolean;
  20930. CLIPPLANE4: boolean;
  20931. CLIPPLANE5: boolean;
  20932. CLIPPLANE6: boolean;
  20933. POINTSIZE: boolean;
  20934. FOG: boolean;
  20935. LOGARITHMICDEPTH: boolean;
  20936. FORCENORMALFORWARD: boolean;
  20937. SPECULARAA: boolean;
  20938. CLEARCOAT: boolean;
  20939. CLEARCOAT_DEFAULTIOR: boolean;
  20940. CLEARCOAT_TEXTURE: boolean;
  20941. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20942. CLEARCOAT_TEXTUREDIRECTUV: number;
  20943. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20944. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20945. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20946. CLEARCOAT_BUMP: boolean;
  20947. CLEARCOAT_BUMPDIRECTUV: number;
  20948. CLEARCOAT_REMAP_F0: boolean;
  20949. CLEARCOAT_TINT: boolean;
  20950. CLEARCOAT_TINT_TEXTURE: boolean;
  20951. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20952. ANISOTROPIC: boolean;
  20953. ANISOTROPIC_TEXTURE: boolean;
  20954. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20955. BRDF_V_HEIGHT_CORRELATED: boolean;
  20956. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20957. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20958. SHEEN: boolean;
  20959. SHEEN_TEXTURE: boolean;
  20960. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20961. SHEEN_TEXTUREDIRECTUV: number;
  20962. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20963. SHEEN_LINKWITHALBEDO: boolean;
  20964. SHEEN_ROUGHNESS: boolean;
  20965. SHEEN_ALBEDOSCALING: boolean;
  20966. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20967. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20968. SUBSURFACE: boolean;
  20969. SS_REFRACTION: boolean;
  20970. SS_TRANSLUCENCY: boolean;
  20971. SS_SCATTERING: boolean;
  20972. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20973. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20974. SS_REFRACTIONMAP_3D: boolean;
  20975. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20976. SS_LODINREFRACTIONALPHA: boolean;
  20977. SS_GAMMAREFRACTION: boolean;
  20978. SS_RGBDREFRACTION: boolean;
  20979. SS_LINEARSPECULARREFRACTION: boolean;
  20980. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20981. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20982. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20983. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20984. UNLIT: boolean;
  20985. DEBUGMODE: number;
  20986. /**
  20987. * Initializes the PBR Material defines.
  20988. */
  20989. constructor();
  20990. /**
  20991. * Resets the PBR Material defines.
  20992. */
  20993. reset(): void;
  20994. }
  20995. /**
  20996. * The Physically based material base class of BJS.
  20997. *
  20998. * This offers the main features of a standard PBR material.
  20999. * For more information, please refer to the documentation :
  21000. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21001. */
  21002. export abstract class PBRBaseMaterial extends PushMaterial {
  21003. /**
  21004. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21005. */
  21006. static readonly PBRMATERIAL_OPAQUE: number;
  21007. /**
  21008. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21009. */
  21010. static readonly PBRMATERIAL_ALPHATEST: number;
  21011. /**
  21012. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21013. */
  21014. static readonly PBRMATERIAL_ALPHABLEND: number;
  21015. /**
  21016. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21017. * They are also discarded below the alpha cutoff threshold to improve performances.
  21018. */
  21019. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21020. /**
  21021. * Defines the default value of how much AO map is occluding the analytical lights
  21022. * (point spot...).
  21023. */
  21024. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21025. /**
  21026. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21027. */
  21028. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21029. /**
  21030. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21031. * to enhance interoperability with other engines.
  21032. */
  21033. static readonly LIGHTFALLOFF_GLTF: number;
  21034. /**
  21035. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21036. * to enhance interoperability with other materials.
  21037. */
  21038. static readonly LIGHTFALLOFF_STANDARD: number;
  21039. /**
  21040. * Intensity of the direct lights e.g. the four lights available in your scene.
  21041. * This impacts both the direct diffuse and specular highlights.
  21042. */
  21043. protected _directIntensity: number;
  21044. /**
  21045. * Intensity of the emissive part of the material.
  21046. * This helps controlling the emissive effect without modifying the emissive color.
  21047. */
  21048. protected _emissiveIntensity: number;
  21049. /**
  21050. * Intensity of the environment e.g. how much the environment will light the object
  21051. * either through harmonics for rough material or through the refelction for shiny ones.
  21052. */
  21053. protected _environmentIntensity: number;
  21054. /**
  21055. * This is a special control allowing the reduction of the specular highlights coming from the
  21056. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21057. */
  21058. protected _specularIntensity: number;
  21059. /**
  21060. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21061. */
  21062. private _lightingInfos;
  21063. /**
  21064. * Debug Control allowing disabling the bump map on this material.
  21065. */
  21066. protected _disableBumpMap: boolean;
  21067. /**
  21068. * AKA Diffuse Texture in standard nomenclature.
  21069. */
  21070. protected _albedoTexture: Nullable<BaseTexture>;
  21071. /**
  21072. * AKA Occlusion Texture in other nomenclature.
  21073. */
  21074. protected _ambientTexture: Nullable<BaseTexture>;
  21075. /**
  21076. * AKA Occlusion Texture Intensity in other nomenclature.
  21077. */
  21078. protected _ambientTextureStrength: number;
  21079. /**
  21080. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21081. * 1 means it completely occludes it
  21082. * 0 mean it has no impact
  21083. */
  21084. protected _ambientTextureImpactOnAnalyticalLights: number;
  21085. /**
  21086. * Stores the alpha values in a texture.
  21087. */
  21088. protected _opacityTexture: Nullable<BaseTexture>;
  21089. /**
  21090. * Stores the reflection values in a texture.
  21091. */
  21092. protected _reflectionTexture: Nullable<BaseTexture>;
  21093. /**
  21094. * Stores the emissive values in a texture.
  21095. */
  21096. protected _emissiveTexture: Nullable<BaseTexture>;
  21097. /**
  21098. * AKA Specular texture in other nomenclature.
  21099. */
  21100. protected _reflectivityTexture: Nullable<BaseTexture>;
  21101. /**
  21102. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21103. */
  21104. protected _metallicTexture: Nullable<BaseTexture>;
  21105. /**
  21106. * Specifies the metallic scalar of the metallic/roughness workflow.
  21107. * Can also be used to scale the metalness values of the metallic texture.
  21108. */
  21109. protected _metallic: Nullable<number>;
  21110. /**
  21111. * Specifies the roughness scalar of the metallic/roughness workflow.
  21112. * Can also be used to scale the roughness values of the metallic texture.
  21113. */
  21114. protected _roughness: Nullable<number>;
  21115. /**
  21116. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21117. * By default the indexOfrefraction is used to compute F0;
  21118. *
  21119. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21120. *
  21121. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21122. * F90 = metallicReflectanceColor;
  21123. */
  21124. protected _metallicF0Factor: number;
  21125. /**
  21126. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21127. * By default the F90 is always 1;
  21128. *
  21129. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21130. *
  21131. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21132. * F90 = metallicReflectanceColor;
  21133. */
  21134. protected _metallicReflectanceColor: Color3;
  21135. /**
  21136. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21137. * This is multiply against the scalar values defined in the material.
  21138. */
  21139. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21140. /**
  21141. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21142. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21143. */
  21144. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21145. /**
  21146. * Stores surface normal data used to displace a mesh in a texture.
  21147. */
  21148. protected _bumpTexture: Nullable<BaseTexture>;
  21149. /**
  21150. * Stores the pre-calculated light information of a mesh in a texture.
  21151. */
  21152. protected _lightmapTexture: Nullable<BaseTexture>;
  21153. /**
  21154. * The color of a material in ambient lighting.
  21155. */
  21156. protected _ambientColor: Color3;
  21157. /**
  21158. * AKA Diffuse Color in other nomenclature.
  21159. */
  21160. protected _albedoColor: Color3;
  21161. /**
  21162. * AKA Specular Color in other nomenclature.
  21163. */
  21164. protected _reflectivityColor: Color3;
  21165. /**
  21166. * The color applied when light is reflected from a material.
  21167. */
  21168. protected _reflectionColor: Color3;
  21169. /**
  21170. * The color applied when light is emitted from a material.
  21171. */
  21172. protected _emissiveColor: Color3;
  21173. /**
  21174. * AKA Glossiness in other nomenclature.
  21175. */
  21176. protected _microSurface: number;
  21177. /**
  21178. * Specifies that the material will use the light map as a show map.
  21179. */
  21180. protected _useLightmapAsShadowmap: boolean;
  21181. /**
  21182. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21183. * makes the reflect vector face the model (under horizon).
  21184. */
  21185. protected _useHorizonOcclusion: boolean;
  21186. /**
  21187. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21188. * too much the area relying on ambient texture to define their ambient occlusion.
  21189. */
  21190. protected _useRadianceOcclusion: boolean;
  21191. /**
  21192. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21193. */
  21194. protected _useAlphaFromAlbedoTexture: boolean;
  21195. /**
  21196. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21197. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21198. */
  21199. protected _useSpecularOverAlpha: boolean;
  21200. /**
  21201. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21202. */
  21203. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21204. /**
  21205. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21206. */
  21207. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21208. /**
  21209. * Specifies if the metallic texture contains the roughness information in its green channel.
  21210. */
  21211. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21212. /**
  21213. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21214. */
  21215. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21216. /**
  21217. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21218. */
  21219. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21220. /**
  21221. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21222. */
  21223. protected _useAmbientInGrayScale: boolean;
  21224. /**
  21225. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21226. * The material will try to infer what glossiness each pixel should be.
  21227. */
  21228. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21229. /**
  21230. * Defines the falloff type used in this material.
  21231. * It by default is Physical.
  21232. */
  21233. protected _lightFalloff: number;
  21234. /**
  21235. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21236. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21237. */
  21238. protected _useRadianceOverAlpha: boolean;
  21239. /**
  21240. * Allows using an object space normal map (instead of tangent space).
  21241. */
  21242. protected _useObjectSpaceNormalMap: boolean;
  21243. /**
  21244. * Allows using the bump map in parallax mode.
  21245. */
  21246. protected _useParallax: boolean;
  21247. /**
  21248. * Allows using the bump map in parallax occlusion mode.
  21249. */
  21250. protected _useParallaxOcclusion: boolean;
  21251. /**
  21252. * Controls the scale bias of the parallax mode.
  21253. */
  21254. protected _parallaxScaleBias: number;
  21255. /**
  21256. * If sets to true, disables all the lights affecting the material.
  21257. */
  21258. protected _disableLighting: boolean;
  21259. /**
  21260. * Number of Simultaneous lights allowed on the material.
  21261. */
  21262. protected _maxSimultaneousLights: number;
  21263. /**
  21264. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21265. */
  21266. protected _invertNormalMapX: boolean;
  21267. /**
  21268. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21269. */
  21270. protected _invertNormalMapY: boolean;
  21271. /**
  21272. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21273. */
  21274. protected _twoSidedLighting: boolean;
  21275. /**
  21276. * Defines the alpha limits in alpha test mode.
  21277. */
  21278. protected _alphaCutOff: number;
  21279. /**
  21280. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21281. */
  21282. protected _forceAlphaTest: boolean;
  21283. /**
  21284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21285. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21286. */
  21287. protected _useAlphaFresnel: boolean;
  21288. /**
  21289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21290. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21291. */
  21292. protected _useLinearAlphaFresnel: boolean;
  21293. /**
  21294. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21295. * from cos thetav and roughness:
  21296. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21297. */
  21298. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21299. /**
  21300. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21301. */
  21302. protected _forceIrradianceInFragment: boolean;
  21303. private _realTimeFiltering;
  21304. /**
  21305. * Enables realtime filtering on the texture.
  21306. */
  21307. get realTimeFiltering(): boolean;
  21308. set realTimeFiltering(b: boolean);
  21309. private _realTimeFilteringQuality;
  21310. /**
  21311. * Quality switch for realtime filtering
  21312. */
  21313. get realTimeFilteringQuality(): number;
  21314. set realTimeFilteringQuality(n: number);
  21315. /**
  21316. * Can this material render to several textures at once
  21317. */
  21318. get canRenderToMRT(): boolean;
  21319. /**
  21320. * Force normal to face away from face.
  21321. */
  21322. protected _forceNormalForward: boolean;
  21323. /**
  21324. * Enables specular anti aliasing in the PBR shader.
  21325. * It will both interacts on the Geometry for analytical and IBL lighting.
  21326. * It also prefilter the roughness map based on the bump values.
  21327. */
  21328. protected _enableSpecularAntiAliasing: boolean;
  21329. /**
  21330. * Default configuration related to image processing available in the PBR Material.
  21331. */
  21332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21333. /**
  21334. * Keep track of the image processing observer to allow dispose and replace.
  21335. */
  21336. private _imageProcessingObserver;
  21337. /**
  21338. * Attaches a new image processing configuration to the PBR Material.
  21339. * @param configuration
  21340. */
  21341. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21342. /**
  21343. * Stores the available render targets.
  21344. */
  21345. private _renderTargets;
  21346. /**
  21347. * Sets the global ambient color for the material used in lighting calculations.
  21348. */
  21349. private _globalAmbientColor;
  21350. /**
  21351. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21352. */
  21353. private _useLogarithmicDepth;
  21354. /**
  21355. * If set to true, no lighting calculations will be applied.
  21356. */
  21357. private _unlit;
  21358. private _debugMode;
  21359. /**
  21360. * @hidden
  21361. * This is reserved for the inspector.
  21362. * Defines the material debug mode.
  21363. * It helps seeing only some components of the material while troubleshooting.
  21364. */
  21365. debugMode: number;
  21366. /**
  21367. * @hidden
  21368. * This is reserved for the inspector.
  21369. * Specify from where on screen the debug mode should start.
  21370. * The value goes from -1 (full screen) to 1 (not visible)
  21371. * It helps with side by side comparison against the final render
  21372. * This defaults to -1
  21373. */
  21374. private debugLimit;
  21375. /**
  21376. * @hidden
  21377. * This is reserved for the inspector.
  21378. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21379. * You can use the factor to better multiply the final value.
  21380. */
  21381. private debugFactor;
  21382. /**
  21383. * Defines the clear coat layer parameters for the material.
  21384. */
  21385. readonly clearCoat: PBRClearCoatConfiguration;
  21386. /**
  21387. * Defines the anisotropic parameters for the material.
  21388. */
  21389. readonly anisotropy: PBRAnisotropicConfiguration;
  21390. /**
  21391. * Defines the BRDF parameters for the material.
  21392. */
  21393. readonly brdf: PBRBRDFConfiguration;
  21394. /**
  21395. * Defines the Sheen parameters for the material.
  21396. */
  21397. readonly sheen: PBRSheenConfiguration;
  21398. /**
  21399. * Defines the SubSurface parameters for the material.
  21400. */
  21401. readonly subSurface: PBRSubSurfaceConfiguration;
  21402. /**
  21403. * Defines additionnal PrePass parameters for the material.
  21404. */
  21405. readonly prePassConfiguration: PrePassConfiguration;
  21406. /**
  21407. * Defines the detail map parameters for the material.
  21408. */
  21409. readonly detailMap: DetailMapConfiguration;
  21410. protected _rebuildInParallel: boolean;
  21411. /**
  21412. * Instantiates a new PBRMaterial instance.
  21413. *
  21414. * @param name The material name
  21415. * @param scene The scene the material will be use in.
  21416. */
  21417. constructor(name: string, scene: Scene);
  21418. /**
  21419. * Gets a boolean indicating that current material needs to register RTT
  21420. */
  21421. get hasRenderTargetTextures(): boolean;
  21422. /**
  21423. * Gets the name of the material class.
  21424. */
  21425. getClassName(): string;
  21426. /**
  21427. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21428. */
  21429. get useLogarithmicDepth(): boolean;
  21430. /**
  21431. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21432. */
  21433. set useLogarithmicDepth(value: boolean);
  21434. /**
  21435. * Returns true if alpha blending should be disabled.
  21436. */
  21437. protected get _disableAlphaBlending(): boolean;
  21438. /**
  21439. * Specifies whether or not this material should be rendered in alpha blend mode.
  21440. */
  21441. needAlphaBlending(): boolean;
  21442. /**
  21443. * Specifies whether or not this material should be rendered in alpha test mode.
  21444. */
  21445. needAlphaTesting(): boolean;
  21446. /**
  21447. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21448. */
  21449. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21450. /**
  21451. * Specifies whether or not there is a usable alpha channel for transparency.
  21452. */
  21453. protected _hasAlphaChannel(): boolean;
  21454. /**
  21455. * Gets the texture used for the alpha test.
  21456. */
  21457. getAlphaTestTexture(): Nullable<BaseTexture>;
  21458. /**
  21459. * Specifies that the submesh is ready to be used.
  21460. * @param mesh - BJS mesh.
  21461. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21462. * @param useInstances - Specifies that instances should be used.
  21463. * @returns - boolean indicating that the submesh is ready or not.
  21464. */
  21465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21466. /**
  21467. * Specifies if the material uses metallic roughness workflow.
  21468. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21469. */
  21470. isMetallicWorkflow(): boolean;
  21471. private _prepareEffect;
  21472. private _prepareDefines;
  21473. /**
  21474. * Force shader compilation
  21475. */
  21476. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21477. /**
  21478. * Initializes the uniform buffer layout for the shader.
  21479. */
  21480. buildUniformLayout(): void;
  21481. /**
  21482. * Unbinds the material from the mesh
  21483. */
  21484. unbind(): void;
  21485. /**
  21486. * Binds the submesh data.
  21487. * @param world - The world matrix.
  21488. * @param mesh - The BJS mesh.
  21489. * @param subMesh - A submesh of the BJS mesh.
  21490. */
  21491. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21492. /**
  21493. * Returns the animatable textures.
  21494. * @returns - Array of animatable textures.
  21495. */
  21496. getAnimatables(): IAnimatable[];
  21497. /**
  21498. * Returns the texture used for reflections.
  21499. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21500. */
  21501. private _getReflectionTexture;
  21502. /**
  21503. * Returns an array of the actively used textures.
  21504. * @returns - Array of BaseTextures
  21505. */
  21506. getActiveTextures(): BaseTexture[];
  21507. /**
  21508. * Checks to see if a texture is used in the material.
  21509. * @param texture - Base texture to use.
  21510. * @returns - Boolean specifying if a texture is used in the material.
  21511. */
  21512. hasTexture(texture: BaseTexture): boolean;
  21513. /**
  21514. * Sets the required values to the prepass renderer.
  21515. * @param prePassRenderer defines the prepass renderer to setup
  21516. */
  21517. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21518. /**
  21519. * Disposes the resources of the material.
  21520. * @param forceDisposeEffect - Forces the disposal of effects.
  21521. * @param forceDisposeTextures - Forces the disposal of all textures.
  21522. */
  21523. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21524. }
  21525. }
  21526. declare module BABYLON {
  21527. /**
  21528. * The Physically based material of BJS.
  21529. *
  21530. * This offers the main features of a standard PBR material.
  21531. * For more information, please refer to the documentation :
  21532. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21533. */
  21534. export class PBRMaterial extends PBRBaseMaterial {
  21535. /**
  21536. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21537. */
  21538. static readonly PBRMATERIAL_OPAQUE: number;
  21539. /**
  21540. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21541. */
  21542. static readonly PBRMATERIAL_ALPHATEST: number;
  21543. /**
  21544. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21545. */
  21546. static readonly PBRMATERIAL_ALPHABLEND: number;
  21547. /**
  21548. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21549. * They are also discarded below the alpha cutoff threshold to improve performances.
  21550. */
  21551. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21552. /**
  21553. * Defines the default value of how much AO map is occluding the analytical lights
  21554. * (point spot...).
  21555. */
  21556. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21557. /**
  21558. * Intensity of the direct lights e.g. the four lights available in your scene.
  21559. * This impacts both the direct diffuse and specular highlights.
  21560. */
  21561. directIntensity: number;
  21562. /**
  21563. * Intensity of the emissive part of the material.
  21564. * This helps controlling the emissive effect without modifying the emissive color.
  21565. */
  21566. emissiveIntensity: number;
  21567. /**
  21568. * Intensity of the environment e.g. how much the environment will light the object
  21569. * either through harmonics for rough material or through the refelction for shiny ones.
  21570. */
  21571. environmentIntensity: number;
  21572. /**
  21573. * This is a special control allowing the reduction of the specular highlights coming from the
  21574. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21575. */
  21576. specularIntensity: number;
  21577. /**
  21578. * Debug Control allowing disabling the bump map on this material.
  21579. */
  21580. disableBumpMap: boolean;
  21581. /**
  21582. * AKA Diffuse Texture in standard nomenclature.
  21583. */
  21584. albedoTexture: BaseTexture;
  21585. /**
  21586. * AKA Occlusion Texture in other nomenclature.
  21587. */
  21588. ambientTexture: BaseTexture;
  21589. /**
  21590. * AKA Occlusion Texture Intensity in other nomenclature.
  21591. */
  21592. ambientTextureStrength: number;
  21593. /**
  21594. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21595. * 1 means it completely occludes it
  21596. * 0 mean it has no impact
  21597. */
  21598. ambientTextureImpactOnAnalyticalLights: number;
  21599. /**
  21600. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21601. */
  21602. opacityTexture: BaseTexture;
  21603. /**
  21604. * Stores the reflection values in a texture.
  21605. */
  21606. reflectionTexture: Nullable<BaseTexture>;
  21607. /**
  21608. * Stores the emissive values in a texture.
  21609. */
  21610. emissiveTexture: BaseTexture;
  21611. /**
  21612. * AKA Specular texture in other nomenclature.
  21613. */
  21614. reflectivityTexture: BaseTexture;
  21615. /**
  21616. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21617. */
  21618. metallicTexture: BaseTexture;
  21619. /**
  21620. * Specifies the metallic scalar of the metallic/roughness workflow.
  21621. * Can also be used to scale the metalness values of the metallic texture.
  21622. */
  21623. metallic: Nullable<number>;
  21624. /**
  21625. * Specifies the roughness scalar of the metallic/roughness workflow.
  21626. * Can also be used to scale the roughness values of the metallic texture.
  21627. */
  21628. roughness: Nullable<number>;
  21629. /**
  21630. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21631. * By default the indexOfrefraction is used to compute F0;
  21632. *
  21633. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21634. *
  21635. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21636. * F90 = metallicReflectanceColor;
  21637. */
  21638. metallicF0Factor: number;
  21639. /**
  21640. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21641. * By default the F90 is always 1;
  21642. *
  21643. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21644. *
  21645. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21646. * F90 = metallicReflectanceColor;
  21647. */
  21648. metallicReflectanceColor: Color3;
  21649. /**
  21650. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21651. * This is multiply against the scalar values defined in the material.
  21652. */
  21653. metallicReflectanceTexture: Nullable<BaseTexture>;
  21654. /**
  21655. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21656. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21657. */
  21658. microSurfaceTexture: BaseTexture;
  21659. /**
  21660. * Stores surface normal data used to displace a mesh in a texture.
  21661. */
  21662. bumpTexture: BaseTexture;
  21663. /**
  21664. * Stores the pre-calculated light information of a mesh in a texture.
  21665. */
  21666. lightmapTexture: BaseTexture;
  21667. /**
  21668. * Stores the refracted light information in a texture.
  21669. */
  21670. get refractionTexture(): Nullable<BaseTexture>;
  21671. set refractionTexture(value: Nullable<BaseTexture>);
  21672. /**
  21673. * The color of a material in ambient lighting.
  21674. */
  21675. ambientColor: Color3;
  21676. /**
  21677. * AKA Diffuse Color in other nomenclature.
  21678. */
  21679. albedoColor: Color3;
  21680. /**
  21681. * AKA Specular Color in other nomenclature.
  21682. */
  21683. reflectivityColor: Color3;
  21684. /**
  21685. * The color reflected from the material.
  21686. */
  21687. reflectionColor: Color3;
  21688. /**
  21689. * The color emitted from the material.
  21690. */
  21691. emissiveColor: Color3;
  21692. /**
  21693. * AKA Glossiness in other nomenclature.
  21694. */
  21695. microSurface: number;
  21696. /**
  21697. * Index of refraction of the material base layer.
  21698. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21699. *
  21700. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21701. *
  21702. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21703. */
  21704. get indexOfRefraction(): number;
  21705. set indexOfRefraction(value: number);
  21706. /**
  21707. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21708. */
  21709. get invertRefractionY(): boolean;
  21710. set invertRefractionY(value: boolean);
  21711. /**
  21712. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21713. * Materials half opaque for instance using refraction could benefit from this control.
  21714. */
  21715. get linkRefractionWithTransparency(): boolean;
  21716. set linkRefractionWithTransparency(value: boolean);
  21717. /**
  21718. * If true, the light map contains occlusion information instead of lighting info.
  21719. */
  21720. useLightmapAsShadowmap: boolean;
  21721. /**
  21722. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21723. */
  21724. useAlphaFromAlbedoTexture: boolean;
  21725. /**
  21726. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21727. */
  21728. forceAlphaTest: boolean;
  21729. /**
  21730. * Defines the alpha limits in alpha test mode.
  21731. */
  21732. alphaCutOff: number;
  21733. /**
  21734. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21735. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21736. */
  21737. useSpecularOverAlpha: boolean;
  21738. /**
  21739. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21740. */
  21741. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21742. /**
  21743. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21744. */
  21745. useRoughnessFromMetallicTextureAlpha: boolean;
  21746. /**
  21747. * Specifies if the metallic texture contains the roughness information in its green channel.
  21748. */
  21749. useRoughnessFromMetallicTextureGreen: boolean;
  21750. /**
  21751. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21752. */
  21753. useMetallnessFromMetallicTextureBlue: boolean;
  21754. /**
  21755. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21756. */
  21757. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21758. /**
  21759. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21760. */
  21761. useAmbientInGrayScale: boolean;
  21762. /**
  21763. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21764. * The material will try to infer what glossiness each pixel should be.
  21765. */
  21766. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21767. /**
  21768. * BJS is using an harcoded light falloff based on a manually sets up range.
  21769. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21770. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21771. */
  21772. get usePhysicalLightFalloff(): boolean;
  21773. /**
  21774. * BJS is using an harcoded light falloff based on a manually sets up range.
  21775. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21776. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21777. */
  21778. set usePhysicalLightFalloff(value: boolean);
  21779. /**
  21780. * In order to support the falloff compatibility with gltf, a special mode has been added
  21781. * to reproduce the gltf light falloff.
  21782. */
  21783. get useGLTFLightFalloff(): boolean;
  21784. /**
  21785. * In order to support the falloff compatibility with gltf, a special mode has been added
  21786. * to reproduce the gltf light falloff.
  21787. */
  21788. set useGLTFLightFalloff(value: boolean);
  21789. /**
  21790. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21791. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21792. */
  21793. useRadianceOverAlpha: boolean;
  21794. /**
  21795. * Allows using an object space normal map (instead of tangent space).
  21796. */
  21797. useObjectSpaceNormalMap: boolean;
  21798. /**
  21799. * Allows using the bump map in parallax mode.
  21800. */
  21801. useParallax: boolean;
  21802. /**
  21803. * Allows using the bump map in parallax occlusion mode.
  21804. */
  21805. useParallaxOcclusion: boolean;
  21806. /**
  21807. * Controls the scale bias of the parallax mode.
  21808. */
  21809. parallaxScaleBias: number;
  21810. /**
  21811. * If sets to true, disables all the lights affecting the material.
  21812. */
  21813. disableLighting: boolean;
  21814. /**
  21815. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21816. */
  21817. forceIrradianceInFragment: boolean;
  21818. /**
  21819. * Number of Simultaneous lights allowed on the material.
  21820. */
  21821. maxSimultaneousLights: number;
  21822. /**
  21823. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21824. */
  21825. invertNormalMapX: boolean;
  21826. /**
  21827. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21828. */
  21829. invertNormalMapY: boolean;
  21830. /**
  21831. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21832. */
  21833. twoSidedLighting: boolean;
  21834. /**
  21835. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21836. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21837. */
  21838. useAlphaFresnel: boolean;
  21839. /**
  21840. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21841. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21842. */
  21843. useLinearAlphaFresnel: boolean;
  21844. /**
  21845. * Let user defines the brdf lookup texture used for IBL.
  21846. * A default 8bit version is embedded but you could point at :
  21847. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21848. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21849. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21850. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21851. */
  21852. environmentBRDFTexture: Nullable<BaseTexture>;
  21853. /**
  21854. * Force normal to face away from face.
  21855. */
  21856. forceNormalForward: boolean;
  21857. /**
  21858. * Enables specular anti aliasing in the PBR shader.
  21859. * It will both interacts on the Geometry for analytical and IBL lighting.
  21860. * It also prefilter the roughness map based on the bump values.
  21861. */
  21862. enableSpecularAntiAliasing: boolean;
  21863. /**
  21864. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21865. * makes the reflect vector face the model (under horizon).
  21866. */
  21867. useHorizonOcclusion: boolean;
  21868. /**
  21869. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21870. * too much the area relying on ambient texture to define their ambient occlusion.
  21871. */
  21872. useRadianceOcclusion: boolean;
  21873. /**
  21874. * If set to true, no lighting calculations will be applied.
  21875. */
  21876. unlit: boolean;
  21877. /**
  21878. * Gets the image processing configuration used either in this material.
  21879. */
  21880. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21881. /**
  21882. * Sets the Default image processing configuration used either in the this material.
  21883. *
  21884. * If sets to null, the scene one is in use.
  21885. */
  21886. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21887. /**
  21888. * Gets wether the color curves effect is enabled.
  21889. */
  21890. get cameraColorCurvesEnabled(): boolean;
  21891. /**
  21892. * Sets wether the color curves effect is enabled.
  21893. */
  21894. set cameraColorCurvesEnabled(value: boolean);
  21895. /**
  21896. * Gets wether the color grading effect is enabled.
  21897. */
  21898. get cameraColorGradingEnabled(): boolean;
  21899. /**
  21900. * Gets wether the color grading effect is enabled.
  21901. */
  21902. set cameraColorGradingEnabled(value: boolean);
  21903. /**
  21904. * Gets wether tonemapping is enabled or not.
  21905. */
  21906. get cameraToneMappingEnabled(): boolean;
  21907. /**
  21908. * Sets wether tonemapping is enabled or not
  21909. */
  21910. set cameraToneMappingEnabled(value: boolean);
  21911. /**
  21912. * The camera exposure used on this material.
  21913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21914. * This corresponds to a photographic exposure.
  21915. */
  21916. get cameraExposure(): number;
  21917. /**
  21918. * The camera exposure used on this material.
  21919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21920. * This corresponds to a photographic exposure.
  21921. */
  21922. set cameraExposure(value: number);
  21923. /**
  21924. * Gets The camera contrast used on this material.
  21925. */
  21926. get cameraContrast(): number;
  21927. /**
  21928. * Sets The camera contrast used on this material.
  21929. */
  21930. set cameraContrast(value: number);
  21931. /**
  21932. * Gets the Color Grading 2D Lookup Texture.
  21933. */
  21934. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21935. /**
  21936. * Sets the Color Grading 2D Lookup Texture.
  21937. */
  21938. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21939. /**
  21940. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21941. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21942. * 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;
  21943. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21944. */
  21945. get cameraColorCurves(): Nullable<ColorCurves>;
  21946. /**
  21947. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21948. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21949. * 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;
  21950. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21951. */
  21952. set cameraColorCurves(value: Nullable<ColorCurves>);
  21953. /**
  21954. * Instantiates a new PBRMaterial instance.
  21955. *
  21956. * @param name The material name
  21957. * @param scene The scene the material will be use in.
  21958. */
  21959. constructor(name: string, scene: Scene);
  21960. /**
  21961. * Returns the name of this material class.
  21962. */
  21963. getClassName(): string;
  21964. /**
  21965. * Makes a duplicate of the current material.
  21966. * @param name - name to use for the new material.
  21967. */
  21968. clone(name: string): PBRMaterial;
  21969. /**
  21970. * Serializes this PBR Material.
  21971. * @returns - An object with the serialized material.
  21972. */
  21973. serialize(): any;
  21974. /**
  21975. * Parses a PBR Material from a serialized object.
  21976. * @param source - Serialized object.
  21977. * @param scene - BJS scene instance.
  21978. * @param rootUrl - url for the scene object
  21979. * @returns - PBRMaterial
  21980. */
  21981. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21982. }
  21983. }
  21984. declare module BABYLON {
  21985. /** @hidden */
  21986. export var mrtFragmentDeclaration: {
  21987. name: string;
  21988. shader: string;
  21989. };
  21990. }
  21991. declare module BABYLON {
  21992. /** @hidden */
  21993. export var geometryPixelShader: {
  21994. name: string;
  21995. shader: string;
  21996. };
  21997. }
  21998. declare module BABYLON {
  21999. /** @hidden */
  22000. export var geometryVertexShader: {
  22001. name: string;
  22002. shader: string;
  22003. };
  22004. }
  22005. declare module BABYLON {
  22006. /** @hidden */
  22007. interface ISavedTransformationMatrix {
  22008. world: Matrix;
  22009. viewProjection: Matrix;
  22010. }
  22011. /**
  22012. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22013. */
  22014. export class GeometryBufferRenderer {
  22015. /**
  22016. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22017. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22018. */
  22019. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22020. /**
  22021. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22022. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22023. */
  22024. static readonly POSITION_TEXTURE_TYPE: number;
  22025. /**
  22026. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22027. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22028. */
  22029. static readonly VELOCITY_TEXTURE_TYPE: number;
  22030. /**
  22031. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22032. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22033. */
  22034. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22035. /**
  22036. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22037. * in order to compute objects velocities when enableVelocity is set to "true"
  22038. * @hidden
  22039. */
  22040. _previousTransformationMatrices: {
  22041. [index: number]: ISavedTransformationMatrix;
  22042. };
  22043. /**
  22044. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22045. * in order to compute objects velocities when enableVelocity is set to "true"
  22046. * @hidden
  22047. */
  22048. _previousBonesTransformationMatrices: {
  22049. [index: number]: Float32Array;
  22050. };
  22051. /**
  22052. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22053. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22054. */
  22055. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22056. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22057. renderTransparentMeshes: boolean;
  22058. private _scene;
  22059. private _resizeObserver;
  22060. private _multiRenderTarget;
  22061. private _ratio;
  22062. private _enablePosition;
  22063. private _enableVelocity;
  22064. private _enableReflectivity;
  22065. private _positionIndex;
  22066. private _velocityIndex;
  22067. private _reflectivityIndex;
  22068. private _depthNormalIndex;
  22069. private _linkedWithPrePass;
  22070. private _prePassRenderer;
  22071. private _attachments;
  22072. protected _effect: Effect;
  22073. protected _cachedDefines: string;
  22074. /**
  22075. * @hidden
  22076. * Sets up internal structures to share outputs with PrePassRenderer
  22077. * This method should only be called by the PrePassRenderer itself
  22078. */
  22079. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22080. /**
  22081. * @hidden
  22082. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22083. * This method should only be called by the PrePassRenderer itself
  22084. */
  22085. _unlinkPrePassRenderer(): void;
  22086. /**
  22087. * @hidden
  22088. * Resets the geometry buffer layout
  22089. */
  22090. _resetLayout(): void;
  22091. /**
  22092. * @hidden
  22093. * Replaces a texture in the geometry buffer renderer
  22094. * Useful when linking textures of the prepass renderer
  22095. */
  22096. _forceTextureType(geometryBufferType: number, index: number): void;
  22097. /**
  22098. * @hidden
  22099. * Sets texture attachments
  22100. * Useful when linking textures of the prepass renderer
  22101. */
  22102. _setAttachments(attachments: number[]): void;
  22103. /**
  22104. * @hidden
  22105. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22106. * Useful when linking textures of the prepass renderer
  22107. */
  22108. _linkInternalTexture(internalTexture: InternalTexture): void;
  22109. /**
  22110. * Gets the render list (meshes to be rendered) used in the G buffer.
  22111. */
  22112. get renderList(): Nullable<AbstractMesh[]>;
  22113. /**
  22114. * Set the render list (meshes to be rendered) used in the G buffer.
  22115. */
  22116. set renderList(meshes: Nullable<AbstractMesh[]>);
  22117. /**
  22118. * Gets wether or not G buffer are supported by the running hardware.
  22119. * This requires draw buffer supports
  22120. */
  22121. get isSupported(): boolean;
  22122. /**
  22123. * Returns the index of the given texture type in the G-Buffer textures array
  22124. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22125. * @returns the index of the given texture type in the G-Buffer textures array
  22126. */
  22127. getTextureIndex(textureType: number): number;
  22128. /**
  22129. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22130. */
  22131. get enablePosition(): boolean;
  22132. /**
  22133. * Sets whether or not objects positions are enabled for the G buffer.
  22134. */
  22135. set enablePosition(enable: boolean);
  22136. /**
  22137. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22138. */
  22139. get enableVelocity(): boolean;
  22140. /**
  22141. * Sets wether or not objects velocities are enabled for the G buffer.
  22142. */
  22143. set enableVelocity(enable: boolean);
  22144. /**
  22145. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22146. */
  22147. get enableReflectivity(): boolean;
  22148. /**
  22149. * Sets wether or not objects roughness are enabled for the G buffer.
  22150. */
  22151. set enableReflectivity(enable: boolean);
  22152. /**
  22153. * Gets the scene associated with the buffer.
  22154. */
  22155. get scene(): Scene;
  22156. /**
  22157. * Gets the ratio used by the buffer during its creation.
  22158. * How big is the buffer related to the main canvas.
  22159. */
  22160. get ratio(): number;
  22161. /** @hidden */
  22162. static _SceneComponentInitialization: (scene: Scene) => void;
  22163. /**
  22164. * Creates a new G Buffer for the scene
  22165. * @param scene The scene the buffer belongs to
  22166. * @param ratio How big is the buffer related to the main canvas.
  22167. */
  22168. constructor(scene: Scene, ratio?: number);
  22169. /**
  22170. * Checks wether everything is ready to render a submesh to the G buffer.
  22171. * @param subMesh the submesh to check readiness for
  22172. * @param useInstances is the mesh drawn using instance or not
  22173. * @returns true if ready otherwise false
  22174. */
  22175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22176. /**
  22177. * Gets the current underlying G Buffer.
  22178. * @returns the buffer
  22179. */
  22180. getGBuffer(): MultiRenderTarget;
  22181. /**
  22182. * Gets the number of samples used to render the buffer (anti aliasing).
  22183. */
  22184. get samples(): number;
  22185. /**
  22186. * Sets the number of samples used to render the buffer (anti aliasing).
  22187. */
  22188. set samples(value: number);
  22189. /**
  22190. * Disposes the renderer and frees up associated resources.
  22191. */
  22192. dispose(): void;
  22193. private _assignRenderTargetIndices;
  22194. protected _createRenderTargets(): void;
  22195. private _copyBonesTransformationMatrices;
  22196. }
  22197. }
  22198. declare module BABYLON {
  22199. /**
  22200. * Renders a pre pass of the scene
  22201. * This means every mesh in the scene will be rendered to a render target texture
  22202. * And then this texture will be composited to the rendering canvas with post processes
  22203. * It is necessary for effects like subsurface scattering or deferred shading
  22204. */
  22205. export class PrePassRenderer {
  22206. /** @hidden */
  22207. static _SceneComponentInitialization: (scene: Scene) => void;
  22208. private _textureFormats;
  22209. /**
  22210. * To save performance, we can excluded skinned meshes from the prepass
  22211. */
  22212. excludedSkinnedMesh: AbstractMesh[];
  22213. /**
  22214. * Force material to be excluded from the prepass
  22215. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22216. * and you don't want a material to show in the effect.
  22217. */
  22218. excludedMaterials: Material[];
  22219. private _textureIndices;
  22220. private _scene;
  22221. private _engine;
  22222. private _isDirty;
  22223. /**
  22224. * Number of textures in the multi render target texture where the scene is directly rendered
  22225. */
  22226. mrtCount: number;
  22227. /**
  22228. * The render target where the scene is directly rendered
  22229. */
  22230. prePassRT: MultiRenderTarget;
  22231. private _multiRenderAttachments;
  22232. private _defaultAttachments;
  22233. private _clearAttachments;
  22234. private _postProcesses;
  22235. private readonly _clearColor;
  22236. /**
  22237. * Image processing post process for composition
  22238. */
  22239. imageProcessingPostProcess: ImageProcessingPostProcess;
  22240. /**
  22241. * Configuration for prepass effects
  22242. */
  22243. private _effectConfigurations;
  22244. private _mrtFormats;
  22245. private _mrtLayout;
  22246. private _enabled;
  22247. /**
  22248. * Indicates if the prepass is enabled
  22249. */
  22250. get enabled(): boolean;
  22251. /**
  22252. * How many samples are used for MSAA of the scene render target
  22253. */
  22254. get samples(): number;
  22255. set samples(n: number);
  22256. private _geometryBuffer;
  22257. private _useGeometryBufferFallback;
  22258. /**
  22259. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22260. */
  22261. get useGeometryBufferFallback(): boolean;
  22262. set useGeometryBufferFallback(value: boolean);
  22263. /**
  22264. * Set to true to disable gamma transform in PrePass.
  22265. * Can be useful in case you already proceed to gamma transform on a material level
  22266. * and your post processes don't need to be in linear color space.
  22267. */
  22268. disableGammaTransform: boolean;
  22269. /**
  22270. * Instanciates a prepass renderer
  22271. * @param scene The scene
  22272. */
  22273. constructor(scene: Scene);
  22274. private _initializeAttachments;
  22275. private _createCompositionEffect;
  22276. /**
  22277. * Indicates if rendering a prepass is supported
  22278. */
  22279. get isSupported(): boolean;
  22280. /**
  22281. * Sets the proper output textures to draw in the engine.
  22282. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22283. * @param subMesh Submesh on which the effect is applied
  22284. */
  22285. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22286. /**
  22287. * Restores attachments for single texture draw.
  22288. */
  22289. restoreAttachments(): void;
  22290. /**
  22291. * @hidden
  22292. */
  22293. _beforeCameraDraw(): void;
  22294. /**
  22295. * @hidden
  22296. */
  22297. _afterCameraDraw(): void;
  22298. private _checkRTSize;
  22299. private _bindFrameBuffer;
  22300. /**
  22301. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22302. */
  22303. clear(): void;
  22304. private _setState;
  22305. private _updateGeometryBufferLayout;
  22306. /**
  22307. * Adds an effect configuration to the prepass.
  22308. * If an effect has already been added, it won't add it twice and will return the configuration
  22309. * already present.
  22310. * @param cfg the effect configuration
  22311. * @return the effect configuration now used by the prepass
  22312. */
  22313. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22314. /**
  22315. * Returns the index of a texture in the multi render target texture array.
  22316. * @param type Texture type
  22317. * @return The index
  22318. */
  22319. getIndex(type: number): number;
  22320. private _enable;
  22321. private _disable;
  22322. private _resetLayout;
  22323. private _resetPostProcessChain;
  22324. private _bindPostProcessChain;
  22325. /**
  22326. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22327. */
  22328. markAsDirty(): void;
  22329. /**
  22330. * Enables a texture on the MultiRenderTarget for prepass
  22331. */
  22332. private _enableTextures;
  22333. private _update;
  22334. private _markAllMaterialsAsPrePassDirty;
  22335. /**
  22336. * Disposes the prepass renderer.
  22337. */
  22338. dispose(): void;
  22339. }
  22340. }
  22341. declare module BABYLON {
  22342. /**
  22343. * Size options for a post process
  22344. */
  22345. export type PostProcessOptions = {
  22346. width: number;
  22347. height: number;
  22348. };
  22349. /**
  22350. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22351. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22352. */
  22353. export class PostProcess {
  22354. /**
  22355. * Gets or sets the unique id of the post process
  22356. */
  22357. uniqueId: number;
  22358. /** Name of the PostProcess. */
  22359. name: string;
  22360. /**
  22361. * Width of the texture to apply the post process on
  22362. */
  22363. width: number;
  22364. /**
  22365. * Height of the texture to apply the post process on
  22366. */
  22367. height: number;
  22368. /**
  22369. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22370. */
  22371. nodeMaterialSource: Nullable<NodeMaterial>;
  22372. /**
  22373. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22374. * @hidden
  22375. */
  22376. _outputTexture: Nullable<InternalTexture>;
  22377. /**
  22378. * Sampling mode used by the shader
  22379. * See https://doc.babylonjs.com/classes/3.1/texture
  22380. */
  22381. renderTargetSamplingMode: number;
  22382. /**
  22383. * Clear color to use when screen clearing
  22384. */
  22385. clearColor: Color4;
  22386. /**
  22387. * If the buffer needs to be cleared before applying the post process. (default: true)
  22388. * Should be set to false if shader will overwrite all previous pixels.
  22389. */
  22390. autoClear: boolean;
  22391. /**
  22392. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22393. */
  22394. alphaMode: number;
  22395. /**
  22396. * Sets the setAlphaBlendConstants of the babylon engine
  22397. */
  22398. alphaConstants: Color4;
  22399. /**
  22400. * Animations to be used for the post processing
  22401. */
  22402. animations: Animation[];
  22403. /**
  22404. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22405. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22406. */
  22407. enablePixelPerfectMode: boolean;
  22408. /**
  22409. * Force the postprocess to be applied without taking in account viewport
  22410. */
  22411. forceFullscreenViewport: boolean;
  22412. /**
  22413. * List of inspectable custom properties (used by the Inspector)
  22414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22415. */
  22416. inspectableCustomProperties: IInspectable[];
  22417. /**
  22418. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22419. *
  22420. * | Value | Type | Description |
  22421. * | ----- | ----------------------------------- | ----------- |
  22422. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22423. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22424. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22425. *
  22426. */
  22427. scaleMode: number;
  22428. /**
  22429. * Force textures to be a power of two (default: false)
  22430. */
  22431. alwaysForcePOT: boolean;
  22432. private _samples;
  22433. /**
  22434. * Number of sample textures (default: 1)
  22435. */
  22436. get samples(): number;
  22437. set samples(n: number);
  22438. /**
  22439. * Modify the scale of the post process to be the same as the viewport (default: false)
  22440. */
  22441. adaptScaleToCurrentViewport: boolean;
  22442. private _camera;
  22443. protected _scene: Scene;
  22444. private _engine;
  22445. private _options;
  22446. private _reusable;
  22447. private _textureType;
  22448. private _textureFormat;
  22449. /**
  22450. * Smart array of input and output textures for the post process.
  22451. * @hidden
  22452. */
  22453. _textures: SmartArray<InternalTexture>;
  22454. /**
  22455. * The index in _textures that corresponds to the output texture.
  22456. * @hidden
  22457. */
  22458. _currentRenderTextureInd: number;
  22459. private _effect;
  22460. private _samplers;
  22461. private _fragmentUrl;
  22462. private _vertexUrl;
  22463. private _parameters;
  22464. private _scaleRatio;
  22465. protected _indexParameters: any;
  22466. private _shareOutputWithPostProcess;
  22467. private _texelSize;
  22468. private _forcedOutputTexture;
  22469. /**
  22470. * Prepass configuration in case this post process needs a texture from prepass
  22471. * @hidden
  22472. */
  22473. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22474. /**
  22475. * Returns the fragment url or shader name used in the post process.
  22476. * @returns the fragment url or name in the shader store.
  22477. */
  22478. getEffectName(): string;
  22479. /**
  22480. * An event triggered when the postprocess is activated.
  22481. */
  22482. onActivateObservable: Observable<Camera>;
  22483. private _onActivateObserver;
  22484. /**
  22485. * A function that is added to the onActivateObservable
  22486. */
  22487. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22488. /**
  22489. * An event triggered when the postprocess changes its size.
  22490. */
  22491. onSizeChangedObservable: Observable<PostProcess>;
  22492. private _onSizeChangedObserver;
  22493. /**
  22494. * A function that is added to the onSizeChangedObservable
  22495. */
  22496. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22497. /**
  22498. * An event triggered when the postprocess applies its effect.
  22499. */
  22500. onApplyObservable: Observable<Effect>;
  22501. private _onApplyObserver;
  22502. /**
  22503. * A function that is added to the onApplyObservable
  22504. */
  22505. set onApply(callback: (effect: Effect) => void);
  22506. /**
  22507. * An event triggered before rendering the postprocess
  22508. */
  22509. onBeforeRenderObservable: Observable<Effect>;
  22510. private _onBeforeRenderObserver;
  22511. /**
  22512. * A function that is added to the onBeforeRenderObservable
  22513. */
  22514. set onBeforeRender(callback: (effect: Effect) => void);
  22515. /**
  22516. * An event triggered after rendering the postprocess
  22517. */
  22518. onAfterRenderObservable: Observable<Effect>;
  22519. private _onAfterRenderObserver;
  22520. /**
  22521. * A function that is added to the onAfterRenderObservable
  22522. */
  22523. set onAfterRender(callback: (efect: Effect) => void);
  22524. /**
  22525. * 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
  22526. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22527. */
  22528. get inputTexture(): InternalTexture;
  22529. set inputTexture(value: InternalTexture);
  22530. /**
  22531. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22532. * the only way to unset it is to use this function to restore its internal state
  22533. */
  22534. restoreDefaultInputTexture(): void;
  22535. /**
  22536. * Gets the camera which post process is applied to.
  22537. * @returns The camera the post process is applied to.
  22538. */
  22539. getCamera(): Camera;
  22540. /**
  22541. * Gets the texel size of the postprocess.
  22542. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22543. */
  22544. get texelSize(): Vector2;
  22545. /**
  22546. * Creates a new instance PostProcess
  22547. * @param name The name of the PostProcess.
  22548. * @param fragmentUrl The url of the fragment shader to be used.
  22549. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22550. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22551. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22552. * @param camera The camera to apply the render pass to.
  22553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22554. * @param engine The engine which the post process will be applied. (default: current engine)
  22555. * @param reusable If the post process can be reused on the same frame. (default: false)
  22556. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22557. * @param textureType Type of textures used when performing the post process. (default: 0)
  22558. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22559. * @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
  22560. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22561. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22562. */
  22563. 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);
  22564. /**
  22565. * Gets a string identifying the name of the class
  22566. * @returns "PostProcess" string
  22567. */
  22568. getClassName(): string;
  22569. /**
  22570. * Gets the engine which this post process belongs to.
  22571. * @returns The engine the post process was enabled with.
  22572. */
  22573. getEngine(): Engine;
  22574. /**
  22575. * The effect that is created when initializing the post process.
  22576. * @returns The created effect corresponding the the postprocess.
  22577. */
  22578. getEffect(): Effect;
  22579. /**
  22580. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22581. * @param postProcess The post process to share the output with.
  22582. * @returns This post process.
  22583. */
  22584. shareOutputWith(postProcess: PostProcess): PostProcess;
  22585. /**
  22586. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22587. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22588. */
  22589. useOwnOutput(): void;
  22590. /**
  22591. * Updates the effect with the current post process compile time values and recompiles the shader.
  22592. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22593. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22594. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22595. * @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
  22596. * @param onCompiled Called when the shader has been compiled.
  22597. * @param onError Called if there is an error when compiling a shader.
  22598. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22599. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22600. */
  22601. 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;
  22602. /**
  22603. * The post process is reusable if it can be used multiple times within one frame.
  22604. * @returns If the post process is reusable
  22605. */
  22606. isReusable(): boolean;
  22607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22608. markTextureDirty(): void;
  22609. /**
  22610. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22611. * 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.
  22612. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22613. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22614. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22615. * @returns The target texture that was bound to be written to.
  22616. */
  22617. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22618. /**
  22619. * If the post process is supported.
  22620. */
  22621. get isSupported(): boolean;
  22622. /**
  22623. * The aspect ratio of the output texture.
  22624. */
  22625. get aspectRatio(): number;
  22626. /**
  22627. * Get a value indicating if the post-process is ready to be used
  22628. * @returns true if the post-process is ready (shader is compiled)
  22629. */
  22630. isReady(): boolean;
  22631. /**
  22632. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22633. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22634. */
  22635. apply(): Nullable<Effect>;
  22636. private _disposeTextures;
  22637. /**
  22638. * Sets the required values to the prepass renderer.
  22639. * @param prePassRenderer defines the prepass renderer to setup.
  22640. * @returns true if the pre pass is needed.
  22641. */
  22642. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22643. /**
  22644. * Disposes the post process.
  22645. * @param camera The camera to dispose the post process on.
  22646. */
  22647. dispose(camera?: Camera): void;
  22648. /**
  22649. * Serializes the particle system to a JSON object
  22650. * @returns the JSON object
  22651. */
  22652. serialize(): any;
  22653. /**
  22654. * Creates a material from parsed material data
  22655. * @param parsedPostProcess defines parsed post process data
  22656. * @param scene defines the hosting scene
  22657. * @param rootUrl defines the root URL to use to load textures
  22658. * @returns a new post process
  22659. */
  22660. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22661. }
  22662. }
  22663. declare module BABYLON {
  22664. /** @hidden */
  22665. export var kernelBlurVaryingDeclaration: {
  22666. name: string;
  22667. shader: string;
  22668. };
  22669. }
  22670. declare module BABYLON {
  22671. /** @hidden */
  22672. export var packingFunctions: {
  22673. name: string;
  22674. shader: string;
  22675. };
  22676. }
  22677. declare module BABYLON {
  22678. /** @hidden */
  22679. export var kernelBlurFragment: {
  22680. name: string;
  22681. shader: string;
  22682. };
  22683. }
  22684. declare module BABYLON {
  22685. /** @hidden */
  22686. export var kernelBlurFragment2: {
  22687. name: string;
  22688. shader: string;
  22689. };
  22690. }
  22691. declare module BABYLON {
  22692. /** @hidden */
  22693. export var kernelBlurPixelShader: {
  22694. name: string;
  22695. shader: string;
  22696. };
  22697. }
  22698. declare module BABYLON {
  22699. /** @hidden */
  22700. export var kernelBlurVertex: {
  22701. name: string;
  22702. shader: string;
  22703. };
  22704. }
  22705. declare module BABYLON {
  22706. /** @hidden */
  22707. export var kernelBlurVertexShader: {
  22708. name: string;
  22709. shader: string;
  22710. };
  22711. }
  22712. declare module BABYLON {
  22713. /**
  22714. * The Blur Post Process which blurs an image based on a kernel and direction.
  22715. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22716. */
  22717. export class BlurPostProcess extends PostProcess {
  22718. private blockCompilation;
  22719. protected _kernel: number;
  22720. protected _idealKernel: number;
  22721. protected _packedFloat: boolean;
  22722. private _staticDefines;
  22723. /** The direction in which to blur the image. */
  22724. direction: Vector2;
  22725. /**
  22726. * Sets the length in pixels of the blur sample region
  22727. */
  22728. set kernel(v: number);
  22729. /**
  22730. * Gets the length in pixels of the blur sample region
  22731. */
  22732. get kernel(): number;
  22733. /**
  22734. * Sets wether or not the blur needs to unpack/repack floats
  22735. */
  22736. set packedFloat(v: boolean);
  22737. /**
  22738. * Gets wether or not the blur is unpacking/repacking floats
  22739. */
  22740. get packedFloat(): boolean;
  22741. /**
  22742. * Gets a string identifying the name of the class
  22743. * @returns "BlurPostProcess" string
  22744. */
  22745. getClassName(): string;
  22746. /**
  22747. * Creates a new instance BlurPostProcess
  22748. * @param name The name of the effect.
  22749. * @param direction The direction in which to blur the image.
  22750. * @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.
  22751. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22752. * @param camera The camera to apply the render pass to.
  22753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22754. * @param engine The engine which the post process will be applied. (default: current engine)
  22755. * @param reusable If the post process can be reused on the same frame. (default: false)
  22756. * @param textureType Type of textures used when performing the post process. (default: 0)
  22757. * @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)
  22758. */
  22759. 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);
  22760. /**
  22761. * Updates the effect with the current post process compile time values and recompiles the shader.
  22762. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22763. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22764. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22765. * @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
  22766. * @param onCompiled Called when the shader has been compiled.
  22767. * @param onError Called if there is an error when compiling a shader.
  22768. */
  22769. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22770. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22771. /**
  22772. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22773. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22774. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22775. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22776. * The gaps between physical kernels are compensated for in the weighting of the samples
  22777. * @param idealKernel Ideal blur kernel.
  22778. * @return Nearest best kernel.
  22779. */
  22780. protected _nearestBestKernel(idealKernel: number): number;
  22781. /**
  22782. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22783. * @param x The point on the Gaussian distribution to sample.
  22784. * @return the value of the Gaussian function at x.
  22785. */
  22786. protected _gaussianWeight(x: number): number;
  22787. /**
  22788. * Generates a string that can be used as a floating point number in GLSL.
  22789. * @param x Value to print.
  22790. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22791. * @return GLSL float string.
  22792. */
  22793. protected _glslFloat(x: number, decimalFigures?: number): string;
  22794. /** @hidden */
  22795. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22796. }
  22797. }
  22798. declare module BABYLON {
  22799. /**
  22800. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22801. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22802. * You can then easily use it as a reflectionTexture on a flat surface.
  22803. * In case the surface is not a plane, please consider relying on reflection probes.
  22804. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22805. */
  22806. export class MirrorTexture extends RenderTargetTexture {
  22807. private scene;
  22808. /**
  22809. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22810. * 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.
  22811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22812. */
  22813. mirrorPlane: Plane;
  22814. /**
  22815. * Define the blur ratio used to blur the reflection if needed.
  22816. */
  22817. set blurRatio(value: number);
  22818. get blurRatio(): number;
  22819. /**
  22820. * Define the adaptive blur kernel used to blur the reflection if needed.
  22821. * This will autocompute the closest best match for the `blurKernel`
  22822. */
  22823. set adaptiveBlurKernel(value: number);
  22824. /**
  22825. * Define the blur kernel used to blur the reflection if needed.
  22826. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22827. */
  22828. set blurKernel(value: number);
  22829. /**
  22830. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22831. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22832. */
  22833. set blurKernelX(value: number);
  22834. get blurKernelX(): number;
  22835. /**
  22836. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22837. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22838. */
  22839. set blurKernelY(value: number);
  22840. get blurKernelY(): number;
  22841. private _autoComputeBlurKernel;
  22842. protected _onRatioRescale(): void;
  22843. private _updateGammaSpace;
  22844. private _imageProcessingConfigChangeObserver;
  22845. private _transformMatrix;
  22846. private _mirrorMatrix;
  22847. private _savedViewMatrix;
  22848. private _blurX;
  22849. private _blurY;
  22850. private _adaptiveBlurKernel;
  22851. private _blurKernelX;
  22852. private _blurKernelY;
  22853. private _blurRatio;
  22854. /**
  22855. * Instantiates a Mirror Texture.
  22856. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22857. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22858. * You can then easily use it as a reflectionTexture on a flat surface.
  22859. * In case the surface is not a plane, please consider relying on reflection probes.
  22860. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22861. * @param name
  22862. * @param size
  22863. * @param scene
  22864. * @param generateMipMaps
  22865. * @param type
  22866. * @param samplingMode
  22867. * @param generateDepthBuffer
  22868. */
  22869. constructor(name: string, size: number | {
  22870. width: number;
  22871. height: number;
  22872. } | {
  22873. ratio: number;
  22874. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22875. private _preparePostProcesses;
  22876. /**
  22877. * Clone the mirror texture.
  22878. * @returns the cloned texture
  22879. */
  22880. clone(): MirrorTexture;
  22881. /**
  22882. * Serialize the texture to a JSON representation you could use in Parse later on
  22883. * @returns the serialized JSON representation
  22884. */
  22885. serialize(): any;
  22886. /**
  22887. * Dispose the texture and release its associated resources.
  22888. */
  22889. dispose(): void;
  22890. }
  22891. }
  22892. declare module BABYLON {
  22893. /**
  22894. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22895. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22896. */
  22897. export class Texture extends BaseTexture {
  22898. /**
  22899. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22900. */
  22901. static SerializeBuffers: boolean;
  22902. /**
  22903. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22904. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22905. */
  22906. static ForceSerializeBuffers: boolean;
  22907. /** @hidden */
  22908. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22909. /** @hidden */
  22910. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22911. /** @hidden */
  22912. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22913. /** nearest is mag = nearest and min = nearest and mip = linear */
  22914. static readonly NEAREST_SAMPLINGMODE: number;
  22915. /** nearest is mag = nearest and min = nearest and mip = linear */
  22916. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22917. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22918. static readonly BILINEAR_SAMPLINGMODE: number;
  22919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22920. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22921. /** Trilinear is mag = linear and min = linear and mip = linear */
  22922. static readonly TRILINEAR_SAMPLINGMODE: number;
  22923. /** Trilinear is mag = linear and min = linear and mip = linear */
  22924. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22925. /** mag = nearest and min = nearest and mip = nearest */
  22926. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22927. /** mag = nearest and min = linear and mip = nearest */
  22928. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22929. /** mag = nearest and min = linear and mip = linear */
  22930. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22931. /** mag = nearest and min = linear and mip = none */
  22932. static readonly NEAREST_LINEAR: number;
  22933. /** mag = nearest and min = nearest and mip = none */
  22934. static readonly NEAREST_NEAREST: number;
  22935. /** mag = linear and min = nearest and mip = nearest */
  22936. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22937. /** mag = linear and min = nearest and mip = linear */
  22938. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22939. /** mag = linear and min = linear and mip = none */
  22940. static readonly LINEAR_LINEAR: number;
  22941. /** mag = linear and min = nearest and mip = none */
  22942. static readonly LINEAR_NEAREST: number;
  22943. /** Explicit coordinates mode */
  22944. static readonly EXPLICIT_MODE: number;
  22945. /** Spherical coordinates mode */
  22946. static readonly SPHERICAL_MODE: number;
  22947. /** Planar coordinates mode */
  22948. static readonly PLANAR_MODE: number;
  22949. /** Cubic coordinates mode */
  22950. static readonly CUBIC_MODE: number;
  22951. /** Projection coordinates mode */
  22952. static readonly PROJECTION_MODE: number;
  22953. /** Inverse Cubic coordinates mode */
  22954. static readonly SKYBOX_MODE: number;
  22955. /** Inverse Cubic coordinates mode */
  22956. static readonly INVCUBIC_MODE: number;
  22957. /** Equirectangular coordinates mode */
  22958. static readonly EQUIRECTANGULAR_MODE: number;
  22959. /** Equirectangular Fixed coordinates mode */
  22960. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22961. /** Equirectangular Fixed Mirrored coordinates mode */
  22962. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22963. /** Texture is not repeating outside of 0..1 UVs */
  22964. static readonly CLAMP_ADDRESSMODE: number;
  22965. /** Texture is repeating outside of 0..1 UVs */
  22966. static readonly WRAP_ADDRESSMODE: number;
  22967. /** Texture is repeating and mirrored */
  22968. static readonly MIRROR_ADDRESSMODE: number;
  22969. /**
  22970. * 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
  22971. */
  22972. static UseSerializedUrlIfAny: boolean;
  22973. /**
  22974. * Define the url of the texture.
  22975. */
  22976. url: Nullable<string>;
  22977. /**
  22978. * Define an offset on the texture to offset the u coordinates of the UVs
  22979. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22980. */
  22981. uOffset: number;
  22982. /**
  22983. * Define an offset on the texture to offset the v coordinates of the UVs
  22984. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. vOffset: number;
  22987. /**
  22988. * Define an offset on the texture to scale the u coordinates of the UVs
  22989. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22990. */
  22991. uScale: number;
  22992. /**
  22993. * Define an offset on the texture to scale the v coordinates of the UVs
  22994. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. vScale: number;
  22997. /**
  22998. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22999. * @see https://doc.babylonjs.com/how_to/more_materials
  23000. */
  23001. uAng: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23004. * @see https://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. vAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23009. * @see https://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. wAng: number;
  23012. /**
  23013. * Defines the center of rotation (U)
  23014. */
  23015. uRotationCenter: number;
  23016. /**
  23017. * Defines the center of rotation (V)
  23018. */
  23019. vRotationCenter: number;
  23020. /**
  23021. * Defines the center of rotation (W)
  23022. */
  23023. wRotationCenter: number;
  23024. /**
  23025. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23026. */
  23027. homogeneousRotationInUVTransform: boolean;
  23028. /**
  23029. * Are mip maps generated for this texture or not.
  23030. */
  23031. get noMipmap(): boolean;
  23032. /**
  23033. * List of inspectable custom properties (used by the Inspector)
  23034. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23035. */
  23036. inspectableCustomProperties: Nullable<IInspectable[]>;
  23037. private _noMipmap;
  23038. /** @hidden */
  23039. _invertY: boolean;
  23040. private _rowGenerationMatrix;
  23041. private _cachedTextureMatrix;
  23042. private _projectionModeMatrix;
  23043. private _t0;
  23044. private _t1;
  23045. private _t2;
  23046. private _cachedUOffset;
  23047. private _cachedVOffset;
  23048. private _cachedUScale;
  23049. private _cachedVScale;
  23050. private _cachedUAng;
  23051. private _cachedVAng;
  23052. private _cachedWAng;
  23053. private _cachedProjectionMatrixId;
  23054. private _cachedURotationCenter;
  23055. private _cachedVRotationCenter;
  23056. private _cachedWRotationCenter;
  23057. private _cachedHomogeneousRotationInUVTransform;
  23058. private _cachedCoordinatesMode;
  23059. /** @hidden */
  23060. protected _initialSamplingMode: number;
  23061. /** @hidden */
  23062. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23063. private _deleteBuffer;
  23064. protected _format: Nullable<number>;
  23065. private _delayedOnLoad;
  23066. private _delayedOnError;
  23067. private _mimeType?;
  23068. private _loaderOptions?;
  23069. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23070. get mimeType(): string | undefined;
  23071. /**
  23072. * Observable triggered once the texture has been loaded.
  23073. */
  23074. onLoadObservable: Observable<Texture>;
  23075. protected _isBlocking: boolean;
  23076. /**
  23077. * Is the texture preventing material to render while loading.
  23078. * If false, a default texture will be used instead of the loading one during the preparation step.
  23079. */
  23080. set isBlocking(value: boolean);
  23081. get isBlocking(): boolean;
  23082. /**
  23083. * Get the current sampling mode associated with the texture.
  23084. */
  23085. get samplingMode(): number;
  23086. /**
  23087. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23088. */
  23089. get invertY(): boolean;
  23090. /**
  23091. * Instantiates a new texture.
  23092. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23093. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23094. * @param url defines the url of the picture to load as a texture
  23095. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23096. * @param noMipmap defines if the texture will require mip maps or not
  23097. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23098. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23099. * @param onLoad defines a callback triggered when the texture has been loaded
  23100. * @param onError defines a callback triggered when an error occurred during the loading session
  23101. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23102. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23103. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23104. * @param mimeType defines an optional mime type information
  23105. * @param loaderOptions options to be passed to the loader
  23106. */
  23107. 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);
  23108. /**
  23109. * Update the url (and optional buffer) of this texture if url was null during construction.
  23110. * @param url the url of the texture
  23111. * @param buffer the buffer of the texture (defaults to null)
  23112. * @param onLoad callback called when the texture is loaded (defaults to null)
  23113. */
  23114. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23115. /**
  23116. * Finish the loading sequence of a texture flagged as delayed load.
  23117. * @hidden
  23118. */
  23119. delayLoad(): void;
  23120. private _prepareRowForTextureGeneration;
  23121. /**
  23122. * Checks if the texture has the same transform matrix than another texture
  23123. * @param texture texture to check against
  23124. * @returns true if the transforms are the same, else false
  23125. */
  23126. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23127. /**
  23128. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23129. * @returns the transform matrix of the texture.
  23130. */
  23131. getTextureMatrix(uBase?: number): Matrix;
  23132. /**
  23133. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23134. * @returns The reflection texture transform
  23135. */
  23136. getReflectionTextureMatrix(): Matrix;
  23137. /**
  23138. * Clones the texture.
  23139. * @returns the cloned texture
  23140. */
  23141. clone(): Texture;
  23142. /**
  23143. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23144. * @returns The JSON representation of the texture
  23145. */
  23146. serialize(): any;
  23147. /**
  23148. * Get the current class name of the texture useful for serialization or dynamic coding.
  23149. * @returns "Texture"
  23150. */
  23151. getClassName(): string;
  23152. /**
  23153. * Dispose the texture and release its associated resources.
  23154. */
  23155. dispose(): void;
  23156. /**
  23157. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23158. * @param parsedTexture Define the JSON representation of the texture
  23159. * @param scene Define the scene the parsed texture should be instantiated in
  23160. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23161. * @returns The parsed texture if successful
  23162. */
  23163. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23164. /**
  23165. * Creates a texture from its base 64 representation.
  23166. * @param data Define the base64 payload without the data: prefix
  23167. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23168. * @param scene Define the scene the texture should belong to
  23169. * @param noMipmap Forces the texture to not create mip map information if true
  23170. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23171. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23172. * @param onLoad define a callback triggered when the texture has been loaded
  23173. * @param onError define a callback triggered when an error occurred during the loading session
  23174. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23175. * @returns the created texture
  23176. */
  23177. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23178. /**
  23179. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23180. * @param data Define the base64 payload without the data: prefix
  23181. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23182. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23183. * @param scene Define the scene the texture should belong to
  23184. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23185. * @param noMipmap Forces the texture to not create mip map information if true
  23186. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23187. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23188. * @param onLoad define a callback triggered when the texture has been loaded
  23189. * @param onError define a callback triggered when an error occurred during the loading session
  23190. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23191. * @returns the created texture
  23192. */
  23193. 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;
  23194. }
  23195. }
  23196. declare module BABYLON {
  23197. /**
  23198. * ThinSprite Class used to represent a thin sprite
  23199. * This is the base class for sprites but can also directly be used with ThinEngine
  23200. * @see https://doc.babylonjs.com/babylon101/sprites
  23201. */
  23202. export class ThinSprite {
  23203. /** Gets or sets the cell index in the sprite sheet */
  23204. cellIndex: number;
  23205. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23206. cellRef: string;
  23207. /** Gets or sets the current world position */
  23208. position: IVector3Like;
  23209. /** Gets or sets the main color */
  23210. color: IColor4Like;
  23211. /** Gets or sets the width */
  23212. width: number;
  23213. /** Gets or sets the height */
  23214. height: number;
  23215. /** Gets or sets rotation angle */
  23216. angle: number;
  23217. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23218. invertU: boolean;
  23219. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23220. invertV: boolean;
  23221. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23222. isVisible: boolean;
  23223. /**
  23224. * Returns a boolean indicating if the animation is started
  23225. */
  23226. get animationStarted(): boolean;
  23227. /** Gets the initial key for the animation (setting it will restart the animation) */
  23228. get fromIndex(): number;
  23229. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23230. get toIndex(): number;
  23231. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23232. get loopAnimation(): boolean;
  23233. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23234. get delay(): number;
  23235. /** @hidden */
  23236. _xOffset: number;
  23237. /** @hidden */
  23238. _yOffset: number;
  23239. /** @hidden */
  23240. _xSize: number;
  23241. /** @hidden */
  23242. _ySize: number;
  23243. private _animationStarted;
  23244. protected _loopAnimation: boolean;
  23245. protected _fromIndex: number;
  23246. protected _toIndex: number;
  23247. protected _delay: number;
  23248. private _direction;
  23249. private _time;
  23250. private _onBaseAnimationEnd;
  23251. /**
  23252. * Creates a new Thin Sprite
  23253. */
  23254. constructor();
  23255. /**
  23256. * Starts an animation
  23257. * @param from defines the initial key
  23258. * @param to defines the end key
  23259. * @param loop defines if the animation must loop
  23260. * @param delay defines the start delay (in ms)
  23261. * @param onAnimationEnd defines a callback for when the animation ends
  23262. */
  23263. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23264. /** Stops current animation (if any) */
  23265. stopAnimation(): void;
  23266. /** @hidden */
  23267. _animate(deltaTime: number): void;
  23268. }
  23269. }
  23270. declare module BABYLON {
  23271. /** @hidden */
  23272. export var imageProcessingCompatibility: {
  23273. name: string;
  23274. shader: string;
  23275. };
  23276. }
  23277. declare module BABYLON {
  23278. /** @hidden */
  23279. export var spritesPixelShader: {
  23280. name: string;
  23281. shader: string;
  23282. };
  23283. }
  23284. declare module BABYLON {
  23285. /** @hidden */
  23286. export var spritesVertexShader: {
  23287. name: string;
  23288. shader: string;
  23289. };
  23290. }
  23291. declare module BABYLON {
  23292. /**
  23293. * Class used to render sprites.
  23294. *
  23295. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23296. */
  23297. export class SpriteRenderer {
  23298. /**
  23299. * Defines the texture of the spritesheet
  23300. */
  23301. texture: Nullable<ThinTexture>;
  23302. /**
  23303. * Defines the default width of a cell in the spritesheet
  23304. */
  23305. cellWidth: number;
  23306. /**
  23307. * Defines the default height of a cell in the spritesheet
  23308. */
  23309. cellHeight: number;
  23310. /**
  23311. * Blend mode use to render the particle, it can be any of
  23312. * the static Constants.ALPHA_x properties provided in this class.
  23313. * Default value is Constants.ALPHA_COMBINE
  23314. */
  23315. blendMode: number;
  23316. /**
  23317. * Gets or sets a boolean indicating if alpha mode is automatically
  23318. * reset.
  23319. */
  23320. autoResetAlpha: boolean;
  23321. /**
  23322. * Disables writing to the depth buffer when rendering the sprites.
  23323. * It can be handy to disable depth writing when using textures without alpha channel
  23324. * and setting some specific blend modes.
  23325. */
  23326. disableDepthWrite: boolean;
  23327. /**
  23328. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23329. */
  23330. fogEnabled: boolean;
  23331. /**
  23332. * Gets the capacity of the manager
  23333. */
  23334. get capacity(): number;
  23335. private readonly _engine;
  23336. private readonly _useVAO;
  23337. private readonly _useInstancing;
  23338. private readonly _scene;
  23339. private readonly _capacity;
  23340. private readonly _epsilon;
  23341. private _vertexBufferSize;
  23342. private _vertexData;
  23343. private _buffer;
  23344. private _vertexBuffers;
  23345. private _spriteBuffer;
  23346. private _indexBuffer;
  23347. private _effectBase;
  23348. private _effectFog;
  23349. private _vertexArrayObject;
  23350. /**
  23351. * Creates a new sprite Renderer
  23352. * @param engine defines the engine the renderer works with
  23353. * @param capacity defines the maximum allowed number of sprites
  23354. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23355. * @param scene defines the hosting scene
  23356. */
  23357. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23358. /**
  23359. * Render all child sprites
  23360. * @param sprites defines the list of sprites to render
  23361. * @param deltaTime defines the time since last frame
  23362. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23363. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23364. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23365. */
  23366. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23367. private _appendSpriteVertex;
  23368. /**
  23369. * Release associated resources
  23370. */
  23371. dispose(): void;
  23372. }
  23373. }
  23374. declare module BABYLON {
  23375. /**
  23376. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23377. */
  23378. export interface ISpriteManager extends IDisposable {
  23379. /**
  23380. * Gets manager's name
  23381. */
  23382. name: string;
  23383. /**
  23384. * Restricts the camera to viewing objects with the same layerMask.
  23385. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23386. */
  23387. layerMask: number;
  23388. /**
  23389. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23390. */
  23391. isPickable: boolean;
  23392. /**
  23393. * Gets the hosting scene
  23394. */
  23395. scene: Scene;
  23396. /**
  23397. * Specifies the rendering group id for this mesh (0 by default)
  23398. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23399. */
  23400. renderingGroupId: number;
  23401. /**
  23402. * Defines the list of sprites managed by the manager.
  23403. */
  23404. sprites: Array<Sprite>;
  23405. /**
  23406. * Gets or sets the spritesheet texture
  23407. */
  23408. texture: Texture;
  23409. /** Defines the default width of a cell in the spritesheet */
  23410. cellWidth: number;
  23411. /** Defines the default height of a cell in the spritesheet */
  23412. cellHeight: number;
  23413. /**
  23414. * Tests the intersection of a sprite with a specific ray.
  23415. * @param ray The ray we are sending to test the collision
  23416. * @param camera The camera space we are sending rays in
  23417. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23418. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23419. * @returns picking info or null.
  23420. */
  23421. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23422. /**
  23423. * Intersects the sprites with a ray
  23424. * @param ray defines the ray to intersect with
  23425. * @param camera defines the current active camera
  23426. * @param predicate defines a predicate used to select candidate sprites
  23427. * @returns null if no hit or a PickingInfo array
  23428. */
  23429. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23430. /**
  23431. * Renders the list of sprites on screen.
  23432. */
  23433. render(): void;
  23434. }
  23435. /**
  23436. * Class used to manage multiple sprites on the same spritesheet
  23437. * @see https://doc.babylonjs.com/babylon101/sprites
  23438. */
  23439. export class SpriteManager implements ISpriteManager {
  23440. /** defines the manager's name */
  23441. name: string;
  23442. /** Define the Url to load snippets */
  23443. static SnippetUrl: string;
  23444. /** Snippet ID if the manager was created from the snippet server */
  23445. snippetId: string;
  23446. /** Gets the list of sprites */
  23447. sprites: Sprite[];
  23448. /** Gets or sets the rendering group id (0 by default) */
  23449. renderingGroupId: number;
  23450. /** Gets or sets camera layer mask */
  23451. layerMask: number;
  23452. /** Gets or sets a boolean indicating if the sprites are pickable */
  23453. isPickable: boolean;
  23454. /**
  23455. * An event triggered when the manager is disposed.
  23456. */
  23457. onDisposeObservable: Observable<SpriteManager>;
  23458. /**
  23459. * Callback called when the manager is disposed
  23460. */
  23461. set onDispose(callback: () => void);
  23462. /**
  23463. * Gets or sets the unique id of the sprite
  23464. */
  23465. uniqueId: number;
  23466. /**
  23467. * Gets the array of sprites
  23468. */
  23469. get children(): Sprite[];
  23470. /**
  23471. * Gets the hosting scene
  23472. */
  23473. get scene(): Scene;
  23474. /**
  23475. * Gets the capacity of the manager
  23476. */
  23477. get capacity(): number;
  23478. /**
  23479. * Gets or sets the spritesheet texture
  23480. */
  23481. get texture(): Texture;
  23482. set texture(value: Texture);
  23483. /** Defines the default width of a cell in the spritesheet */
  23484. get cellWidth(): number;
  23485. set cellWidth(value: number);
  23486. /** Defines the default height of a cell in the spritesheet */
  23487. get cellHeight(): number;
  23488. set cellHeight(value: number);
  23489. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23490. get fogEnabled(): boolean;
  23491. set fogEnabled(value: boolean);
  23492. /**
  23493. * Blend mode use to render the particle, it can be any of
  23494. * the static Constants.ALPHA_x properties provided in this class.
  23495. * Default value is Constants.ALPHA_COMBINE
  23496. */
  23497. get blendMode(): number;
  23498. set blendMode(blendMode: number);
  23499. /** Disables writing to the depth buffer when rendering the sprites.
  23500. * It can be handy to disable depth writing when using textures without alpha channel
  23501. * and setting some specific blend modes.
  23502. */
  23503. disableDepthWrite: boolean;
  23504. private _spriteRenderer;
  23505. /** Associative array from JSON sprite data file */
  23506. private _cellData;
  23507. /** Array of sprite names from JSON sprite data file */
  23508. private _spriteMap;
  23509. /** True when packed cell data from JSON file is ready*/
  23510. private _packedAndReady;
  23511. private _textureContent;
  23512. private _onDisposeObserver;
  23513. private _fromPacked;
  23514. private _scene;
  23515. /**
  23516. * Creates a new sprite manager
  23517. * @param name defines the manager's name
  23518. * @param imgUrl defines the sprite sheet url
  23519. * @param capacity defines the maximum allowed number of sprites
  23520. * @param cellSize defines the size of a sprite cell
  23521. * @param scene defines the hosting scene
  23522. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23523. * @param samplingMode defines the smapling mode to use with spritesheet
  23524. * @param fromPacked set to false; do not alter
  23525. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23526. */
  23527. constructor(
  23528. /** defines the manager's name */
  23529. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23530. /**
  23531. * Returns the string "SpriteManager"
  23532. * @returns "SpriteManager"
  23533. */
  23534. getClassName(): string;
  23535. private _makePacked;
  23536. private _checkTextureAlpha;
  23537. /**
  23538. * Intersects the sprites with a ray
  23539. * @param ray defines the ray to intersect with
  23540. * @param camera defines the current active camera
  23541. * @param predicate defines a predicate used to select candidate sprites
  23542. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23543. * @returns null if no hit or a PickingInfo
  23544. */
  23545. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23546. /**
  23547. * Intersects the sprites with a ray
  23548. * @param ray defines the ray to intersect with
  23549. * @param camera defines the current active camera
  23550. * @param predicate defines a predicate used to select candidate sprites
  23551. * @returns null if no hit or a PickingInfo array
  23552. */
  23553. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23554. /**
  23555. * Render all child sprites
  23556. */
  23557. render(): void;
  23558. private _customUpdate;
  23559. /**
  23560. * Release associated resources
  23561. */
  23562. dispose(): void;
  23563. /**
  23564. * Serializes the sprite manager to a JSON object
  23565. * @param serializeTexture defines if the texture must be serialized as well
  23566. * @returns the JSON object
  23567. */
  23568. serialize(serializeTexture?: boolean): any;
  23569. /**
  23570. * Parses a JSON object to create a new sprite manager.
  23571. * @param parsedManager The JSON object to parse
  23572. * @param scene The scene to create the sprite managerin
  23573. * @param rootUrl The root url to use to load external dependencies like texture
  23574. * @returns the new sprite manager
  23575. */
  23576. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23577. /**
  23578. * Creates a sprite manager from a snippet saved in a remote file
  23579. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23580. * @param url defines the url to load from
  23581. * @param scene defines the hosting scene
  23582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23583. * @returns a promise that will resolve to the new sprite manager
  23584. */
  23585. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23586. /**
  23587. * Creates a sprite manager from a snippet saved by the sprite editor
  23588. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23589. * @param scene defines the hosting scene
  23590. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23591. * @returns a promise that will resolve to the new sprite manager
  23592. */
  23593. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23594. }
  23595. }
  23596. declare module BABYLON {
  23597. /**
  23598. * Class used to represent a sprite
  23599. * @see https://doc.babylonjs.com/babylon101/sprites
  23600. */
  23601. export class Sprite extends ThinSprite implements IAnimatable {
  23602. /** defines the name */
  23603. name: string;
  23604. /** Gets or sets the current world position */
  23605. position: Vector3;
  23606. /** Gets or sets the main color */
  23607. color: Color4;
  23608. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23609. disposeWhenFinishedAnimating: boolean;
  23610. /** Gets the list of attached animations */
  23611. animations: Nullable<Array<Animation>>;
  23612. /** Gets or sets a boolean indicating if the sprite can be picked */
  23613. isPickable: boolean;
  23614. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23615. useAlphaForPicking: boolean;
  23616. /**
  23617. * Gets or sets the associated action manager
  23618. */
  23619. actionManager: Nullable<ActionManager>;
  23620. /**
  23621. * An event triggered when the control has been disposed
  23622. */
  23623. onDisposeObservable: Observable<Sprite>;
  23624. private _manager;
  23625. private _onAnimationEnd;
  23626. /**
  23627. * Gets or sets the sprite size
  23628. */
  23629. get size(): number;
  23630. set size(value: number);
  23631. /**
  23632. * Gets or sets the unique id of the sprite
  23633. */
  23634. uniqueId: number;
  23635. /**
  23636. * Gets the manager of this sprite
  23637. */
  23638. get manager(): ISpriteManager;
  23639. /**
  23640. * Creates a new Sprite
  23641. * @param name defines the name
  23642. * @param manager defines the manager
  23643. */
  23644. constructor(
  23645. /** defines the name */
  23646. name: string, manager: ISpriteManager);
  23647. /**
  23648. * Returns the string "Sprite"
  23649. * @returns "Sprite"
  23650. */
  23651. getClassName(): string;
  23652. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23653. get fromIndex(): number;
  23654. set fromIndex(value: number);
  23655. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23656. get toIndex(): number;
  23657. set toIndex(value: number);
  23658. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23659. get loopAnimation(): boolean;
  23660. set loopAnimation(value: boolean);
  23661. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23662. get delay(): number;
  23663. set delay(value: number);
  23664. /**
  23665. * Starts an animation
  23666. * @param from defines the initial key
  23667. * @param to defines the end key
  23668. * @param loop defines if the animation must loop
  23669. * @param delay defines the start delay (in ms)
  23670. * @param onAnimationEnd defines a callback to call when animation ends
  23671. */
  23672. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23673. private _endAnimation;
  23674. /** Release associated resources */
  23675. dispose(): void;
  23676. /**
  23677. * Serializes the sprite to a JSON object
  23678. * @returns the JSON object
  23679. */
  23680. serialize(): any;
  23681. /**
  23682. * Parses a JSON object to create a new sprite
  23683. * @param parsedSprite The JSON object to parse
  23684. * @param manager defines the hosting manager
  23685. * @returns the new sprite
  23686. */
  23687. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23688. }
  23689. }
  23690. declare module BABYLON {
  23691. /**
  23692. * Information about the result of picking within a scene
  23693. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23694. */
  23695. export class PickingInfo {
  23696. /** @hidden */
  23697. _pickingUnavailable: boolean;
  23698. /**
  23699. * If the pick collided with an object
  23700. */
  23701. hit: boolean;
  23702. /**
  23703. * Distance away where the pick collided
  23704. */
  23705. distance: number;
  23706. /**
  23707. * The location of pick collision
  23708. */
  23709. pickedPoint: Nullable<Vector3>;
  23710. /**
  23711. * The mesh corresponding the the pick collision
  23712. */
  23713. pickedMesh: Nullable<AbstractMesh>;
  23714. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23715. bu: number;
  23716. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23717. bv: number;
  23718. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23719. faceId: number;
  23720. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23721. subMeshFaceId: number;
  23722. /** Id of the the submesh that was picked */
  23723. subMeshId: number;
  23724. /** If a sprite was picked, this will be the sprite the pick collided with */
  23725. pickedSprite: Nullable<Sprite>;
  23726. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23727. thinInstanceIndex: number;
  23728. /**
  23729. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23730. */
  23731. originMesh: Nullable<AbstractMesh>;
  23732. /**
  23733. * The ray that was used to perform the picking.
  23734. */
  23735. ray: Nullable<Ray>;
  23736. /**
  23737. * Gets the normal correspodning to the face the pick collided with
  23738. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23739. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23740. * @returns The normal correspodning to the face the pick collided with
  23741. */
  23742. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23743. /**
  23744. * Gets the texture coordinates of where the pick occured
  23745. * @returns the vector containing the coordnates of the texture
  23746. */
  23747. getTextureCoordinates(): Nullable<Vector2>;
  23748. }
  23749. }
  23750. declare module BABYLON {
  23751. /**
  23752. * Gather the list of pointer event types as constants.
  23753. */
  23754. export class PointerEventTypes {
  23755. /**
  23756. * 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.
  23757. */
  23758. static readonly POINTERDOWN: number;
  23759. /**
  23760. * The pointerup event is fired when a pointer is no longer active.
  23761. */
  23762. static readonly POINTERUP: number;
  23763. /**
  23764. * The pointermove event is fired when a pointer changes coordinates.
  23765. */
  23766. static readonly POINTERMOVE: number;
  23767. /**
  23768. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23769. */
  23770. static readonly POINTERWHEEL: number;
  23771. /**
  23772. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23773. */
  23774. static readonly POINTERPICK: number;
  23775. /**
  23776. * The pointertap event is fired when a the object has been touched and released without drag.
  23777. */
  23778. static readonly POINTERTAP: number;
  23779. /**
  23780. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23781. */
  23782. static readonly POINTERDOUBLETAP: number;
  23783. }
  23784. /**
  23785. * Base class of pointer info types.
  23786. */
  23787. export class PointerInfoBase {
  23788. /**
  23789. * Defines the type of event (PointerEventTypes)
  23790. */
  23791. type: number;
  23792. /**
  23793. * Defines the related dom event
  23794. */
  23795. event: PointerEvent | MouseWheelEvent;
  23796. /**
  23797. * Instantiates the base class of pointers info.
  23798. * @param type Defines the type of event (PointerEventTypes)
  23799. * @param event Defines the related dom event
  23800. */
  23801. constructor(
  23802. /**
  23803. * Defines the type of event (PointerEventTypes)
  23804. */
  23805. type: number,
  23806. /**
  23807. * Defines the related dom event
  23808. */
  23809. event: PointerEvent | MouseWheelEvent);
  23810. }
  23811. /**
  23812. * This class is used to store pointer related info for the onPrePointerObservable event.
  23813. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23814. */
  23815. export class PointerInfoPre extends PointerInfoBase {
  23816. /**
  23817. * Ray from a pointer if availible (eg. 6dof controller)
  23818. */
  23819. ray: Nullable<Ray>;
  23820. /**
  23821. * Defines the local position of the pointer on the canvas.
  23822. */
  23823. localPosition: Vector2;
  23824. /**
  23825. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23826. */
  23827. skipOnPointerObservable: boolean;
  23828. /**
  23829. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23830. * @param type Defines the type of event (PointerEventTypes)
  23831. * @param event Defines the related dom event
  23832. * @param localX Defines the local x coordinates of the pointer when the event occured
  23833. * @param localY Defines the local y coordinates of the pointer when the event occured
  23834. */
  23835. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23836. }
  23837. /**
  23838. * This type contains all the data related to a pointer event in Babylon.js.
  23839. * 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.
  23840. */
  23841. export class PointerInfo extends PointerInfoBase {
  23842. /**
  23843. * Defines the picking info associated to the info (if any)\
  23844. */
  23845. pickInfo: Nullable<PickingInfo>;
  23846. /**
  23847. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23848. * @param type Defines the type of event (PointerEventTypes)
  23849. * @param event Defines the related dom event
  23850. * @param pickInfo Defines the picking info associated to the info (if any)\
  23851. */
  23852. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23853. /**
  23854. * Defines the picking info associated to the info (if any)\
  23855. */
  23856. pickInfo: Nullable<PickingInfo>);
  23857. }
  23858. /**
  23859. * Data relating to a touch event on the screen.
  23860. */
  23861. export interface PointerTouch {
  23862. /**
  23863. * X coordinate of touch.
  23864. */
  23865. x: number;
  23866. /**
  23867. * Y coordinate of touch.
  23868. */
  23869. y: number;
  23870. /**
  23871. * Id of touch. Unique for each finger.
  23872. */
  23873. pointerId: number;
  23874. /**
  23875. * Event type passed from DOM.
  23876. */
  23877. type: any;
  23878. }
  23879. }
  23880. declare module BABYLON {
  23881. /**
  23882. * Manage the mouse inputs to control the movement of a free camera.
  23883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23884. */
  23885. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23886. /**
  23887. * Define if touch is enabled in the mouse input
  23888. */
  23889. touchEnabled: boolean;
  23890. /**
  23891. * Defines the camera the input is attached to.
  23892. */
  23893. camera: FreeCamera;
  23894. /**
  23895. * Defines the buttons associated with the input to handle camera move.
  23896. */
  23897. buttons: number[];
  23898. /**
  23899. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23900. */
  23901. angularSensibility: number;
  23902. private _pointerInput;
  23903. private _onMouseMove;
  23904. private _observer;
  23905. private previousPosition;
  23906. /**
  23907. * Observable for when a pointer move event occurs containing the move offset
  23908. */
  23909. onPointerMovedObservable: Observable<{
  23910. offsetX: number;
  23911. offsetY: number;
  23912. }>;
  23913. /**
  23914. * @hidden
  23915. * If the camera should be rotated automatically based on pointer movement
  23916. */
  23917. _allowCameraRotation: boolean;
  23918. /**
  23919. * Manage the mouse inputs to control the movement of a free camera.
  23920. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23921. * @param touchEnabled Defines if touch is enabled or not
  23922. */
  23923. constructor(
  23924. /**
  23925. * Define if touch is enabled in the mouse input
  23926. */
  23927. touchEnabled?: boolean);
  23928. /**
  23929. * Attach the input controls to a specific dom element to get the input from.
  23930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23931. */
  23932. attachControl(noPreventDefault?: boolean): void;
  23933. /**
  23934. * Called on JS contextmenu event.
  23935. * Override this method to provide functionality.
  23936. */
  23937. protected onContextMenu(evt: PointerEvent): void;
  23938. /**
  23939. * Detach the current controls from the specified dom element.
  23940. */
  23941. detachControl(): void;
  23942. /**
  23943. * Gets the class name of the current intput.
  23944. * @returns the class name
  23945. */
  23946. getClassName(): string;
  23947. /**
  23948. * Get the friendly name associated with the input class.
  23949. * @returns the input friendly name
  23950. */
  23951. getSimpleName(): string;
  23952. }
  23953. }
  23954. declare module BABYLON {
  23955. /**
  23956. * Base class for mouse wheel input..
  23957. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23958. * for example usage.
  23959. */
  23960. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23961. /**
  23962. * Defines the camera the input is attached to.
  23963. */
  23964. abstract camera: Camera;
  23965. /**
  23966. * How fast is the camera moves in relation to X axis mouseWheel events.
  23967. * Use negative value to reverse direction.
  23968. */
  23969. wheelPrecisionX: number;
  23970. /**
  23971. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23972. * Use negative value to reverse direction.
  23973. */
  23974. wheelPrecisionY: number;
  23975. /**
  23976. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23977. * Use negative value to reverse direction.
  23978. */
  23979. wheelPrecisionZ: number;
  23980. /**
  23981. * Observable for when a mouse wheel move event occurs.
  23982. */
  23983. onChangedObservable: Observable<{
  23984. wheelDeltaX: number;
  23985. wheelDeltaY: number;
  23986. wheelDeltaZ: number;
  23987. }>;
  23988. private _wheel;
  23989. private _observer;
  23990. /**
  23991. * Attach the input controls to a specific dom element to get the input from.
  23992. * @param noPreventDefault Defines whether event caught by the controls
  23993. * should call preventdefault().
  23994. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23995. */
  23996. attachControl(noPreventDefault?: boolean): void;
  23997. /**
  23998. * Detach the current controls from the specified dom element.
  23999. */
  24000. detachControl(): void;
  24001. /**
  24002. * Called for each rendered frame.
  24003. */
  24004. checkInputs(): void;
  24005. /**
  24006. * Gets the class name of the current intput.
  24007. * @returns the class name
  24008. */
  24009. getClassName(): string;
  24010. /**
  24011. * Get the friendly name associated with the input class.
  24012. * @returns the input friendly name
  24013. */
  24014. getSimpleName(): string;
  24015. /**
  24016. * Incremental value of multiple mouse wheel movements of the X axis.
  24017. * Should be zero-ed when read.
  24018. */
  24019. protected _wheelDeltaX: number;
  24020. /**
  24021. * Incremental value of multiple mouse wheel movements of the Y axis.
  24022. * Should be zero-ed when read.
  24023. */
  24024. protected _wheelDeltaY: number;
  24025. /**
  24026. * Incremental value of multiple mouse wheel movements of the Z axis.
  24027. * Should be zero-ed when read.
  24028. */
  24029. protected _wheelDeltaZ: number;
  24030. /**
  24031. * Firefox uses a different scheme to report scroll distances to other
  24032. * browsers. Rather than use complicated methods to calculate the exact
  24033. * multiple we need to apply, let's just cheat and use a constant.
  24034. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24035. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24036. */
  24037. private readonly _ffMultiplier;
  24038. /**
  24039. * Different event attributes for wheel data fall into a few set ranges.
  24040. * Some relevant but dated date here:
  24041. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24042. */
  24043. private readonly _normalize;
  24044. }
  24045. }
  24046. declare module BABYLON {
  24047. /**
  24048. * Manage the mouse wheel inputs to control a free camera.
  24049. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24050. */
  24051. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24052. /**
  24053. * Defines the camera the input is attached to.
  24054. */
  24055. camera: FreeCamera;
  24056. /**
  24057. * Gets the class name of the current input.
  24058. * @returns the class name
  24059. */
  24060. getClassName(): string;
  24061. /**
  24062. * Set which movement axis (relative to camera's orientation) the mouse
  24063. * wheel's X axis controls.
  24064. * @param axis The axis to be moved. Set null to clear.
  24065. */
  24066. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24067. /**
  24068. * Get the configured movement axis (relative to camera's orientation) the
  24069. * mouse wheel's X axis controls.
  24070. * @returns The configured axis or null if none.
  24071. */
  24072. get wheelXMoveRelative(): Nullable<Coordinate>;
  24073. /**
  24074. * Set which movement axis (relative to camera's orientation) the mouse
  24075. * wheel's Y axis controls.
  24076. * @param axis The axis to be moved. Set null to clear.
  24077. */
  24078. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24079. /**
  24080. * Get the configured movement axis (relative to camera's orientation) the
  24081. * mouse wheel's Y axis controls.
  24082. * @returns The configured axis or null if none.
  24083. */
  24084. get wheelYMoveRelative(): Nullable<Coordinate>;
  24085. /**
  24086. * Set which movement axis (relative to camera's orientation) the mouse
  24087. * wheel's Z axis controls.
  24088. * @param axis The axis to be moved. Set null to clear.
  24089. */
  24090. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24091. /**
  24092. * Get the configured movement axis (relative to camera's orientation) the
  24093. * mouse wheel's Z axis controls.
  24094. * @returns The configured axis or null if none.
  24095. */
  24096. get wheelZMoveRelative(): Nullable<Coordinate>;
  24097. /**
  24098. * Set which rotation axis (relative to camera's orientation) the mouse
  24099. * wheel's X axis controls.
  24100. * @param axis The axis to be moved. Set null to clear.
  24101. */
  24102. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24103. /**
  24104. * Get the configured rotation axis (relative to camera's orientation) the
  24105. * mouse wheel's X axis controls.
  24106. * @returns The configured axis or null if none.
  24107. */
  24108. get wheelXRotateRelative(): Nullable<Coordinate>;
  24109. /**
  24110. * Set which rotation axis (relative to camera's orientation) the mouse
  24111. * wheel's Y axis controls.
  24112. * @param axis The axis to be moved. Set null to clear.
  24113. */
  24114. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24115. /**
  24116. * Get the configured rotation axis (relative to camera's orientation) the
  24117. * mouse wheel's Y axis controls.
  24118. * @returns The configured axis or null if none.
  24119. */
  24120. get wheelYRotateRelative(): Nullable<Coordinate>;
  24121. /**
  24122. * Set which rotation axis (relative to camera's orientation) the mouse
  24123. * wheel's Z axis controls.
  24124. * @param axis The axis to be moved. Set null to clear.
  24125. */
  24126. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24127. /**
  24128. * Get the configured rotation axis (relative to camera's orientation) the
  24129. * mouse wheel's Z axis controls.
  24130. * @returns The configured axis or null if none.
  24131. */
  24132. get wheelZRotateRelative(): Nullable<Coordinate>;
  24133. /**
  24134. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24135. * controls.
  24136. * @param axis The axis to be moved. Set null to clear.
  24137. */
  24138. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24139. /**
  24140. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24141. * X axis controls.
  24142. * @returns The configured axis or null if none.
  24143. */
  24144. get wheelXMoveScene(): Nullable<Coordinate>;
  24145. /**
  24146. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24147. * controls.
  24148. * @param axis The axis to be moved. Set null to clear.
  24149. */
  24150. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24151. /**
  24152. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24153. * Y axis controls.
  24154. * @returns The configured axis or null if none.
  24155. */
  24156. get wheelYMoveScene(): Nullable<Coordinate>;
  24157. /**
  24158. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24159. * controls.
  24160. * @param axis The axis to be moved. Set null to clear.
  24161. */
  24162. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24163. /**
  24164. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24165. * Z axis controls.
  24166. * @returns The configured axis or null if none.
  24167. */
  24168. get wheelZMoveScene(): Nullable<Coordinate>;
  24169. /**
  24170. * Called for each rendered frame.
  24171. */
  24172. checkInputs(): void;
  24173. private _moveRelative;
  24174. private _rotateRelative;
  24175. private _moveScene;
  24176. /**
  24177. * These are set to the desired default behaviour.
  24178. */
  24179. private _wheelXAction;
  24180. private _wheelXActionCoordinate;
  24181. private _wheelYAction;
  24182. private _wheelYActionCoordinate;
  24183. private _wheelZAction;
  24184. private _wheelZActionCoordinate;
  24185. /**
  24186. * Update the camera according to any configured properties for the 3
  24187. * mouse-wheel axis.
  24188. */
  24189. private _updateCamera;
  24190. }
  24191. }
  24192. declare module BABYLON {
  24193. /**
  24194. * Manage the touch inputs to control the movement of a free camera.
  24195. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24196. */
  24197. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24198. /**
  24199. * Define if mouse events can be treated as touch events
  24200. */
  24201. allowMouse: boolean;
  24202. /**
  24203. * Defines the camera the input is attached to.
  24204. */
  24205. camera: FreeCamera;
  24206. /**
  24207. * Defines the touch sensibility for rotation.
  24208. * The higher the faster.
  24209. */
  24210. touchAngularSensibility: number;
  24211. /**
  24212. * Defines the touch sensibility for move.
  24213. * The higher the faster.
  24214. */
  24215. touchMoveSensibility: number;
  24216. private _offsetX;
  24217. private _offsetY;
  24218. private _pointerPressed;
  24219. private _pointerInput?;
  24220. private _observer;
  24221. private _onLostFocus;
  24222. /**
  24223. * Manage the touch inputs to control the movement of a free camera.
  24224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24225. * @param allowMouse Defines if mouse events can be treated as touch events
  24226. */
  24227. constructor(
  24228. /**
  24229. * Define if mouse events can be treated as touch events
  24230. */
  24231. allowMouse?: boolean);
  24232. /**
  24233. * Attach the input controls to a specific dom element to get the input from.
  24234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24235. */
  24236. attachControl(noPreventDefault?: boolean): void;
  24237. /**
  24238. * Detach the current controls from the specified dom element.
  24239. */
  24240. detachControl(): void;
  24241. /**
  24242. * Update the current camera state depending on the inputs that have been used this frame.
  24243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24244. */
  24245. checkInputs(): void;
  24246. /**
  24247. * Gets the class name of the current intput.
  24248. * @returns the class name
  24249. */
  24250. getClassName(): string;
  24251. /**
  24252. * Get the friendly name associated with the input class.
  24253. * @returns the input friendly name
  24254. */
  24255. getSimpleName(): string;
  24256. }
  24257. }
  24258. declare module BABYLON {
  24259. /**
  24260. * Default Inputs manager for the FreeCamera.
  24261. * It groups all the default supported inputs for ease of use.
  24262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24263. */
  24264. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24265. /**
  24266. * @hidden
  24267. */
  24268. _mouseInput: Nullable<FreeCameraMouseInput>;
  24269. /**
  24270. * @hidden
  24271. */
  24272. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24273. /**
  24274. * Instantiates a new FreeCameraInputsManager.
  24275. * @param camera Defines the camera the inputs belong to
  24276. */
  24277. constructor(camera: FreeCamera);
  24278. /**
  24279. * Add keyboard input support to the input manager.
  24280. * @returns the current input manager
  24281. */
  24282. addKeyboard(): FreeCameraInputsManager;
  24283. /**
  24284. * Add mouse input support to the input manager.
  24285. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24286. * @returns the current input manager
  24287. */
  24288. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24289. /**
  24290. * Removes the mouse input support from the manager
  24291. * @returns the current input manager
  24292. */
  24293. removeMouse(): FreeCameraInputsManager;
  24294. /**
  24295. * Add mouse wheel input support to the input manager.
  24296. * @returns the current input manager
  24297. */
  24298. addMouseWheel(): FreeCameraInputsManager;
  24299. /**
  24300. * Removes the mouse wheel input support from the manager
  24301. * @returns the current input manager
  24302. */
  24303. removeMouseWheel(): FreeCameraInputsManager;
  24304. /**
  24305. * Add touch input support to the input manager.
  24306. * @returns the current input manager
  24307. */
  24308. addTouch(): FreeCameraInputsManager;
  24309. /**
  24310. * Remove all attached input methods from a camera
  24311. */
  24312. clear(): void;
  24313. }
  24314. }
  24315. declare module BABYLON {
  24316. /**
  24317. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24318. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24319. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24320. */
  24321. export class FreeCamera extends TargetCamera {
  24322. /**
  24323. * Define the collision ellipsoid of the camera.
  24324. * This is helpful to simulate a camera body like the player body around the camera
  24325. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24326. */
  24327. ellipsoid: Vector3;
  24328. /**
  24329. * Define an offset for the position of the ellipsoid around the camera.
  24330. * This can be helpful to determine the center of the body near the gravity center of the body
  24331. * instead of its head.
  24332. */
  24333. ellipsoidOffset: Vector3;
  24334. /**
  24335. * Enable or disable collisions of the camera with the rest of the scene objects.
  24336. */
  24337. checkCollisions: boolean;
  24338. /**
  24339. * Enable or disable gravity on the camera.
  24340. */
  24341. applyGravity: boolean;
  24342. /**
  24343. * Define the input manager associated to the camera.
  24344. */
  24345. inputs: FreeCameraInputsManager;
  24346. /**
  24347. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24348. * Higher values reduce sensitivity.
  24349. */
  24350. get angularSensibility(): number;
  24351. /**
  24352. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24353. * Higher values reduce sensitivity.
  24354. */
  24355. set angularSensibility(value: number);
  24356. /**
  24357. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24358. */
  24359. get keysUp(): number[];
  24360. set keysUp(value: number[]);
  24361. /**
  24362. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24363. */
  24364. get keysUpward(): number[];
  24365. set keysUpward(value: number[]);
  24366. /**
  24367. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24368. */
  24369. get keysDown(): number[];
  24370. set keysDown(value: number[]);
  24371. /**
  24372. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24373. */
  24374. get keysDownward(): number[];
  24375. set keysDownward(value: number[]);
  24376. /**
  24377. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24378. */
  24379. get keysLeft(): number[];
  24380. set keysLeft(value: number[]);
  24381. /**
  24382. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24383. */
  24384. get keysRight(): number[];
  24385. set keysRight(value: number[]);
  24386. /**
  24387. * Event raised when the camera collide with a mesh in the scene.
  24388. */
  24389. onCollide: (collidedMesh: AbstractMesh) => void;
  24390. private _collider;
  24391. private _needMoveForGravity;
  24392. private _oldPosition;
  24393. private _diffPosition;
  24394. private _newPosition;
  24395. /** @hidden */
  24396. _localDirection: Vector3;
  24397. /** @hidden */
  24398. _transformedDirection: Vector3;
  24399. /**
  24400. * Instantiates a Free Camera.
  24401. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24402. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24403. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24404. * @param name Define the name of the camera in the scene
  24405. * @param position Define the start position of the camera in the scene
  24406. * @param scene Define the scene the camera belongs to
  24407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24408. */
  24409. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24410. /**
  24411. * Attach the input controls to a specific dom element to get the input from.
  24412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24413. */
  24414. attachControl(noPreventDefault?: boolean): void;
  24415. /**
  24416. * Attach the input controls to a specific dom element to get the input from.
  24417. * @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
  24418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24419. * BACK COMPAT SIGNATURE ONLY.
  24420. */
  24421. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24422. /**
  24423. * Detach the current controls from the specified dom element.
  24424. */
  24425. detachControl(): void;
  24426. /**
  24427. * Detach the current controls from the specified dom element.
  24428. * @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
  24429. */
  24430. detachControl(ignored: any): void;
  24431. private _collisionMask;
  24432. /**
  24433. * Define a collision mask to limit the list of object the camera can collide with
  24434. */
  24435. get collisionMask(): number;
  24436. set collisionMask(mask: number);
  24437. /** @hidden */
  24438. _collideWithWorld(displacement: Vector3): void;
  24439. private _onCollisionPositionChange;
  24440. /** @hidden */
  24441. _checkInputs(): void;
  24442. /** @hidden */
  24443. _decideIfNeedsToMove(): boolean;
  24444. /** @hidden */
  24445. _updatePosition(): void;
  24446. /**
  24447. * Destroy the camera and release the current resources hold by it.
  24448. */
  24449. dispose(): void;
  24450. /**
  24451. * Gets the current object class name.
  24452. * @return the class name
  24453. */
  24454. getClassName(): string;
  24455. }
  24456. }
  24457. declare module BABYLON {
  24458. /**
  24459. * Represents a gamepad control stick position
  24460. */
  24461. export class StickValues {
  24462. /**
  24463. * The x component of the control stick
  24464. */
  24465. x: number;
  24466. /**
  24467. * The y component of the control stick
  24468. */
  24469. y: number;
  24470. /**
  24471. * Initializes the gamepad x and y control stick values
  24472. * @param x The x component of the gamepad control stick value
  24473. * @param y The y component of the gamepad control stick value
  24474. */
  24475. constructor(
  24476. /**
  24477. * The x component of the control stick
  24478. */
  24479. x: number,
  24480. /**
  24481. * The y component of the control stick
  24482. */
  24483. y: number);
  24484. }
  24485. /**
  24486. * An interface which manages callbacks for gamepad button changes
  24487. */
  24488. export interface GamepadButtonChanges {
  24489. /**
  24490. * Called when a gamepad has been changed
  24491. */
  24492. changed: boolean;
  24493. /**
  24494. * Called when a gamepad press event has been triggered
  24495. */
  24496. pressChanged: boolean;
  24497. /**
  24498. * Called when a touch event has been triggered
  24499. */
  24500. touchChanged: boolean;
  24501. /**
  24502. * Called when a value has changed
  24503. */
  24504. valueChanged: boolean;
  24505. }
  24506. /**
  24507. * Represents a gamepad
  24508. */
  24509. export class Gamepad {
  24510. /**
  24511. * The id of the gamepad
  24512. */
  24513. id: string;
  24514. /**
  24515. * The index of the gamepad
  24516. */
  24517. index: number;
  24518. /**
  24519. * The browser gamepad
  24520. */
  24521. browserGamepad: any;
  24522. /**
  24523. * Specifies what type of gamepad this represents
  24524. */
  24525. type: number;
  24526. private _leftStick;
  24527. private _rightStick;
  24528. /** @hidden */
  24529. _isConnected: boolean;
  24530. private _leftStickAxisX;
  24531. private _leftStickAxisY;
  24532. private _rightStickAxisX;
  24533. private _rightStickAxisY;
  24534. /**
  24535. * Triggered when the left control stick has been changed
  24536. */
  24537. private _onleftstickchanged;
  24538. /**
  24539. * Triggered when the right control stick has been changed
  24540. */
  24541. private _onrightstickchanged;
  24542. /**
  24543. * Represents a gamepad controller
  24544. */
  24545. static GAMEPAD: number;
  24546. /**
  24547. * Represents a generic controller
  24548. */
  24549. static GENERIC: number;
  24550. /**
  24551. * Represents an XBox controller
  24552. */
  24553. static XBOX: number;
  24554. /**
  24555. * Represents a pose-enabled controller
  24556. */
  24557. static POSE_ENABLED: number;
  24558. /**
  24559. * Represents an Dual Shock controller
  24560. */
  24561. static DUALSHOCK: number;
  24562. /**
  24563. * Specifies whether the left control stick should be Y-inverted
  24564. */
  24565. protected _invertLeftStickY: boolean;
  24566. /**
  24567. * Specifies if the gamepad has been connected
  24568. */
  24569. get isConnected(): boolean;
  24570. /**
  24571. * Initializes the gamepad
  24572. * @param id The id of the gamepad
  24573. * @param index The index of the gamepad
  24574. * @param browserGamepad The browser gamepad
  24575. * @param leftStickX The x component of the left joystick
  24576. * @param leftStickY The y component of the left joystick
  24577. * @param rightStickX The x component of the right joystick
  24578. * @param rightStickY The y component of the right joystick
  24579. */
  24580. constructor(
  24581. /**
  24582. * The id of the gamepad
  24583. */
  24584. id: string,
  24585. /**
  24586. * The index of the gamepad
  24587. */
  24588. index: number,
  24589. /**
  24590. * The browser gamepad
  24591. */
  24592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24593. /**
  24594. * Callback triggered when the left joystick has changed
  24595. * @param callback
  24596. */
  24597. onleftstickchanged(callback: (values: StickValues) => void): void;
  24598. /**
  24599. * Callback triggered when the right joystick has changed
  24600. * @param callback
  24601. */
  24602. onrightstickchanged(callback: (values: StickValues) => void): void;
  24603. /**
  24604. * Gets the left joystick
  24605. */
  24606. get leftStick(): StickValues;
  24607. /**
  24608. * Sets the left joystick values
  24609. */
  24610. set leftStick(newValues: StickValues);
  24611. /**
  24612. * Gets the right joystick
  24613. */
  24614. get rightStick(): StickValues;
  24615. /**
  24616. * Sets the right joystick value
  24617. */
  24618. set rightStick(newValues: StickValues);
  24619. /**
  24620. * Updates the gamepad joystick positions
  24621. */
  24622. update(): void;
  24623. /**
  24624. * Disposes the gamepad
  24625. */
  24626. dispose(): void;
  24627. }
  24628. /**
  24629. * Represents a generic gamepad
  24630. */
  24631. export class GenericPad extends Gamepad {
  24632. private _buttons;
  24633. private _onbuttondown;
  24634. private _onbuttonup;
  24635. /**
  24636. * Observable triggered when a button has been pressed
  24637. */
  24638. onButtonDownObservable: Observable<number>;
  24639. /**
  24640. * Observable triggered when a button has been released
  24641. */
  24642. onButtonUpObservable: Observable<number>;
  24643. /**
  24644. * Callback triggered when a button has been pressed
  24645. * @param callback Called when a button has been pressed
  24646. */
  24647. onbuttondown(callback: (buttonPressed: number) => void): void;
  24648. /**
  24649. * Callback triggered when a button has been released
  24650. * @param callback Called when a button has been released
  24651. */
  24652. onbuttonup(callback: (buttonReleased: number) => void): void;
  24653. /**
  24654. * Initializes the generic gamepad
  24655. * @param id The id of the generic gamepad
  24656. * @param index The index of the generic gamepad
  24657. * @param browserGamepad The browser gamepad
  24658. */
  24659. constructor(id: string, index: number, browserGamepad: any);
  24660. private _setButtonValue;
  24661. /**
  24662. * Updates the generic gamepad
  24663. */
  24664. update(): void;
  24665. /**
  24666. * Disposes the generic gamepad
  24667. */
  24668. dispose(): void;
  24669. }
  24670. }
  24671. declare module BABYLON {
  24672. /**
  24673. * Defines a runtime animation
  24674. */
  24675. export class RuntimeAnimation {
  24676. private _events;
  24677. /**
  24678. * The current frame of the runtime animation
  24679. */
  24680. private _currentFrame;
  24681. /**
  24682. * The animation used by the runtime animation
  24683. */
  24684. private _animation;
  24685. /**
  24686. * The target of the runtime animation
  24687. */
  24688. private _target;
  24689. /**
  24690. * The initiating animatable
  24691. */
  24692. private _host;
  24693. /**
  24694. * The original value of the runtime animation
  24695. */
  24696. private _originalValue;
  24697. /**
  24698. * The original blend value of the runtime animation
  24699. */
  24700. private _originalBlendValue;
  24701. /**
  24702. * The offsets cache of the runtime animation
  24703. */
  24704. private _offsetsCache;
  24705. /**
  24706. * The high limits cache of the runtime animation
  24707. */
  24708. private _highLimitsCache;
  24709. /**
  24710. * Specifies if the runtime animation has been stopped
  24711. */
  24712. private _stopped;
  24713. /**
  24714. * The blending factor of the runtime animation
  24715. */
  24716. private _blendingFactor;
  24717. /**
  24718. * The BabylonJS scene
  24719. */
  24720. private _scene;
  24721. /**
  24722. * The current value of the runtime animation
  24723. */
  24724. private _currentValue;
  24725. /** @hidden */
  24726. _animationState: _IAnimationState;
  24727. /**
  24728. * The active target of the runtime animation
  24729. */
  24730. private _activeTargets;
  24731. private _currentActiveTarget;
  24732. private _directTarget;
  24733. /**
  24734. * The target path of the runtime animation
  24735. */
  24736. private _targetPath;
  24737. /**
  24738. * The weight of the runtime animation
  24739. */
  24740. private _weight;
  24741. /**
  24742. * The ratio offset of the runtime animation
  24743. */
  24744. private _ratioOffset;
  24745. /**
  24746. * The previous delay of the runtime animation
  24747. */
  24748. private _previousDelay;
  24749. /**
  24750. * The previous ratio of the runtime animation
  24751. */
  24752. private _previousRatio;
  24753. private _enableBlending;
  24754. private _keys;
  24755. private _minFrame;
  24756. private _maxFrame;
  24757. private _minValue;
  24758. private _maxValue;
  24759. private _targetIsArray;
  24760. /**
  24761. * Gets the current frame of the runtime animation
  24762. */
  24763. get currentFrame(): number;
  24764. /**
  24765. * Gets the weight of the runtime animation
  24766. */
  24767. get weight(): number;
  24768. /**
  24769. * Gets the current value of the runtime animation
  24770. */
  24771. get currentValue(): any;
  24772. /**
  24773. * Gets the target path of the runtime animation
  24774. */
  24775. get targetPath(): string;
  24776. /**
  24777. * Gets the actual target of the runtime animation
  24778. */
  24779. get target(): any;
  24780. /**
  24781. * Gets the additive state of the runtime animation
  24782. */
  24783. get isAdditive(): boolean;
  24784. /** @hidden */
  24785. _onLoop: () => void;
  24786. /**
  24787. * Create a new RuntimeAnimation object
  24788. * @param target defines the target of the animation
  24789. * @param animation defines the source animation object
  24790. * @param scene defines the hosting scene
  24791. * @param host defines the initiating Animatable
  24792. */
  24793. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24794. private _preparePath;
  24795. /**
  24796. * Gets the animation from the runtime animation
  24797. */
  24798. get animation(): Animation;
  24799. /**
  24800. * Resets the runtime animation to the beginning
  24801. * @param restoreOriginal defines whether to restore the target property to the original value
  24802. */
  24803. reset(restoreOriginal?: boolean): void;
  24804. /**
  24805. * Specifies if the runtime animation is stopped
  24806. * @returns Boolean specifying if the runtime animation is stopped
  24807. */
  24808. isStopped(): boolean;
  24809. /**
  24810. * Disposes of the runtime animation
  24811. */
  24812. dispose(): void;
  24813. /**
  24814. * Apply the interpolated value to the target
  24815. * @param currentValue defines the value computed by the animation
  24816. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24817. */
  24818. setValue(currentValue: any, weight: number): void;
  24819. private _getOriginalValues;
  24820. private _setValue;
  24821. /**
  24822. * Gets the loop pmode of the runtime animation
  24823. * @returns Loop Mode
  24824. */
  24825. private _getCorrectLoopMode;
  24826. /**
  24827. * Move the current animation to a given frame
  24828. * @param frame defines the frame to move to
  24829. */
  24830. goToFrame(frame: number): void;
  24831. /**
  24832. * @hidden Internal use only
  24833. */
  24834. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24835. /**
  24836. * Execute the current animation
  24837. * @param delay defines the delay to add to the current frame
  24838. * @param from defines the lower bound of the animation range
  24839. * @param to defines the upper bound of the animation range
  24840. * @param loop defines if the current animation must loop
  24841. * @param speedRatio defines the current speed ratio
  24842. * @param weight defines the weight of the animation (default is -1 so no weight)
  24843. * @param onLoop optional callback called when animation loops
  24844. * @returns a boolean indicating if the animation is running
  24845. */
  24846. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24847. }
  24848. }
  24849. declare module BABYLON {
  24850. /**
  24851. * Class used to store an actual running animation
  24852. */
  24853. export class Animatable {
  24854. /** defines the target object */
  24855. target: any;
  24856. /** defines the starting frame number (default is 0) */
  24857. fromFrame: number;
  24858. /** defines the ending frame number (default is 100) */
  24859. toFrame: number;
  24860. /** defines if the animation must loop (default is false) */
  24861. loopAnimation: boolean;
  24862. /** defines a callback to call when animation ends if it is not looping */
  24863. onAnimationEnd?: (() => void) | null | undefined;
  24864. /** defines a callback to call when animation loops */
  24865. onAnimationLoop?: (() => void) | null | undefined;
  24866. /** defines whether the animation should be evaluated additively */
  24867. isAdditive: boolean;
  24868. private _localDelayOffset;
  24869. private _pausedDelay;
  24870. private _runtimeAnimations;
  24871. private _paused;
  24872. private _scene;
  24873. private _speedRatio;
  24874. private _weight;
  24875. private _syncRoot;
  24876. /**
  24877. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24878. * This will only apply for non looping animation (default is true)
  24879. */
  24880. disposeOnEnd: boolean;
  24881. /**
  24882. * Gets a boolean indicating if the animation has started
  24883. */
  24884. animationStarted: boolean;
  24885. /**
  24886. * Observer raised when the animation ends
  24887. */
  24888. onAnimationEndObservable: Observable<Animatable>;
  24889. /**
  24890. * Observer raised when the animation loops
  24891. */
  24892. onAnimationLoopObservable: Observable<Animatable>;
  24893. /**
  24894. * Gets the root Animatable used to synchronize and normalize animations
  24895. */
  24896. get syncRoot(): Nullable<Animatable>;
  24897. /**
  24898. * Gets the current frame of the first RuntimeAnimation
  24899. * Used to synchronize Animatables
  24900. */
  24901. get masterFrame(): number;
  24902. /**
  24903. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24904. */
  24905. get weight(): number;
  24906. set weight(value: number);
  24907. /**
  24908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24909. */
  24910. get speedRatio(): number;
  24911. set speedRatio(value: number);
  24912. /**
  24913. * Creates a new Animatable
  24914. * @param scene defines the hosting scene
  24915. * @param target defines the target object
  24916. * @param fromFrame defines the starting frame number (default is 0)
  24917. * @param toFrame defines the ending frame number (default is 100)
  24918. * @param loopAnimation defines if the animation must loop (default is false)
  24919. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24920. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24921. * @param animations defines a group of animation to add to the new Animatable
  24922. * @param onAnimationLoop defines a callback to call when animation loops
  24923. * @param isAdditive defines whether the animation should be evaluated additively
  24924. */
  24925. constructor(scene: Scene,
  24926. /** defines the target object */
  24927. target: any,
  24928. /** defines the starting frame number (default is 0) */
  24929. fromFrame?: number,
  24930. /** defines the ending frame number (default is 100) */
  24931. toFrame?: number,
  24932. /** defines if the animation must loop (default is false) */
  24933. loopAnimation?: boolean, speedRatio?: number,
  24934. /** defines a callback to call when animation ends if it is not looping */
  24935. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24936. /** defines a callback to call when animation loops */
  24937. onAnimationLoop?: (() => void) | null | undefined,
  24938. /** defines whether the animation should be evaluated additively */
  24939. isAdditive?: boolean);
  24940. /**
  24941. * Synchronize and normalize current Animatable with a source Animatable
  24942. * This is useful when using animation weights and when animations are not of the same length
  24943. * @param root defines the root Animatable to synchronize with
  24944. * @returns the current Animatable
  24945. */
  24946. syncWith(root: Animatable): Animatable;
  24947. /**
  24948. * Gets the list of runtime animations
  24949. * @returns an array of RuntimeAnimation
  24950. */
  24951. getAnimations(): RuntimeAnimation[];
  24952. /**
  24953. * Adds more animations to the current animatable
  24954. * @param target defines the target of the animations
  24955. * @param animations defines the new animations to add
  24956. */
  24957. appendAnimations(target: any, animations: Animation[]): void;
  24958. /**
  24959. * Gets the source animation for a specific property
  24960. * @param property defines the propertyu to look for
  24961. * @returns null or the source animation for the given property
  24962. */
  24963. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24964. /**
  24965. * Gets the runtime animation for a specific property
  24966. * @param property defines the propertyu to look for
  24967. * @returns null or the runtime animation for the given property
  24968. */
  24969. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24970. /**
  24971. * Resets the animatable to its original state
  24972. */
  24973. reset(): void;
  24974. /**
  24975. * Allows the animatable to blend with current running animations
  24976. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24977. * @param blendingSpeed defines the blending speed to use
  24978. */
  24979. enableBlending(blendingSpeed: number): void;
  24980. /**
  24981. * Disable animation blending
  24982. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24983. */
  24984. disableBlending(): void;
  24985. /**
  24986. * Jump directly to a given frame
  24987. * @param frame defines the frame to jump to
  24988. */
  24989. goToFrame(frame: number): void;
  24990. /**
  24991. * Pause the animation
  24992. */
  24993. pause(): void;
  24994. /**
  24995. * Restart the animation
  24996. */
  24997. restart(): void;
  24998. private _raiseOnAnimationEnd;
  24999. /**
  25000. * Stop and delete the current animation
  25001. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25002. * @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)
  25003. */
  25004. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25005. /**
  25006. * Wait asynchronously for the animation to end
  25007. * @returns a promise which will be fullfilled when the animation ends
  25008. */
  25009. waitAsync(): Promise<Animatable>;
  25010. /** @hidden */
  25011. _animate(delay: number): boolean;
  25012. }
  25013. interface Scene {
  25014. /** @hidden */
  25015. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25016. /** @hidden */
  25017. _processLateAnimationBindingsForMatrices(holder: {
  25018. totalWeight: number;
  25019. totalAdditiveWeight: number;
  25020. animations: RuntimeAnimation[];
  25021. additiveAnimations: RuntimeAnimation[];
  25022. originalValue: Matrix;
  25023. }): any;
  25024. /** @hidden */
  25025. _processLateAnimationBindingsForQuaternions(holder: {
  25026. totalWeight: number;
  25027. totalAdditiveWeight: number;
  25028. animations: RuntimeAnimation[];
  25029. additiveAnimations: RuntimeAnimation[];
  25030. originalValue: Quaternion;
  25031. }, refQuaternion: Quaternion): Quaternion;
  25032. /** @hidden */
  25033. _processLateAnimationBindings(): void;
  25034. /**
  25035. * Will start the animation sequence of a given target
  25036. * @param target defines the target
  25037. * @param from defines from which frame should animation start
  25038. * @param to defines until which frame should animation run.
  25039. * @param weight defines the weight to apply to the animation (1.0 by default)
  25040. * @param loop defines if the animation loops
  25041. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25042. * @param onAnimationEnd defines the function to be executed when the animation ends
  25043. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25044. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25045. * @param onAnimationLoop defines the callback to call when an animation loops
  25046. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25047. * @returns the animatable object created for this animation
  25048. */
  25049. 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;
  25050. /**
  25051. * Will start the animation sequence of a given target
  25052. * @param target defines the target
  25053. * @param from defines from which frame should animation start
  25054. * @param to defines until which frame should animation run.
  25055. * @param loop defines if the animation loops
  25056. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25057. * @param onAnimationEnd defines the function to be executed when the animation ends
  25058. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25059. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25060. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25061. * @param onAnimationLoop defines the callback to call when an animation loops
  25062. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25063. * @returns the animatable object created for this animation
  25064. */
  25065. 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;
  25066. /**
  25067. * Will start the animation sequence of a given target and its hierarchy
  25068. * @param target defines the target
  25069. * @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.
  25070. * @param from defines from which frame should animation start
  25071. * @param to defines until which frame should animation run.
  25072. * @param loop defines if the animation loops
  25073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25074. * @param onAnimationEnd defines the function to be executed when the animation ends
  25075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25077. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25078. * @param onAnimationLoop defines the callback to call when an animation loops
  25079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25080. * @returns the list of created animatables
  25081. */
  25082. 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[];
  25083. /**
  25084. * Begin a new animation on a given node
  25085. * @param target defines the target where the animation will take place
  25086. * @param animations defines the list of animations to start
  25087. * @param from defines the initial value
  25088. * @param to defines the final value
  25089. * @param loop defines if you want animation to loop (off by default)
  25090. * @param speedRatio defines the speed ratio to apply to all animations
  25091. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25092. * @param onAnimationLoop defines the callback to call when an animation loops
  25093. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25094. * @returns the list of created animatables
  25095. */
  25096. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25097. /**
  25098. * Begin a new animation on a given node and its hierarchy
  25099. * @param target defines the root node where the animation will take place
  25100. * @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.
  25101. * @param animations defines the list of animations to start
  25102. * @param from defines the initial value
  25103. * @param to defines the final value
  25104. * @param loop defines if you want animation to loop (off by default)
  25105. * @param speedRatio defines the speed ratio to apply to all animations
  25106. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25107. * @param onAnimationLoop defines the callback to call when an animation loops
  25108. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25109. * @returns the list of animatables created for all nodes
  25110. */
  25111. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25112. /**
  25113. * Gets the animatable associated with a specific target
  25114. * @param target defines the target of the animatable
  25115. * @returns the required animatable if found
  25116. */
  25117. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25118. /**
  25119. * Gets all animatables associated with a given target
  25120. * @param target defines the target to look animatables for
  25121. * @returns an array of Animatables
  25122. */
  25123. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25124. /**
  25125. * Stops and removes all animations that have been applied to the scene
  25126. */
  25127. stopAllAnimations(): void;
  25128. /**
  25129. * Gets the current delta time used by animation engine
  25130. */
  25131. deltaTime: number;
  25132. }
  25133. interface Bone {
  25134. /**
  25135. * Copy an animation range from another bone
  25136. * @param source defines the source bone
  25137. * @param rangeName defines the range name to copy
  25138. * @param frameOffset defines the frame offset
  25139. * @param rescaleAsRequired defines if rescaling must be applied if required
  25140. * @param skelDimensionsRatio defines the scaling ratio
  25141. * @returns true if operation was successful
  25142. */
  25143. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25144. }
  25145. }
  25146. declare module BABYLON {
  25147. /**
  25148. * Class used to override all child animations of a given target
  25149. */
  25150. export class AnimationPropertiesOverride {
  25151. /**
  25152. * Gets or sets a value indicating if animation blending must be used
  25153. */
  25154. enableBlending: boolean;
  25155. /**
  25156. * Gets or sets the blending speed to use when enableBlending is true
  25157. */
  25158. blendingSpeed: number;
  25159. /**
  25160. * Gets or sets the default loop mode to use
  25161. */
  25162. loopMode: number;
  25163. }
  25164. }
  25165. declare module BABYLON {
  25166. /**
  25167. * Class used to handle skinning animations
  25168. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25169. */
  25170. export class Skeleton implements IAnimatable {
  25171. /** defines the skeleton name */
  25172. name: string;
  25173. /** defines the skeleton Id */
  25174. id: string;
  25175. /**
  25176. * Defines the list of child bones
  25177. */
  25178. bones: Bone[];
  25179. /**
  25180. * Defines an estimate of the dimension of the skeleton at rest
  25181. */
  25182. dimensionsAtRest: Vector3;
  25183. /**
  25184. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25185. */
  25186. needInitialSkinMatrix: boolean;
  25187. /**
  25188. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25189. */
  25190. overrideMesh: Nullable<AbstractMesh>;
  25191. /**
  25192. * Gets the list of animations attached to this skeleton
  25193. */
  25194. animations: Array<Animation>;
  25195. private _scene;
  25196. private _isDirty;
  25197. private _transformMatrices;
  25198. private _transformMatrixTexture;
  25199. private _meshesWithPoseMatrix;
  25200. private _animatables;
  25201. private _identity;
  25202. private _synchronizedWithMesh;
  25203. private _ranges;
  25204. private _lastAbsoluteTransformsUpdateId;
  25205. private _canUseTextureForBones;
  25206. private _uniqueId;
  25207. /** @hidden */
  25208. _numBonesWithLinkedTransformNode: number;
  25209. /** @hidden */
  25210. _hasWaitingData: Nullable<boolean>;
  25211. /** @hidden */
  25212. _waitingOverrideMeshId: Nullable<string>;
  25213. /**
  25214. * Specifies if the skeleton should be serialized
  25215. */
  25216. doNotSerialize: boolean;
  25217. private _useTextureToStoreBoneMatrices;
  25218. /**
  25219. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25220. * Please note that this option is not available if the hardware does not support it
  25221. */
  25222. get useTextureToStoreBoneMatrices(): boolean;
  25223. set useTextureToStoreBoneMatrices(value: boolean);
  25224. private _animationPropertiesOverride;
  25225. /**
  25226. * Gets or sets the animation properties override
  25227. */
  25228. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25229. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25230. /**
  25231. * List of inspectable custom properties (used by the Inspector)
  25232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25233. */
  25234. inspectableCustomProperties: IInspectable[];
  25235. /**
  25236. * An observable triggered before computing the skeleton's matrices
  25237. */
  25238. onBeforeComputeObservable: Observable<Skeleton>;
  25239. /**
  25240. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25241. */
  25242. get isUsingTextureForMatrices(): boolean;
  25243. /**
  25244. * Gets the unique ID of this skeleton
  25245. */
  25246. get uniqueId(): number;
  25247. /**
  25248. * Creates a new skeleton
  25249. * @param name defines the skeleton name
  25250. * @param id defines the skeleton Id
  25251. * @param scene defines the hosting scene
  25252. */
  25253. constructor(
  25254. /** defines the skeleton name */
  25255. name: string,
  25256. /** defines the skeleton Id */
  25257. id: string, scene: Scene);
  25258. /**
  25259. * Gets the current object class name.
  25260. * @return the class name
  25261. */
  25262. getClassName(): string;
  25263. /**
  25264. * Returns an array containing the root bones
  25265. * @returns an array containing the root bones
  25266. */
  25267. getChildren(): Array<Bone>;
  25268. /**
  25269. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25270. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25271. * @returns a Float32Array containing matrices data
  25272. */
  25273. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25274. /**
  25275. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25276. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25277. * @returns a raw texture containing the data
  25278. */
  25279. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25280. /**
  25281. * Gets the current hosting scene
  25282. * @returns a scene object
  25283. */
  25284. getScene(): Scene;
  25285. /**
  25286. * Gets a string representing the current skeleton data
  25287. * @param fullDetails defines a boolean indicating if we want a verbose version
  25288. * @returns a string representing the current skeleton data
  25289. */
  25290. toString(fullDetails?: boolean): string;
  25291. /**
  25292. * Get bone's index searching by name
  25293. * @param name defines bone's name to search for
  25294. * @return the indice of the bone. Returns -1 if not found
  25295. */
  25296. getBoneIndexByName(name: string): number;
  25297. /**
  25298. * Creater a new animation range
  25299. * @param name defines the name of the range
  25300. * @param from defines the start key
  25301. * @param to defines the end key
  25302. */
  25303. createAnimationRange(name: string, from: number, to: number): void;
  25304. /**
  25305. * Delete a specific animation range
  25306. * @param name defines the name of the range
  25307. * @param deleteFrames defines if frames must be removed as well
  25308. */
  25309. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25310. /**
  25311. * Gets a specific animation range
  25312. * @param name defines the name of the range to look for
  25313. * @returns the requested animation range or null if not found
  25314. */
  25315. getAnimationRange(name: string): Nullable<AnimationRange>;
  25316. /**
  25317. * Gets the list of all animation ranges defined on this skeleton
  25318. * @returns an array
  25319. */
  25320. getAnimationRanges(): Nullable<AnimationRange>[];
  25321. /**
  25322. * Copy animation range from a source skeleton.
  25323. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25324. * @param source defines the source skeleton
  25325. * @param name defines the name of the range to copy
  25326. * @param rescaleAsRequired defines if rescaling must be applied if required
  25327. * @returns true if operation was successful
  25328. */
  25329. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25330. /**
  25331. * Forces the skeleton to go to rest pose
  25332. */
  25333. returnToRest(): void;
  25334. private _getHighestAnimationFrame;
  25335. /**
  25336. * Begin a specific animation range
  25337. * @param name defines the name of the range to start
  25338. * @param loop defines if looping must be turned on (false by default)
  25339. * @param speedRatio defines the speed ratio to apply (1 by default)
  25340. * @param onAnimationEnd defines a callback which will be called when animation will end
  25341. * @returns a new animatable
  25342. */
  25343. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25344. /**
  25345. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25346. * @param skeleton defines the Skeleton containing the animation range to convert
  25347. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25348. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25349. * @returns the original skeleton
  25350. */
  25351. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25352. /** @hidden */
  25353. _markAsDirty(): void;
  25354. /** @hidden */
  25355. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25356. /** @hidden */
  25357. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25358. private _computeTransformMatrices;
  25359. /**
  25360. * Build all resources required to render a skeleton
  25361. */
  25362. prepare(): void;
  25363. /**
  25364. * Gets the list of animatables currently running for this skeleton
  25365. * @returns an array of animatables
  25366. */
  25367. getAnimatables(): IAnimatable[];
  25368. /**
  25369. * Clone the current skeleton
  25370. * @param name defines the name of the new skeleton
  25371. * @param id defines the id of the new skeleton
  25372. * @returns the new skeleton
  25373. */
  25374. clone(name: string, id?: string): Skeleton;
  25375. /**
  25376. * Enable animation blending for this skeleton
  25377. * @param blendingSpeed defines the blending speed to apply
  25378. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25379. */
  25380. enableBlending(blendingSpeed?: number): void;
  25381. /**
  25382. * Releases all resources associated with the current skeleton
  25383. */
  25384. dispose(): void;
  25385. /**
  25386. * Serialize the skeleton in a JSON object
  25387. * @returns a JSON object
  25388. */
  25389. serialize(): any;
  25390. /**
  25391. * Creates a new skeleton from serialized data
  25392. * @param parsedSkeleton defines the serialized data
  25393. * @param scene defines the hosting scene
  25394. * @returns a new skeleton
  25395. */
  25396. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25397. /**
  25398. * Compute all node absolute transforms
  25399. * @param forceUpdate defines if computation must be done even if cache is up to date
  25400. */
  25401. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25402. /**
  25403. * Gets the root pose matrix
  25404. * @returns a matrix
  25405. */
  25406. getPoseMatrix(): Nullable<Matrix>;
  25407. /**
  25408. * Sorts bones per internal index
  25409. */
  25410. sortBones(): void;
  25411. private _sortBones;
  25412. /**
  25413. * Set the current local matrix as the restPose for all bones in the skeleton.
  25414. */
  25415. setCurrentPoseAsRest(): void;
  25416. }
  25417. }
  25418. declare module BABYLON {
  25419. /**
  25420. * Class used to store bone information
  25421. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25422. */
  25423. export class Bone extends Node {
  25424. /**
  25425. * defines the bone name
  25426. */
  25427. name: string;
  25428. private static _tmpVecs;
  25429. private static _tmpQuat;
  25430. private static _tmpMats;
  25431. /**
  25432. * Gets the list of child bones
  25433. */
  25434. children: Bone[];
  25435. /** Gets the animations associated with this bone */
  25436. animations: Animation[];
  25437. /**
  25438. * Gets or sets bone length
  25439. */
  25440. length: number;
  25441. /**
  25442. * @hidden Internal only
  25443. * Set this value to map this bone to a different index in the transform matrices
  25444. * Set this value to -1 to exclude the bone from the transform matrices
  25445. */
  25446. _index: Nullable<number>;
  25447. private _skeleton;
  25448. private _localMatrix;
  25449. private _restPose;
  25450. private _bindPose;
  25451. private _baseMatrix;
  25452. private _absoluteTransform;
  25453. private _invertedAbsoluteTransform;
  25454. private _parent;
  25455. private _scalingDeterminant;
  25456. private _worldTransform;
  25457. private _localScaling;
  25458. private _localRotation;
  25459. private _localPosition;
  25460. private _needToDecompose;
  25461. private _needToCompose;
  25462. /** @hidden */
  25463. _linkedTransformNode: Nullable<TransformNode>;
  25464. /** @hidden */
  25465. _waitingTransformNodeId: Nullable<string>;
  25466. /** @hidden */
  25467. get _matrix(): Matrix;
  25468. /** @hidden */
  25469. set _matrix(value: Matrix);
  25470. /**
  25471. * Create a new bone
  25472. * @param name defines the bone name
  25473. * @param skeleton defines the parent skeleton
  25474. * @param parentBone defines the parent (can be null if the bone is the root)
  25475. * @param localMatrix defines the local matrix
  25476. * @param restPose defines the rest pose matrix
  25477. * @param baseMatrix defines the base matrix
  25478. * @param index defines index of the bone in the hiearchy
  25479. */
  25480. constructor(
  25481. /**
  25482. * defines the bone name
  25483. */
  25484. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25485. /**
  25486. * Gets the current object class name.
  25487. * @return the class name
  25488. */
  25489. getClassName(): string;
  25490. /**
  25491. * Gets the parent skeleton
  25492. * @returns a skeleton
  25493. */
  25494. getSkeleton(): Skeleton;
  25495. /**
  25496. * Gets parent bone
  25497. * @returns a bone or null if the bone is the root of the bone hierarchy
  25498. */
  25499. getParent(): Nullable<Bone>;
  25500. /**
  25501. * Returns an array containing the root bones
  25502. * @returns an array containing the root bones
  25503. */
  25504. getChildren(): Array<Bone>;
  25505. /**
  25506. * Gets the node index in matrix array generated for rendering
  25507. * @returns the node index
  25508. */
  25509. getIndex(): number;
  25510. /**
  25511. * Sets the parent bone
  25512. * @param parent defines the parent (can be null if the bone is the root)
  25513. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25514. */
  25515. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25516. /**
  25517. * Gets the local matrix
  25518. * @returns a matrix
  25519. */
  25520. getLocalMatrix(): Matrix;
  25521. /**
  25522. * Gets the base matrix (initial matrix which remains unchanged)
  25523. * @returns a matrix
  25524. */
  25525. getBaseMatrix(): Matrix;
  25526. /**
  25527. * Gets the rest pose matrix
  25528. * @returns a matrix
  25529. */
  25530. getRestPose(): Matrix;
  25531. /**
  25532. * Sets the rest pose matrix
  25533. * @param matrix the local-space rest pose to set for this bone
  25534. */
  25535. setRestPose(matrix: Matrix): void;
  25536. /**
  25537. * Gets the bind pose matrix
  25538. * @returns the bind pose matrix
  25539. */
  25540. getBindPose(): Matrix;
  25541. /**
  25542. * Sets the bind pose matrix
  25543. * @param matrix the local-space bind pose to set for this bone
  25544. */
  25545. setBindPose(matrix: Matrix): void;
  25546. /**
  25547. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25548. */
  25549. getWorldMatrix(): Matrix;
  25550. /**
  25551. * Sets the local matrix to rest pose matrix
  25552. */
  25553. returnToRest(): void;
  25554. /**
  25555. * Gets the inverse of the absolute transform matrix.
  25556. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25557. * @returns a matrix
  25558. */
  25559. getInvertedAbsoluteTransform(): Matrix;
  25560. /**
  25561. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25562. * @returns a matrix
  25563. */
  25564. getAbsoluteTransform(): Matrix;
  25565. /**
  25566. * Links with the given transform node.
  25567. * The local matrix of this bone is copied from the transform node every frame.
  25568. * @param transformNode defines the transform node to link to
  25569. */
  25570. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25571. /**
  25572. * Gets the node used to drive the bone's transformation
  25573. * @returns a transform node or null
  25574. */
  25575. getTransformNode(): Nullable<TransformNode>;
  25576. /** Gets or sets current position (in local space) */
  25577. get position(): Vector3;
  25578. set position(newPosition: Vector3);
  25579. /** Gets or sets current rotation (in local space) */
  25580. get rotation(): Vector3;
  25581. set rotation(newRotation: Vector3);
  25582. /** Gets or sets current rotation quaternion (in local space) */
  25583. get rotationQuaternion(): Quaternion;
  25584. set rotationQuaternion(newRotation: Quaternion);
  25585. /** Gets or sets current scaling (in local space) */
  25586. get scaling(): Vector3;
  25587. set scaling(newScaling: Vector3);
  25588. /**
  25589. * Gets the animation properties override
  25590. */
  25591. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25592. private _decompose;
  25593. private _compose;
  25594. /**
  25595. * Update the base and local matrices
  25596. * @param matrix defines the new base or local matrix
  25597. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25598. * @param updateLocalMatrix defines if the local matrix should be updated
  25599. */
  25600. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25601. /** @hidden */
  25602. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25603. /**
  25604. * Flag the bone as dirty (Forcing it to update everything)
  25605. */
  25606. markAsDirty(): void;
  25607. /** @hidden */
  25608. _markAsDirtyAndCompose(): void;
  25609. private _markAsDirtyAndDecompose;
  25610. /**
  25611. * Translate the bone in local or world space
  25612. * @param vec The amount to translate the bone
  25613. * @param space The space that the translation is in
  25614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25615. */
  25616. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25617. /**
  25618. * Set the postion of the bone in local or world space
  25619. * @param position The position to set the bone
  25620. * @param space The space that the position is in
  25621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25622. */
  25623. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25624. /**
  25625. * Set the absolute position of the bone (world space)
  25626. * @param position The position to set the bone
  25627. * @param mesh The mesh that this bone is attached to
  25628. */
  25629. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25630. /**
  25631. * Scale the bone on the x, y and z axes (in local space)
  25632. * @param x The amount to scale the bone on the x axis
  25633. * @param y The amount to scale the bone on the y axis
  25634. * @param z The amount to scale the bone on the z axis
  25635. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25636. */
  25637. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25638. /**
  25639. * Set the bone scaling in local space
  25640. * @param scale defines the scaling vector
  25641. */
  25642. setScale(scale: Vector3): void;
  25643. /**
  25644. * Gets the current scaling in local space
  25645. * @returns the current scaling vector
  25646. */
  25647. getScale(): Vector3;
  25648. /**
  25649. * Gets the current scaling in local space and stores it in a target vector
  25650. * @param result defines the target vector
  25651. */
  25652. getScaleToRef(result: Vector3): void;
  25653. /**
  25654. * Set the yaw, pitch, and roll of the bone in local or world space
  25655. * @param yaw The rotation of the bone on the y axis
  25656. * @param pitch The rotation of the bone on the x axis
  25657. * @param roll The rotation of the bone on the z axis
  25658. * @param space The space that the axes of rotation are in
  25659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25660. */
  25661. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25662. /**
  25663. * Add a rotation to the bone on an axis in local or world space
  25664. * @param axis The axis to rotate the bone on
  25665. * @param amount The amount to rotate the bone
  25666. * @param space The space that the axis is in
  25667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25668. */
  25669. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25670. /**
  25671. * Set the rotation of the bone to a particular axis angle in local or world space
  25672. * @param axis The axis to rotate the bone on
  25673. * @param angle The angle that the bone should be rotated to
  25674. * @param space The space that the axis is in
  25675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25676. */
  25677. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25678. /**
  25679. * Set the euler rotation of the bone in local or world space
  25680. * @param rotation The euler rotation that the bone should be set to
  25681. * @param space The space that the rotation is in
  25682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25683. */
  25684. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25685. /**
  25686. * Set the quaternion rotation of the bone in local or world space
  25687. * @param quat The quaternion rotation that the bone should be set to
  25688. * @param space The space that the rotation is in
  25689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25690. */
  25691. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25692. /**
  25693. * Set the rotation matrix of the bone in local or world space
  25694. * @param rotMat The rotation matrix that the bone should be set to
  25695. * @param space The space that the rotation is in
  25696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25697. */
  25698. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25699. private _rotateWithMatrix;
  25700. private _getNegativeRotationToRef;
  25701. /**
  25702. * Get the position of the bone in local or world space
  25703. * @param space The space that the returned position is in
  25704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25705. * @returns The position of the bone
  25706. */
  25707. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25708. /**
  25709. * Copy the position of the bone to a vector3 in local or world space
  25710. * @param space The space that the returned position is in
  25711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25712. * @param result The vector3 to copy the position to
  25713. */
  25714. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25715. /**
  25716. * Get the absolute position of the bone (world space)
  25717. * @param mesh The mesh that this bone is attached to
  25718. * @returns The absolute position of the bone
  25719. */
  25720. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25721. /**
  25722. * Copy the absolute position of the bone (world space) to the result param
  25723. * @param mesh The mesh that this bone is attached to
  25724. * @param result The vector3 to copy the absolute position to
  25725. */
  25726. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25727. /**
  25728. * Compute the absolute transforms of this bone and its children
  25729. */
  25730. computeAbsoluteTransforms(): void;
  25731. /**
  25732. * Get the world direction from an axis that is in the local space of the bone
  25733. * @param localAxis The local direction that is used to compute the world direction
  25734. * @param mesh The mesh that this bone is attached to
  25735. * @returns The world direction
  25736. */
  25737. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25738. /**
  25739. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25740. * @param localAxis The local direction that is used to compute the world direction
  25741. * @param mesh The mesh that this bone is attached to
  25742. * @param result The vector3 that the world direction will be copied to
  25743. */
  25744. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25745. /**
  25746. * Get the euler rotation of the bone in local or world space
  25747. * @param space The space that the rotation should be in
  25748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25749. * @returns The euler rotation
  25750. */
  25751. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25752. /**
  25753. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25754. * @param space The space that the rotation should be in
  25755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25756. * @param result The vector3 that the rotation should be copied to
  25757. */
  25758. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25759. /**
  25760. * Get the quaternion rotation of the bone in either local or world space
  25761. * @param space The space that the rotation should be in
  25762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25763. * @returns The quaternion rotation
  25764. */
  25765. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25766. /**
  25767. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25768. * @param space The space that the rotation should be in
  25769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25770. * @param result The quaternion that the rotation should be copied to
  25771. */
  25772. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25773. /**
  25774. * Get the rotation matrix of the bone in local or world space
  25775. * @param space The space that the rotation should be in
  25776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25777. * @returns The rotation matrix
  25778. */
  25779. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25780. /**
  25781. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25782. * @param space The space that the rotation should be in
  25783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25784. * @param result The quaternion that the rotation should be copied to
  25785. */
  25786. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25787. /**
  25788. * Get the world position of a point that is in the local space of the bone
  25789. * @param position The local position
  25790. * @param mesh The mesh that this bone is attached to
  25791. * @returns The world position
  25792. */
  25793. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25794. /**
  25795. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25796. * @param position The local position
  25797. * @param mesh The mesh that this bone is attached to
  25798. * @param result The vector3 that the world position should be copied to
  25799. */
  25800. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25801. /**
  25802. * Get the local position of a point that is in world space
  25803. * @param position The world position
  25804. * @param mesh The mesh that this bone is attached to
  25805. * @returns The local position
  25806. */
  25807. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25808. /**
  25809. * Get the local position of a point that is in world space and copy it to the result param
  25810. * @param position The world position
  25811. * @param mesh The mesh that this bone is attached to
  25812. * @param result The vector3 that the local position should be copied to
  25813. */
  25814. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25815. /**
  25816. * Set the current local matrix as the restPose for this bone.
  25817. */
  25818. setCurrentPoseAsRest(): void;
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. /**
  25823. * 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.
  25824. * @see https://doc.babylonjs.com/how_to/transformnode
  25825. */
  25826. export class TransformNode extends Node {
  25827. /**
  25828. * Object will not rotate to face the camera
  25829. */
  25830. static BILLBOARDMODE_NONE: number;
  25831. /**
  25832. * Object will rotate to face the camera but only on the x axis
  25833. */
  25834. static BILLBOARDMODE_X: number;
  25835. /**
  25836. * Object will rotate to face the camera but only on the y axis
  25837. */
  25838. static BILLBOARDMODE_Y: number;
  25839. /**
  25840. * Object will rotate to face the camera but only on the z axis
  25841. */
  25842. static BILLBOARDMODE_Z: number;
  25843. /**
  25844. * Object will rotate to face the camera
  25845. */
  25846. static BILLBOARDMODE_ALL: number;
  25847. /**
  25848. * Object will rotate to face the camera's position instead of orientation
  25849. */
  25850. static BILLBOARDMODE_USE_POSITION: number;
  25851. private static _TmpRotation;
  25852. private static _TmpScaling;
  25853. private static _TmpTranslation;
  25854. private _forward;
  25855. private _forwardInverted;
  25856. private _up;
  25857. private _right;
  25858. private _rightInverted;
  25859. private _position;
  25860. private _rotation;
  25861. private _rotationQuaternion;
  25862. protected _scaling: Vector3;
  25863. protected _isDirty: boolean;
  25864. private _transformToBoneReferal;
  25865. private _isAbsoluteSynced;
  25866. private _billboardMode;
  25867. /**
  25868. * Gets or sets the billboard mode. Default is 0.
  25869. *
  25870. * | Value | Type | Description |
  25871. * | --- | --- | --- |
  25872. * | 0 | BILLBOARDMODE_NONE | |
  25873. * | 1 | BILLBOARDMODE_X | |
  25874. * | 2 | BILLBOARDMODE_Y | |
  25875. * | 4 | BILLBOARDMODE_Z | |
  25876. * | 7 | BILLBOARDMODE_ALL | |
  25877. *
  25878. */
  25879. get billboardMode(): number;
  25880. set billboardMode(value: number);
  25881. private _preserveParentRotationForBillboard;
  25882. /**
  25883. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25884. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25885. */
  25886. get preserveParentRotationForBillboard(): boolean;
  25887. set preserveParentRotationForBillboard(value: boolean);
  25888. /**
  25889. * 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
  25890. */
  25891. scalingDeterminant: number;
  25892. private _infiniteDistance;
  25893. /**
  25894. * Gets or sets the distance of the object to max, often used by skybox
  25895. */
  25896. get infiniteDistance(): boolean;
  25897. set infiniteDistance(value: boolean);
  25898. /**
  25899. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25900. * By default the system will update normals to compensate
  25901. */
  25902. ignoreNonUniformScaling: boolean;
  25903. /**
  25904. * 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
  25905. */
  25906. reIntegrateRotationIntoRotationQuaternion: boolean;
  25907. /** @hidden */
  25908. _poseMatrix: Nullable<Matrix>;
  25909. /** @hidden */
  25910. _localMatrix: Matrix;
  25911. private _usePivotMatrix;
  25912. private _absolutePosition;
  25913. private _absoluteScaling;
  25914. private _absoluteRotationQuaternion;
  25915. private _pivotMatrix;
  25916. private _pivotMatrixInverse;
  25917. /** @hidden */
  25918. _postMultiplyPivotMatrix: boolean;
  25919. protected _isWorldMatrixFrozen: boolean;
  25920. /** @hidden */
  25921. _indexInSceneTransformNodesArray: number;
  25922. /**
  25923. * An event triggered after the world matrix is updated
  25924. */
  25925. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25926. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25927. /**
  25928. * Gets a string identifying the name of the class
  25929. * @returns "TransformNode" string
  25930. */
  25931. getClassName(): string;
  25932. /**
  25933. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25934. */
  25935. get position(): Vector3;
  25936. set position(newPosition: Vector3);
  25937. /**
  25938. * 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)).
  25939. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25940. */
  25941. get rotation(): Vector3;
  25942. set rotation(newRotation: Vector3);
  25943. /**
  25944. * 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)).
  25945. */
  25946. get scaling(): Vector3;
  25947. set scaling(newScaling: Vector3);
  25948. /**
  25949. * 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).
  25950. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25951. */
  25952. get rotationQuaternion(): Nullable<Quaternion>;
  25953. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25954. /**
  25955. * The forward direction of that transform in world space.
  25956. */
  25957. get forward(): Vector3;
  25958. /**
  25959. * The up direction of that transform in world space.
  25960. */
  25961. get up(): Vector3;
  25962. /**
  25963. * The right direction of that transform in world space.
  25964. */
  25965. get right(): Vector3;
  25966. /**
  25967. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25968. * @param matrix the matrix to copy the pose from
  25969. * @returns this TransformNode.
  25970. */
  25971. updatePoseMatrix(matrix: Matrix): TransformNode;
  25972. /**
  25973. * Returns the mesh Pose matrix.
  25974. * @returns the pose matrix
  25975. */
  25976. getPoseMatrix(): Matrix;
  25977. /** @hidden */
  25978. _isSynchronized(): boolean;
  25979. /** @hidden */
  25980. _initCache(): void;
  25981. /**
  25982. * Flag the transform node as dirty (Forcing it to update everything)
  25983. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25984. * @returns this transform node
  25985. */
  25986. markAsDirty(property: string): TransformNode;
  25987. /**
  25988. * Returns the current mesh absolute position.
  25989. * Returns a Vector3.
  25990. */
  25991. get absolutePosition(): Vector3;
  25992. /**
  25993. * Returns the current mesh absolute scaling.
  25994. * Returns a Vector3.
  25995. */
  25996. get absoluteScaling(): Vector3;
  25997. /**
  25998. * Returns the current mesh absolute rotation.
  25999. * Returns a Quaternion.
  26000. */
  26001. get absoluteRotationQuaternion(): Quaternion;
  26002. /**
  26003. * Sets a new matrix to apply before all other transformation
  26004. * @param matrix defines the transform matrix
  26005. * @returns the current TransformNode
  26006. */
  26007. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26008. /**
  26009. * Sets a new pivot matrix to the current node
  26010. * @param matrix defines the new pivot matrix to use
  26011. * @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
  26012. * @returns the current TransformNode
  26013. */
  26014. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26015. /**
  26016. * Returns the mesh pivot matrix.
  26017. * Default : Identity.
  26018. * @returns the matrix
  26019. */
  26020. getPivotMatrix(): Matrix;
  26021. /**
  26022. * Instantiate (when possible) or clone that node with its hierarchy
  26023. * @param newParent defines the new parent to use for the instance (or clone)
  26024. * @param options defines options to configure how copy is done
  26025. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26026. * @returns an instance (or a clone) of the current node with its hiearchy
  26027. */
  26028. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26029. doNotInstantiate: boolean;
  26030. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26031. /**
  26032. * Prevents the World matrix to be computed any longer
  26033. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26034. * @returns the TransformNode.
  26035. */
  26036. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26037. /**
  26038. * Allows back the World matrix computation.
  26039. * @returns the TransformNode.
  26040. */
  26041. unfreezeWorldMatrix(): this;
  26042. /**
  26043. * True if the World matrix has been frozen.
  26044. */
  26045. get isWorldMatrixFrozen(): boolean;
  26046. /**
  26047. * Retuns the mesh absolute position in the World.
  26048. * @returns a Vector3.
  26049. */
  26050. getAbsolutePosition(): Vector3;
  26051. /**
  26052. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26053. * @param absolutePosition the absolute position to set
  26054. * @returns the TransformNode.
  26055. */
  26056. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26057. /**
  26058. * Sets the mesh position in its local space.
  26059. * @param vector3 the position to set in localspace
  26060. * @returns the TransformNode.
  26061. */
  26062. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26063. /**
  26064. * Returns the mesh position in the local space from the current World matrix values.
  26065. * @returns a new Vector3.
  26066. */
  26067. getPositionExpressedInLocalSpace(): Vector3;
  26068. /**
  26069. * Translates the mesh along the passed Vector3 in its local space.
  26070. * @param vector3 the distance to translate in localspace
  26071. * @returns the TransformNode.
  26072. */
  26073. locallyTranslate(vector3: Vector3): TransformNode;
  26074. private static _lookAtVectorCache;
  26075. /**
  26076. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26077. * @param targetPoint the position (must be in same space as current mesh) to look at
  26078. * @param yawCor optional yaw (y-axis) correction in radians
  26079. * @param pitchCor optional pitch (x-axis) correction in radians
  26080. * @param rollCor optional roll (z-axis) correction in radians
  26081. * @param space the choosen space of the target
  26082. * @returns the TransformNode.
  26083. */
  26084. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26085. /**
  26086. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26087. * This Vector3 is expressed in the World space.
  26088. * @param localAxis axis to rotate
  26089. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26090. */
  26091. getDirection(localAxis: Vector3): Vector3;
  26092. /**
  26093. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26094. * localAxis is expressed in the mesh local space.
  26095. * result is computed in the Wordl space from the mesh World matrix.
  26096. * @param localAxis axis to rotate
  26097. * @param result the resulting transformnode
  26098. * @returns this TransformNode.
  26099. */
  26100. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26101. /**
  26102. * Sets this transform node rotation to the given local axis.
  26103. * @param localAxis the axis in local space
  26104. * @param yawCor optional yaw (y-axis) correction in radians
  26105. * @param pitchCor optional pitch (x-axis) correction in radians
  26106. * @param rollCor optional roll (z-axis) correction in radians
  26107. * @returns this TransformNode
  26108. */
  26109. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26110. /**
  26111. * Sets a new pivot point to the current node
  26112. * @param point defines the new pivot point to use
  26113. * @param space defines if the point is in world or local space (local by default)
  26114. * @returns the current TransformNode
  26115. */
  26116. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26117. /**
  26118. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26119. * @returns the pivot point
  26120. */
  26121. getPivotPoint(): Vector3;
  26122. /**
  26123. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26124. * @param result the vector3 to store the result
  26125. * @returns this TransformNode.
  26126. */
  26127. getPivotPointToRef(result: Vector3): TransformNode;
  26128. /**
  26129. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26130. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26131. */
  26132. getAbsolutePivotPoint(): Vector3;
  26133. /**
  26134. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26135. * @param result vector3 to store the result
  26136. * @returns this TransformNode.
  26137. */
  26138. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26139. /**
  26140. * Defines the passed node as the parent of the current node.
  26141. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26142. * @see https://doc.babylonjs.com/how_to/parenting
  26143. * @param node the node ot set as the parent
  26144. * @returns this TransformNode.
  26145. */
  26146. setParent(node: Nullable<Node>): TransformNode;
  26147. private _nonUniformScaling;
  26148. /**
  26149. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26150. */
  26151. get nonUniformScaling(): boolean;
  26152. /** @hidden */
  26153. _updateNonUniformScalingState(value: boolean): boolean;
  26154. /**
  26155. * Attach the current TransformNode to another TransformNode associated with a bone
  26156. * @param bone Bone affecting the TransformNode
  26157. * @param affectedTransformNode TransformNode associated with the bone
  26158. * @returns this object
  26159. */
  26160. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26161. /**
  26162. * Detach the transform node if its associated with a bone
  26163. * @returns this object
  26164. */
  26165. detachFromBone(): TransformNode;
  26166. private static _rotationAxisCache;
  26167. /**
  26168. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26169. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26170. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26171. * The passed axis is also normalized.
  26172. * @param axis the axis to rotate around
  26173. * @param amount the amount to rotate in radians
  26174. * @param space Space to rotate in (Default: local)
  26175. * @returns the TransformNode.
  26176. */
  26177. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26178. /**
  26179. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26180. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26181. * The passed axis is also normalized. .
  26182. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26183. * @param point the point to rotate around
  26184. * @param axis the axis to rotate around
  26185. * @param amount the amount to rotate in radians
  26186. * @returns the TransformNode
  26187. */
  26188. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26189. /**
  26190. * Translates the mesh along the axis vector for the passed distance in the given space.
  26191. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26192. * @param axis the axis to translate in
  26193. * @param distance the distance to translate
  26194. * @param space Space to rotate in (Default: local)
  26195. * @returns the TransformNode.
  26196. */
  26197. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26198. /**
  26199. * Adds a rotation step to the mesh current rotation.
  26200. * x, y, z are Euler angles expressed in radians.
  26201. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26202. * This means this rotation is made in the mesh local space only.
  26203. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26204. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26205. * ```javascript
  26206. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26207. * ```
  26208. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26209. * 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.
  26210. * @param x Rotation to add
  26211. * @param y Rotation to add
  26212. * @param z Rotation to add
  26213. * @returns the TransformNode.
  26214. */
  26215. addRotation(x: number, y: number, z: number): TransformNode;
  26216. /**
  26217. * @hidden
  26218. */
  26219. protected _getEffectiveParent(): Nullable<Node>;
  26220. /**
  26221. * Computes the world matrix of the node
  26222. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26223. * @returns the world matrix
  26224. */
  26225. computeWorldMatrix(force?: boolean): Matrix;
  26226. /**
  26227. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26228. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26229. */
  26230. resetLocalMatrix(independentOfChildren?: boolean): void;
  26231. protected _afterComputeWorldMatrix(): void;
  26232. /**
  26233. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26234. * @param func callback function to add
  26235. *
  26236. * @returns the TransformNode.
  26237. */
  26238. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26239. /**
  26240. * Removes a registered callback function.
  26241. * @param func callback function to remove
  26242. * @returns the TransformNode.
  26243. */
  26244. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26245. /**
  26246. * Gets the position of the current mesh in camera space
  26247. * @param camera defines the camera to use
  26248. * @returns a position
  26249. */
  26250. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26251. /**
  26252. * Returns the distance from the mesh to the active camera
  26253. * @param camera defines the camera to use
  26254. * @returns the distance
  26255. */
  26256. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26257. /**
  26258. * Clone the current transform node
  26259. * @param name Name of the new clone
  26260. * @param newParent New parent for the clone
  26261. * @param doNotCloneChildren Do not clone children hierarchy
  26262. * @returns the new transform node
  26263. */
  26264. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26265. /**
  26266. * Serializes the objects information.
  26267. * @param currentSerializationObject defines the object to serialize in
  26268. * @returns the serialized object
  26269. */
  26270. serialize(currentSerializationObject?: any): any;
  26271. /**
  26272. * Returns a new TransformNode object parsed from the source provided.
  26273. * @param parsedTransformNode is the source.
  26274. * @param scene the scne the object belongs to
  26275. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26276. * @returns a new TransformNode object parsed from the source provided.
  26277. */
  26278. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26279. /**
  26280. * Get all child-transformNodes of this node
  26281. * @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
  26282. * @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
  26283. * @returns an array of TransformNode
  26284. */
  26285. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26286. /**
  26287. * Releases resources associated with this transform node.
  26288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26290. */
  26291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26292. /**
  26293. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26294. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26295. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26296. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26297. * @returns the current mesh
  26298. */
  26299. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26300. private _syncAbsoluteScalingAndRotation;
  26301. }
  26302. }
  26303. declare module BABYLON {
  26304. /**
  26305. * Defines the types of pose enabled controllers that are supported
  26306. */
  26307. export enum PoseEnabledControllerType {
  26308. /**
  26309. * HTC Vive
  26310. */
  26311. VIVE = 0,
  26312. /**
  26313. * Oculus Rift
  26314. */
  26315. OCULUS = 1,
  26316. /**
  26317. * Windows mixed reality
  26318. */
  26319. WINDOWS = 2,
  26320. /**
  26321. * Samsung gear VR
  26322. */
  26323. GEAR_VR = 3,
  26324. /**
  26325. * Google Daydream
  26326. */
  26327. DAYDREAM = 4,
  26328. /**
  26329. * Generic
  26330. */
  26331. GENERIC = 5
  26332. }
  26333. /**
  26334. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26335. */
  26336. export interface MutableGamepadButton {
  26337. /**
  26338. * Value of the button/trigger
  26339. */
  26340. value: number;
  26341. /**
  26342. * If the button/trigger is currently touched
  26343. */
  26344. touched: boolean;
  26345. /**
  26346. * If the button/trigger is currently pressed
  26347. */
  26348. pressed: boolean;
  26349. }
  26350. /**
  26351. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26352. * @hidden
  26353. */
  26354. export interface ExtendedGamepadButton extends GamepadButton {
  26355. /**
  26356. * If the button/trigger is currently pressed
  26357. */
  26358. readonly pressed: boolean;
  26359. /**
  26360. * If the button/trigger is currently touched
  26361. */
  26362. readonly touched: boolean;
  26363. /**
  26364. * Value of the button/trigger
  26365. */
  26366. readonly value: number;
  26367. }
  26368. /** @hidden */
  26369. export interface _GamePadFactory {
  26370. /**
  26371. * Returns whether or not the current gamepad can be created for this type of controller.
  26372. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26373. * @returns true if it can be created, otherwise false
  26374. */
  26375. canCreate(gamepadInfo: any): boolean;
  26376. /**
  26377. * Creates a new instance of the Gamepad.
  26378. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26379. * @returns the new gamepad instance
  26380. */
  26381. create(gamepadInfo: any): Gamepad;
  26382. }
  26383. /**
  26384. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26385. */
  26386. export class PoseEnabledControllerHelper {
  26387. /** @hidden */
  26388. static _ControllerFactories: _GamePadFactory[];
  26389. /** @hidden */
  26390. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26391. /**
  26392. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26393. * @param vrGamepad the gamepad to initialized
  26394. * @returns a vr controller of the type the gamepad identified as
  26395. */
  26396. static InitiateController(vrGamepad: any): Gamepad;
  26397. }
  26398. /**
  26399. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26400. */
  26401. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26402. /**
  26403. * If the controller is used in a webXR session
  26404. */
  26405. isXR: boolean;
  26406. private _deviceRoomPosition;
  26407. private _deviceRoomRotationQuaternion;
  26408. /**
  26409. * The device position in babylon space
  26410. */
  26411. devicePosition: Vector3;
  26412. /**
  26413. * The device rotation in babylon space
  26414. */
  26415. deviceRotationQuaternion: Quaternion;
  26416. /**
  26417. * The scale factor of the device in babylon space
  26418. */
  26419. deviceScaleFactor: number;
  26420. /**
  26421. * (Likely devicePosition should be used instead) The device position in its room space
  26422. */
  26423. position: Vector3;
  26424. /**
  26425. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26426. */
  26427. rotationQuaternion: Quaternion;
  26428. /**
  26429. * The type of controller (Eg. Windows mixed reality)
  26430. */
  26431. controllerType: PoseEnabledControllerType;
  26432. protected _calculatedPosition: Vector3;
  26433. private _calculatedRotation;
  26434. /**
  26435. * The raw pose from the device
  26436. */
  26437. rawPose: DevicePose;
  26438. private _trackPosition;
  26439. private _maxRotationDistFromHeadset;
  26440. private _draggedRoomRotation;
  26441. /**
  26442. * @hidden
  26443. */
  26444. _disableTrackPosition(fixedPosition: Vector3): void;
  26445. /**
  26446. * Internal, the mesh attached to the controller
  26447. * @hidden
  26448. */
  26449. _mesh: Nullable<AbstractMesh>;
  26450. private _poseControlledCamera;
  26451. private _leftHandSystemQuaternion;
  26452. /**
  26453. * Internal, matrix used to convert room space to babylon space
  26454. * @hidden
  26455. */
  26456. _deviceToWorld: Matrix;
  26457. /**
  26458. * Node to be used when casting a ray from the controller
  26459. * @hidden
  26460. */
  26461. _pointingPoseNode: Nullable<TransformNode>;
  26462. /**
  26463. * Name of the child mesh that can be used to cast a ray from the controller
  26464. */
  26465. static readonly POINTING_POSE: string;
  26466. /**
  26467. * Creates a new PoseEnabledController from a gamepad
  26468. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26469. */
  26470. constructor(browserGamepad: any);
  26471. private _workingMatrix;
  26472. /**
  26473. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26474. */
  26475. update(): void;
  26476. /**
  26477. * Updates only the pose device and mesh without doing any button event checking
  26478. */
  26479. protected _updatePoseAndMesh(): void;
  26480. /**
  26481. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26482. * @param poseData raw pose fromthe device
  26483. */
  26484. updateFromDevice(poseData: DevicePose): void;
  26485. /**
  26486. * @hidden
  26487. */
  26488. _meshAttachedObservable: Observable<AbstractMesh>;
  26489. /**
  26490. * Attaches a mesh to the controller
  26491. * @param mesh the mesh to be attached
  26492. */
  26493. attachToMesh(mesh: AbstractMesh): void;
  26494. /**
  26495. * Attaches the controllers mesh to a camera
  26496. * @param camera the camera the mesh should be attached to
  26497. */
  26498. attachToPoseControlledCamera(camera: TargetCamera): void;
  26499. /**
  26500. * Disposes of the controller
  26501. */
  26502. dispose(): void;
  26503. /**
  26504. * The mesh that is attached to the controller
  26505. */
  26506. get mesh(): Nullable<AbstractMesh>;
  26507. /**
  26508. * Gets the ray of the controller in the direction the controller is pointing
  26509. * @param length the length the resulting ray should be
  26510. * @returns a ray in the direction the controller is pointing
  26511. */
  26512. getForwardRay(length?: number): Ray;
  26513. }
  26514. }
  26515. declare module BABYLON {
  26516. /**
  26517. * Defines the WebVRController object that represents controllers tracked in 3D space
  26518. */
  26519. export abstract class WebVRController extends PoseEnabledController {
  26520. /**
  26521. * Internal, the default controller model for the controller
  26522. */
  26523. protected _defaultModel: Nullable<AbstractMesh>;
  26524. /**
  26525. * Fired when the trigger state has changed
  26526. */
  26527. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26528. /**
  26529. * Fired when the main button state has changed
  26530. */
  26531. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26532. /**
  26533. * Fired when the secondary button state has changed
  26534. */
  26535. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26536. /**
  26537. * Fired when the pad state has changed
  26538. */
  26539. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26540. /**
  26541. * Fired when controllers stick values have changed
  26542. */
  26543. onPadValuesChangedObservable: Observable<StickValues>;
  26544. /**
  26545. * Array of button availible on the controller
  26546. */
  26547. protected _buttons: Array<MutableGamepadButton>;
  26548. private _onButtonStateChange;
  26549. /**
  26550. * Fired when a controller button's state has changed
  26551. * @param callback the callback containing the button that was modified
  26552. */
  26553. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26554. /**
  26555. * X and Y axis corresponding to the controllers joystick
  26556. */
  26557. pad: StickValues;
  26558. /**
  26559. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26560. */
  26561. hand: string;
  26562. /**
  26563. * The default controller model for the controller
  26564. */
  26565. get defaultModel(): Nullable<AbstractMesh>;
  26566. /**
  26567. * Creates a new WebVRController from a gamepad
  26568. * @param vrGamepad the gamepad that the WebVRController should be created from
  26569. */
  26570. constructor(vrGamepad: any);
  26571. /**
  26572. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26573. */
  26574. update(): void;
  26575. /**
  26576. * Function to be called when a button is modified
  26577. */
  26578. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26579. /**
  26580. * Loads a mesh and attaches it to the controller
  26581. * @param scene the scene the mesh should be added to
  26582. * @param meshLoaded callback for when the mesh has been loaded
  26583. */
  26584. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26585. private _setButtonValue;
  26586. private _changes;
  26587. private _checkChanges;
  26588. /**
  26589. * Disposes of th webVRCOntroller
  26590. */
  26591. dispose(): void;
  26592. }
  26593. }
  26594. declare module BABYLON {
  26595. /**
  26596. * The HemisphericLight simulates the ambient environment light,
  26597. * so the passed direction is the light reflection direction, not the incoming direction.
  26598. */
  26599. export class HemisphericLight extends Light {
  26600. /**
  26601. * The groundColor is the light in the opposite direction to the one specified during creation.
  26602. * 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.
  26603. */
  26604. groundColor: Color3;
  26605. /**
  26606. * The light reflection direction, not the incoming direction.
  26607. */
  26608. direction: Vector3;
  26609. /**
  26610. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26611. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26612. * The HemisphericLight can't cast shadows.
  26613. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26614. * @param name The friendly name of the light
  26615. * @param direction The direction of the light reflection
  26616. * @param scene The scene the light belongs to
  26617. */
  26618. constructor(name: string, direction: Vector3, scene: Scene);
  26619. protected _buildUniformLayout(): void;
  26620. /**
  26621. * Returns the string "HemisphericLight".
  26622. * @return The class name
  26623. */
  26624. getClassName(): string;
  26625. /**
  26626. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26627. * Returns the updated direction.
  26628. * @param target The target the direction should point to
  26629. * @return The computed direction
  26630. */
  26631. setDirectionToTarget(target: Vector3): Vector3;
  26632. /**
  26633. * Returns the shadow generator associated to the light.
  26634. * @returns Always null for hemispheric lights because it does not support shadows.
  26635. */
  26636. getShadowGenerator(): Nullable<IShadowGenerator>;
  26637. /**
  26638. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26639. * @param effect The effect to update
  26640. * @param lightIndex The index of the light in the effect to update
  26641. * @returns The hemispheric light
  26642. */
  26643. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26644. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26645. /**
  26646. * Computes the world matrix of the node
  26647. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26648. * @param useWasUpdatedFlag defines a reserved property
  26649. * @returns the world matrix
  26650. */
  26651. computeWorldMatrix(): Matrix;
  26652. /**
  26653. * Returns the integer 3.
  26654. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26655. */
  26656. getTypeID(): number;
  26657. /**
  26658. * Prepares the list of defines specific to the light type.
  26659. * @param defines the list of defines
  26660. * @param lightIndex defines the index of the light for the effect
  26661. */
  26662. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26663. }
  26664. }
  26665. declare module BABYLON {
  26666. /** @hidden */
  26667. export var vrMultiviewToSingleviewPixelShader: {
  26668. name: string;
  26669. shader: string;
  26670. };
  26671. }
  26672. declare module BABYLON {
  26673. /**
  26674. * Renders to multiple views with a single draw call
  26675. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26676. */
  26677. export class MultiviewRenderTarget extends RenderTargetTexture {
  26678. /**
  26679. * Creates a multiview render target
  26680. * @param scene scene used with the render target
  26681. * @param size the size of the render target (used for each view)
  26682. */
  26683. constructor(scene: Scene, size?: number | {
  26684. width: number;
  26685. height: number;
  26686. } | {
  26687. ratio: number;
  26688. });
  26689. /**
  26690. * @hidden
  26691. * @param faceIndex the face index, if its a cube texture
  26692. */
  26693. _bindFrameBuffer(faceIndex?: number): void;
  26694. /**
  26695. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26696. * @returns the view count
  26697. */
  26698. getViewCount(): number;
  26699. }
  26700. }
  26701. declare module BABYLON {
  26702. interface Engine {
  26703. /**
  26704. * Creates a new multiview render target
  26705. * @param width defines the width of the texture
  26706. * @param height defines the height of the texture
  26707. * @returns the created multiview texture
  26708. */
  26709. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26710. /**
  26711. * Binds a multiview framebuffer to be drawn to
  26712. * @param multiviewTexture texture to bind
  26713. */
  26714. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26715. }
  26716. interface Camera {
  26717. /**
  26718. * @hidden
  26719. * 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)
  26720. */
  26721. _useMultiviewToSingleView: boolean;
  26722. /**
  26723. * @hidden
  26724. * 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)
  26725. */
  26726. _multiviewTexture: Nullable<RenderTargetTexture>;
  26727. /**
  26728. * @hidden
  26729. * ensures the multiview texture of the camera exists and has the specified width/height
  26730. * @param width height to set on the multiview texture
  26731. * @param height width to set on the multiview texture
  26732. */
  26733. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26734. }
  26735. interface Scene {
  26736. /** @hidden */
  26737. _transformMatrixR: Matrix;
  26738. /** @hidden */
  26739. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26740. /** @hidden */
  26741. _createMultiviewUbo(): void;
  26742. /** @hidden */
  26743. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26744. /** @hidden */
  26745. _renderMultiviewToSingleView(camera: Camera): void;
  26746. }
  26747. }
  26748. declare module BABYLON {
  26749. /**
  26750. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26751. * This will not be used for webXR as it supports displaying texture arrays directly
  26752. */
  26753. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26754. /**
  26755. * Gets a string identifying the name of the class
  26756. * @returns "VRMultiviewToSingleviewPostProcess" string
  26757. */
  26758. getClassName(): string;
  26759. /**
  26760. * Initializes a VRMultiviewToSingleview
  26761. * @param name name of the post process
  26762. * @param camera camera to be applied to
  26763. * @param scaleFactor scaling factor to the size of the output texture
  26764. */
  26765. constructor(name: string, camera: Camera, scaleFactor: number);
  26766. }
  26767. }
  26768. declare module BABYLON {
  26769. /**
  26770. * Interface used to define additional presentation attributes
  26771. */
  26772. export interface IVRPresentationAttributes {
  26773. /**
  26774. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26775. */
  26776. highRefreshRate: boolean;
  26777. /**
  26778. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26779. */
  26780. foveationLevel: number;
  26781. }
  26782. interface Engine {
  26783. /** @hidden */
  26784. _vrDisplay: any;
  26785. /** @hidden */
  26786. _vrSupported: boolean;
  26787. /** @hidden */
  26788. _oldSize: Size;
  26789. /** @hidden */
  26790. _oldHardwareScaleFactor: number;
  26791. /** @hidden */
  26792. _vrExclusivePointerMode: boolean;
  26793. /** @hidden */
  26794. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26795. /** @hidden */
  26796. _onVRDisplayPointerRestricted: () => void;
  26797. /** @hidden */
  26798. _onVRDisplayPointerUnrestricted: () => void;
  26799. /** @hidden */
  26800. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26801. /** @hidden */
  26802. _onVrDisplayDisconnect: Nullable<() => void>;
  26803. /** @hidden */
  26804. _onVrDisplayPresentChange: Nullable<() => void>;
  26805. /**
  26806. * Observable signaled when VR display mode changes
  26807. */
  26808. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26809. /**
  26810. * Observable signaled when VR request present is complete
  26811. */
  26812. onVRRequestPresentComplete: Observable<boolean>;
  26813. /**
  26814. * Observable signaled when VR request present starts
  26815. */
  26816. onVRRequestPresentStart: Observable<Engine>;
  26817. /**
  26818. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26819. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26820. */
  26821. isInVRExclusivePointerMode: boolean;
  26822. /**
  26823. * Gets a boolean indicating if a webVR device was detected
  26824. * @returns true if a webVR device was detected
  26825. */
  26826. isVRDevicePresent(): boolean;
  26827. /**
  26828. * Gets the current webVR device
  26829. * @returns the current webVR device (or null)
  26830. */
  26831. getVRDevice(): any;
  26832. /**
  26833. * Initializes a webVR display and starts listening to display change events
  26834. * The onVRDisplayChangedObservable will be notified upon these changes
  26835. * @returns A promise containing a VRDisplay and if vr is supported
  26836. */
  26837. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26838. /** @hidden */
  26839. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26840. /**
  26841. * Gets or sets the presentation attributes used to configure VR rendering
  26842. */
  26843. vrPresentationAttributes?: IVRPresentationAttributes;
  26844. /**
  26845. * Call this function to switch to webVR mode
  26846. * Will do nothing if webVR is not supported or if there is no webVR device
  26847. * @param options the webvr options provided to the camera. mainly used for multiview
  26848. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26849. */
  26850. enableVR(options: WebVROptions): void;
  26851. /** @hidden */
  26852. _onVRFullScreenTriggered(): void;
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. /**
  26857. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26858. * IMPORTANT!! The data is right-hand data.
  26859. * @export
  26860. * @interface DevicePose
  26861. */
  26862. export interface DevicePose {
  26863. /**
  26864. * The position of the device, values in array are [x,y,z].
  26865. */
  26866. readonly position: Nullable<Float32Array>;
  26867. /**
  26868. * The linearVelocity of the device, values in array are [x,y,z].
  26869. */
  26870. readonly linearVelocity: Nullable<Float32Array>;
  26871. /**
  26872. * The linearAcceleration of the device, values in array are [x,y,z].
  26873. */
  26874. readonly linearAcceleration: Nullable<Float32Array>;
  26875. /**
  26876. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26877. */
  26878. readonly orientation: Nullable<Float32Array>;
  26879. /**
  26880. * The angularVelocity of the device, values in array are [x,y,z].
  26881. */
  26882. readonly angularVelocity: Nullable<Float32Array>;
  26883. /**
  26884. * The angularAcceleration of the device, values in array are [x,y,z].
  26885. */
  26886. readonly angularAcceleration: Nullable<Float32Array>;
  26887. }
  26888. /**
  26889. * Interface representing a pose controlled object in Babylon.
  26890. * A pose controlled object has both regular pose values as well as pose values
  26891. * from an external device such as a VR head mounted display
  26892. */
  26893. export interface PoseControlled {
  26894. /**
  26895. * The position of the object in babylon space.
  26896. */
  26897. position: Vector3;
  26898. /**
  26899. * The rotation quaternion of the object in babylon space.
  26900. */
  26901. rotationQuaternion: Quaternion;
  26902. /**
  26903. * The position of the device in babylon space.
  26904. */
  26905. devicePosition?: Vector3;
  26906. /**
  26907. * The rotation quaternion of the device in babylon space.
  26908. */
  26909. deviceRotationQuaternion: Quaternion;
  26910. /**
  26911. * The raw pose coming from the device.
  26912. */
  26913. rawPose: Nullable<DevicePose>;
  26914. /**
  26915. * The scale of the device to be used when translating from device space to babylon space.
  26916. */
  26917. deviceScaleFactor: number;
  26918. /**
  26919. * Updates the poseControlled values based on the input device pose.
  26920. * @param poseData the pose data to update the object with
  26921. */
  26922. updateFromDevice(poseData: DevicePose): void;
  26923. }
  26924. /**
  26925. * Set of options to customize the webVRCamera
  26926. */
  26927. export interface WebVROptions {
  26928. /**
  26929. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26930. */
  26931. trackPosition?: boolean;
  26932. /**
  26933. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26934. */
  26935. positionScale?: number;
  26936. /**
  26937. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26938. */
  26939. displayName?: string;
  26940. /**
  26941. * Should the native controller meshes be initialized. (default: true)
  26942. */
  26943. controllerMeshes?: boolean;
  26944. /**
  26945. * Creating a default HemiLight only on controllers. (default: true)
  26946. */
  26947. defaultLightingOnControllers?: boolean;
  26948. /**
  26949. * If you don't want to use the default VR button of the helper. (default: false)
  26950. */
  26951. useCustomVRButton?: boolean;
  26952. /**
  26953. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26954. */
  26955. customVRButton?: HTMLButtonElement;
  26956. /**
  26957. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26958. */
  26959. rayLength?: number;
  26960. /**
  26961. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26962. */
  26963. defaultHeight?: number;
  26964. /**
  26965. * If multiview should be used if availible (default: false)
  26966. */
  26967. useMultiview?: boolean;
  26968. }
  26969. /**
  26970. * This represents a WebVR camera.
  26971. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26972. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26973. */
  26974. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26975. private webVROptions;
  26976. /**
  26977. * @hidden
  26978. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26979. */
  26980. _vrDevice: any;
  26981. /**
  26982. * The rawPose of the vrDevice.
  26983. */
  26984. rawPose: Nullable<DevicePose>;
  26985. private _onVREnabled;
  26986. private _specsVersion;
  26987. private _attached;
  26988. private _frameData;
  26989. protected _descendants: Array<Node>;
  26990. private _deviceRoomPosition;
  26991. /** @hidden */
  26992. _deviceRoomRotationQuaternion: Quaternion;
  26993. private _standingMatrix;
  26994. /**
  26995. * Represents device position in babylon space.
  26996. */
  26997. devicePosition: Vector3;
  26998. /**
  26999. * Represents device rotation in babylon space.
  27000. */
  27001. deviceRotationQuaternion: Quaternion;
  27002. /**
  27003. * The scale of the device to be used when translating from device space to babylon space.
  27004. */
  27005. deviceScaleFactor: number;
  27006. private _deviceToWorld;
  27007. private _worldToDevice;
  27008. /**
  27009. * References to the webVR controllers for the vrDevice.
  27010. */
  27011. controllers: Array<WebVRController>;
  27012. /**
  27013. * Emits an event when a controller is attached.
  27014. */
  27015. onControllersAttachedObservable: Observable<WebVRController[]>;
  27016. /**
  27017. * Emits an event when a controller's mesh has been loaded;
  27018. */
  27019. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27020. /**
  27021. * Emits an event when the HMD's pose has been updated.
  27022. */
  27023. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27024. private _poseSet;
  27025. /**
  27026. * If the rig cameras be used as parent instead of this camera.
  27027. */
  27028. rigParenting: boolean;
  27029. private _lightOnControllers;
  27030. private _defaultHeight?;
  27031. /**
  27032. * Instantiates a WebVRFreeCamera.
  27033. * @param name The name of the WebVRFreeCamera
  27034. * @param position The starting anchor position for the camera
  27035. * @param scene The scene the camera belongs to
  27036. * @param webVROptions a set of customizable options for the webVRCamera
  27037. */
  27038. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27039. /**
  27040. * Gets the device distance from the ground in meters.
  27041. * @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.
  27042. */
  27043. deviceDistanceToRoomGround(): number;
  27044. /**
  27045. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27046. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27047. */
  27048. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27049. /**
  27050. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27051. * @returns A promise with a boolean set to if the standing matrix is supported.
  27052. */
  27053. useStandingMatrixAsync(): Promise<boolean>;
  27054. /**
  27055. * Disposes the camera
  27056. */
  27057. dispose(): void;
  27058. /**
  27059. * Gets a vrController by name.
  27060. * @param name The name of the controller to retreive
  27061. * @returns the controller matching the name specified or null if not found
  27062. */
  27063. getControllerByName(name: string): Nullable<WebVRController>;
  27064. private _leftController;
  27065. /**
  27066. * The controller corresponding to the users left hand.
  27067. */
  27068. get leftController(): Nullable<WebVRController>;
  27069. private _rightController;
  27070. /**
  27071. * The controller corresponding to the users right hand.
  27072. */
  27073. get rightController(): Nullable<WebVRController>;
  27074. /**
  27075. * Casts a ray forward from the vrCamera's gaze.
  27076. * @param length Length of the ray (default: 100)
  27077. * @returns the ray corresponding to the gaze
  27078. */
  27079. getForwardRay(length?: number): Ray;
  27080. /**
  27081. * @hidden
  27082. * Updates the camera based on device's frame data
  27083. */
  27084. _checkInputs(): void;
  27085. /**
  27086. * Updates the poseControlled values based on the input device pose.
  27087. * @param poseData Pose coming from the device
  27088. */
  27089. updateFromDevice(poseData: DevicePose): void;
  27090. private _detachIfAttached;
  27091. /**
  27092. * WebVR's attach control will start broadcasting frames to the device.
  27093. * Note that in certain browsers (chrome for example) this function must be called
  27094. * within a user-interaction callback. Example:
  27095. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27096. *
  27097. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27098. */
  27099. attachControl(noPreventDefault?: boolean): void;
  27100. /**
  27101. * Detach the current controls from the specified dom element.
  27102. */
  27103. detachControl(): void;
  27104. /**
  27105. * @returns the name of this class
  27106. */
  27107. getClassName(): string;
  27108. /**
  27109. * Calls resetPose on the vrDisplay
  27110. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27111. */
  27112. resetToCurrentRotation(): void;
  27113. /**
  27114. * @hidden
  27115. * Updates the rig cameras (left and right eye)
  27116. */
  27117. _updateRigCameras(): void;
  27118. private _workingVector;
  27119. private _oneVector;
  27120. private _workingMatrix;
  27121. private updateCacheCalled;
  27122. private _correctPositionIfNotTrackPosition;
  27123. /**
  27124. * @hidden
  27125. * Updates the cached values of the camera
  27126. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27127. */
  27128. _updateCache(ignoreParentClass?: boolean): void;
  27129. /**
  27130. * @hidden
  27131. * Get current device position in babylon world
  27132. */
  27133. _computeDevicePosition(): void;
  27134. /**
  27135. * Updates the current device position and rotation in the babylon world
  27136. */
  27137. update(): void;
  27138. /**
  27139. * @hidden
  27140. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27141. * @returns an identity matrix
  27142. */
  27143. _getViewMatrix(): Matrix;
  27144. private _tmpMatrix;
  27145. /**
  27146. * This function is called by the two RIG cameras.
  27147. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27148. * @hidden
  27149. */
  27150. _getWebVRViewMatrix(): Matrix;
  27151. /** @hidden */
  27152. _getWebVRProjectionMatrix(): Matrix;
  27153. private _onGamepadConnectedObserver;
  27154. private _onGamepadDisconnectedObserver;
  27155. private _updateCacheWhenTrackingDisabledObserver;
  27156. /**
  27157. * Initializes the controllers and their meshes
  27158. */
  27159. initControllers(): void;
  27160. }
  27161. }
  27162. declare module BABYLON {
  27163. /**
  27164. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27165. *
  27166. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27167. *
  27168. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27169. */
  27170. export class MaterialHelper {
  27171. /**
  27172. * Bind the current view position to an effect.
  27173. * @param effect The effect to be bound
  27174. * @param scene The scene the eyes position is used from
  27175. * @param variableName name of the shader variable that will hold the eye position
  27176. */
  27177. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27178. /**
  27179. * Helps preparing the defines values about the UVs in used in the effect.
  27180. * UVs are shared as much as we can accross channels in the shaders.
  27181. * @param texture The texture we are preparing the UVs for
  27182. * @param defines The defines to update
  27183. * @param key The channel key "diffuse", "specular"... used in the shader
  27184. */
  27185. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27186. /**
  27187. * Binds a texture matrix value to its corrsponding uniform
  27188. * @param texture The texture to bind the matrix for
  27189. * @param uniformBuffer The uniform buffer receivin the data
  27190. * @param key The channel key "diffuse", "specular"... used in the shader
  27191. */
  27192. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27193. /**
  27194. * Gets the current status of the fog (should it be enabled?)
  27195. * @param mesh defines the mesh to evaluate for fog support
  27196. * @param scene defines the hosting scene
  27197. * @returns true if fog must be enabled
  27198. */
  27199. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27200. /**
  27201. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27202. * @param mesh defines the current mesh
  27203. * @param scene defines the current scene
  27204. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27205. * @param pointsCloud defines if point cloud rendering has to be turned on
  27206. * @param fogEnabled defines if fog has to be turned on
  27207. * @param alphaTest defines if alpha testing has to be turned on
  27208. * @param defines defines the current list of defines
  27209. */
  27210. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27211. /**
  27212. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27213. * @param scene defines the current scene
  27214. * @param engine defines the current engine
  27215. * @param defines specifies the list of active defines
  27216. * @param useInstances defines if instances have to be turned on
  27217. * @param useClipPlane defines if clip plane have to be turned on
  27218. * @param useInstances defines if instances have to be turned on
  27219. * @param useThinInstances defines if thin instances have to be turned on
  27220. */
  27221. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27222. /**
  27223. * Prepares the defines for bones
  27224. * @param mesh The mesh containing the geometry data we will draw
  27225. * @param defines The defines to update
  27226. */
  27227. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27228. /**
  27229. * Prepares the defines for morph targets
  27230. * @param mesh The mesh containing the geometry data we will draw
  27231. * @param defines The defines to update
  27232. */
  27233. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27234. /**
  27235. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27236. * @param mesh The mesh containing the geometry data we will draw
  27237. * @param defines The defines to update
  27238. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27239. * @param useBones Precise whether bones should be used or not (override mesh info)
  27240. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27241. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27242. * @returns false if defines are considered not dirty and have not been checked
  27243. */
  27244. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27245. /**
  27246. * Prepares the defines related to multiview
  27247. * @param scene The scene we are intending to draw
  27248. * @param defines The defines to update
  27249. */
  27250. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27251. /**
  27252. * Prepares the defines related to the prepass
  27253. * @param scene The scene we are intending to draw
  27254. * @param defines The defines to update
  27255. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27256. */
  27257. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27258. /**
  27259. * Prepares the defines related to the light information passed in parameter
  27260. * @param scene The scene we are intending to draw
  27261. * @param mesh The mesh the effect is compiling for
  27262. * @param light The light the effect is compiling for
  27263. * @param lightIndex The index of the light
  27264. * @param defines The defines to update
  27265. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27266. * @param state Defines the current state regarding what is needed (normals, etc...)
  27267. */
  27268. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27269. needNormals: boolean;
  27270. needRebuild: boolean;
  27271. shadowEnabled: boolean;
  27272. specularEnabled: boolean;
  27273. lightmapMode: boolean;
  27274. }): void;
  27275. /**
  27276. * Prepares the defines related to the light information passed in parameter
  27277. * @param scene The scene we are intending to draw
  27278. * @param mesh The mesh the effect is compiling for
  27279. * @param defines The defines to update
  27280. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27281. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27282. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27283. * @returns true if normals will be required for the rest of the effect
  27284. */
  27285. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27286. /**
  27287. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27288. * @param lightIndex defines the light index
  27289. * @param uniformsList The uniform list
  27290. * @param samplersList The sampler list
  27291. * @param projectedLightTexture defines if projected texture must be used
  27292. * @param uniformBuffersList defines an optional list of uniform buffers
  27293. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27294. */
  27295. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27296. /**
  27297. * Prepares the uniforms and samplers list to be used in the effect
  27298. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27299. * @param samplersList The sampler list
  27300. * @param defines The defines helping in the list generation
  27301. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27302. */
  27303. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27304. /**
  27305. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27306. * @param defines The defines to update while falling back
  27307. * @param fallbacks The authorized effect fallbacks
  27308. * @param maxSimultaneousLights The maximum number of lights allowed
  27309. * @param rank the current rank of the Effect
  27310. * @returns The newly affected rank
  27311. */
  27312. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27313. private static _TmpMorphInfluencers;
  27314. /**
  27315. * Prepares the list of attributes required for morph targets according to the effect defines.
  27316. * @param attribs The current list of supported attribs
  27317. * @param mesh The mesh to prepare the morph targets attributes for
  27318. * @param influencers The number of influencers
  27319. */
  27320. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27321. /**
  27322. * Prepares the list of attributes required for morph targets according to the effect defines.
  27323. * @param attribs The current list of supported attribs
  27324. * @param mesh The mesh to prepare the morph targets attributes for
  27325. * @param defines The current Defines of the effect
  27326. */
  27327. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27328. /**
  27329. * Prepares the list of attributes required for bones according to the effect defines.
  27330. * @param attribs The current list of supported attribs
  27331. * @param mesh The mesh to prepare the bones attributes for
  27332. * @param defines The current Defines of the effect
  27333. * @param fallbacks The current efffect fallback strategy
  27334. */
  27335. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27336. /**
  27337. * Check and prepare the list of attributes required for instances according to the effect defines.
  27338. * @param attribs The current list of supported attribs
  27339. * @param defines The current MaterialDefines of the effect
  27340. */
  27341. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27342. /**
  27343. * Add the list of attributes required for instances to the attribs array.
  27344. * @param attribs The current list of supported attribs
  27345. */
  27346. static PushAttributesForInstances(attribs: string[]): void;
  27347. /**
  27348. * Binds the light information to the effect.
  27349. * @param light The light containing the generator
  27350. * @param effect The effect we are binding the data to
  27351. * @param lightIndex The light index in the effect used to render
  27352. */
  27353. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27354. /**
  27355. * Binds the lights information from the scene to the effect for the given mesh.
  27356. * @param light Light to bind
  27357. * @param lightIndex Light index
  27358. * @param scene The scene where the light belongs to
  27359. * @param effect The effect we are binding the data to
  27360. * @param useSpecular Defines if specular is supported
  27361. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27362. */
  27363. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27364. /**
  27365. * Binds the lights information from the scene to the effect for the given mesh.
  27366. * @param scene The scene the lights belongs to
  27367. * @param mesh The mesh we are binding the information to render
  27368. * @param effect The effect we are binding the data to
  27369. * @param defines The generated defines for the effect
  27370. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27371. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27372. */
  27373. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27374. private static _tempFogColor;
  27375. /**
  27376. * Binds the fog information from the scene to the effect for the given mesh.
  27377. * @param scene The scene the lights belongs to
  27378. * @param mesh The mesh we are binding the information to render
  27379. * @param effect The effect we are binding the data to
  27380. * @param linearSpace Defines if the fog effect is applied in linear space
  27381. */
  27382. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27383. /**
  27384. * Binds the bones information from the mesh to the effect.
  27385. * @param mesh The mesh we are binding the information to render
  27386. * @param effect The effect we are binding the data to
  27387. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27388. */
  27389. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27390. private static _CopyBonesTransformationMatrices;
  27391. /**
  27392. * Binds the morph targets information from the mesh to the effect.
  27393. * @param abstractMesh The mesh we are binding the information to render
  27394. * @param effect The effect we are binding the data to
  27395. */
  27396. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27397. /**
  27398. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27399. * @param defines The generated defines used in the effect
  27400. * @param effect The effect we are binding the data to
  27401. * @param scene The scene we are willing to render with logarithmic scale for
  27402. */
  27403. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27404. /**
  27405. * Binds the clip plane information from the scene to the effect.
  27406. * @param scene The scene the clip plane information are extracted from
  27407. * @param effect The effect we are binding the data to
  27408. */
  27409. static BindClipPlane(effect: Effect, scene: Scene): void;
  27410. }
  27411. }
  27412. declare module BABYLON {
  27413. /** @hidden */
  27414. export var bayerDitherFunctions: {
  27415. name: string;
  27416. shader: string;
  27417. };
  27418. }
  27419. declare module BABYLON {
  27420. /** @hidden */
  27421. export var shadowMapFragmentDeclaration: {
  27422. name: string;
  27423. shader: string;
  27424. };
  27425. }
  27426. declare module BABYLON {
  27427. /** @hidden */
  27428. export var shadowMapFragment: {
  27429. name: string;
  27430. shader: string;
  27431. };
  27432. }
  27433. declare module BABYLON {
  27434. /** @hidden */
  27435. export var shadowMapPixelShader: {
  27436. name: string;
  27437. shader: string;
  27438. };
  27439. }
  27440. declare module BABYLON {
  27441. /** @hidden */
  27442. export var shadowMapVertexDeclaration: {
  27443. name: string;
  27444. shader: string;
  27445. };
  27446. }
  27447. declare module BABYLON {
  27448. /** @hidden */
  27449. export var shadowMapVertexNormalBias: {
  27450. name: string;
  27451. shader: string;
  27452. };
  27453. }
  27454. declare module BABYLON {
  27455. /** @hidden */
  27456. export var shadowMapVertexMetric: {
  27457. name: string;
  27458. shader: string;
  27459. };
  27460. }
  27461. declare module BABYLON {
  27462. /** @hidden */
  27463. export var shadowMapVertexShader: {
  27464. name: string;
  27465. shader: string;
  27466. };
  27467. }
  27468. declare module BABYLON {
  27469. /** @hidden */
  27470. export var depthBoxBlurPixelShader: {
  27471. name: string;
  27472. shader: string;
  27473. };
  27474. }
  27475. declare module BABYLON {
  27476. /** @hidden */
  27477. export var shadowMapFragmentSoftTransparentShadow: {
  27478. name: string;
  27479. shader: string;
  27480. };
  27481. }
  27482. declare module BABYLON {
  27483. /**
  27484. * Creates an instance based on a source mesh.
  27485. */
  27486. export class InstancedMesh extends AbstractMesh {
  27487. private _sourceMesh;
  27488. private _currentLOD;
  27489. /** @hidden */
  27490. _indexInSourceMeshInstanceArray: number;
  27491. constructor(name: string, source: Mesh);
  27492. /**
  27493. * Returns the string "InstancedMesh".
  27494. */
  27495. getClassName(): string;
  27496. /** Gets the list of lights affecting that mesh */
  27497. get lightSources(): Light[];
  27498. _resyncLightSources(): void;
  27499. _resyncLightSource(light: Light): void;
  27500. _removeLightSource(light: Light, dispose: boolean): void;
  27501. /**
  27502. * If the source mesh receives shadows
  27503. */
  27504. get receiveShadows(): boolean;
  27505. /**
  27506. * The material of the source mesh
  27507. */
  27508. get material(): Nullable<Material>;
  27509. /**
  27510. * Visibility of the source mesh
  27511. */
  27512. get visibility(): number;
  27513. /**
  27514. * Skeleton of the source mesh
  27515. */
  27516. get skeleton(): Nullable<Skeleton>;
  27517. /**
  27518. * Rendering ground id of the source mesh
  27519. */
  27520. get renderingGroupId(): number;
  27521. set renderingGroupId(value: number);
  27522. /**
  27523. * Returns the total number of vertices (integer).
  27524. */
  27525. getTotalVertices(): number;
  27526. /**
  27527. * Returns a positive integer : the total number of indices in this mesh geometry.
  27528. * @returns the numner of indices or zero if the mesh has no geometry.
  27529. */
  27530. getTotalIndices(): number;
  27531. /**
  27532. * The source mesh of the instance
  27533. */
  27534. get sourceMesh(): Mesh;
  27535. /**
  27536. * Creates a new InstancedMesh object from the mesh model.
  27537. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27538. * @param name defines the name of the new instance
  27539. * @returns a new InstancedMesh
  27540. */
  27541. createInstance(name: string): InstancedMesh;
  27542. /**
  27543. * Is this node ready to be used/rendered
  27544. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27545. * @return {boolean} is it ready
  27546. */
  27547. isReady(completeCheck?: boolean): boolean;
  27548. /**
  27549. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27550. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27551. * @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.
  27552. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27553. */
  27554. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27555. /**
  27556. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27557. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27558. * The `data` are either a numeric array either a Float32Array.
  27559. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27560. * 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).
  27561. * Note that a new underlying VertexBuffer object is created each call.
  27562. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27563. *
  27564. * Possible `kind` values :
  27565. * - VertexBuffer.PositionKind
  27566. * - VertexBuffer.UVKind
  27567. * - VertexBuffer.UV2Kind
  27568. * - VertexBuffer.UV3Kind
  27569. * - VertexBuffer.UV4Kind
  27570. * - VertexBuffer.UV5Kind
  27571. * - VertexBuffer.UV6Kind
  27572. * - VertexBuffer.ColorKind
  27573. * - VertexBuffer.MatricesIndicesKind
  27574. * - VertexBuffer.MatricesIndicesExtraKind
  27575. * - VertexBuffer.MatricesWeightsKind
  27576. * - VertexBuffer.MatricesWeightsExtraKind
  27577. *
  27578. * Returns the Mesh.
  27579. */
  27580. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27581. /**
  27582. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27583. * If the mesh has no geometry, it is simply returned as it is.
  27584. * The `data` are either a numeric array either a Float32Array.
  27585. * No new underlying VertexBuffer object is created.
  27586. * 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.
  27587. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27588. *
  27589. * Possible `kind` values :
  27590. * - VertexBuffer.PositionKind
  27591. * - VertexBuffer.UVKind
  27592. * - VertexBuffer.UV2Kind
  27593. * - VertexBuffer.UV3Kind
  27594. * - VertexBuffer.UV4Kind
  27595. * - VertexBuffer.UV5Kind
  27596. * - VertexBuffer.UV6Kind
  27597. * - VertexBuffer.ColorKind
  27598. * - VertexBuffer.MatricesIndicesKind
  27599. * - VertexBuffer.MatricesIndicesExtraKind
  27600. * - VertexBuffer.MatricesWeightsKind
  27601. * - VertexBuffer.MatricesWeightsExtraKind
  27602. *
  27603. * Returns the Mesh.
  27604. */
  27605. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27606. /**
  27607. * Sets the mesh indices.
  27608. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27609. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27610. * This method creates a new index buffer each call.
  27611. * Returns the Mesh.
  27612. */
  27613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27614. /**
  27615. * Boolean : True if the mesh owns the requested kind of data.
  27616. */
  27617. isVerticesDataPresent(kind: string): boolean;
  27618. /**
  27619. * Returns an array of indices (IndicesArray).
  27620. */
  27621. getIndices(): Nullable<IndicesArray>;
  27622. get _positions(): Nullable<Vector3[]>;
  27623. /**
  27624. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27625. * This means the mesh underlying bounding box and sphere are recomputed.
  27626. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27627. * @returns the current mesh
  27628. */
  27629. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27630. /** @hidden */
  27631. _preActivate(): InstancedMesh;
  27632. /** @hidden */
  27633. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27634. /** @hidden */
  27635. _postActivate(): void;
  27636. getWorldMatrix(): Matrix;
  27637. get isAnInstance(): boolean;
  27638. /**
  27639. * Returns the current associated LOD AbstractMesh.
  27640. */
  27641. getLOD(camera: Camera): AbstractMesh;
  27642. /** @hidden */
  27643. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27644. /** @hidden */
  27645. _syncSubMeshes(): InstancedMesh;
  27646. /** @hidden */
  27647. _generatePointsArray(): boolean;
  27648. /** @hidden */
  27649. _updateBoundingInfo(): AbstractMesh;
  27650. /**
  27651. * Creates a new InstancedMesh from the current mesh.
  27652. * - name (string) : the cloned mesh name
  27653. * - newParent (optional Node) : the optional Node to parent the clone to.
  27654. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27655. *
  27656. * Returns the clone.
  27657. */
  27658. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27659. /**
  27660. * Disposes the InstancedMesh.
  27661. * Returns nothing.
  27662. */
  27663. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27664. }
  27665. interface Mesh {
  27666. /**
  27667. * Register a custom buffer that will be instanced
  27668. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27669. * @param kind defines the buffer kind
  27670. * @param stride defines the stride in floats
  27671. */
  27672. registerInstancedBuffer(kind: string, stride: number): void;
  27673. /**
  27674. * true to use the edge renderer for all instances of this mesh
  27675. */
  27676. edgesShareWithInstances: boolean;
  27677. /** @hidden */
  27678. _userInstancedBuffersStorage: {
  27679. data: {
  27680. [key: string]: Float32Array;
  27681. };
  27682. sizes: {
  27683. [key: string]: number;
  27684. };
  27685. vertexBuffers: {
  27686. [key: string]: Nullable<VertexBuffer>;
  27687. };
  27688. strides: {
  27689. [key: string]: number;
  27690. };
  27691. };
  27692. }
  27693. interface AbstractMesh {
  27694. /**
  27695. * Object used to store instanced buffers defined by user
  27696. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27697. */
  27698. instancedBuffers: {
  27699. [key: string]: any;
  27700. };
  27701. }
  27702. }
  27703. declare module BABYLON {
  27704. /**
  27705. * Defines the options associated with the creation of a shader material.
  27706. */
  27707. export interface IShaderMaterialOptions {
  27708. /**
  27709. * Does the material work in alpha blend mode
  27710. */
  27711. needAlphaBlending: boolean;
  27712. /**
  27713. * Does the material work in alpha test mode
  27714. */
  27715. needAlphaTesting: boolean;
  27716. /**
  27717. * The list of attribute names used in the shader
  27718. */
  27719. attributes: string[];
  27720. /**
  27721. * The list of unifrom names used in the shader
  27722. */
  27723. uniforms: string[];
  27724. /**
  27725. * The list of UBO names used in the shader
  27726. */
  27727. uniformBuffers: string[];
  27728. /**
  27729. * The list of sampler names used in the shader
  27730. */
  27731. samplers: string[];
  27732. /**
  27733. * The list of defines used in the shader
  27734. */
  27735. defines: string[];
  27736. }
  27737. /**
  27738. * 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.
  27739. *
  27740. * This returned material effects how the mesh will look based on the code in the shaders.
  27741. *
  27742. * @see https://doc.babylonjs.com/how_to/shader_material
  27743. */
  27744. export class ShaderMaterial extends Material {
  27745. private _shaderPath;
  27746. private _options;
  27747. private _textures;
  27748. private _textureArrays;
  27749. private _floats;
  27750. private _ints;
  27751. private _floatsArrays;
  27752. private _colors3;
  27753. private _colors3Arrays;
  27754. private _colors4;
  27755. private _colors4Arrays;
  27756. private _vectors2;
  27757. private _vectors3;
  27758. private _vectors4;
  27759. private _matrices;
  27760. private _matrixArrays;
  27761. private _matrices3x3;
  27762. private _matrices2x2;
  27763. private _vectors2Arrays;
  27764. private _vectors3Arrays;
  27765. private _vectors4Arrays;
  27766. private _cachedWorldViewMatrix;
  27767. private _cachedWorldViewProjectionMatrix;
  27768. private _renderId;
  27769. private _multiview;
  27770. private _cachedDefines;
  27771. /** Define the Url to load snippets */
  27772. static SnippetUrl: string;
  27773. /** Snippet ID if the material was created from the snippet server */
  27774. snippetId: string;
  27775. /**
  27776. * Instantiate a new shader material.
  27777. * 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.
  27778. * This returned material effects how the mesh will look based on the code in the shaders.
  27779. * @see https://doc.babylonjs.com/how_to/shader_material
  27780. * @param name Define the name of the material in the scene
  27781. * @param scene Define the scene the material belongs to
  27782. * @param shaderPath Defines the route to the shader code in one of three ways:
  27783. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27784. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27785. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27786. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27787. * @param options Define the options used to create the shader
  27788. */
  27789. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27790. /**
  27791. * Gets the shader path used to define the shader code
  27792. * It can be modified to trigger a new compilation
  27793. */
  27794. get shaderPath(): any;
  27795. /**
  27796. * Sets the shader path used to define the shader code
  27797. * It can be modified to trigger a new compilation
  27798. */
  27799. set shaderPath(shaderPath: any);
  27800. /**
  27801. * Gets the options used to compile the shader.
  27802. * They can be modified to trigger a new compilation
  27803. */
  27804. get options(): IShaderMaterialOptions;
  27805. /**
  27806. * Gets the current class name of the material e.g. "ShaderMaterial"
  27807. * Mainly use in serialization.
  27808. * @returns the class name
  27809. */
  27810. getClassName(): string;
  27811. /**
  27812. * Specifies if the material will require alpha blending
  27813. * @returns a boolean specifying if alpha blending is needed
  27814. */
  27815. needAlphaBlending(): boolean;
  27816. /**
  27817. * Specifies if this material should be rendered in alpha test mode
  27818. * @returns a boolean specifying if an alpha test is needed.
  27819. */
  27820. needAlphaTesting(): boolean;
  27821. private _checkUniform;
  27822. /**
  27823. * Set a texture in the shader.
  27824. * @param name Define the name of the uniform samplers as defined in the shader
  27825. * @param texture Define the texture to bind to this sampler
  27826. * @return the material itself allowing "fluent" like uniform updates
  27827. */
  27828. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27829. /**
  27830. * Set a texture array in the shader.
  27831. * @param name Define the name of the uniform sampler array as defined in the shader
  27832. * @param textures Define the list of textures to bind to this sampler
  27833. * @return the material itself allowing "fluent" like uniform updates
  27834. */
  27835. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27836. /**
  27837. * Set a float in the shader.
  27838. * @param name Define the name of the uniform as defined in the shader
  27839. * @param value Define the value to give to the uniform
  27840. * @return the material itself allowing "fluent" like uniform updates
  27841. */
  27842. setFloat(name: string, value: number): ShaderMaterial;
  27843. /**
  27844. * Set a int in the shader.
  27845. * @param name Define the name of the uniform as defined in the shader
  27846. * @param value Define the value to give to the uniform
  27847. * @return the material itself allowing "fluent" like uniform updates
  27848. */
  27849. setInt(name: string, value: number): ShaderMaterial;
  27850. /**
  27851. * Set an array of floats in the shader.
  27852. * @param name Define the name of the uniform as defined in the shader
  27853. * @param value Define the value to give to the uniform
  27854. * @return the material itself allowing "fluent" like uniform updates
  27855. */
  27856. setFloats(name: string, value: number[]): ShaderMaterial;
  27857. /**
  27858. * Set a vec3 in the shader from a Color3.
  27859. * @param name Define the name of the uniform as defined in the shader
  27860. * @param value Define the value to give to the uniform
  27861. * @return the material itself allowing "fluent" like uniform updates
  27862. */
  27863. setColor3(name: string, value: Color3): ShaderMaterial;
  27864. /**
  27865. * Set a vec3 array in the shader from a Color3 array.
  27866. * @param name Define the name of the uniform as defined in the shader
  27867. * @param value Define the value to give to the uniform
  27868. * @return the material itself allowing "fluent" like uniform updates
  27869. */
  27870. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27871. /**
  27872. * Set a vec4 in the shader from a Color4.
  27873. * @param name Define the name of the uniform as defined in the shader
  27874. * @param value Define the value to give to the uniform
  27875. * @return the material itself allowing "fluent" like uniform updates
  27876. */
  27877. setColor4(name: string, value: Color4): ShaderMaterial;
  27878. /**
  27879. * Set a vec4 array in the shader from a Color4 array.
  27880. * @param name Define the name of the uniform as defined in the shader
  27881. * @param value Define the value to give to the uniform
  27882. * @return the material itself allowing "fluent" like uniform updates
  27883. */
  27884. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27885. /**
  27886. * Set a vec2 in the shader from a Vector2.
  27887. * @param name Define the name of the uniform as defined in the shader
  27888. * @param value Define the value to give to the uniform
  27889. * @return the material itself allowing "fluent" like uniform updates
  27890. */
  27891. setVector2(name: string, value: Vector2): ShaderMaterial;
  27892. /**
  27893. * Set a vec3 in the shader from a Vector3.
  27894. * @param name Define the name of the uniform as defined in the shader
  27895. * @param value Define the value to give to the uniform
  27896. * @return the material itself allowing "fluent" like uniform updates
  27897. */
  27898. setVector3(name: string, value: Vector3): ShaderMaterial;
  27899. /**
  27900. * Set a vec4 in the shader from a Vector4.
  27901. * @param name Define the name of the uniform as defined in the shader
  27902. * @param value Define the value to give to the uniform
  27903. * @return the material itself allowing "fluent" like uniform updates
  27904. */
  27905. setVector4(name: string, value: Vector4): ShaderMaterial;
  27906. /**
  27907. * Set a mat4 in the shader from a Matrix.
  27908. * @param name Define the name of the uniform as defined in the shader
  27909. * @param value Define the value to give to the uniform
  27910. * @return the material itself allowing "fluent" like uniform updates
  27911. */
  27912. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27913. /**
  27914. * Set a float32Array in the shader from a matrix array.
  27915. * @param name Define the name of the uniform as defined in the shader
  27916. * @param value Define the value to give to the uniform
  27917. * @return the material itself allowing "fluent" like uniform updates
  27918. */
  27919. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27920. /**
  27921. * Set a mat3 in the shader from a Float32Array.
  27922. * @param name Define the name of the uniform as defined in the shader
  27923. * @param value Define the value to give to the uniform
  27924. * @return the material itself allowing "fluent" like uniform updates
  27925. */
  27926. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27927. /**
  27928. * Set a mat2 in the shader from a Float32Array.
  27929. * @param name Define the name of the uniform as defined in the shader
  27930. * @param value Define the value to give to the uniform
  27931. * @return the material itself allowing "fluent" like uniform updates
  27932. */
  27933. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27934. /**
  27935. * Set a vec2 array in the shader from a number array.
  27936. * @param name Define the name of the uniform as defined in the shader
  27937. * @param value Define the value to give to the uniform
  27938. * @return the material itself allowing "fluent" like uniform updates
  27939. */
  27940. setArray2(name: string, value: number[]): ShaderMaterial;
  27941. /**
  27942. * Set a vec3 array in the shader from a number array.
  27943. * @param name Define the name of the uniform as defined in the shader
  27944. * @param value Define the value to give to the uniform
  27945. * @return the material itself allowing "fluent" like uniform updates
  27946. */
  27947. setArray3(name: string, value: number[]): ShaderMaterial;
  27948. /**
  27949. * Set a vec4 array in the shader from a number array.
  27950. * @param name Define the name of the uniform as defined in the shader
  27951. * @param value Define the value to give to the uniform
  27952. * @return the material itself allowing "fluent" like uniform updates
  27953. */
  27954. setArray4(name: string, value: number[]): ShaderMaterial;
  27955. private _checkCache;
  27956. /**
  27957. * Specifies that the submesh is ready to be used
  27958. * @param mesh defines the mesh to check
  27959. * @param subMesh defines which submesh to check
  27960. * @param useInstances specifies that instances should be used
  27961. * @returns a boolean indicating that the submesh is ready or not
  27962. */
  27963. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27964. /**
  27965. * Checks if the material is ready to render the requested mesh
  27966. * @param mesh Define the mesh to render
  27967. * @param useInstances Define whether or not the material is used with instances
  27968. * @returns true if ready, otherwise false
  27969. */
  27970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27971. /**
  27972. * Binds the world matrix to the material
  27973. * @param world defines the world transformation matrix
  27974. * @param effectOverride - If provided, use this effect instead of internal effect
  27975. */
  27976. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27977. /**
  27978. * Binds the submesh to this material by preparing the effect and shader to draw
  27979. * @param world defines the world transformation matrix
  27980. * @param mesh defines the mesh containing the submesh
  27981. * @param subMesh defines the submesh to bind the material to
  27982. */
  27983. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27984. /**
  27985. * Binds the material to the mesh
  27986. * @param world defines the world transformation matrix
  27987. * @param mesh defines the mesh to bind the material to
  27988. * @param effectOverride - If provided, use this effect instead of internal effect
  27989. */
  27990. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27991. protected _afterBind(mesh?: Mesh): void;
  27992. /**
  27993. * Gets the active textures from the material
  27994. * @returns an array of textures
  27995. */
  27996. getActiveTextures(): BaseTexture[];
  27997. /**
  27998. * Specifies if the material uses a texture
  27999. * @param texture defines the texture to check against the material
  28000. * @returns a boolean specifying if the material uses the texture
  28001. */
  28002. hasTexture(texture: BaseTexture): boolean;
  28003. /**
  28004. * Makes a duplicate of the material, and gives it a new name
  28005. * @param name defines the new name for the duplicated material
  28006. * @returns the cloned material
  28007. */
  28008. clone(name: string): ShaderMaterial;
  28009. /**
  28010. * Disposes the material
  28011. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28012. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28013. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28014. */
  28015. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28016. /**
  28017. * Serializes this material in a JSON representation
  28018. * @returns the serialized material object
  28019. */
  28020. serialize(): any;
  28021. /**
  28022. * Creates a shader material from parsed shader material data
  28023. * @param source defines the JSON represnetation of the material
  28024. * @param scene defines the hosting scene
  28025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28026. * @returns a new material
  28027. */
  28028. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28029. /**
  28030. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28031. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28032. * @param url defines the url to load from
  28033. * @param scene defines the hosting scene
  28034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28035. * @returns a promise that will resolve to the new ShaderMaterial
  28036. */
  28037. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28038. /**
  28039. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28040. * @param snippetId defines the snippet to load
  28041. * @param scene defines the hosting scene
  28042. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28043. * @returns a promise that will resolve to the new ShaderMaterial
  28044. */
  28045. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28046. }
  28047. }
  28048. declare module BABYLON {
  28049. /** @hidden */
  28050. export var colorPixelShader: {
  28051. name: string;
  28052. shader: string;
  28053. };
  28054. }
  28055. declare module BABYLON {
  28056. /** @hidden */
  28057. export var colorVertexShader: {
  28058. name: string;
  28059. shader: string;
  28060. };
  28061. }
  28062. declare module BABYLON {
  28063. /**
  28064. * Line mesh
  28065. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28066. */
  28067. export class LinesMesh extends Mesh {
  28068. /**
  28069. * If vertex color should be applied to the mesh
  28070. */
  28071. readonly useVertexColor?: boolean | undefined;
  28072. /**
  28073. * If vertex alpha should be applied to the mesh
  28074. */
  28075. readonly useVertexAlpha?: boolean | undefined;
  28076. /**
  28077. * Color of the line (Default: White)
  28078. */
  28079. color: Color3;
  28080. /**
  28081. * Alpha of the line (Default: 1)
  28082. */
  28083. alpha: number;
  28084. /**
  28085. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28086. * This margin is expressed in world space coordinates, so its value may vary.
  28087. * Default value is 0.1
  28088. */
  28089. intersectionThreshold: number;
  28090. private _colorShader;
  28091. private color4;
  28092. /**
  28093. * Creates a new LinesMesh
  28094. * @param name defines the name
  28095. * @param scene defines the hosting scene
  28096. * @param parent defines the parent mesh if any
  28097. * @param source defines the optional source LinesMesh used to clone data from
  28098. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28099. * When false, achieved by calling a clone(), also passing False.
  28100. * This will make creation of children, recursive.
  28101. * @param useVertexColor defines if this LinesMesh supports vertex color
  28102. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28103. */
  28104. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28105. /**
  28106. * If vertex color should be applied to the mesh
  28107. */
  28108. useVertexColor?: boolean | undefined,
  28109. /**
  28110. * If vertex alpha should be applied to the mesh
  28111. */
  28112. useVertexAlpha?: boolean | undefined);
  28113. private _addClipPlaneDefine;
  28114. private _removeClipPlaneDefine;
  28115. isReady(): boolean;
  28116. /**
  28117. * Returns the string "LineMesh"
  28118. */
  28119. getClassName(): string;
  28120. /**
  28121. * @hidden
  28122. */
  28123. get material(): Material;
  28124. /**
  28125. * @hidden
  28126. */
  28127. set material(value: Material);
  28128. /**
  28129. * @hidden
  28130. */
  28131. get checkCollisions(): boolean;
  28132. /** @hidden */
  28133. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28134. /** @hidden */
  28135. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28136. /**
  28137. * Disposes of the line mesh
  28138. * @param doNotRecurse If children should be disposed
  28139. */
  28140. dispose(doNotRecurse?: boolean): void;
  28141. /**
  28142. * Returns a new LineMesh object cloned from the current one.
  28143. */
  28144. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28145. /**
  28146. * Creates a new InstancedLinesMesh object from the mesh model.
  28147. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28148. * @param name defines the name of the new instance
  28149. * @returns a new InstancedLinesMesh
  28150. */
  28151. createInstance(name: string): InstancedLinesMesh;
  28152. }
  28153. /**
  28154. * Creates an instance based on a source LinesMesh
  28155. */
  28156. export class InstancedLinesMesh extends InstancedMesh {
  28157. /**
  28158. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28159. * This margin is expressed in world space coordinates, so its value may vary.
  28160. * Initilized with the intersectionThreshold value of the source LinesMesh
  28161. */
  28162. intersectionThreshold: number;
  28163. constructor(name: string, source: LinesMesh);
  28164. /**
  28165. * Returns the string "InstancedLinesMesh".
  28166. */
  28167. getClassName(): string;
  28168. }
  28169. }
  28170. declare module BABYLON {
  28171. /** @hidden */
  28172. export var linePixelShader: {
  28173. name: string;
  28174. shader: string;
  28175. };
  28176. }
  28177. declare module BABYLON {
  28178. /** @hidden */
  28179. export var lineVertexShader: {
  28180. name: string;
  28181. shader: string;
  28182. };
  28183. }
  28184. declare module BABYLON {
  28185. interface Scene {
  28186. /** @hidden */
  28187. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28188. }
  28189. interface AbstractMesh {
  28190. /**
  28191. * Gets the edgesRenderer associated with the mesh
  28192. */
  28193. edgesRenderer: Nullable<EdgesRenderer>;
  28194. }
  28195. interface LinesMesh {
  28196. /**
  28197. * Enables the edge rendering mode on the mesh.
  28198. * This mode makes the mesh edges visible
  28199. * @param epsilon defines the maximal distance between two angles to detect a face
  28200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28201. * @returns the currentAbstractMesh
  28202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28203. */
  28204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28205. }
  28206. interface InstancedLinesMesh {
  28207. /**
  28208. * Enables the edge rendering mode on the mesh.
  28209. * This mode makes the mesh edges visible
  28210. * @param epsilon defines the maximal distance between two angles to detect a face
  28211. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28212. * @returns the current InstancedLinesMesh
  28213. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28214. */
  28215. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28216. }
  28217. /**
  28218. * Defines the minimum contract an Edges renderer should follow.
  28219. */
  28220. export interface IEdgesRenderer extends IDisposable {
  28221. /**
  28222. * Gets or sets a boolean indicating if the edgesRenderer is active
  28223. */
  28224. isEnabled: boolean;
  28225. /**
  28226. * Renders the edges of the attached mesh,
  28227. */
  28228. render(): void;
  28229. /**
  28230. * Checks wether or not the edges renderer is ready to render.
  28231. * @return true if ready, otherwise false.
  28232. */
  28233. isReady(): boolean;
  28234. /**
  28235. * List of instances to render in case the source mesh has instances
  28236. */
  28237. customInstances: SmartArray<Matrix>;
  28238. }
  28239. /**
  28240. * Defines the additional options of the edges renderer
  28241. */
  28242. export interface IEdgesRendererOptions {
  28243. /**
  28244. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28245. * If not defined, the default value is true
  28246. */
  28247. useAlternateEdgeFinder?: boolean;
  28248. /**
  28249. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28250. * If not defined, the default value is true.
  28251. * 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)
  28252. * This option is used only if useAlternateEdgeFinder = true
  28253. */
  28254. useFastVertexMerger?: boolean;
  28255. /**
  28256. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28257. * The default value is 1e-6
  28258. * This option is used only if useAlternateEdgeFinder = true
  28259. */
  28260. epsilonVertexMerge?: number;
  28261. /**
  28262. * 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
  28263. * 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.
  28264. * This option is used only if useAlternateEdgeFinder = true
  28265. */
  28266. applyTessellation?: boolean;
  28267. /**
  28268. * 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
  28269. * The default value is 1e-6
  28270. * This option is used only if useAlternateEdgeFinder = true
  28271. */
  28272. epsilonVertexAligned?: number;
  28273. }
  28274. /**
  28275. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28276. */
  28277. export class EdgesRenderer implements IEdgesRenderer {
  28278. /**
  28279. * Define the size of the edges with an orthographic camera
  28280. */
  28281. edgesWidthScalerForOrthographic: number;
  28282. /**
  28283. * Define the size of the edges with a perspective camera
  28284. */
  28285. edgesWidthScalerForPerspective: number;
  28286. protected _source: AbstractMesh;
  28287. protected _linesPositions: number[];
  28288. protected _linesNormals: number[];
  28289. protected _linesIndices: number[];
  28290. protected _epsilon: number;
  28291. protected _indicesCount: number;
  28292. protected _lineShader: ShaderMaterial;
  28293. protected _ib: DataBuffer;
  28294. protected _buffers: {
  28295. [key: string]: Nullable<VertexBuffer>;
  28296. };
  28297. protected _buffersForInstances: {
  28298. [key: string]: Nullable<VertexBuffer>;
  28299. };
  28300. protected _checkVerticesInsteadOfIndices: boolean;
  28301. protected _options: Nullable<IEdgesRendererOptions>;
  28302. private _meshRebuildObserver;
  28303. private _meshDisposeObserver;
  28304. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28305. isEnabled: boolean;
  28306. /** Gets the vertices generated by the edge renderer */
  28307. get linesPositions(): Immutable<Array<number>>;
  28308. /** Gets the normals generated by the edge renderer */
  28309. get linesNormals(): Immutable<Array<number>>;
  28310. /** Gets the indices generated by the edge renderer */
  28311. get linesIndices(): Immutable<Array<number>>;
  28312. /**
  28313. * List of instances to render in case the source mesh has instances
  28314. */
  28315. customInstances: SmartArray<Matrix>;
  28316. private static GetShader;
  28317. /**
  28318. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28319. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28320. * @param source Mesh used to create edges
  28321. * @param epsilon sum of angles in adjacency to check for edge
  28322. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28323. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28324. * @param options The options to apply when generating the edges
  28325. */
  28326. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28327. protected _prepareRessources(): void;
  28328. /** @hidden */
  28329. _rebuild(): void;
  28330. /**
  28331. * Releases the required resources for the edges renderer
  28332. */
  28333. dispose(): void;
  28334. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28335. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28336. /**
  28337. * Checks if the pair of p0 and p1 is en edge
  28338. * @param faceIndex
  28339. * @param edge
  28340. * @param faceNormals
  28341. * @param p0
  28342. * @param p1
  28343. * @private
  28344. */
  28345. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28346. /**
  28347. * push line into the position, normal and index buffer
  28348. * @protected
  28349. */
  28350. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28351. /**
  28352. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28353. */
  28354. private _tessellateTriangle;
  28355. private _generateEdgesLinesAlternate;
  28356. /**
  28357. * Generates lines edges from adjacencjes
  28358. * @private
  28359. */
  28360. _generateEdgesLines(): void;
  28361. /**
  28362. * Checks wether or not the edges renderer is ready to render.
  28363. * @return true if ready, otherwise false.
  28364. */
  28365. isReady(): boolean;
  28366. /**
  28367. * Renders the edges of the attached mesh,
  28368. */
  28369. render(): void;
  28370. }
  28371. /**
  28372. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28373. */
  28374. export class LineEdgesRenderer extends EdgesRenderer {
  28375. /**
  28376. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28377. * @param source LineMesh used to generate edges
  28378. * @param epsilon not important (specified angle for edge detection)
  28379. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28380. */
  28381. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28382. /**
  28383. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28384. */
  28385. _generateEdgesLines(): void;
  28386. }
  28387. }
  28388. declare module BABYLON {
  28389. /**
  28390. * This represents the object necessary to create a rendering group.
  28391. * This is exclusively used and created by the rendering manager.
  28392. * To modify the behavior, you use the available helpers in your scene or meshes.
  28393. * @hidden
  28394. */
  28395. export class RenderingGroup {
  28396. index: number;
  28397. private static _zeroVector;
  28398. private _scene;
  28399. private _opaqueSubMeshes;
  28400. private _transparentSubMeshes;
  28401. private _alphaTestSubMeshes;
  28402. private _depthOnlySubMeshes;
  28403. private _particleSystems;
  28404. private _spriteManagers;
  28405. private _opaqueSortCompareFn;
  28406. private _alphaTestSortCompareFn;
  28407. private _transparentSortCompareFn;
  28408. private _renderOpaque;
  28409. private _renderAlphaTest;
  28410. private _renderTransparent;
  28411. /** @hidden */
  28412. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28413. onBeforeTransparentRendering: () => void;
  28414. /**
  28415. * Set the opaque sort comparison function.
  28416. * If null the sub meshes will be render in the order they were created
  28417. */
  28418. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28419. /**
  28420. * Set the alpha test sort comparison function.
  28421. * If null the sub meshes will be render in the order they were created
  28422. */
  28423. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28424. /**
  28425. * Set the transparent sort comparison function.
  28426. * If null the sub meshes will be render in the order they were created
  28427. */
  28428. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28429. /**
  28430. * Creates a new rendering group.
  28431. * @param index The rendering group index
  28432. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28433. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28434. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28435. */
  28436. 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>);
  28437. /**
  28438. * Render all the sub meshes contained in the group.
  28439. * @param customRenderFunction Used to override the default render behaviour of the group.
  28440. * @returns true if rendered some submeshes.
  28441. */
  28442. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28443. /**
  28444. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28445. * @param subMeshes The submeshes to render
  28446. */
  28447. private renderOpaqueSorted;
  28448. /**
  28449. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28450. * @param subMeshes The submeshes to render
  28451. */
  28452. private renderAlphaTestSorted;
  28453. /**
  28454. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28455. * @param subMeshes The submeshes to render
  28456. */
  28457. private renderTransparentSorted;
  28458. /**
  28459. * Renders the submeshes in a specified order.
  28460. * @param subMeshes The submeshes to sort before render
  28461. * @param sortCompareFn The comparison function use to sort
  28462. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28463. * @param transparent Specifies to activate blending if true
  28464. */
  28465. private static renderSorted;
  28466. /**
  28467. * Renders the submeshes in the order they were dispatched (no sort applied).
  28468. * @param subMeshes The submeshes to render
  28469. */
  28470. private static renderUnsorted;
  28471. /**
  28472. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28473. * are rendered back to front if in the same alpha index.
  28474. *
  28475. * @param a The first submesh
  28476. * @param b The second submesh
  28477. * @returns The result of the comparison
  28478. */
  28479. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28480. /**
  28481. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28482. * are rendered back to front.
  28483. *
  28484. * @param a The first submesh
  28485. * @param b The second submesh
  28486. * @returns The result of the comparison
  28487. */
  28488. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28489. /**
  28490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28491. * are rendered front to back (prevent overdraw).
  28492. *
  28493. * @param a The first submesh
  28494. * @param b The second submesh
  28495. * @returns The result of the comparison
  28496. */
  28497. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28498. /**
  28499. * Resets the different lists of submeshes to prepare a new frame.
  28500. */
  28501. prepare(): void;
  28502. dispose(): void;
  28503. /**
  28504. * Inserts the submesh in its correct queue depending on its material.
  28505. * @param subMesh The submesh to dispatch
  28506. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28507. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28508. */
  28509. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28510. dispatchSprites(spriteManager: ISpriteManager): void;
  28511. dispatchParticles(particleSystem: IParticleSystem): void;
  28512. private _renderParticles;
  28513. private _renderSprites;
  28514. }
  28515. }
  28516. declare module BABYLON {
  28517. /**
  28518. * Interface describing the different options available in the rendering manager
  28519. * regarding Auto Clear between groups.
  28520. */
  28521. export interface IRenderingManagerAutoClearSetup {
  28522. /**
  28523. * Defines whether or not autoclear is enable.
  28524. */
  28525. autoClear: boolean;
  28526. /**
  28527. * Defines whether or not to autoclear the depth buffer.
  28528. */
  28529. depth: boolean;
  28530. /**
  28531. * Defines whether or not to autoclear the stencil buffer.
  28532. */
  28533. stencil: boolean;
  28534. }
  28535. /**
  28536. * This class is used by the onRenderingGroupObservable
  28537. */
  28538. export class RenderingGroupInfo {
  28539. /**
  28540. * The Scene that being rendered
  28541. */
  28542. scene: Scene;
  28543. /**
  28544. * The camera currently used for the rendering pass
  28545. */
  28546. camera: Nullable<Camera>;
  28547. /**
  28548. * The ID of the renderingGroup being processed
  28549. */
  28550. renderingGroupId: number;
  28551. }
  28552. /**
  28553. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28554. * It is enable to manage the different groups as well as the different necessary sort functions.
  28555. * This should not be used directly aside of the few static configurations
  28556. */
  28557. export class RenderingManager {
  28558. /**
  28559. * The max id used for rendering groups (not included)
  28560. */
  28561. static MAX_RENDERINGGROUPS: number;
  28562. /**
  28563. * The min id used for rendering groups (included)
  28564. */
  28565. static MIN_RENDERINGGROUPS: number;
  28566. /**
  28567. * Used to globally prevent autoclearing scenes.
  28568. */
  28569. static AUTOCLEAR: boolean;
  28570. /**
  28571. * @hidden
  28572. */
  28573. _useSceneAutoClearSetup: boolean;
  28574. private _scene;
  28575. private _renderingGroups;
  28576. private _depthStencilBufferAlreadyCleaned;
  28577. private _autoClearDepthStencil;
  28578. private _customOpaqueSortCompareFn;
  28579. private _customAlphaTestSortCompareFn;
  28580. private _customTransparentSortCompareFn;
  28581. private _renderingGroupInfo;
  28582. /**
  28583. * Instantiates a new rendering group for a particular scene
  28584. * @param scene Defines the scene the groups belongs to
  28585. */
  28586. constructor(scene: Scene);
  28587. private _clearDepthStencilBuffer;
  28588. /**
  28589. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28590. * @hidden
  28591. */
  28592. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28593. /**
  28594. * Resets the different information of the group to prepare a new frame
  28595. * @hidden
  28596. */
  28597. reset(): void;
  28598. /**
  28599. * Dispose and release the group and its associated resources.
  28600. * @hidden
  28601. */
  28602. dispose(): void;
  28603. /**
  28604. * Clear the info related to rendering groups preventing retention points during dispose.
  28605. */
  28606. freeRenderingGroups(): void;
  28607. private _prepareRenderingGroup;
  28608. /**
  28609. * Add a sprite manager to the rendering manager in order to render it this frame.
  28610. * @param spriteManager Define the sprite manager to render
  28611. */
  28612. dispatchSprites(spriteManager: ISpriteManager): void;
  28613. /**
  28614. * Add a particle system to the rendering manager in order to render it this frame.
  28615. * @param particleSystem Define the particle system to render
  28616. */
  28617. dispatchParticles(particleSystem: IParticleSystem): void;
  28618. /**
  28619. * Add a submesh to the manager in order to render it this frame
  28620. * @param subMesh The submesh to dispatch
  28621. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28622. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28623. */
  28624. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28625. /**
  28626. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28627. * This allowed control for front to back rendering or reversly depending of the special needs.
  28628. *
  28629. * @param renderingGroupId The rendering group id corresponding to its index
  28630. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28631. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28632. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28633. */
  28634. 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;
  28635. /**
  28636. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28637. *
  28638. * @param renderingGroupId The rendering group id corresponding to its index
  28639. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28640. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28641. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28642. */
  28643. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28644. /**
  28645. * Gets the current auto clear configuration for one rendering group of the rendering
  28646. * manager.
  28647. * @param index the rendering group index to get the information for
  28648. * @returns The auto clear setup for the requested rendering group
  28649. */
  28650. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28651. }
  28652. }
  28653. declare module BABYLON {
  28654. /**
  28655. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28656. */
  28657. export interface ICustomShaderOptions {
  28658. /**
  28659. * Gets or sets the custom shader name to use
  28660. */
  28661. shaderName: string;
  28662. /**
  28663. * The list of attribute names used in the shader
  28664. */
  28665. attributes?: string[];
  28666. /**
  28667. * The list of unifrom names used in the shader
  28668. */
  28669. uniforms?: string[];
  28670. /**
  28671. * The list of sampler names used in the shader
  28672. */
  28673. samplers?: string[];
  28674. /**
  28675. * The list of defines used in the shader
  28676. */
  28677. defines?: string[];
  28678. }
  28679. /**
  28680. * Interface to implement to create a shadow generator compatible with BJS.
  28681. */
  28682. export interface IShadowGenerator {
  28683. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28684. id: string;
  28685. /**
  28686. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28687. * @returns The render target texture if present otherwise, null
  28688. */
  28689. getShadowMap(): Nullable<RenderTargetTexture>;
  28690. /**
  28691. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28692. * @param subMesh The submesh we want to render in the shadow map
  28693. * @param useInstances Defines wether will draw in the map using instances
  28694. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28695. * @returns true if ready otherwise, false
  28696. */
  28697. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28698. /**
  28699. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28700. * @param defines Defines of the material we want to update
  28701. * @param lightIndex Index of the light in the enabled light list of the material
  28702. */
  28703. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28704. /**
  28705. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28706. * defined in the generator but impacting the effect).
  28707. * It implies the unifroms available on the materials are the standard BJS ones.
  28708. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28709. * @param effect The effect we are binfing the information for
  28710. */
  28711. bindShadowLight(lightIndex: string, effect: Effect): void;
  28712. /**
  28713. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28714. * (eq to shadow prjection matrix * light transform matrix)
  28715. * @returns The transform matrix used to create the shadow map
  28716. */
  28717. getTransformMatrix(): Matrix;
  28718. /**
  28719. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28720. * Cube and 2D textures for instance.
  28721. */
  28722. recreateShadowMap(): void;
  28723. /**
  28724. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28725. * @param onCompiled Callback triggered at the and of the effects compilation
  28726. * @param options Sets of optional options forcing the compilation with different modes
  28727. */
  28728. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28729. useInstances: boolean;
  28730. }>): void;
  28731. /**
  28732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28733. * @param options Sets of optional options forcing the compilation with different modes
  28734. * @returns A promise that resolves when the compilation completes
  28735. */
  28736. forceCompilationAsync(options?: Partial<{
  28737. useInstances: boolean;
  28738. }>): Promise<void>;
  28739. /**
  28740. * Serializes the shadow generator setup to a json object.
  28741. * @returns The serialized JSON object
  28742. */
  28743. serialize(): any;
  28744. /**
  28745. * Disposes the Shadow map and related Textures and effects.
  28746. */
  28747. dispose(): void;
  28748. }
  28749. /**
  28750. * Default implementation IShadowGenerator.
  28751. * This is the main object responsible of generating shadows in the framework.
  28752. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28753. */
  28754. export class ShadowGenerator implements IShadowGenerator {
  28755. /**
  28756. * Name of the shadow generator class
  28757. */
  28758. static CLASSNAME: string;
  28759. /**
  28760. * Shadow generator mode None: no filtering applied.
  28761. */
  28762. static readonly FILTER_NONE: number;
  28763. /**
  28764. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28765. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28766. */
  28767. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28768. /**
  28769. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28770. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28771. */
  28772. static readonly FILTER_POISSONSAMPLING: number;
  28773. /**
  28774. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28775. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28776. */
  28777. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28778. /**
  28779. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28780. * edge artifacts on steep falloff.
  28781. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28782. */
  28783. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28784. /**
  28785. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28786. * edge artifacts on steep falloff.
  28787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28788. */
  28789. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28790. /**
  28791. * Shadow generator mode PCF: Percentage Closer Filtering
  28792. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28793. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28794. */
  28795. static readonly FILTER_PCF: number;
  28796. /**
  28797. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28798. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28799. * Contact Hardening
  28800. */
  28801. static readonly FILTER_PCSS: number;
  28802. /**
  28803. * Reserved for PCF and PCSS
  28804. * Highest Quality.
  28805. *
  28806. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28807. *
  28808. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28809. */
  28810. static readonly QUALITY_HIGH: number;
  28811. /**
  28812. * Reserved for PCF and PCSS
  28813. * Good tradeoff for quality/perf cross devices
  28814. *
  28815. * Execute PCF on a 3*3 kernel.
  28816. *
  28817. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28818. */
  28819. static readonly QUALITY_MEDIUM: number;
  28820. /**
  28821. * Reserved for PCF and PCSS
  28822. * The lowest quality but the fastest.
  28823. *
  28824. * Execute PCF on a 1*1 kernel.
  28825. *
  28826. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28827. */
  28828. static readonly QUALITY_LOW: number;
  28829. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28830. id: string;
  28831. /** Gets or sets the custom shader name to use */
  28832. customShaderOptions: ICustomShaderOptions;
  28833. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28834. customAllowRendering: (subMesh: SubMesh) => boolean;
  28835. /**
  28836. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28837. */
  28838. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28839. /**
  28840. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28841. */
  28842. onAfterShadowMapRenderObservable: Observable<Effect>;
  28843. /**
  28844. * Observable triggered before a mesh is rendered in the shadow map.
  28845. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28846. */
  28847. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28848. /**
  28849. * Observable triggered after a mesh is rendered in the shadow map.
  28850. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28851. */
  28852. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28853. protected _bias: number;
  28854. /**
  28855. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28856. */
  28857. get bias(): number;
  28858. /**
  28859. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28860. */
  28861. set bias(bias: number);
  28862. protected _normalBias: number;
  28863. /**
  28864. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28865. */
  28866. get normalBias(): number;
  28867. /**
  28868. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28869. */
  28870. set normalBias(normalBias: number);
  28871. protected _blurBoxOffset: number;
  28872. /**
  28873. * Gets the blur box offset: offset applied during the blur pass.
  28874. * Only useful if useKernelBlur = false
  28875. */
  28876. get blurBoxOffset(): number;
  28877. /**
  28878. * Sets the blur box offset: offset applied during the blur pass.
  28879. * Only useful if useKernelBlur = false
  28880. */
  28881. set blurBoxOffset(value: number);
  28882. protected _blurScale: number;
  28883. /**
  28884. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28885. * 2 means half of the size.
  28886. */
  28887. get blurScale(): number;
  28888. /**
  28889. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28890. * 2 means half of the size.
  28891. */
  28892. set blurScale(value: number);
  28893. protected _blurKernel: number;
  28894. /**
  28895. * Gets the blur kernel: kernel size of the blur pass.
  28896. * Only useful if useKernelBlur = true
  28897. */
  28898. get blurKernel(): number;
  28899. /**
  28900. * Sets the blur kernel: kernel size of the blur pass.
  28901. * Only useful if useKernelBlur = true
  28902. */
  28903. set blurKernel(value: number);
  28904. protected _useKernelBlur: boolean;
  28905. /**
  28906. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28907. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28908. */
  28909. get useKernelBlur(): boolean;
  28910. /**
  28911. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28912. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28913. */
  28914. set useKernelBlur(value: boolean);
  28915. protected _depthScale: number;
  28916. /**
  28917. * Gets the depth scale used in ESM mode.
  28918. */
  28919. get depthScale(): number;
  28920. /**
  28921. * Sets the depth scale used in ESM mode.
  28922. * This can override the scale stored on the light.
  28923. */
  28924. set depthScale(value: number);
  28925. protected _validateFilter(filter: number): number;
  28926. protected _filter: number;
  28927. /**
  28928. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28929. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28930. */
  28931. get filter(): number;
  28932. /**
  28933. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28934. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28935. */
  28936. set filter(value: number);
  28937. /**
  28938. * Gets if the current filter is set to Poisson Sampling.
  28939. */
  28940. get usePoissonSampling(): boolean;
  28941. /**
  28942. * Sets the current filter to Poisson Sampling.
  28943. */
  28944. set usePoissonSampling(value: boolean);
  28945. /**
  28946. * Gets if the current filter is set to ESM.
  28947. */
  28948. get useExponentialShadowMap(): boolean;
  28949. /**
  28950. * Sets the current filter is to ESM.
  28951. */
  28952. set useExponentialShadowMap(value: boolean);
  28953. /**
  28954. * Gets if the current filter is set to filtered ESM.
  28955. */
  28956. get useBlurExponentialShadowMap(): boolean;
  28957. /**
  28958. * Gets if the current filter is set to filtered ESM.
  28959. */
  28960. set useBlurExponentialShadowMap(value: boolean);
  28961. /**
  28962. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28963. * exponential to prevent steep falloff artifacts).
  28964. */
  28965. get useCloseExponentialShadowMap(): boolean;
  28966. /**
  28967. * Sets the current filter to "close ESM" (using the inverse of the
  28968. * exponential to prevent steep falloff artifacts).
  28969. */
  28970. set useCloseExponentialShadowMap(value: boolean);
  28971. /**
  28972. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28973. * exponential to prevent steep falloff artifacts).
  28974. */
  28975. get useBlurCloseExponentialShadowMap(): boolean;
  28976. /**
  28977. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28978. * exponential to prevent steep falloff artifacts).
  28979. */
  28980. set useBlurCloseExponentialShadowMap(value: boolean);
  28981. /**
  28982. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28983. */
  28984. get usePercentageCloserFiltering(): boolean;
  28985. /**
  28986. * Sets the current filter to "PCF" (percentage closer filtering).
  28987. */
  28988. set usePercentageCloserFiltering(value: boolean);
  28989. protected _filteringQuality: number;
  28990. /**
  28991. * Gets the PCF or PCSS Quality.
  28992. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28993. */
  28994. get filteringQuality(): number;
  28995. /**
  28996. * Sets the PCF or PCSS Quality.
  28997. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28998. */
  28999. set filteringQuality(filteringQuality: number);
  29000. /**
  29001. * Gets if the current filter is set to "PCSS" (contact hardening).
  29002. */
  29003. get useContactHardeningShadow(): boolean;
  29004. /**
  29005. * Sets the current filter to "PCSS" (contact hardening).
  29006. */
  29007. set useContactHardeningShadow(value: boolean);
  29008. protected _contactHardeningLightSizeUVRatio: number;
  29009. /**
  29010. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29011. * Using a ratio helps keeping shape stability independently of the map size.
  29012. *
  29013. * It does not account for the light projection as it was having too much
  29014. * instability during the light setup or during light position changes.
  29015. *
  29016. * Only valid if useContactHardeningShadow is true.
  29017. */
  29018. get contactHardeningLightSizeUVRatio(): number;
  29019. /**
  29020. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29021. * Using a ratio helps keeping shape stability independently of the map size.
  29022. *
  29023. * It does not account for the light projection as it was having too much
  29024. * instability during the light setup or during light position changes.
  29025. *
  29026. * Only valid if useContactHardeningShadow is true.
  29027. */
  29028. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29029. protected _darkness: number;
  29030. /** Gets or sets the actual darkness of a shadow */
  29031. get darkness(): number;
  29032. set darkness(value: number);
  29033. /**
  29034. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29035. * 0 means strongest and 1 would means no shadow.
  29036. * @returns the darkness.
  29037. */
  29038. getDarkness(): number;
  29039. /**
  29040. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29041. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29042. * @returns the shadow generator allowing fluent coding.
  29043. */
  29044. setDarkness(darkness: number): ShadowGenerator;
  29045. protected _transparencyShadow: boolean;
  29046. /** Gets or sets the ability to have transparent shadow */
  29047. get transparencyShadow(): boolean;
  29048. set transparencyShadow(value: boolean);
  29049. /**
  29050. * Sets the ability to have transparent shadow (boolean).
  29051. * @param transparent True if transparent else False
  29052. * @returns the shadow generator allowing fluent coding
  29053. */
  29054. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29055. /**
  29056. * Enables or disables shadows with varying strength based on the transparency
  29057. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29058. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29059. * mesh.visibility * alphaTexture.a
  29060. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29061. */
  29062. enableSoftTransparentShadow: boolean;
  29063. protected _shadowMap: Nullable<RenderTargetTexture>;
  29064. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29065. /**
  29066. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29067. * @returns The render target texture if present otherwise, null
  29068. */
  29069. getShadowMap(): Nullable<RenderTargetTexture>;
  29070. /**
  29071. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29072. * @returns The render target texture if the shadow map is present otherwise, null
  29073. */
  29074. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29075. /**
  29076. * Gets the class name of that object
  29077. * @returns "ShadowGenerator"
  29078. */
  29079. getClassName(): string;
  29080. /**
  29081. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29082. * @param mesh Mesh to add
  29083. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29084. * @returns the Shadow Generator itself
  29085. */
  29086. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29087. /**
  29088. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29089. * @param mesh Mesh to remove
  29090. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29091. * @returns the Shadow Generator itself
  29092. */
  29093. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29094. /**
  29095. * Controls the extent to which the shadows fade out at the edge of the frustum
  29096. */
  29097. frustumEdgeFalloff: number;
  29098. protected _light: IShadowLight;
  29099. /**
  29100. * Returns the associated light object.
  29101. * @returns the light generating the shadow
  29102. */
  29103. getLight(): IShadowLight;
  29104. /**
  29105. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29106. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29107. * It might on the other hand introduce peter panning.
  29108. */
  29109. forceBackFacesOnly: boolean;
  29110. protected _scene: Scene;
  29111. protected _lightDirection: Vector3;
  29112. protected _effect: Effect;
  29113. protected _viewMatrix: Matrix;
  29114. protected _projectionMatrix: Matrix;
  29115. protected _transformMatrix: Matrix;
  29116. protected _cachedPosition: Vector3;
  29117. protected _cachedDirection: Vector3;
  29118. protected _cachedDefines: string;
  29119. protected _currentRenderID: number;
  29120. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29121. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29122. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29123. protected _blurPostProcesses: PostProcess[];
  29124. protected _mapSize: number;
  29125. protected _currentFaceIndex: number;
  29126. protected _currentFaceIndexCache: number;
  29127. protected _textureType: number;
  29128. protected _defaultTextureMatrix: Matrix;
  29129. protected _storedUniqueId: Nullable<number>;
  29130. /** @hidden */
  29131. static _SceneComponentInitialization: (scene: Scene) => void;
  29132. /**
  29133. * Gets or sets the size of the texture what stores the shadows
  29134. */
  29135. get mapSize(): number;
  29136. set mapSize(size: number);
  29137. /**
  29138. * Creates a ShadowGenerator object.
  29139. * A ShadowGenerator is the required tool to use the shadows.
  29140. * Each light casting shadows needs to use its own ShadowGenerator.
  29141. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29142. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29143. * @param light The light object generating the shadows.
  29144. * @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.
  29145. */
  29146. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29147. protected _initializeGenerator(): void;
  29148. protected _createTargetRenderTexture(): void;
  29149. protected _initializeShadowMap(): void;
  29150. protected _initializeBlurRTTAndPostProcesses(): void;
  29151. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29152. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29153. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29154. protected _applyFilterValues(): void;
  29155. /**
  29156. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29157. * @param onCompiled Callback triggered at the and of the effects compilation
  29158. * @param options Sets of optional options forcing the compilation with different modes
  29159. */
  29160. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29161. useInstances: boolean;
  29162. }>): void;
  29163. /**
  29164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29165. * @param options Sets of optional options forcing the compilation with different modes
  29166. * @returns A promise that resolves when the compilation completes
  29167. */
  29168. forceCompilationAsync(options?: Partial<{
  29169. useInstances: boolean;
  29170. }>): Promise<void>;
  29171. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29172. private _prepareShadowDefines;
  29173. /**
  29174. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29175. * @param subMesh The submesh we want to render in the shadow map
  29176. * @param useInstances Defines wether will draw in the map using instances
  29177. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29178. * @returns true if ready otherwise, false
  29179. */
  29180. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29181. /**
  29182. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29183. * @param defines Defines of the material we want to update
  29184. * @param lightIndex Index of the light in the enabled light list of the material
  29185. */
  29186. prepareDefines(defines: any, lightIndex: number): void;
  29187. /**
  29188. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29189. * defined in the generator but impacting the effect).
  29190. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29191. * @param effect The effect we are binfing the information for
  29192. */
  29193. bindShadowLight(lightIndex: string, effect: Effect): void;
  29194. /**
  29195. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29196. * (eq to shadow prjection matrix * light transform matrix)
  29197. * @returns The transform matrix used to create the shadow map
  29198. */
  29199. getTransformMatrix(): Matrix;
  29200. /**
  29201. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29202. * Cube and 2D textures for instance.
  29203. */
  29204. recreateShadowMap(): void;
  29205. protected _disposeBlurPostProcesses(): void;
  29206. protected _disposeRTTandPostProcesses(): void;
  29207. /**
  29208. * Disposes the ShadowGenerator.
  29209. * Returns nothing.
  29210. */
  29211. dispose(): void;
  29212. /**
  29213. * Serializes the shadow generator setup to a json object.
  29214. * @returns The serialized JSON object
  29215. */
  29216. serialize(): any;
  29217. /**
  29218. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29219. * @param parsedShadowGenerator The JSON object to parse
  29220. * @param scene The scene to create the shadow map for
  29221. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29222. * @returns The parsed shadow generator
  29223. */
  29224. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29225. }
  29226. }
  29227. declare module BABYLON {
  29228. /**
  29229. * Options to be used when creating a shadow depth material
  29230. */
  29231. export interface IIOptionShadowDepthMaterial {
  29232. /** Variables in the vertex shader code that need to have their names remapped.
  29233. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29234. * "var_name" should be either: worldPos or vNormalW
  29235. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29236. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29237. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29238. */
  29239. remappedVariables?: string[];
  29240. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29241. standalone?: boolean;
  29242. }
  29243. /**
  29244. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29245. */
  29246. export class ShadowDepthWrapper {
  29247. private _scene;
  29248. private _options?;
  29249. private _baseMaterial;
  29250. private _onEffectCreatedObserver;
  29251. private _subMeshToEffect;
  29252. private _subMeshToDepthEffect;
  29253. private _meshes;
  29254. /** @hidden */
  29255. _matriceNames: any;
  29256. /** Gets the standalone status of the wrapper */
  29257. get standalone(): boolean;
  29258. /** Gets the base material the wrapper is built upon */
  29259. get baseMaterial(): Material;
  29260. /**
  29261. * Instantiate a new shadow depth wrapper.
  29262. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29263. * generate the shadow depth map. For more information, please refer to the documentation:
  29264. * https://doc.babylonjs.com/babylon101/shadows
  29265. * @param baseMaterial Material to wrap
  29266. * @param scene Define the scene the material belongs to
  29267. * @param options Options used to create the wrapper
  29268. */
  29269. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29270. /**
  29271. * Gets the effect to use to generate the depth map
  29272. * @param subMesh subMesh to get the effect for
  29273. * @param shadowGenerator shadow generator to get the effect for
  29274. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29275. */
  29276. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29277. /**
  29278. * Specifies that the submesh is ready to be used for depth rendering
  29279. * @param subMesh submesh to check
  29280. * @param defines the list of defines to take into account when checking the effect
  29281. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29282. * @param useInstances specifies that instances should be used
  29283. * @returns a boolean indicating that the submesh is ready or not
  29284. */
  29285. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29286. /**
  29287. * Disposes the resources
  29288. */
  29289. dispose(): void;
  29290. private _makeEffect;
  29291. }
  29292. }
  29293. declare module BABYLON {
  29294. /**
  29295. * Options for compiling materials.
  29296. */
  29297. export interface IMaterialCompilationOptions {
  29298. /**
  29299. * Defines whether clip planes are enabled.
  29300. */
  29301. clipPlane: boolean;
  29302. /**
  29303. * Defines whether instances are enabled.
  29304. */
  29305. useInstances: boolean;
  29306. }
  29307. /**
  29308. * Options passed when calling customShaderNameResolve
  29309. */
  29310. export interface ICustomShaderNameResolveOptions {
  29311. /**
  29312. * 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
  29313. */
  29314. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29315. }
  29316. /**
  29317. * Base class for the main features of a material in Babylon.js
  29318. */
  29319. export class Material implements IAnimatable {
  29320. /**
  29321. * Returns the triangle fill mode
  29322. */
  29323. static readonly TriangleFillMode: number;
  29324. /**
  29325. * Returns the wireframe mode
  29326. */
  29327. static readonly WireFrameFillMode: number;
  29328. /**
  29329. * Returns the point fill mode
  29330. */
  29331. static readonly PointFillMode: number;
  29332. /**
  29333. * Returns the point list draw mode
  29334. */
  29335. static readonly PointListDrawMode: number;
  29336. /**
  29337. * Returns the line list draw mode
  29338. */
  29339. static readonly LineListDrawMode: number;
  29340. /**
  29341. * Returns the line loop draw mode
  29342. */
  29343. static readonly LineLoopDrawMode: number;
  29344. /**
  29345. * Returns the line strip draw mode
  29346. */
  29347. static readonly LineStripDrawMode: number;
  29348. /**
  29349. * Returns the triangle strip draw mode
  29350. */
  29351. static readonly TriangleStripDrawMode: number;
  29352. /**
  29353. * Returns the triangle fan draw mode
  29354. */
  29355. static readonly TriangleFanDrawMode: number;
  29356. /**
  29357. * Stores the clock-wise side orientation
  29358. */
  29359. static readonly ClockWiseSideOrientation: number;
  29360. /**
  29361. * Stores the counter clock-wise side orientation
  29362. */
  29363. static readonly CounterClockWiseSideOrientation: number;
  29364. /**
  29365. * The dirty texture flag value
  29366. */
  29367. static readonly TextureDirtyFlag: number;
  29368. /**
  29369. * The dirty light flag value
  29370. */
  29371. static readonly LightDirtyFlag: number;
  29372. /**
  29373. * The dirty fresnel flag value
  29374. */
  29375. static readonly FresnelDirtyFlag: number;
  29376. /**
  29377. * The dirty attribute flag value
  29378. */
  29379. static readonly AttributesDirtyFlag: number;
  29380. /**
  29381. * The dirty misc flag value
  29382. */
  29383. static readonly MiscDirtyFlag: number;
  29384. /**
  29385. * The dirty prepass flag value
  29386. */
  29387. static readonly PrePassDirtyFlag: number;
  29388. /**
  29389. * The all dirty flag value
  29390. */
  29391. static readonly AllDirtyFlag: number;
  29392. /**
  29393. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29394. */
  29395. static readonly MATERIAL_OPAQUE: number;
  29396. /**
  29397. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29398. */
  29399. static readonly MATERIAL_ALPHATEST: number;
  29400. /**
  29401. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29402. */
  29403. static readonly MATERIAL_ALPHABLEND: number;
  29404. /**
  29405. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29406. * They are also discarded below the alpha cutoff threshold to improve performances.
  29407. */
  29408. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29409. /**
  29410. * The Whiteout method is used to blend normals.
  29411. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29412. */
  29413. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29414. /**
  29415. * The Reoriented Normal Mapping method is used to blend normals.
  29416. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29417. */
  29418. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29419. /**
  29420. * Custom callback helping to override the default shader used in the material.
  29421. */
  29422. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29423. /**
  29424. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29425. */
  29426. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29427. /**
  29428. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29429. * This means that the material can keep using a previous shader while a new one is being compiled.
  29430. * This is mostly used when shader parallel compilation is supported (true by default)
  29431. */
  29432. allowShaderHotSwapping: boolean;
  29433. /**
  29434. * The ID of the material
  29435. */
  29436. id: string;
  29437. /**
  29438. * Gets or sets the unique id of the material
  29439. */
  29440. uniqueId: number;
  29441. /**
  29442. * The name of the material
  29443. */
  29444. name: string;
  29445. /**
  29446. * Gets or sets user defined metadata
  29447. */
  29448. metadata: any;
  29449. /**
  29450. * For internal use only. Please do not use.
  29451. */
  29452. reservedDataStore: any;
  29453. /**
  29454. * Specifies if the ready state should be checked on each call
  29455. */
  29456. checkReadyOnEveryCall: boolean;
  29457. /**
  29458. * Specifies if the ready state should be checked once
  29459. */
  29460. checkReadyOnlyOnce: boolean;
  29461. /**
  29462. * The state of the material
  29463. */
  29464. state: string;
  29465. /**
  29466. * If the material can be rendered to several textures with MRT extension
  29467. */
  29468. get canRenderToMRT(): boolean;
  29469. /**
  29470. * The alpha value of the material
  29471. */
  29472. protected _alpha: number;
  29473. /**
  29474. * List of inspectable custom properties (used by the Inspector)
  29475. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29476. */
  29477. inspectableCustomProperties: IInspectable[];
  29478. /**
  29479. * Sets the alpha value of the material
  29480. */
  29481. set alpha(value: number);
  29482. /**
  29483. * Gets the alpha value of the material
  29484. */
  29485. get alpha(): number;
  29486. /**
  29487. * Specifies if back face culling is enabled
  29488. */
  29489. protected _backFaceCulling: boolean;
  29490. /**
  29491. * Sets the back-face culling state
  29492. */
  29493. set backFaceCulling(value: boolean);
  29494. /**
  29495. * Gets the back-face culling state
  29496. */
  29497. get backFaceCulling(): boolean;
  29498. /**
  29499. * Stores the value for side orientation
  29500. */
  29501. sideOrientation: number;
  29502. /**
  29503. * Callback triggered when the material is compiled
  29504. */
  29505. onCompiled: Nullable<(effect: Effect) => void>;
  29506. /**
  29507. * Callback triggered when an error occurs
  29508. */
  29509. onError: Nullable<(effect: Effect, errors: string) => void>;
  29510. /**
  29511. * Callback triggered to get the render target textures
  29512. */
  29513. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29514. /**
  29515. * Gets a boolean indicating that current material needs to register RTT
  29516. */
  29517. get hasRenderTargetTextures(): boolean;
  29518. /**
  29519. * Specifies if the material should be serialized
  29520. */
  29521. doNotSerialize: boolean;
  29522. /**
  29523. * @hidden
  29524. */
  29525. _storeEffectOnSubMeshes: boolean;
  29526. /**
  29527. * Stores the animations for the material
  29528. */
  29529. animations: Nullable<Array<Animation>>;
  29530. /**
  29531. * An event triggered when the material is disposed
  29532. */
  29533. onDisposeObservable: Observable<Material>;
  29534. /**
  29535. * An observer which watches for dispose events
  29536. */
  29537. private _onDisposeObserver;
  29538. private _onUnBindObservable;
  29539. /**
  29540. * Called during a dispose event
  29541. */
  29542. set onDispose(callback: () => void);
  29543. private _onBindObservable;
  29544. /**
  29545. * An event triggered when the material is bound
  29546. */
  29547. get onBindObservable(): Observable<AbstractMesh>;
  29548. /**
  29549. * An observer which watches for bind events
  29550. */
  29551. private _onBindObserver;
  29552. /**
  29553. * Called during a bind event
  29554. */
  29555. set onBind(callback: (Mesh: AbstractMesh) => void);
  29556. /**
  29557. * An event triggered when the material is unbound
  29558. */
  29559. get onUnBindObservable(): Observable<Material>;
  29560. protected _onEffectCreatedObservable: Nullable<Observable<{
  29561. effect: Effect;
  29562. subMesh: Nullable<SubMesh>;
  29563. }>>;
  29564. /**
  29565. * An event triggered when the effect is (re)created
  29566. */
  29567. get onEffectCreatedObservable(): Observable<{
  29568. effect: Effect;
  29569. subMesh: Nullable<SubMesh>;
  29570. }>;
  29571. /**
  29572. * Stores the value of the alpha mode
  29573. */
  29574. private _alphaMode;
  29575. /**
  29576. * Sets the value of the alpha mode.
  29577. *
  29578. * | Value | Type | Description |
  29579. * | --- | --- | --- |
  29580. * | 0 | ALPHA_DISABLE | |
  29581. * | 1 | ALPHA_ADD | |
  29582. * | 2 | ALPHA_COMBINE | |
  29583. * | 3 | ALPHA_SUBTRACT | |
  29584. * | 4 | ALPHA_MULTIPLY | |
  29585. * | 5 | ALPHA_MAXIMIZED | |
  29586. * | 6 | ALPHA_ONEONE | |
  29587. * | 7 | ALPHA_PREMULTIPLIED | |
  29588. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29589. * | 9 | ALPHA_INTERPOLATE | |
  29590. * | 10 | ALPHA_SCREENMODE | |
  29591. *
  29592. */
  29593. set alphaMode(value: number);
  29594. /**
  29595. * Gets the value of the alpha mode
  29596. */
  29597. get alphaMode(): number;
  29598. /**
  29599. * Stores the state of the need depth pre-pass value
  29600. */
  29601. private _needDepthPrePass;
  29602. /**
  29603. * Sets the need depth pre-pass value
  29604. */
  29605. set needDepthPrePass(value: boolean);
  29606. /**
  29607. * Gets the depth pre-pass value
  29608. */
  29609. get needDepthPrePass(): boolean;
  29610. /**
  29611. * Specifies if depth writing should be disabled
  29612. */
  29613. disableDepthWrite: boolean;
  29614. /**
  29615. * Specifies if color writing should be disabled
  29616. */
  29617. disableColorWrite: boolean;
  29618. /**
  29619. * Specifies if depth writing should be forced
  29620. */
  29621. forceDepthWrite: boolean;
  29622. /**
  29623. * Specifies the depth function that should be used. 0 means the default engine function
  29624. */
  29625. depthFunction: number;
  29626. /**
  29627. * Specifies if there should be a separate pass for culling
  29628. */
  29629. separateCullingPass: boolean;
  29630. /**
  29631. * Stores the state specifing if fog should be enabled
  29632. */
  29633. private _fogEnabled;
  29634. /**
  29635. * Sets the state for enabling fog
  29636. */
  29637. set fogEnabled(value: boolean);
  29638. /**
  29639. * Gets the value of the fog enabled state
  29640. */
  29641. get fogEnabled(): boolean;
  29642. /**
  29643. * Stores the size of points
  29644. */
  29645. pointSize: number;
  29646. /**
  29647. * Stores the z offset value
  29648. */
  29649. zOffset: number;
  29650. get wireframe(): boolean;
  29651. /**
  29652. * Sets the state of wireframe mode
  29653. */
  29654. set wireframe(value: boolean);
  29655. /**
  29656. * Gets the value specifying if point clouds are enabled
  29657. */
  29658. get pointsCloud(): boolean;
  29659. /**
  29660. * Sets the state of point cloud mode
  29661. */
  29662. set pointsCloud(value: boolean);
  29663. /**
  29664. * Gets the material fill mode
  29665. */
  29666. get fillMode(): number;
  29667. /**
  29668. * Sets the material fill mode
  29669. */
  29670. set fillMode(value: number);
  29671. /**
  29672. * @hidden
  29673. * Stores the effects for the material
  29674. */
  29675. _effect: Nullable<Effect>;
  29676. /**
  29677. * Specifies if uniform buffers should be used
  29678. */
  29679. private _useUBO;
  29680. /**
  29681. * Stores a reference to the scene
  29682. */
  29683. private _scene;
  29684. /**
  29685. * Stores the fill mode state
  29686. */
  29687. private _fillMode;
  29688. /**
  29689. * Specifies if the depth write state should be cached
  29690. */
  29691. private _cachedDepthWriteState;
  29692. /**
  29693. * Specifies if the color write state should be cached
  29694. */
  29695. private _cachedColorWriteState;
  29696. /**
  29697. * Specifies if the depth function state should be cached
  29698. */
  29699. private _cachedDepthFunctionState;
  29700. /**
  29701. * Stores the uniform buffer
  29702. */
  29703. protected _uniformBuffer: UniformBuffer;
  29704. /** @hidden */
  29705. _indexInSceneMaterialArray: number;
  29706. /** @hidden */
  29707. meshMap: Nullable<{
  29708. [id: string]: AbstractMesh | undefined;
  29709. }>;
  29710. /**
  29711. * Creates a material instance
  29712. * @param name defines the name of the material
  29713. * @param scene defines the scene to reference
  29714. * @param doNotAdd specifies if the material should be added to the scene
  29715. */
  29716. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29717. /**
  29718. * Returns a string representation of the current material
  29719. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29720. * @returns a string with material information
  29721. */
  29722. toString(fullDetails?: boolean): string;
  29723. /**
  29724. * Gets the class name of the material
  29725. * @returns a string with the class name of the material
  29726. */
  29727. getClassName(): string;
  29728. /**
  29729. * Specifies if updates for the material been locked
  29730. */
  29731. get isFrozen(): boolean;
  29732. /**
  29733. * Locks updates for the material
  29734. */
  29735. freeze(): void;
  29736. /**
  29737. * Unlocks updates for the material
  29738. */
  29739. unfreeze(): void;
  29740. /**
  29741. * Specifies if the material is ready to be used
  29742. * @param mesh defines the mesh to check
  29743. * @param useInstances specifies if instances should be used
  29744. * @returns a boolean indicating if the material is ready to be used
  29745. */
  29746. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29747. /**
  29748. * Specifies that the submesh is ready to be used
  29749. * @param mesh defines the mesh to check
  29750. * @param subMesh defines which submesh to check
  29751. * @param useInstances specifies that instances should be used
  29752. * @returns a boolean indicating that the submesh is ready or not
  29753. */
  29754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29755. /**
  29756. * Returns the material effect
  29757. * @returns the effect associated with the material
  29758. */
  29759. getEffect(): Nullable<Effect>;
  29760. /**
  29761. * Returns the current scene
  29762. * @returns a Scene
  29763. */
  29764. getScene(): Scene;
  29765. /**
  29766. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29767. */
  29768. protected _forceAlphaTest: boolean;
  29769. /**
  29770. * The transparency mode of the material.
  29771. */
  29772. protected _transparencyMode: Nullable<number>;
  29773. /**
  29774. * Gets the current transparency mode.
  29775. */
  29776. get transparencyMode(): Nullable<number>;
  29777. /**
  29778. * Sets the transparency mode of the material.
  29779. *
  29780. * | Value | Type | Description |
  29781. * | ----- | ----------------------------------- | ----------- |
  29782. * | 0 | OPAQUE | |
  29783. * | 1 | ALPHATEST | |
  29784. * | 2 | ALPHABLEND | |
  29785. * | 3 | ALPHATESTANDBLEND | |
  29786. *
  29787. */
  29788. set transparencyMode(value: Nullable<number>);
  29789. /**
  29790. * Returns true if alpha blending should be disabled.
  29791. */
  29792. protected get _disableAlphaBlending(): boolean;
  29793. /**
  29794. * Specifies whether or not this material should be rendered in alpha blend mode.
  29795. * @returns a boolean specifying if alpha blending is needed
  29796. */
  29797. needAlphaBlending(): boolean;
  29798. /**
  29799. * Specifies if the mesh will require alpha blending
  29800. * @param mesh defines the mesh to check
  29801. * @returns a boolean specifying if alpha blending is needed for the mesh
  29802. */
  29803. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29804. /**
  29805. * Specifies whether or not this material should be rendered in alpha test mode.
  29806. * @returns a boolean specifying if an alpha test is needed.
  29807. */
  29808. needAlphaTesting(): boolean;
  29809. /**
  29810. * Specifies if material alpha testing should be turned on for the mesh
  29811. * @param mesh defines the mesh to check
  29812. */
  29813. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29814. /**
  29815. * Gets the texture used for the alpha test
  29816. * @returns the texture to use for alpha testing
  29817. */
  29818. getAlphaTestTexture(): Nullable<BaseTexture>;
  29819. /**
  29820. * Marks the material to indicate that it needs to be re-calculated
  29821. */
  29822. markDirty(): void;
  29823. /** @hidden */
  29824. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29825. /**
  29826. * Binds the material to the mesh
  29827. * @param world defines the world transformation matrix
  29828. * @param mesh defines the mesh to bind the material to
  29829. */
  29830. bind(world: Matrix, mesh?: Mesh): void;
  29831. /**
  29832. * Binds the submesh to the material
  29833. * @param world defines the world transformation matrix
  29834. * @param mesh defines the mesh containing the submesh
  29835. * @param subMesh defines the submesh to bind the material to
  29836. */
  29837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29838. /**
  29839. * Binds the world matrix to the material
  29840. * @param world defines the world transformation matrix
  29841. */
  29842. bindOnlyWorldMatrix(world: Matrix): void;
  29843. /**
  29844. * Binds the scene's uniform buffer to the effect.
  29845. * @param effect defines the effect to bind to the scene uniform buffer
  29846. * @param sceneUbo defines the uniform buffer storing scene data
  29847. */
  29848. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29849. /**
  29850. * Binds the view matrix to the effect
  29851. * @param effect defines the effect to bind the view matrix to
  29852. */
  29853. bindView(effect: Effect): void;
  29854. /**
  29855. * Binds the view projection matrix to the effect
  29856. * @param effect defines the effect to bind the view projection matrix to
  29857. */
  29858. bindViewProjection(effect: Effect): void;
  29859. /**
  29860. * Processes to execute after binding the material to a mesh
  29861. * @param mesh defines the rendered mesh
  29862. */
  29863. protected _afterBind(mesh?: Mesh): void;
  29864. /**
  29865. * Unbinds the material from the mesh
  29866. */
  29867. unbind(): void;
  29868. /**
  29869. * Gets the active textures from the material
  29870. * @returns an array of textures
  29871. */
  29872. getActiveTextures(): BaseTexture[];
  29873. /**
  29874. * Specifies if the material uses a texture
  29875. * @param texture defines the texture to check against the material
  29876. * @returns a boolean specifying if the material uses the texture
  29877. */
  29878. hasTexture(texture: BaseTexture): boolean;
  29879. /**
  29880. * Makes a duplicate of the material, and gives it a new name
  29881. * @param name defines the new name for the duplicated material
  29882. * @returns the cloned material
  29883. */
  29884. clone(name: string): Nullable<Material>;
  29885. /**
  29886. * Gets the meshes bound to the material
  29887. * @returns an array of meshes bound to the material
  29888. */
  29889. getBindedMeshes(): AbstractMesh[];
  29890. /**
  29891. * Force shader compilation
  29892. * @param mesh defines the mesh associated with this material
  29893. * @param onCompiled defines a function to execute once the material is compiled
  29894. * @param options defines the options to configure the compilation
  29895. * @param onError defines a function to execute if the material fails compiling
  29896. */
  29897. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29898. /**
  29899. * Force shader compilation
  29900. * @param mesh defines the mesh that will use this material
  29901. * @param options defines additional options for compiling the shaders
  29902. * @returns a promise that resolves when the compilation completes
  29903. */
  29904. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29905. private static readonly _AllDirtyCallBack;
  29906. private static readonly _ImageProcessingDirtyCallBack;
  29907. private static readonly _TextureDirtyCallBack;
  29908. private static readonly _FresnelDirtyCallBack;
  29909. private static readonly _MiscDirtyCallBack;
  29910. private static readonly _PrePassDirtyCallBack;
  29911. private static readonly _LightsDirtyCallBack;
  29912. private static readonly _AttributeDirtyCallBack;
  29913. private static _FresnelAndMiscDirtyCallBack;
  29914. private static _TextureAndMiscDirtyCallBack;
  29915. private static readonly _DirtyCallbackArray;
  29916. private static readonly _RunDirtyCallBacks;
  29917. /**
  29918. * Marks a define in the material to indicate that it needs to be re-computed
  29919. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29920. */
  29921. markAsDirty(flag: number): void;
  29922. /**
  29923. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29924. * @param func defines a function which checks material defines against the submeshes
  29925. */
  29926. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29927. /**
  29928. * Indicates that the scene should check if the rendering now needs a prepass
  29929. */
  29930. protected _markScenePrePassDirty(): void;
  29931. /**
  29932. * Indicates that we need to re-calculated for all submeshes
  29933. */
  29934. protected _markAllSubMeshesAsAllDirty(): void;
  29935. /**
  29936. * Indicates that image processing needs to be re-calculated for all submeshes
  29937. */
  29938. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29939. /**
  29940. * Indicates that textures need to be re-calculated for all submeshes
  29941. */
  29942. protected _markAllSubMeshesAsTexturesDirty(): void;
  29943. /**
  29944. * Indicates that fresnel needs to be re-calculated for all submeshes
  29945. */
  29946. protected _markAllSubMeshesAsFresnelDirty(): void;
  29947. /**
  29948. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29949. */
  29950. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29951. /**
  29952. * Indicates that lights need to be re-calculated for all submeshes
  29953. */
  29954. protected _markAllSubMeshesAsLightsDirty(): void;
  29955. /**
  29956. * Indicates that attributes need to be re-calculated for all submeshes
  29957. */
  29958. protected _markAllSubMeshesAsAttributesDirty(): void;
  29959. /**
  29960. * Indicates that misc needs to be re-calculated for all submeshes
  29961. */
  29962. protected _markAllSubMeshesAsMiscDirty(): void;
  29963. /**
  29964. * Indicates that prepass needs to be re-calculated for all submeshes
  29965. */
  29966. protected _markAllSubMeshesAsPrePassDirty(): void;
  29967. /**
  29968. * Indicates that textures and misc need to be re-calculated for all submeshes
  29969. */
  29970. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29971. /**
  29972. * Sets the required values to the prepass renderer.
  29973. * @param prePassRenderer defines the prepass renderer to setup.
  29974. * @returns true if the pre pass is needed.
  29975. */
  29976. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29977. /**
  29978. * Disposes the material
  29979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29981. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29982. */
  29983. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29984. /** @hidden */
  29985. private releaseVertexArrayObject;
  29986. /**
  29987. * Serializes this material
  29988. * @returns the serialized material object
  29989. */
  29990. serialize(): any;
  29991. /**
  29992. * Creates a material from parsed material data
  29993. * @param parsedMaterial defines parsed material data
  29994. * @param scene defines the hosting scene
  29995. * @param rootUrl defines the root URL to use to load textures
  29996. * @returns a new material
  29997. */
  29998. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29999. }
  30000. }
  30001. declare module BABYLON {
  30002. /**
  30003. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30004. * separate meshes. This can be use to improve performances.
  30005. * @see https://doc.babylonjs.com/how_to/multi_materials
  30006. */
  30007. export class MultiMaterial extends Material {
  30008. private _subMaterials;
  30009. /**
  30010. * Gets or Sets the list of Materials used within the multi material.
  30011. * They need to be ordered according to the submeshes order in the associated mesh
  30012. */
  30013. get subMaterials(): Nullable<Material>[];
  30014. set subMaterials(value: Nullable<Material>[]);
  30015. /**
  30016. * Function used to align with Node.getChildren()
  30017. * @returns the list of Materials used within the multi material
  30018. */
  30019. getChildren(): Nullable<Material>[];
  30020. /**
  30021. * Instantiates a new Multi Material
  30022. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30023. * separate meshes. This can be use to improve performances.
  30024. * @see https://doc.babylonjs.com/how_to/multi_materials
  30025. * @param name Define the name in the scene
  30026. * @param scene Define the scene the material belongs to
  30027. */
  30028. constructor(name: string, scene: Scene);
  30029. private _hookArray;
  30030. /**
  30031. * Get one of the submaterial by its index in the submaterials array
  30032. * @param index The index to look the sub material at
  30033. * @returns The Material if the index has been defined
  30034. */
  30035. getSubMaterial(index: number): Nullable<Material>;
  30036. /**
  30037. * Get the list of active textures for the whole sub materials list.
  30038. * @returns All the textures that will be used during the rendering
  30039. */
  30040. getActiveTextures(): BaseTexture[];
  30041. /**
  30042. * Specifies if any sub-materials of this multi-material use a given texture.
  30043. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30044. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30045. */
  30046. hasTexture(texture: BaseTexture): boolean;
  30047. /**
  30048. * Gets the current class name of the material e.g. "MultiMaterial"
  30049. * Mainly use in serialization.
  30050. * @returns the class name
  30051. */
  30052. getClassName(): string;
  30053. /**
  30054. * Checks if the material is ready to render the requested sub mesh
  30055. * @param mesh Define the mesh the submesh belongs to
  30056. * @param subMesh Define the sub mesh to look readyness for
  30057. * @param useInstances Define whether or not the material is used with instances
  30058. * @returns true if ready, otherwise false
  30059. */
  30060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30061. /**
  30062. * Clones the current material and its related sub materials
  30063. * @param name Define the name of the newly cloned material
  30064. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30065. * @returns the cloned material
  30066. */
  30067. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30068. /**
  30069. * Serializes the materials into a JSON representation.
  30070. * @returns the JSON representation
  30071. */
  30072. serialize(): any;
  30073. /**
  30074. * Dispose the material and release its associated resources
  30075. * @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)
  30076. * @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)
  30077. * @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)
  30078. */
  30079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30080. /**
  30081. * Creates a MultiMaterial from parsed MultiMaterial data.
  30082. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30083. * @param scene defines the hosting scene
  30084. * @returns a new MultiMaterial
  30085. */
  30086. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30087. }
  30088. }
  30089. declare module BABYLON {
  30090. /**
  30091. * Defines a subdivision inside a mesh
  30092. */
  30093. export class SubMesh implements ICullable {
  30094. /** the material index to use */
  30095. materialIndex: number;
  30096. /** vertex index start */
  30097. verticesStart: number;
  30098. /** vertices count */
  30099. verticesCount: number;
  30100. /** index start */
  30101. indexStart: number;
  30102. /** indices count */
  30103. indexCount: number;
  30104. /** @hidden */
  30105. _materialDefines: Nullable<MaterialDefines>;
  30106. /** @hidden */
  30107. _materialEffect: Nullable<Effect>;
  30108. /** @hidden */
  30109. _effectOverride: Nullable<Effect>;
  30110. /**
  30111. * Gets material defines used by the effect associated to the sub mesh
  30112. */
  30113. get materialDefines(): Nullable<MaterialDefines>;
  30114. /**
  30115. * Sets material defines used by the effect associated to the sub mesh
  30116. */
  30117. set materialDefines(defines: Nullable<MaterialDefines>);
  30118. /**
  30119. * Gets associated effect
  30120. */
  30121. get effect(): Nullable<Effect>;
  30122. /**
  30123. * Sets associated effect (effect used to render this submesh)
  30124. * @param effect defines the effect to associate with
  30125. * @param defines defines the set of defines used to compile this effect
  30126. */
  30127. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30128. /** @hidden */
  30129. _linesIndexCount: number;
  30130. private _mesh;
  30131. private _renderingMesh;
  30132. private _boundingInfo;
  30133. private _linesIndexBuffer;
  30134. /** @hidden */
  30135. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30136. /** @hidden */
  30137. _trianglePlanes: Plane[];
  30138. /** @hidden */
  30139. _lastColliderTransformMatrix: Nullable<Matrix>;
  30140. /** @hidden */
  30141. _renderId: number;
  30142. /** @hidden */
  30143. _alphaIndex: number;
  30144. /** @hidden */
  30145. _distanceToCamera: number;
  30146. /** @hidden */
  30147. _id: number;
  30148. private _currentMaterial;
  30149. /**
  30150. * Add a new submesh to a mesh
  30151. * @param materialIndex defines the material index to use
  30152. * @param verticesStart defines vertex index start
  30153. * @param verticesCount defines vertices count
  30154. * @param indexStart defines index start
  30155. * @param indexCount defines indices count
  30156. * @param mesh defines the parent mesh
  30157. * @param renderingMesh defines an optional rendering mesh
  30158. * @param createBoundingBox defines if bounding box should be created for this submesh
  30159. * @returns the new submesh
  30160. */
  30161. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30162. /**
  30163. * Creates a new submesh
  30164. * @param materialIndex defines the material index to use
  30165. * @param verticesStart defines vertex index start
  30166. * @param verticesCount defines vertices count
  30167. * @param indexStart defines index start
  30168. * @param indexCount defines indices count
  30169. * @param mesh defines the parent mesh
  30170. * @param renderingMesh defines an optional rendering mesh
  30171. * @param createBoundingBox defines if bounding box should be created for this submesh
  30172. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30173. */
  30174. constructor(
  30175. /** the material index to use */
  30176. materialIndex: number,
  30177. /** vertex index start */
  30178. verticesStart: number,
  30179. /** vertices count */
  30180. verticesCount: number,
  30181. /** index start */
  30182. indexStart: number,
  30183. /** indices count */
  30184. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30185. /**
  30186. * Returns true if this submesh covers the entire parent mesh
  30187. * @ignorenaming
  30188. */
  30189. get IsGlobal(): boolean;
  30190. /**
  30191. * Returns the submesh BoudingInfo object
  30192. * @returns current bounding info (or mesh's one if the submesh is global)
  30193. */
  30194. getBoundingInfo(): BoundingInfo;
  30195. /**
  30196. * Sets the submesh BoundingInfo
  30197. * @param boundingInfo defines the new bounding info to use
  30198. * @returns the SubMesh
  30199. */
  30200. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30201. /**
  30202. * Returns the mesh of the current submesh
  30203. * @return the parent mesh
  30204. */
  30205. getMesh(): AbstractMesh;
  30206. /**
  30207. * Returns the rendering mesh of the submesh
  30208. * @returns the rendering mesh (could be different from parent mesh)
  30209. */
  30210. getRenderingMesh(): Mesh;
  30211. /**
  30212. * Returns the replacement mesh of the submesh
  30213. * @returns the replacement mesh (could be different from parent mesh)
  30214. */
  30215. getReplacementMesh(): Nullable<AbstractMesh>;
  30216. /**
  30217. * Returns the effective mesh of the submesh
  30218. * @returns the effective mesh (could be different from parent mesh)
  30219. */
  30220. getEffectiveMesh(): AbstractMesh;
  30221. /**
  30222. * Returns the submesh material
  30223. * @returns null or the current material
  30224. */
  30225. getMaterial(): Nullable<Material>;
  30226. private _IsMultiMaterial;
  30227. /**
  30228. * Sets a new updated BoundingInfo object to the submesh
  30229. * @param data defines an optional position array to use to determine the bounding info
  30230. * @returns the SubMesh
  30231. */
  30232. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30233. /** @hidden */
  30234. _checkCollision(collider: Collider): boolean;
  30235. /**
  30236. * Updates the submesh BoundingInfo
  30237. * @param world defines the world matrix to use to update the bounding info
  30238. * @returns the submesh
  30239. */
  30240. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30241. /**
  30242. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30243. * @param frustumPlanes defines the frustum planes
  30244. * @returns true if the submesh is intersecting with the frustum
  30245. */
  30246. isInFrustum(frustumPlanes: Plane[]): boolean;
  30247. /**
  30248. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30249. * @param frustumPlanes defines the frustum planes
  30250. * @returns true if the submesh is inside the frustum
  30251. */
  30252. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30253. /**
  30254. * Renders the submesh
  30255. * @param enableAlphaMode defines if alpha needs to be used
  30256. * @returns the submesh
  30257. */
  30258. render(enableAlphaMode: boolean): SubMesh;
  30259. /**
  30260. * @hidden
  30261. */
  30262. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30263. /**
  30264. * Checks if the submesh intersects with a ray
  30265. * @param ray defines the ray to test
  30266. * @returns true is the passed ray intersects the submesh bounding box
  30267. */
  30268. canIntersects(ray: Ray): boolean;
  30269. /**
  30270. * Intersects current submesh with a ray
  30271. * @param ray defines the ray to test
  30272. * @param positions defines mesh's positions array
  30273. * @param indices defines mesh's indices array
  30274. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30275. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30276. * @returns intersection info or null if no intersection
  30277. */
  30278. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30279. /** @hidden */
  30280. private _intersectLines;
  30281. /** @hidden */
  30282. private _intersectUnIndexedLines;
  30283. /** @hidden */
  30284. private _intersectTriangles;
  30285. /** @hidden */
  30286. private _intersectUnIndexedTriangles;
  30287. /** @hidden */
  30288. _rebuild(): void;
  30289. /**
  30290. * Creates a new submesh from the passed mesh
  30291. * @param newMesh defines the new hosting mesh
  30292. * @param newRenderingMesh defines an optional rendering mesh
  30293. * @returns the new submesh
  30294. */
  30295. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30296. /**
  30297. * Release associated resources
  30298. */
  30299. dispose(): void;
  30300. /**
  30301. * Gets the class name
  30302. * @returns the string "SubMesh".
  30303. */
  30304. getClassName(): string;
  30305. /**
  30306. * Creates a new submesh from indices data
  30307. * @param materialIndex the index of the main mesh material
  30308. * @param startIndex the index where to start the copy in the mesh indices array
  30309. * @param indexCount the number of indices to copy then from the startIndex
  30310. * @param mesh the main mesh to create the submesh from
  30311. * @param renderingMesh the optional rendering mesh
  30312. * @returns a new submesh
  30313. */
  30314. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30315. }
  30316. }
  30317. declare module BABYLON {
  30318. /**
  30319. * Class used to represent data loading progression
  30320. */
  30321. export class SceneLoaderFlags {
  30322. private static _ForceFullSceneLoadingForIncremental;
  30323. private static _ShowLoadingScreen;
  30324. private static _CleanBoneMatrixWeights;
  30325. private static _loggingLevel;
  30326. /**
  30327. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30328. */
  30329. static get ForceFullSceneLoadingForIncremental(): boolean;
  30330. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30331. /**
  30332. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30333. */
  30334. static get ShowLoadingScreen(): boolean;
  30335. static set ShowLoadingScreen(value: boolean);
  30336. /**
  30337. * Defines the current logging level (while loading the scene)
  30338. * @ignorenaming
  30339. */
  30340. static get loggingLevel(): number;
  30341. static set loggingLevel(value: number);
  30342. /**
  30343. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30344. */
  30345. static get CleanBoneMatrixWeights(): boolean;
  30346. static set CleanBoneMatrixWeights(value: boolean);
  30347. }
  30348. }
  30349. declare module BABYLON {
  30350. /**
  30351. * Class used to store geometry data (vertex buffers + index buffer)
  30352. */
  30353. export class Geometry implements IGetSetVerticesData {
  30354. /**
  30355. * Gets or sets the ID of the geometry
  30356. */
  30357. id: string;
  30358. /**
  30359. * Gets or sets the unique ID of the geometry
  30360. */
  30361. uniqueId: number;
  30362. /**
  30363. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30364. */
  30365. delayLoadState: number;
  30366. /**
  30367. * Gets the file containing the data to load when running in delay load state
  30368. */
  30369. delayLoadingFile: Nullable<string>;
  30370. /**
  30371. * Callback called when the geometry is updated
  30372. */
  30373. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30374. private _scene;
  30375. private _engine;
  30376. private _meshes;
  30377. private _totalVertices;
  30378. /** @hidden */
  30379. _indices: IndicesArray;
  30380. /** @hidden */
  30381. _vertexBuffers: {
  30382. [key: string]: VertexBuffer;
  30383. };
  30384. private _isDisposed;
  30385. private _extend;
  30386. private _boundingBias;
  30387. /** @hidden */
  30388. _delayInfo: Array<string>;
  30389. private _indexBuffer;
  30390. private _indexBufferIsUpdatable;
  30391. /** @hidden */
  30392. _boundingInfo: Nullable<BoundingInfo>;
  30393. /** @hidden */
  30394. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30395. /** @hidden */
  30396. _softwareSkinningFrameId: number;
  30397. private _vertexArrayObjects;
  30398. private _updatable;
  30399. /** @hidden */
  30400. _positions: Nullable<Vector3[]>;
  30401. private _positionsCache;
  30402. /**
  30403. * 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
  30404. */
  30405. get boundingBias(): Vector2;
  30406. /**
  30407. * 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
  30408. */
  30409. set boundingBias(value: Vector2);
  30410. /**
  30411. * Static function used to attach a new empty geometry to a mesh
  30412. * @param mesh defines the mesh to attach the geometry to
  30413. * @returns the new Geometry
  30414. */
  30415. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30416. /** Get the list of meshes using this geometry */
  30417. get meshes(): Mesh[];
  30418. /**
  30419. * 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
  30420. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30421. */
  30422. useBoundingInfoFromGeometry: boolean;
  30423. /**
  30424. * Creates a new geometry
  30425. * @param id defines the unique ID
  30426. * @param scene defines the hosting scene
  30427. * @param vertexData defines the VertexData used to get geometry data
  30428. * @param updatable defines if geometry must be updatable (false by default)
  30429. * @param mesh defines the mesh that will be associated with the geometry
  30430. */
  30431. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30432. /**
  30433. * Gets the current extend of the geometry
  30434. */
  30435. get extend(): {
  30436. minimum: Vector3;
  30437. maximum: Vector3;
  30438. };
  30439. /**
  30440. * Gets the hosting scene
  30441. * @returns the hosting Scene
  30442. */
  30443. getScene(): Scene;
  30444. /**
  30445. * Gets the hosting engine
  30446. * @returns the hosting Engine
  30447. */
  30448. getEngine(): Engine;
  30449. /**
  30450. * Defines if the geometry is ready to use
  30451. * @returns true if the geometry is ready to be used
  30452. */
  30453. isReady(): boolean;
  30454. /**
  30455. * Gets a value indicating that the geometry should not be serialized
  30456. */
  30457. get doNotSerialize(): boolean;
  30458. /** @hidden */
  30459. _rebuild(): void;
  30460. /**
  30461. * Affects all geometry data in one call
  30462. * @param vertexData defines the geometry data
  30463. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30464. */
  30465. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30466. /**
  30467. * Set specific vertex data
  30468. * @param kind defines the data kind (Position, normal, etc...)
  30469. * @param data defines the vertex data to use
  30470. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30471. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30472. */
  30473. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30474. /**
  30475. * Removes a specific vertex data
  30476. * @param kind defines the data kind (Position, normal, etc...)
  30477. */
  30478. removeVerticesData(kind: string): void;
  30479. /**
  30480. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30481. * @param buffer defines the vertex buffer to use
  30482. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30483. */
  30484. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30485. /**
  30486. * Update a specific vertex buffer
  30487. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30488. * It will do nothing if the buffer is not updatable
  30489. * @param kind defines the data kind (Position, normal, etc...)
  30490. * @param data defines the data to use
  30491. * @param offset defines the offset in the target buffer where to store the data
  30492. * @param useBytes set to true if the offset is in bytes
  30493. */
  30494. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30495. /**
  30496. * Update a specific vertex buffer
  30497. * This function will create a new buffer if the current one is not updatable
  30498. * @param kind defines the data kind (Position, normal, etc...)
  30499. * @param data defines the data to use
  30500. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30501. */
  30502. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30503. private _updateBoundingInfo;
  30504. /** @hidden */
  30505. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30506. /**
  30507. * Gets total number of vertices
  30508. * @returns the total number of vertices
  30509. */
  30510. getTotalVertices(): number;
  30511. /**
  30512. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30513. * @param kind defines the data kind (Position, normal, etc...)
  30514. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30515. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30516. * @returns a float array containing vertex data
  30517. */
  30518. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30519. /**
  30520. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30521. * @param kind defines the data kind (Position, normal, etc...)
  30522. * @returns true if the vertex buffer with the specified kind is updatable
  30523. */
  30524. isVertexBufferUpdatable(kind: string): boolean;
  30525. /**
  30526. * Gets a specific vertex buffer
  30527. * @param kind defines the data kind (Position, normal, etc...)
  30528. * @returns a VertexBuffer
  30529. */
  30530. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30531. /**
  30532. * Returns all vertex buffers
  30533. * @return an object holding all vertex buffers indexed by kind
  30534. */
  30535. getVertexBuffers(): Nullable<{
  30536. [key: string]: VertexBuffer;
  30537. }>;
  30538. /**
  30539. * Gets a boolean indicating if specific vertex buffer is present
  30540. * @param kind defines the data kind (Position, normal, etc...)
  30541. * @returns true if data is present
  30542. */
  30543. isVerticesDataPresent(kind: string): boolean;
  30544. /**
  30545. * Gets a list of all attached data kinds (Position, normal, etc...)
  30546. * @returns a list of string containing all kinds
  30547. */
  30548. getVerticesDataKinds(): string[];
  30549. /**
  30550. * Update index buffer
  30551. * @param indices defines the indices to store in the index buffer
  30552. * @param offset defines the offset in the target buffer where to store the data
  30553. * @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)
  30554. */
  30555. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30556. /**
  30557. * Creates a new index buffer
  30558. * @param indices defines the indices to store in the index buffer
  30559. * @param totalVertices defines the total number of vertices (could be null)
  30560. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30561. */
  30562. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30563. /**
  30564. * Return the total number of indices
  30565. * @returns the total number of indices
  30566. */
  30567. getTotalIndices(): number;
  30568. /**
  30569. * Gets the index buffer array
  30570. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30572. * @returns the index buffer array
  30573. */
  30574. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30575. /**
  30576. * Gets the index buffer
  30577. * @return the index buffer
  30578. */
  30579. getIndexBuffer(): Nullable<DataBuffer>;
  30580. /** @hidden */
  30581. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30582. /**
  30583. * Release the associated resources for a specific mesh
  30584. * @param mesh defines the source mesh
  30585. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30586. */
  30587. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30588. /**
  30589. * Apply current geometry to a given mesh
  30590. * @param mesh defines the mesh to apply geometry to
  30591. */
  30592. applyToMesh(mesh: Mesh): void;
  30593. private _updateExtend;
  30594. private _applyToMesh;
  30595. private notifyUpdate;
  30596. /**
  30597. * Load the geometry if it was flagged as delay loaded
  30598. * @param scene defines the hosting scene
  30599. * @param onLoaded defines a callback called when the geometry is loaded
  30600. */
  30601. load(scene: Scene, onLoaded?: () => void): void;
  30602. private _queueLoad;
  30603. /**
  30604. * Invert the geometry to move from a right handed system to a left handed one.
  30605. */
  30606. toLeftHanded(): void;
  30607. /** @hidden */
  30608. _resetPointsArrayCache(): void;
  30609. /** @hidden */
  30610. _generatePointsArray(): boolean;
  30611. /**
  30612. * Gets a value indicating if the geometry is disposed
  30613. * @returns true if the geometry was disposed
  30614. */
  30615. isDisposed(): boolean;
  30616. private _disposeVertexArrayObjects;
  30617. /**
  30618. * Free all associated resources
  30619. */
  30620. dispose(): void;
  30621. /**
  30622. * Clone the current geometry into a new geometry
  30623. * @param id defines the unique ID of the new geometry
  30624. * @returns a new geometry object
  30625. */
  30626. copy(id: string): Geometry;
  30627. /**
  30628. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30629. * @return a JSON representation of the current geometry data (without the vertices data)
  30630. */
  30631. serialize(): any;
  30632. private toNumberArray;
  30633. /**
  30634. * Serialize all vertices data into a JSON oject
  30635. * @returns a JSON representation of the current geometry data
  30636. */
  30637. serializeVerticeData(): any;
  30638. /**
  30639. * Extracts a clone of a mesh geometry
  30640. * @param mesh defines the source mesh
  30641. * @param id defines the unique ID of the new geometry object
  30642. * @returns the new geometry object
  30643. */
  30644. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30645. /**
  30646. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30647. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30648. * Be aware Math.random() could cause collisions, but:
  30649. * "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"
  30650. * @returns a string containing a new GUID
  30651. */
  30652. static RandomId(): string;
  30653. /** @hidden */
  30654. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30655. private static _CleanMatricesWeights;
  30656. /**
  30657. * Create a new geometry from persisted data (Using .babylon file format)
  30658. * @param parsedVertexData defines the persisted data
  30659. * @param scene defines the hosting scene
  30660. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30661. * @returns the new geometry object
  30662. */
  30663. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30664. }
  30665. }
  30666. declare module BABYLON {
  30667. /**
  30668. * Defines a target to use with MorphTargetManager
  30669. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30670. */
  30671. export class MorphTarget implements IAnimatable {
  30672. /** defines the name of the target */
  30673. name: string;
  30674. /**
  30675. * Gets or sets the list of animations
  30676. */
  30677. animations: Animation[];
  30678. private _scene;
  30679. private _positions;
  30680. private _normals;
  30681. private _tangents;
  30682. private _uvs;
  30683. private _influence;
  30684. private _uniqueId;
  30685. /**
  30686. * Observable raised when the influence changes
  30687. */
  30688. onInfluenceChanged: Observable<boolean>;
  30689. /** @hidden */
  30690. _onDataLayoutChanged: Observable<void>;
  30691. /**
  30692. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30693. */
  30694. get influence(): number;
  30695. set influence(influence: number);
  30696. /**
  30697. * Gets or sets the id of the morph Target
  30698. */
  30699. id: string;
  30700. private _animationPropertiesOverride;
  30701. /**
  30702. * Gets or sets the animation properties override
  30703. */
  30704. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30705. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30706. /**
  30707. * Creates a new MorphTarget
  30708. * @param name defines the name of the target
  30709. * @param influence defines the influence to use
  30710. * @param scene defines the scene the morphtarget belongs to
  30711. */
  30712. constructor(
  30713. /** defines the name of the target */
  30714. name: string, influence?: number, scene?: Nullable<Scene>);
  30715. /**
  30716. * Gets the unique ID of this manager
  30717. */
  30718. get uniqueId(): number;
  30719. /**
  30720. * Gets a boolean defining if the target contains position data
  30721. */
  30722. get hasPositions(): boolean;
  30723. /**
  30724. * Gets a boolean defining if the target contains normal data
  30725. */
  30726. get hasNormals(): boolean;
  30727. /**
  30728. * Gets a boolean defining if the target contains tangent data
  30729. */
  30730. get hasTangents(): boolean;
  30731. /**
  30732. * Gets a boolean defining if the target contains texture coordinates data
  30733. */
  30734. get hasUVs(): boolean;
  30735. /**
  30736. * Affects position data to this target
  30737. * @param data defines the position data to use
  30738. */
  30739. setPositions(data: Nullable<FloatArray>): void;
  30740. /**
  30741. * Gets the position data stored in this target
  30742. * @returns a FloatArray containing the position data (or null if not present)
  30743. */
  30744. getPositions(): Nullable<FloatArray>;
  30745. /**
  30746. * Affects normal data to this target
  30747. * @param data defines the normal data to use
  30748. */
  30749. setNormals(data: Nullable<FloatArray>): void;
  30750. /**
  30751. * Gets the normal data stored in this target
  30752. * @returns a FloatArray containing the normal data (or null if not present)
  30753. */
  30754. getNormals(): Nullable<FloatArray>;
  30755. /**
  30756. * Affects tangent data to this target
  30757. * @param data defines the tangent data to use
  30758. */
  30759. setTangents(data: Nullable<FloatArray>): void;
  30760. /**
  30761. * Gets the tangent data stored in this target
  30762. * @returns a FloatArray containing the tangent data (or null if not present)
  30763. */
  30764. getTangents(): Nullable<FloatArray>;
  30765. /**
  30766. * Affects texture coordinates data to this target
  30767. * @param data defines the texture coordinates data to use
  30768. */
  30769. setUVs(data: Nullable<FloatArray>): void;
  30770. /**
  30771. * Gets the texture coordinates data stored in this target
  30772. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30773. */
  30774. getUVs(): Nullable<FloatArray>;
  30775. /**
  30776. * Clone the current target
  30777. * @returns a new MorphTarget
  30778. */
  30779. clone(): MorphTarget;
  30780. /**
  30781. * Serializes the current target into a Serialization object
  30782. * @returns the serialized object
  30783. */
  30784. serialize(): any;
  30785. /**
  30786. * Returns the string "MorphTarget"
  30787. * @returns "MorphTarget"
  30788. */
  30789. getClassName(): string;
  30790. /**
  30791. * Creates a new target from serialized data
  30792. * @param serializationObject defines the serialized data to use
  30793. * @returns a new MorphTarget
  30794. */
  30795. static Parse(serializationObject: any): MorphTarget;
  30796. /**
  30797. * Creates a MorphTarget from mesh data
  30798. * @param mesh defines the source mesh
  30799. * @param name defines the name to use for the new target
  30800. * @param influence defines the influence to attach to the target
  30801. * @returns a new MorphTarget
  30802. */
  30803. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30804. }
  30805. }
  30806. declare module BABYLON {
  30807. /**
  30808. * This class is used to deform meshes using morphing between different targets
  30809. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30810. */
  30811. export class MorphTargetManager {
  30812. private _targets;
  30813. private _targetInfluenceChangedObservers;
  30814. private _targetDataLayoutChangedObservers;
  30815. private _activeTargets;
  30816. private _scene;
  30817. private _influences;
  30818. private _supportsNormals;
  30819. private _supportsTangents;
  30820. private _supportsUVs;
  30821. private _vertexCount;
  30822. private _uniqueId;
  30823. private _tempInfluences;
  30824. /**
  30825. * Gets or sets a boolean indicating if normals must be morphed
  30826. */
  30827. enableNormalMorphing: boolean;
  30828. /**
  30829. * Gets or sets a boolean indicating if tangents must be morphed
  30830. */
  30831. enableTangentMorphing: boolean;
  30832. /**
  30833. * Gets or sets a boolean indicating if UV must be morphed
  30834. */
  30835. enableUVMorphing: boolean;
  30836. /**
  30837. * Creates a new MorphTargetManager
  30838. * @param scene defines the current scene
  30839. */
  30840. constructor(scene?: Nullable<Scene>);
  30841. /**
  30842. * Gets the unique ID of this manager
  30843. */
  30844. get uniqueId(): number;
  30845. /**
  30846. * Gets the number of vertices handled by this manager
  30847. */
  30848. get vertexCount(): number;
  30849. /**
  30850. * Gets a boolean indicating if this manager supports morphing of normals
  30851. */
  30852. get supportsNormals(): boolean;
  30853. /**
  30854. * Gets a boolean indicating if this manager supports morphing of tangents
  30855. */
  30856. get supportsTangents(): boolean;
  30857. /**
  30858. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30859. */
  30860. get supportsUVs(): boolean;
  30861. /**
  30862. * Gets the number of targets stored in this manager
  30863. */
  30864. get numTargets(): number;
  30865. /**
  30866. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30867. */
  30868. get numInfluencers(): number;
  30869. /**
  30870. * Gets the list of influences (one per target)
  30871. */
  30872. get influences(): Float32Array;
  30873. /**
  30874. * Gets the active target at specified index. An active target is a target with an influence > 0
  30875. * @param index defines the index to check
  30876. * @returns the requested target
  30877. */
  30878. getActiveTarget(index: number): MorphTarget;
  30879. /**
  30880. * Gets the target at specified index
  30881. * @param index defines the index to check
  30882. * @returns the requested target
  30883. */
  30884. getTarget(index: number): MorphTarget;
  30885. /**
  30886. * Add a new target to this manager
  30887. * @param target defines the target to add
  30888. */
  30889. addTarget(target: MorphTarget): void;
  30890. /**
  30891. * Removes a target from the manager
  30892. * @param target defines the target to remove
  30893. */
  30894. removeTarget(target: MorphTarget): void;
  30895. /**
  30896. * Clone the current manager
  30897. * @returns a new MorphTargetManager
  30898. */
  30899. clone(): MorphTargetManager;
  30900. /**
  30901. * Serializes the current manager into a Serialization object
  30902. * @returns the serialized object
  30903. */
  30904. serialize(): any;
  30905. private _syncActiveTargets;
  30906. /**
  30907. * Syncrhonize the targets with all the meshes using this morph target manager
  30908. */
  30909. synchronize(): void;
  30910. /**
  30911. * Creates a new MorphTargetManager from serialized data
  30912. * @param serializationObject defines the serialized data
  30913. * @param scene defines the hosting scene
  30914. * @returns the new MorphTargetManager
  30915. */
  30916. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30917. }
  30918. }
  30919. declare module BABYLON {
  30920. /**
  30921. * Class used to represent a specific level of detail of a mesh
  30922. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30923. */
  30924. export class MeshLODLevel {
  30925. /** Defines the distance where this level should start being displayed */
  30926. distance: number;
  30927. /** Defines the mesh to use to render this level */
  30928. mesh: Nullable<Mesh>;
  30929. /**
  30930. * Creates a new LOD level
  30931. * @param distance defines the distance where this level should star being displayed
  30932. * @param mesh defines the mesh to use to render this level
  30933. */
  30934. constructor(
  30935. /** Defines the distance where this level should start being displayed */
  30936. distance: number,
  30937. /** Defines the mesh to use to render this level */
  30938. mesh: Nullable<Mesh>);
  30939. }
  30940. }
  30941. declare module BABYLON {
  30942. /**
  30943. * Helper class used to generate a canvas to manipulate images
  30944. */
  30945. export class CanvasGenerator {
  30946. /**
  30947. * Create a new canvas (or offscreen canvas depending on the context)
  30948. * @param width defines the expected width
  30949. * @param height defines the expected height
  30950. * @return a new canvas or offscreen canvas
  30951. */
  30952. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30953. }
  30954. }
  30955. declare module BABYLON {
  30956. /**
  30957. * Mesh representing the gorund
  30958. */
  30959. export class GroundMesh extends Mesh {
  30960. /** If octree should be generated */
  30961. generateOctree: boolean;
  30962. private _heightQuads;
  30963. /** @hidden */
  30964. _subdivisionsX: number;
  30965. /** @hidden */
  30966. _subdivisionsY: number;
  30967. /** @hidden */
  30968. _width: number;
  30969. /** @hidden */
  30970. _height: number;
  30971. /** @hidden */
  30972. _minX: number;
  30973. /** @hidden */
  30974. _maxX: number;
  30975. /** @hidden */
  30976. _minZ: number;
  30977. /** @hidden */
  30978. _maxZ: number;
  30979. constructor(name: string, scene: Scene);
  30980. /**
  30981. * "GroundMesh"
  30982. * @returns "GroundMesh"
  30983. */
  30984. getClassName(): string;
  30985. /**
  30986. * The minimum of x and y subdivisions
  30987. */
  30988. get subdivisions(): number;
  30989. /**
  30990. * X subdivisions
  30991. */
  30992. get subdivisionsX(): number;
  30993. /**
  30994. * Y subdivisions
  30995. */
  30996. get subdivisionsY(): number;
  30997. /**
  30998. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30999. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31000. * @param chunksCount the number of subdivisions for x and y
  31001. * @param octreeBlocksSize (Default: 32)
  31002. */
  31003. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31004. /**
  31005. * Returns a height (y) value in the Worl system :
  31006. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31007. * @param x x coordinate
  31008. * @param z z coordinate
  31009. * @returns the ground y position if (x, z) are outside the ground surface.
  31010. */
  31011. getHeightAtCoordinates(x: number, z: number): number;
  31012. /**
  31013. * Returns a normalized vector (Vector3) orthogonal to the ground
  31014. * at the ground coordinates (x, z) expressed in the World system.
  31015. * @param x x coordinate
  31016. * @param z z coordinate
  31017. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31018. */
  31019. getNormalAtCoordinates(x: number, z: number): Vector3;
  31020. /**
  31021. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31022. * at the ground coordinates (x, z) expressed in the World system.
  31023. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31024. * @param x x coordinate
  31025. * @param z z coordinate
  31026. * @param ref vector to store the result
  31027. * @returns the GroundMesh.
  31028. */
  31029. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31030. /**
  31031. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31032. * if the ground has been updated.
  31033. * This can be used in the render loop.
  31034. * @returns the GroundMesh.
  31035. */
  31036. updateCoordinateHeights(): GroundMesh;
  31037. private _getFacetAt;
  31038. private _initHeightQuads;
  31039. private _computeHeightQuads;
  31040. /**
  31041. * Serializes this ground mesh
  31042. * @param serializationObject object to write serialization to
  31043. */
  31044. serialize(serializationObject: any): void;
  31045. /**
  31046. * Parses a serialized ground mesh
  31047. * @param parsedMesh the serialized mesh
  31048. * @param scene the scene to create the ground mesh in
  31049. * @returns the created ground mesh
  31050. */
  31051. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31052. }
  31053. }
  31054. declare module BABYLON {
  31055. /**
  31056. * Interface for Physics-Joint data
  31057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31058. */
  31059. export interface PhysicsJointData {
  31060. /**
  31061. * The main pivot of the joint
  31062. */
  31063. mainPivot?: Vector3;
  31064. /**
  31065. * The connected pivot of the joint
  31066. */
  31067. connectedPivot?: Vector3;
  31068. /**
  31069. * The main axis of the joint
  31070. */
  31071. mainAxis?: Vector3;
  31072. /**
  31073. * The connected axis of the joint
  31074. */
  31075. connectedAxis?: Vector3;
  31076. /**
  31077. * The collision of the joint
  31078. */
  31079. collision?: boolean;
  31080. /**
  31081. * Native Oimo/Cannon/Energy data
  31082. */
  31083. nativeParams?: any;
  31084. }
  31085. /**
  31086. * This is a holder class for the physics joint created by the physics plugin
  31087. * It holds a set of functions to control the underlying joint
  31088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31089. */
  31090. export class PhysicsJoint {
  31091. /**
  31092. * The type of the physics joint
  31093. */
  31094. type: number;
  31095. /**
  31096. * The data for the physics joint
  31097. */
  31098. jointData: PhysicsJointData;
  31099. private _physicsJoint;
  31100. protected _physicsPlugin: IPhysicsEnginePlugin;
  31101. /**
  31102. * Initializes the physics joint
  31103. * @param type The type of the physics joint
  31104. * @param jointData The data for the physics joint
  31105. */
  31106. constructor(
  31107. /**
  31108. * The type of the physics joint
  31109. */
  31110. type: number,
  31111. /**
  31112. * The data for the physics joint
  31113. */
  31114. jointData: PhysicsJointData);
  31115. /**
  31116. * Gets the physics joint
  31117. */
  31118. get physicsJoint(): any;
  31119. /**
  31120. * Sets the physics joint
  31121. */
  31122. set physicsJoint(newJoint: any);
  31123. /**
  31124. * Sets the physics plugin
  31125. */
  31126. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31127. /**
  31128. * Execute a function that is physics-plugin specific.
  31129. * @param {Function} func the function that will be executed.
  31130. * It accepts two parameters: the physics world and the physics joint
  31131. */
  31132. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31133. /**
  31134. * Distance-Joint type
  31135. */
  31136. static DistanceJoint: number;
  31137. /**
  31138. * Hinge-Joint type
  31139. */
  31140. static HingeJoint: number;
  31141. /**
  31142. * Ball-and-Socket joint type
  31143. */
  31144. static BallAndSocketJoint: number;
  31145. /**
  31146. * Wheel-Joint type
  31147. */
  31148. static WheelJoint: number;
  31149. /**
  31150. * Slider-Joint type
  31151. */
  31152. static SliderJoint: number;
  31153. /**
  31154. * Prismatic-Joint type
  31155. */
  31156. static PrismaticJoint: number;
  31157. /**
  31158. * Universal-Joint type
  31159. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31160. */
  31161. static UniversalJoint: number;
  31162. /**
  31163. * Hinge-Joint 2 type
  31164. */
  31165. static Hinge2Joint: number;
  31166. /**
  31167. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31168. */
  31169. static PointToPointJoint: number;
  31170. /**
  31171. * Spring-Joint type
  31172. */
  31173. static SpringJoint: number;
  31174. /**
  31175. * Lock-Joint type
  31176. */
  31177. static LockJoint: number;
  31178. }
  31179. /**
  31180. * A class representing a physics distance joint
  31181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31182. */
  31183. export class DistanceJoint extends PhysicsJoint {
  31184. /**
  31185. *
  31186. * @param jointData The data for the Distance-Joint
  31187. */
  31188. constructor(jointData: DistanceJointData);
  31189. /**
  31190. * Update the predefined distance.
  31191. * @param maxDistance The maximum preferred distance
  31192. * @param minDistance The minimum preferred distance
  31193. */
  31194. updateDistance(maxDistance: number, minDistance?: number): void;
  31195. }
  31196. /**
  31197. * Represents a Motor-Enabled Joint
  31198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31199. */
  31200. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31201. /**
  31202. * Initializes the Motor-Enabled Joint
  31203. * @param type The type of the joint
  31204. * @param jointData The physica joint data for the joint
  31205. */
  31206. constructor(type: number, jointData: PhysicsJointData);
  31207. /**
  31208. * Set the motor values.
  31209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31210. * @param force the force to apply
  31211. * @param maxForce max force for this motor.
  31212. */
  31213. setMotor(force?: number, maxForce?: number): void;
  31214. /**
  31215. * Set the motor's limits.
  31216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31217. * @param upperLimit The upper limit of the motor
  31218. * @param lowerLimit The lower limit of the motor
  31219. */
  31220. setLimit(upperLimit: number, lowerLimit?: number): void;
  31221. }
  31222. /**
  31223. * This class represents a single physics Hinge-Joint
  31224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31225. */
  31226. export class HingeJoint extends MotorEnabledJoint {
  31227. /**
  31228. * Initializes the Hinge-Joint
  31229. * @param jointData The joint data for the Hinge-Joint
  31230. */
  31231. constructor(jointData: PhysicsJointData);
  31232. /**
  31233. * Set the motor values.
  31234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31235. * @param {number} force the force to apply
  31236. * @param {number} maxForce max force for this motor.
  31237. */
  31238. setMotor(force?: number, maxForce?: number): void;
  31239. /**
  31240. * Set the motor's limits.
  31241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31242. * @param upperLimit The upper limit of the motor
  31243. * @param lowerLimit The lower limit of the motor
  31244. */
  31245. setLimit(upperLimit: number, lowerLimit?: number): void;
  31246. }
  31247. /**
  31248. * This class represents a dual hinge physics joint (same as wheel joint)
  31249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31250. */
  31251. export class Hinge2Joint extends MotorEnabledJoint {
  31252. /**
  31253. * Initializes the Hinge2-Joint
  31254. * @param jointData The joint data for the Hinge2-Joint
  31255. */
  31256. constructor(jointData: PhysicsJointData);
  31257. /**
  31258. * Set the motor values.
  31259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31260. * @param {number} targetSpeed the speed the motor is to reach
  31261. * @param {number} maxForce max force for this motor.
  31262. * @param {motorIndex} the motor's index, 0 or 1.
  31263. */
  31264. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31265. /**
  31266. * Set the motor limits.
  31267. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31268. * @param {number} upperLimit the upper limit
  31269. * @param {number} lowerLimit lower limit
  31270. * @param {motorIndex} the motor's index, 0 or 1.
  31271. */
  31272. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31273. }
  31274. /**
  31275. * Interface for a motor enabled joint
  31276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31277. */
  31278. export interface IMotorEnabledJoint {
  31279. /**
  31280. * Physics joint
  31281. */
  31282. physicsJoint: any;
  31283. /**
  31284. * Sets the motor of the motor-enabled joint
  31285. * @param force The force of the motor
  31286. * @param maxForce The maximum force of the motor
  31287. * @param motorIndex The index of the motor
  31288. */
  31289. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31290. /**
  31291. * Sets the limit of the motor
  31292. * @param upperLimit The upper limit of the motor
  31293. * @param lowerLimit The lower limit of the motor
  31294. * @param motorIndex The index of the motor
  31295. */
  31296. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31297. }
  31298. /**
  31299. * Joint data for a Distance-Joint
  31300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31301. */
  31302. export interface DistanceJointData extends PhysicsJointData {
  31303. /**
  31304. * Max distance the 2 joint objects can be apart
  31305. */
  31306. maxDistance: number;
  31307. }
  31308. /**
  31309. * Joint data from a spring joint
  31310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31311. */
  31312. export interface SpringJointData extends PhysicsJointData {
  31313. /**
  31314. * Length of the spring
  31315. */
  31316. length: number;
  31317. /**
  31318. * Stiffness of the spring
  31319. */
  31320. stiffness: number;
  31321. /**
  31322. * Damping of the spring
  31323. */
  31324. damping: number;
  31325. /** this callback will be called when applying the force to the impostors. */
  31326. forceApplicationCallback: () => void;
  31327. }
  31328. }
  31329. declare module BABYLON {
  31330. /**
  31331. * Holds the data for the raycast result
  31332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31333. */
  31334. export class PhysicsRaycastResult {
  31335. private _hasHit;
  31336. private _hitDistance;
  31337. private _hitNormalWorld;
  31338. private _hitPointWorld;
  31339. private _rayFromWorld;
  31340. private _rayToWorld;
  31341. /**
  31342. * Gets if there was a hit
  31343. */
  31344. get hasHit(): boolean;
  31345. /**
  31346. * Gets the distance from the hit
  31347. */
  31348. get hitDistance(): number;
  31349. /**
  31350. * Gets the hit normal/direction in the world
  31351. */
  31352. get hitNormalWorld(): Vector3;
  31353. /**
  31354. * Gets the hit point in the world
  31355. */
  31356. get hitPointWorld(): Vector3;
  31357. /**
  31358. * Gets the ray "start point" of the ray in the world
  31359. */
  31360. get rayFromWorld(): Vector3;
  31361. /**
  31362. * Gets the ray "end point" of the ray in the world
  31363. */
  31364. get rayToWorld(): Vector3;
  31365. /**
  31366. * Sets the hit data (normal & point in world space)
  31367. * @param hitNormalWorld defines the normal in world space
  31368. * @param hitPointWorld defines the point in world space
  31369. */
  31370. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31371. /**
  31372. * Sets the distance from the start point to the hit point
  31373. * @param distance
  31374. */
  31375. setHitDistance(distance: number): void;
  31376. /**
  31377. * Calculates the distance manually
  31378. */
  31379. calculateHitDistance(): void;
  31380. /**
  31381. * Resets all the values to default
  31382. * @param from The from point on world space
  31383. * @param to The to point on world space
  31384. */
  31385. reset(from?: Vector3, to?: Vector3): void;
  31386. }
  31387. /**
  31388. * Interface for the size containing width and height
  31389. */
  31390. interface IXYZ {
  31391. /**
  31392. * X
  31393. */
  31394. x: number;
  31395. /**
  31396. * Y
  31397. */
  31398. y: number;
  31399. /**
  31400. * Z
  31401. */
  31402. z: number;
  31403. }
  31404. }
  31405. declare module BABYLON {
  31406. /**
  31407. * Interface used to describe a physics joint
  31408. */
  31409. export interface PhysicsImpostorJoint {
  31410. /** Defines the main impostor to which the joint is linked */
  31411. mainImpostor: PhysicsImpostor;
  31412. /** Defines the impostor that is connected to the main impostor using this joint */
  31413. connectedImpostor: PhysicsImpostor;
  31414. /** Defines the joint itself */
  31415. joint: PhysicsJoint;
  31416. }
  31417. /** @hidden */
  31418. export interface IPhysicsEnginePlugin {
  31419. world: any;
  31420. name: string;
  31421. setGravity(gravity: Vector3): void;
  31422. setTimeStep(timeStep: number): void;
  31423. getTimeStep(): number;
  31424. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31425. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31427. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31428. removePhysicsBody(impostor: PhysicsImpostor): void;
  31429. generateJoint(joint: PhysicsImpostorJoint): void;
  31430. removeJoint(joint: PhysicsImpostorJoint): void;
  31431. isSupported(): boolean;
  31432. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31433. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31434. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31435. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31436. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31437. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31438. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31439. getBodyMass(impostor: PhysicsImpostor): number;
  31440. getBodyFriction(impostor: PhysicsImpostor): number;
  31441. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31442. getBodyRestitution(impostor: PhysicsImpostor): number;
  31443. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31444. getBodyPressure?(impostor: PhysicsImpostor): number;
  31445. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31446. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31447. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31448. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31449. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31450. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31451. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31452. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31453. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31454. sleepBody(impostor: PhysicsImpostor): void;
  31455. wakeUpBody(impostor: PhysicsImpostor): void;
  31456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31457. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31458. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31459. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31460. getRadius(impostor: PhysicsImpostor): number;
  31461. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31463. dispose(): void;
  31464. }
  31465. /**
  31466. * Interface used to define a physics engine
  31467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31468. */
  31469. export interface IPhysicsEngine {
  31470. /**
  31471. * Gets the gravity vector used by the simulation
  31472. */
  31473. gravity: Vector3;
  31474. /**
  31475. * Sets the gravity vector used by the simulation
  31476. * @param gravity defines the gravity vector to use
  31477. */
  31478. setGravity(gravity: Vector3): void;
  31479. /**
  31480. * Set the time step of the physics engine.
  31481. * Default is 1/60.
  31482. * To slow it down, enter 1/600 for example.
  31483. * To speed it up, 1/30
  31484. * @param newTimeStep the new timestep to apply to this world.
  31485. */
  31486. setTimeStep(newTimeStep: number): void;
  31487. /**
  31488. * Get the time step of the physics engine.
  31489. * @returns the current time step
  31490. */
  31491. getTimeStep(): number;
  31492. /**
  31493. * Set the sub time step of the physics engine.
  31494. * Default is 0 meaning there is no sub steps
  31495. * To increase physics resolution precision, set a small value (like 1 ms)
  31496. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31497. */
  31498. setSubTimeStep(subTimeStep: number): void;
  31499. /**
  31500. * Get the sub time step of the physics engine.
  31501. * @returns the current sub time step
  31502. */
  31503. getSubTimeStep(): number;
  31504. /**
  31505. * Release all resources
  31506. */
  31507. dispose(): void;
  31508. /**
  31509. * Gets the name of the current physics plugin
  31510. * @returns the name of the plugin
  31511. */
  31512. getPhysicsPluginName(): string;
  31513. /**
  31514. * Adding a new impostor for the impostor tracking.
  31515. * This will be done by the impostor itself.
  31516. * @param impostor the impostor to add
  31517. */
  31518. addImpostor(impostor: PhysicsImpostor): void;
  31519. /**
  31520. * Remove an impostor from the engine.
  31521. * This impostor and its mesh will not longer be updated by the physics engine.
  31522. * @param impostor the impostor to remove
  31523. */
  31524. removeImpostor(impostor: PhysicsImpostor): void;
  31525. /**
  31526. * Add a joint to the physics engine
  31527. * @param mainImpostor defines the main impostor to which the joint is added.
  31528. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31529. * @param joint defines the joint that will connect both impostors.
  31530. */
  31531. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31532. /**
  31533. * Removes a joint from the simulation
  31534. * @param mainImpostor defines the impostor used with the joint
  31535. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31536. * @param joint defines the joint to remove
  31537. */
  31538. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31539. /**
  31540. * Gets the current plugin used to run the simulation
  31541. * @returns current plugin
  31542. */
  31543. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31544. /**
  31545. * Gets the list of physic impostors
  31546. * @returns an array of PhysicsImpostor
  31547. */
  31548. getImpostors(): Array<PhysicsImpostor>;
  31549. /**
  31550. * Gets the impostor for a physics enabled object
  31551. * @param object defines the object impersonated by the impostor
  31552. * @returns the PhysicsImpostor or null if not found
  31553. */
  31554. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31555. /**
  31556. * Gets the impostor for a physics body object
  31557. * @param body defines physics body used by the impostor
  31558. * @returns the PhysicsImpostor or null if not found
  31559. */
  31560. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31561. /**
  31562. * Does a raycast in the physics world
  31563. * @param from when should the ray start?
  31564. * @param to when should the ray end?
  31565. * @returns PhysicsRaycastResult
  31566. */
  31567. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31568. /**
  31569. * Called by the scene. No need to call it.
  31570. * @param delta defines the timespam between frames
  31571. */
  31572. _step(delta: number): void;
  31573. }
  31574. }
  31575. declare module BABYLON {
  31576. /**
  31577. * The interface for the physics imposter parameters
  31578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31579. */
  31580. export interface PhysicsImpostorParameters {
  31581. /**
  31582. * The mass of the physics imposter
  31583. */
  31584. mass: number;
  31585. /**
  31586. * The friction of the physics imposter
  31587. */
  31588. friction?: number;
  31589. /**
  31590. * The coefficient of restitution of the physics imposter
  31591. */
  31592. restitution?: number;
  31593. /**
  31594. * The native options of the physics imposter
  31595. */
  31596. nativeOptions?: any;
  31597. /**
  31598. * Specifies if the parent should be ignored
  31599. */
  31600. ignoreParent?: boolean;
  31601. /**
  31602. * Specifies if bi-directional transformations should be disabled
  31603. */
  31604. disableBidirectionalTransformation?: boolean;
  31605. /**
  31606. * The pressure inside the physics imposter, soft object only
  31607. */
  31608. pressure?: number;
  31609. /**
  31610. * The stiffness the physics imposter, soft object only
  31611. */
  31612. stiffness?: number;
  31613. /**
  31614. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31615. */
  31616. velocityIterations?: number;
  31617. /**
  31618. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31619. */
  31620. positionIterations?: number;
  31621. /**
  31622. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31623. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31624. * Add to fix multiple points
  31625. */
  31626. fixedPoints?: number;
  31627. /**
  31628. * The collision margin around a soft object
  31629. */
  31630. margin?: number;
  31631. /**
  31632. * The collision margin around a soft object
  31633. */
  31634. damping?: number;
  31635. /**
  31636. * The path for a rope based on an extrusion
  31637. */
  31638. path?: any;
  31639. /**
  31640. * The shape of an extrusion used for a rope based on an extrusion
  31641. */
  31642. shape?: any;
  31643. }
  31644. /**
  31645. * Interface for a physics-enabled object
  31646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31647. */
  31648. export interface IPhysicsEnabledObject {
  31649. /**
  31650. * The position of the physics-enabled object
  31651. */
  31652. position: Vector3;
  31653. /**
  31654. * The rotation of the physics-enabled object
  31655. */
  31656. rotationQuaternion: Nullable<Quaternion>;
  31657. /**
  31658. * The scale of the physics-enabled object
  31659. */
  31660. scaling: Vector3;
  31661. /**
  31662. * The rotation of the physics-enabled object
  31663. */
  31664. rotation?: Vector3;
  31665. /**
  31666. * The parent of the physics-enabled object
  31667. */
  31668. parent?: any;
  31669. /**
  31670. * The bounding info of the physics-enabled object
  31671. * @returns The bounding info of the physics-enabled object
  31672. */
  31673. getBoundingInfo(): BoundingInfo;
  31674. /**
  31675. * Computes the world matrix
  31676. * @param force Specifies if the world matrix should be computed by force
  31677. * @returns A world matrix
  31678. */
  31679. computeWorldMatrix(force: boolean): Matrix;
  31680. /**
  31681. * Gets the world matrix
  31682. * @returns A world matrix
  31683. */
  31684. getWorldMatrix?(): Matrix;
  31685. /**
  31686. * Gets the child meshes
  31687. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31688. * @returns An array of abstract meshes
  31689. */
  31690. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31691. /**
  31692. * Gets the vertex data
  31693. * @param kind The type of vertex data
  31694. * @returns A nullable array of numbers, or a float32 array
  31695. */
  31696. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31697. /**
  31698. * Gets the indices from the mesh
  31699. * @returns A nullable array of index arrays
  31700. */
  31701. getIndices?(): Nullable<IndicesArray>;
  31702. /**
  31703. * Gets the scene from the mesh
  31704. * @returns the indices array or null
  31705. */
  31706. getScene?(): Scene;
  31707. /**
  31708. * Gets the absolute position from the mesh
  31709. * @returns the absolute position
  31710. */
  31711. getAbsolutePosition(): Vector3;
  31712. /**
  31713. * Gets the absolute pivot point from the mesh
  31714. * @returns the absolute pivot point
  31715. */
  31716. getAbsolutePivotPoint(): Vector3;
  31717. /**
  31718. * Rotates the mesh
  31719. * @param axis The axis of rotation
  31720. * @param amount The amount of rotation
  31721. * @param space The space of the rotation
  31722. * @returns The rotation transform node
  31723. */
  31724. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31725. /**
  31726. * Translates the mesh
  31727. * @param axis The axis of translation
  31728. * @param distance The distance of translation
  31729. * @param space The space of the translation
  31730. * @returns The transform node
  31731. */
  31732. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31733. /**
  31734. * Sets the absolute position of the mesh
  31735. * @param absolutePosition The absolute position of the mesh
  31736. * @returns The transform node
  31737. */
  31738. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31739. /**
  31740. * Gets the class name of the mesh
  31741. * @returns The class name
  31742. */
  31743. getClassName(): string;
  31744. }
  31745. /**
  31746. * Represents a physics imposter
  31747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31748. */
  31749. export class PhysicsImpostor {
  31750. /**
  31751. * The physics-enabled object used as the physics imposter
  31752. */
  31753. object: IPhysicsEnabledObject;
  31754. /**
  31755. * The type of the physics imposter
  31756. */
  31757. type: number;
  31758. private _options;
  31759. private _scene?;
  31760. /**
  31761. * The default object size of the imposter
  31762. */
  31763. static DEFAULT_OBJECT_SIZE: Vector3;
  31764. /**
  31765. * The identity quaternion of the imposter
  31766. */
  31767. static IDENTITY_QUATERNION: Quaternion;
  31768. /** @hidden */
  31769. _pluginData: any;
  31770. private _physicsEngine;
  31771. private _physicsBody;
  31772. private _bodyUpdateRequired;
  31773. private _onBeforePhysicsStepCallbacks;
  31774. private _onAfterPhysicsStepCallbacks;
  31775. /** @hidden */
  31776. _onPhysicsCollideCallbacks: Array<{
  31777. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31778. otherImpostors: Array<PhysicsImpostor>;
  31779. }>;
  31780. private _deltaPosition;
  31781. private _deltaRotation;
  31782. private _deltaRotationConjugated;
  31783. /** @hidden */
  31784. _isFromLine: boolean;
  31785. private _parent;
  31786. private _isDisposed;
  31787. private static _tmpVecs;
  31788. private static _tmpQuat;
  31789. /**
  31790. * Specifies if the physics imposter is disposed
  31791. */
  31792. get isDisposed(): boolean;
  31793. /**
  31794. * Gets the mass of the physics imposter
  31795. */
  31796. get mass(): number;
  31797. set mass(value: number);
  31798. /**
  31799. * Gets the coefficient of friction
  31800. */
  31801. get friction(): number;
  31802. /**
  31803. * Sets the coefficient of friction
  31804. */
  31805. set friction(value: number);
  31806. /**
  31807. * Gets the coefficient of restitution
  31808. */
  31809. get restitution(): number;
  31810. /**
  31811. * Sets the coefficient of restitution
  31812. */
  31813. set restitution(value: number);
  31814. /**
  31815. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31816. */
  31817. get pressure(): number;
  31818. /**
  31819. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31820. */
  31821. set pressure(value: number);
  31822. /**
  31823. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31824. */
  31825. get stiffness(): number;
  31826. /**
  31827. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31828. */
  31829. set stiffness(value: number);
  31830. /**
  31831. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31832. */
  31833. get velocityIterations(): number;
  31834. /**
  31835. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31836. */
  31837. set velocityIterations(value: number);
  31838. /**
  31839. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31840. */
  31841. get positionIterations(): number;
  31842. /**
  31843. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31844. */
  31845. set positionIterations(value: number);
  31846. /**
  31847. * The unique id of the physics imposter
  31848. * set by the physics engine when adding this impostor to the array
  31849. */
  31850. uniqueId: number;
  31851. /**
  31852. * @hidden
  31853. */
  31854. soft: boolean;
  31855. /**
  31856. * @hidden
  31857. */
  31858. segments: number;
  31859. private _joints;
  31860. /**
  31861. * Initializes the physics imposter
  31862. * @param object The physics-enabled object used as the physics imposter
  31863. * @param type The type of the physics imposter
  31864. * @param _options The options for the physics imposter
  31865. * @param _scene The Babylon scene
  31866. */
  31867. constructor(
  31868. /**
  31869. * The physics-enabled object used as the physics imposter
  31870. */
  31871. object: IPhysicsEnabledObject,
  31872. /**
  31873. * The type of the physics imposter
  31874. */
  31875. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31876. /**
  31877. * This function will completly initialize this impostor.
  31878. * It will create a new body - but only if this mesh has no parent.
  31879. * If it has, this impostor will not be used other than to define the impostor
  31880. * of the child mesh.
  31881. * @hidden
  31882. */
  31883. _init(): void;
  31884. private _getPhysicsParent;
  31885. /**
  31886. * Should a new body be generated.
  31887. * @returns boolean specifying if body initialization is required
  31888. */
  31889. isBodyInitRequired(): boolean;
  31890. /**
  31891. * Sets the updated scaling
  31892. * @param updated Specifies if the scaling is updated
  31893. */
  31894. setScalingUpdated(): void;
  31895. /**
  31896. * Force a regeneration of this or the parent's impostor's body.
  31897. * Use under cautious - This will remove all joints already implemented.
  31898. */
  31899. forceUpdate(): void;
  31900. /**
  31901. * Gets the body that holds this impostor. Either its own, or its parent.
  31902. */
  31903. get physicsBody(): any;
  31904. /**
  31905. * Get the parent of the physics imposter
  31906. * @returns Physics imposter or null
  31907. */
  31908. get parent(): Nullable<PhysicsImpostor>;
  31909. /**
  31910. * Sets the parent of the physics imposter
  31911. */
  31912. set parent(value: Nullable<PhysicsImpostor>);
  31913. /**
  31914. * Set the physics body. Used mainly by the physics engine/plugin
  31915. */
  31916. set physicsBody(physicsBody: any);
  31917. /**
  31918. * Resets the update flags
  31919. */
  31920. resetUpdateFlags(): void;
  31921. /**
  31922. * Gets the object extend size
  31923. * @returns the object extend size
  31924. */
  31925. getObjectExtendSize(): Vector3;
  31926. /**
  31927. * Gets the object center
  31928. * @returns The object center
  31929. */
  31930. getObjectCenter(): Vector3;
  31931. /**
  31932. * Get a specific parameter from the options parameters
  31933. * @param paramName The object parameter name
  31934. * @returns The object parameter
  31935. */
  31936. getParam(paramName: string): any;
  31937. /**
  31938. * Sets a specific parameter in the options given to the physics plugin
  31939. * @param paramName The parameter name
  31940. * @param value The value of the parameter
  31941. */
  31942. setParam(paramName: string, value: number): void;
  31943. /**
  31944. * Specifically change the body's mass option. Won't recreate the physics body object
  31945. * @param mass The mass of the physics imposter
  31946. */
  31947. setMass(mass: number): void;
  31948. /**
  31949. * Gets the linear velocity
  31950. * @returns linear velocity or null
  31951. */
  31952. getLinearVelocity(): Nullable<Vector3>;
  31953. /**
  31954. * Sets the linear velocity
  31955. * @param velocity linear velocity or null
  31956. */
  31957. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31958. /**
  31959. * Gets the angular velocity
  31960. * @returns angular velocity or null
  31961. */
  31962. getAngularVelocity(): Nullable<Vector3>;
  31963. /**
  31964. * Sets the angular velocity
  31965. * @param velocity The velocity or null
  31966. */
  31967. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31968. /**
  31969. * Execute a function with the physics plugin native code
  31970. * Provide a function the will have two variables - the world object and the physics body object
  31971. * @param func The function to execute with the physics plugin native code
  31972. */
  31973. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31974. /**
  31975. * Register a function that will be executed before the physics world is stepping forward
  31976. * @param func The function to execute before the physics world is stepped forward
  31977. */
  31978. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31979. /**
  31980. * Unregister a function that will be executed before the physics world is stepping forward
  31981. * @param func The function to execute before the physics world is stepped forward
  31982. */
  31983. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31984. /**
  31985. * Register a function that will be executed after the physics step
  31986. * @param func The function to execute after physics step
  31987. */
  31988. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31989. /**
  31990. * Unregisters a function that will be executed after the physics step
  31991. * @param func The function to execute after physics step
  31992. */
  31993. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31994. /**
  31995. * register a function that will be executed when this impostor collides against a different body
  31996. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31997. * @param func Callback that is executed on collision
  31998. */
  31999. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32000. /**
  32001. * Unregisters the physics imposter on contact
  32002. * @param collideAgainst The physics object to collide against
  32003. * @param func Callback to execute on collision
  32004. */
  32005. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32006. private _tmpQuat;
  32007. private _tmpQuat2;
  32008. /**
  32009. * Get the parent rotation
  32010. * @returns The parent rotation
  32011. */
  32012. getParentsRotation(): Quaternion;
  32013. /**
  32014. * this function is executed by the physics engine.
  32015. */
  32016. beforeStep: () => void;
  32017. /**
  32018. * this function is executed by the physics engine
  32019. */
  32020. afterStep: () => void;
  32021. /**
  32022. * Legacy collision detection event support
  32023. */
  32024. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32025. /**
  32026. * event and body object due to cannon's event-based architecture.
  32027. */
  32028. onCollide: (e: {
  32029. body: any;
  32030. point: Nullable<Vector3>;
  32031. }) => void;
  32032. /**
  32033. * Apply a force
  32034. * @param force The force to apply
  32035. * @param contactPoint The contact point for the force
  32036. * @returns The physics imposter
  32037. */
  32038. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32039. /**
  32040. * Apply an impulse
  32041. * @param force The impulse force
  32042. * @param contactPoint The contact point for the impulse force
  32043. * @returns The physics imposter
  32044. */
  32045. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32046. /**
  32047. * A help function to create a joint
  32048. * @param otherImpostor A physics imposter used to create a joint
  32049. * @param jointType The type of joint
  32050. * @param jointData The data for the joint
  32051. * @returns The physics imposter
  32052. */
  32053. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32054. /**
  32055. * Add a joint to this impostor with a different impostor
  32056. * @param otherImpostor A physics imposter used to add a joint
  32057. * @param joint The joint to add
  32058. * @returns The physics imposter
  32059. */
  32060. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32061. /**
  32062. * Add an anchor to a cloth impostor
  32063. * @param otherImpostor rigid impostor to anchor to
  32064. * @param width ratio across width from 0 to 1
  32065. * @param height ratio up height from 0 to 1
  32066. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32067. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32068. * @returns impostor the soft imposter
  32069. */
  32070. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32071. /**
  32072. * Add a hook to a rope impostor
  32073. * @param otherImpostor rigid impostor to anchor to
  32074. * @param length ratio across rope from 0 to 1
  32075. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32076. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32077. * @returns impostor the rope imposter
  32078. */
  32079. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32080. /**
  32081. * Will keep this body still, in a sleep mode.
  32082. * @returns the physics imposter
  32083. */
  32084. sleep(): PhysicsImpostor;
  32085. /**
  32086. * Wake the body up.
  32087. * @returns The physics imposter
  32088. */
  32089. wakeUp(): PhysicsImpostor;
  32090. /**
  32091. * Clones the physics imposter
  32092. * @param newObject The physics imposter clones to this physics-enabled object
  32093. * @returns A nullable physics imposter
  32094. */
  32095. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32096. /**
  32097. * Disposes the physics imposter
  32098. */
  32099. dispose(): void;
  32100. /**
  32101. * Sets the delta position
  32102. * @param position The delta position amount
  32103. */
  32104. setDeltaPosition(position: Vector3): void;
  32105. /**
  32106. * Sets the delta rotation
  32107. * @param rotation The delta rotation amount
  32108. */
  32109. setDeltaRotation(rotation: Quaternion): void;
  32110. /**
  32111. * Gets the box size of the physics imposter and stores the result in the input parameter
  32112. * @param result Stores the box size
  32113. * @returns The physics imposter
  32114. */
  32115. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32116. /**
  32117. * Gets the radius of the physics imposter
  32118. * @returns Radius of the physics imposter
  32119. */
  32120. getRadius(): number;
  32121. /**
  32122. * Sync a bone with this impostor
  32123. * @param bone The bone to sync to the impostor.
  32124. * @param boneMesh The mesh that the bone is influencing.
  32125. * @param jointPivot The pivot of the joint / bone in local space.
  32126. * @param distToJoint Optional distance from the impostor to the joint.
  32127. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32128. */
  32129. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32130. /**
  32131. * Sync impostor to a bone
  32132. * @param bone The bone that the impostor will be synced to.
  32133. * @param boneMesh The mesh that the bone is influencing.
  32134. * @param jointPivot The pivot of the joint / bone in local space.
  32135. * @param distToJoint Optional distance from the impostor to the joint.
  32136. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32137. * @param boneAxis Optional vector3 axis the bone is aligned with
  32138. */
  32139. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32140. /**
  32141. * No-Imposter type
  32142. */
  32143. static NoImpostor: number;
  32144. /**
  32145. * Sphere-Imposter type
  32146. */
  32147. static SphereImpostor: number;
  32148. /**
  32149. * Box-Imposter type
  32150. */
  32151. static BoxImpostor: number;
  32152. /**
  32153. * Plane-Imposter type
  32154. */
  32155. static PlaneImpostor: number;
  32156. /**
  32157. * Mesh-imposter type
  32158. */
  32159. static MeshImpostor: number;
  32160. /**
  32161. * Capsule-Impostor type (Ammo.js plugin only)
  32162. */
  32163. static CapsuleImpostor: number;
  32164. /**
  32165. * Cylinder-Imposter type
  32166. */
  32167. static CylinderImpostor: number;
  32168. /**
  32169. * Particle-Imposter type
  32170. */
  32171. static ParticleImpostor: number;
  32172. /**
  32173. * Heightmap-Imposter type
  32174. */
  32175. static HeightmapImpostor: number;
  32176. /**
  32177. * ConvexHull-Impostor type (Ammo.js plugin only)
  32178. */
  32179. static ConvexHullImpostor: number;
  32180. /**
  32181. * Custom-Imposter type (Ammo.js plugin only)
  32182. */
  32183. static CustomImpostor: number;
  32184. /**
  32185. * Rope-Imposter type
  32186. */
  32187. static RopeImpostor: number;
  32188. /**
  32189. * Cloth-Imposter type
  32190. */
  32191. static ClothImpostor: number;
  32192. /**
  32193. * Softbody-Imposter type
  32194. */
  32195. static SoftbodyImpostor: number;
  32196. }
  32197. }
  32198. declare module BABYLON {
  32199. /**
  32200. * @hidden
  32201. **/
  32202. export class _CreationDataStorage {
  32203. closePath?: boolean;
  32204. closeArray?: boolean;
  32205. idx: number[];
  32206. dashSize: number;
  32207. gapSize: number;
  32208. path3D: Path3D;
  32209. pathArray: Vector3[][];
  32210. arc: number;
  32211. radius: number;
  32212. cap: number;
  32213. tessellation: number;
  32214. }
  32215. /**
  32216. * @hidden
  32217. **/
  32218. class _InstanceDataStorage {
  32219. visibleInstances: any;
  32220. batchCache: _InstancesBatch;
  32221. instancesBufferSize: number;
  32222. instancesBuffer: Nullable<Buffer>;
  32223. instancesData: Float32Array;
  32224. overridenInstanceCount: number;
  32225. isFrozen: boolean;
  32226. previousBatch: Nullable<_InstancesBatch>;
  32227. hardwareInstancedRendering: boolean;
  32228. sideOrientation: number;
  32229. manualUpdate: boolean;
  32230. previousRenderId: number;
  32231. }
  32232. /**
  32233. * @hidden
  32234. **/
  32235. export class _InstancesBatch {
  32236. mustReturn: boolean;
  32237. visibleInstances: Nullable<InstancedMesh[]>[];
  32238. renderSelf: boolean[];
  32239. hardwareInstancedRendering: boolean[];
  32240. }
  32241. /**
  32242. * @hidden
  32243. **/
  32244. class _ThinInstanceDataStorage {
  32245. instancesCount: number;
  32246. matrixBuffer: Nullable<Buffer>;
  32247. matrixBufferSize: number;
  32248. matrixData: Nullable<Float32Array>;
  32249. boundingVectors: Array<Vector3>;
  32250. worldMatrices: Nullable<Matrix[]>;
  32251. }
  32252. /**
  32253. * Class used to represent renderable models
  32254. */
  32255. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32256. /**
  32257. * Mesh side orientation : usually the external or front surface
  32258. */
  32259. static readonly FRONTSIDE: number;
  32260. /**
  32261. * Mesh side orientation : usually the internal or back surface
  32262. */
  32263. static readonly BACKSIDE: number;
  32264. /**
  32265. * Mesh side orientation : both internal and external or front and back surfaces
  32266. */
  32267. static readonly DOUBLESIDE: number;
  32268. /**
  32269. * Mesh side orientation : by default, `FRONTSIDE`
  32270. */
  32271. static readonly DEFAULTSIDE: number;
  32272. /**
  32273. * Mesh cap setting : no cap
  32274. */
  32275. static readonly NO_CAP: number;
  32276. /**
  32277. * Mesh cap setting : one cap at the beginning of the mesh
  32278. */
  32279. static readonly CAP_START: number;
  32280. /**
  32281. * Mesh cap setting : one cap at the end of the mesh
  32282. */
  32283. static readonly CAP_END: number;
  32284. /**
  32285. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32286. */
  32287. static readonly CAP_ALL: number;
  32288. /**
  32289. * Mesh pattern setting : no flip or rotate
  32290. */
  32291. static readonly NO_FLIP: number;
  32292. /**
  32293. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32294. */
  32295. static readonly FLIP_TILE: number;
  32296. /**
  32297. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32298. */
  32299. static readonly ROTATE_TILE: number;
  32300. /**
  32301. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32302. */
  32303. static readonly FLIP_ROW: number;
  32304. /**
  32305. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32306. */
  32307. static readonly ROTATE_ROW: number;
  32308. /**
  32309. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32310. */
  32311. static readonly FLIP_N_ROTATE_TILE: number;
  32312. /**
  32313. * Mesh pattern setting : rotate pattern and rotate
  32314. */
  32315. static readonly FLIP_N_ROTATE_ROW: number;
  32316. /**
  32317. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32318. */
  32319. static readonly CENTER: number;
  32320. /**
  32321. * Mesh tile positioning : part tiles on left
  32322. */
  32323. static readonly LEFT: number;
  32324. /**
  32325. * Mesh tile positioning : part tiles on right
  32326. */
  32327. static readonly RIGHT: number;
  32328. /**
  32329. * Mesh tile positioning : part tiles on top
  32330. */
  32331. static readonly TOP: number;
  32332. /**
  32333. * Mesh tile positioning : part tiles on bottom
  32334. */
  32335. static readonly BOTTOM: number;
  32336. /**
  32337. * Gets the default side orientation.
  32338. * @param orientation the orientation to value to attempt to get
  32339. * @returns the default orientation
  32340. * @hidden
  32341. */
  32342. static _GetDefaultSideOrientation(orientation?: number): number;
  32343. private _internalMeshDataInfo;
  32344. get computeBonesUsingShaders(): boolean;
  32345. set computeBonesUsingShaders(value: boolean);
  32346. /**
  32347. * An event triggered before rendering the mesh
  32348. */
  32349. get onBeforeRenderObservable(): Observable<Mesh>;
  32350. /**
  32351. * An event triggered before binding the mesh
  32352. */
  32353. get onBeforeBindObservable(): Observable<Mesh>;
  32354. /**
  32355. * An event triggered after rendering the mesh
  32356. */
  32357. get onAfterRenderObservable(): Observable<Mesh>;
  32358. /**
  32359. * An event triggered before drawing the mesh
  32360. */
  32361. get onBeforeDrawObservable(): Observable<Mesh>;
  32362. private _onBeforeDrawObserver;
  32363. /**
  32364. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32365. */
  32366. set onBeforeDraw(callback: () => void);
  32367. get hasInstances(): boolean;
  32368. get hasThinInstances(): boolean;
  32369. /**
  32370. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32371. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32372. */
  32373. delayLoadState: number;
  32374. /**
  32375. * Gets the list of instances created from this mesh
  32376. * it is not supposed to be modified manually.
  32377. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32378. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32379. */
  32380. instances: InstancedMesh[];
  32381. /**
  32382. * Gets the file containing delay loading data for this mesh
  32383. */
  32384. delayLoadingFile: string;
  32385. /** @hidden */
  32386. _binaryInfo: any;
  32387. /**
  32388. * User defined function used to change how LOD level selection is done
  32389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32390. */
  32391. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32392. /**
  32393. * Gets or sets the morph target manager
  32394. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32395. */
  32396. get morphTargetManager(): Nullable<MorphTargetManager>;
  32397. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32398. /** @hidden */
  32399. _creationDataStorage: Nullable<_CreationDataStorage>;
  32400. /** @hidden */
  32401. _geometry: Nullable<Geometry>;
  32402. /** @hidden */
  32403. _delayInfo: Array<string>;
  32404. /** @hidden */
  32405. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32406. /** @hidden */
  32407. _instanceDataStorage: _InstanceDataStorage;
  32408. /** @hidden */
  32409. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32410. private _effectiveMaterial;
  32411. /** @hidden */
  32412. _shouldGenerateFlatShading: boolean;
  32413. /** @hidden */
  32414. _originalBuilderSideOrientation: number;
  32415. /**
  32416. * Use this property to change the original side orientation defined at construction time
  32417. */
  32418. overrideMaterialSideOrientation: Nullable<number>;
  32419. /**
  32420. * Gets the source mesh (the one used to clone this one from)
  32421. */
  32422. get source(): Nullable<Mesh>;
  32423. /**
  32424. * Gets the list of clones of this mesh
  32425. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32426. * Note that useClonedMeshMap=true is the default setting
  32427. */
  32428. get cloneMeshMap(): Nullable<{
  32429. [id: string]: Mesh | undefined;
  32430. }>;
  32431. /**
  32432. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32433. */
  32434. get isUnIndexed(): boolean;
  32435. set isUnIndexed(value: boolean);
  32436. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32437. get worldMatrixInstancedBuffer(): Float32Array;
  32438. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32439. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32440. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32441. /**
  32442. * @constructor
  32443. * @param name The value used by scene.getMeshByName() to do a lookup.
  32444. * @param scene The scene to add this mesh to.
  32445. * @param parent The parent of this mesh, if it has one
  32446. * @param source An optional Mesh from which geometry is shared, cloned.
  32447. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32448. * When false, achieved by calling a clone(), also passing False.
  32449. * This will make creation of children, recursive.
  32450. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32451. */
  32452. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32453. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32454. doNotInstantiate: boolean;
  32455. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32456. /**
  32457. * Gets the class name
  32458. * @returns the string "Mesh".
  32459. */
  32460. getClassName(): string;
  32461. /** @hidden */
  32462. get _isMesh(): boolean;
  32463. /**
  32464. * Returns a description of this mesh
  32465. * @param fullDetails define if full details about this mesh must be used
  32466. * @returns a descriptive string representing this mesh
  32467. */
  32468. toString(fullDetails?: boolean): string;
  32469. /** @hidden */
  32470. _unBindEffect(): void;
  32471. /**
  32472. * Gets a boolean indicating if this mesh has LOD
  32473. */
  32474. get hasLODLevels(): boolean;
  32475. /**
  32476. * Gets the list of MeshLODLevel associated with the current mesh
  32477. * @returns an array of MeshLODLevel
  32478. */
  32479. getLODLevels(): MeshLODLevel[];
  32480. private _sortLODLevels;
  32481. /**
  32482. * Add a mesh as LOD level triggered at the given distance.
  32483. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32484. * @param distance The distance from the center of the object to show this level
  32485. * @param mesh The mesh to be added as LOD level (can be null)
  32486. * @return This mesh (for chaining)
  32487. */
  32488. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32489. /**
  32490. * Returns the LOD level mesh at the passed distance or null if not found.
  32491. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32492. * @param distance The distance from the center of the object to show this level
  32493. * @returns a Mesh or `null`
  32494. */
  32495. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32496. /**
  32497. * Remove a mesh from the LOD array
  32498. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32499. * @param mesh defines the mesh to be removed
  32500. * @return This mesh (for chaining)
  32501. */
  32502. removeLODLevel(mesh: Mesh): Mesh;
  32503. /**
  32504. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32505. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32506. * @param camera defines the camera to use to compute distance
  32507. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32508. * @return This mesh (for chaining)
  32509. */
  32510. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32511. /**
  32512. * Gets the mesh internal Geometry object
  32513. */
  32514. get geometry(): Nullable<Geometry>;
  32515. /**
  32516. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32517. * @returns the total number of vertices
  32518. */
  32519. getTotalVertices(): number;
  32520. /**
  32521. * Returns the content of an associated vertex buffer
  32522. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32523. * - VertexBuffer.PositionKind
  32524. * - VertexBuffer.UVKind
  32525. * - VertexBuffer.UV2Kind
  32526. * - VertexBuffer.UV3Kind
  32527. * - VertexBuffer.UV4Kind
  32528. * - VertexBuffer.UV5Kind
  32529. * - VertexBuffer.UV6Kind
  32530. * - VertexBuffer.ColorKind
  32531. * - VertexBuffer.MatricesIndicesKind
  32532. * - VertexBuffer.MatricesIndicesExtraKind
  32533. * - VertexBuffer.MatricesWeightsKind
  32534. * - VertexBuffer.MatricesWeightsExtraKind
  32535. * @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
  32536. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32537. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32538. */
  32539. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32540. /**
  32541. * Returns the mesh VertexBuffer object from the requested `kind`
  32542. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32543. * - VertexBuffer.PositionKind
  32544. * - VertexBuffer.NormalKind
  32545. * - VertexBuffer.UVKind
  32546. * - VertexBuffer.UV2Kind
  32547. * - VertexBuffer.UV3Kind
  32548. * - VertexBuffer.UV4Kind
  32549. * - VertexBuffer.UV5Kind
  32550. * - VertexBuffer.UV6Kind
  32551. * - VertexBuffer.ColorKind
  32552. * - VertexBuffer.MatricesIndicesKind
  32553. * - VertexBuffer.MatricesIndicesExtraKind
  32554. * - VertexBuffer.MatricesWeightsKind
  32555. * - VertexBuffer.MatricesWeightsExtraKind
  32556. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32557. */
  32558. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32559. /**
  32560. * Tests if a specific vertex buffer is associated with this mesh
  32561. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32562. * - VertexBuffer.PositionKind
  32563. * - VertexBuffer.NormalKind
  32564. * - VertexBuffer.UVKind
  32565. * - VertexBuffer.UV2Kind
  32566. * - VertexBuffer.UV3Kind
  32567. * - VertexBuffer.UV4Kind
  32568. * - VertexBuffer.UV5Kind
  32569. * - VertexBuffer.UV6Kind
  32570. * - VertexBuffer.ColorKind
  32571. * - VertexBuffer.MatricesIndicesKind
  32572. * - VertexBuffer.MatricesIndicesExtraKind
  32573. * - VertexBuffer.MatricesWeightsKind
  32574. * - VertexBuffer.MatricesWeightsExtraKind
  32575. * @returns a boolean
  32576. */
  32577. isVerticesDataPresent(kind: string): boolean;
  32578. /**
  32579. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32580. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32581. * - VertexBuffer.PositionKind
  32582. * - VertexBuffer.UVKind
  32583. * - VertexBuffer.UV2Kind
  32584. * - VertexBuffer.UV3Kind
  32585. * - VertexBuffer.UV4Kind
  32586. * - VertexBuffer.UV5Kind
  32587. * - VertexBuffer.UV6Kind
  32588. * - VertexBuffer.ColorKind
  32589. * - VertexBuffer.MatricesIndicesKind
  32590. * - VertexBuffer.MatricesIndicesExtraKind
  32591. * - VertexBuffer.MatricesWeightsKind
  32592. * - VertexBuffer.MatricesWeightsExtraKind
  32593. * @returns a boolean
  32594. */
  32595. isVertexBufferUpdatable(kind: string): boolean;
  32596. /**
  32597. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32598. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32599. * - VertexBuffer.PositionKind
  32600. * - VertexBuffer.NormalKind
  32601. * - VertexBuffer.UVKind
  32602. * - VertexBuffer.UV2Kind
  32603. * - VertexBuffer.UV3Kind
  32604. * - VertexBuffer.UV4Kind
  32605. * - VertexBuffer.UV5Kind
  32606. * - VertexBuffer.UV6Kind
  32607. * - VertexBuffer.ColorKind
  32608. * - VertexBuffer.MatricesIndicesKind
  32609. * - VertexBuffer.MatricesIndicesExtraKind
  32610. * - VertexBuffer.MatricesWeightsKind
  32611. * - VertexBuffer.MatricesWeightsExtraKind
  32612. * @returns an array of strings
  32613. */
  32614. getVerticesDataKinds(): string[];
  32615. /**
  32616. * Returns a positive integer : the total number of indices in this mesh geometry.
  32617. * @returns the numner of indices or zero if the mesh has no geometry.
  32618. */
  32619. getTotalIndices(): number;
  32620. /**
  32621. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32622. * @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.
  32623. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32624. * @returns the indices array or an empty array if the mesh has no geometry
  32625. */
  32626. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32627. get isBlocked(): boolean;
  32628. /**
  32629. * Determine if the current mesh is ready to be rendered
  32630. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32631. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32632. * @returns true if all associated assets are ready (material, textures, shaders)
  32633. */
  32634. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32635. /**
  32636. * 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.
  32637. */
  32638. get areNormalsFrozen(): boolean;
  32639. /**
  32640. * 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.
  32641. * @returns the current mesh
  32642. */
  32643. freezeNormals(): Mesh;
  32644. /**
  32645. * 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
  32646. * @returns the current mesh
  32647. */
  32648. unfreezeNormals(): Mesh;
  32649. /**
  32650. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32651. */
  32652. set overridenInstanceCount(count: number);
  32653. /** @hidden */
  32654. _preActivate(): Mesh;
  32655. /** @hidden */
  32656. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32657. /** @hidden */
  32658. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32659. protected _afterComputeWorldMatrix(): void;
  32660. /** @hidden */
  32661. _postActivate(): void;
  32662. /**
  32663. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32664. * This means the mesh underlying bounding box and sphere are recomputed.
  32665. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32666. * @returns the current mesh
  32667. */
  32668. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32669. /** @hidden */
  32670. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32671. /**
  32672. * This function will subdivide the mesh into multiple submeshes
  32673. * @param count defines the expected number of submeshes
  32674. */
  32675. subdivide(count: number): void;
  32676. /**
  32677. * Copy a FloatArray into a specific associated vertex buffer
  32678. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32679. * - VertexBuffer.PositionKind
  32680. * - VertexBuffer.UVKind
  32681. * - VertexBuffer.UV2Kind
  32682. * - VertexBuffer.UV3Kind
  32683. * - VertexBuffer.UV4Kind
  32684. * - VertexBuffer.UV5Kind
  32685. * - VertexBuffer.UV6Kind
  32686. * - VertexBuffer.ColorKind
  32687. * - VertexBuffer.MatricesIndicesKind
  32688. * - VertexBuffer.MatricesIndicesExtraKind
  32689. * - VertexBuffer.MatricesWeightsKind
  32690. * - VertexBuffer.MatricesWeightsExtraKind
  32691. * @param data defines the data source
  32692. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32693. * @param stride defines the data stride size (can be null)
  32694. * @returns the current mesh
  32695. */
  32696. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32697. /**
  32698. * Delete a vertex buffer associated with this mesh
  32699. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32700. * - VertexBuffer.PositionKind
  32701. * - VertexBuffer.UVKind
  32702. * - VertexBuffer.UV2Kind
  32703. * - VertexBuffer.UV3Kind
  32704. * - VertexBuffer.UV4Kind
  32705. * - VertexBuffer.UV5Kind
  32706. * - VertexBuffer.UV6Kind
  32707. * - VertexBuffer.ColorKind
  32708. * - VertexBuffer.MatricesIndicesKind
  32709. * - VertexBuffer.MatricesIndicesExtraKind
  32710. * - VertexBuffer.MatricesWeightsKind
  32711. * - VertexBuffer.MatricesWeightsExtraKind
  32712. */
  32713. removeVerticesData(kind: string): void;
  32714. /**
  32715. * Flags an associated vertex buffer as updatable
  32716. * @param kind defines which buffer to use (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 updatable defines if the updated vertex buffer must be flagged as updatable
  32730. */
  32731. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32732. /**
  32733. * Sets the mesh global Vertex Buffer
  32734. * @param buffer defines the buffer to use
  32735. * @returns the current mesh
  32736. */
  32737. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32738. /**
  32739. * Update a specific associated vertex buffer
  32740. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32741. * - VertexBuffer.PositionKind
  32742. * - VertexBuffer.UVKind
  32743. * - VertexBuffer.UV2Kind
  32744. * - VertexBuffer.UV3Kind
  32745. * - VertexBuffer.UV4Kind
  32746. * - VertexBuffer.UV5Kind
  32747. * - VertexBuffer.UV6Kind
  32748. * - VertexBuffer.ColorKind
  32749. * - VertexBuffer.MatricesIndicesKind
  32750. * - VertexBuffer.MatricesIndicesExtraKind
  32751. * - VertexBuffer.MatricesWeightsKind
  32752. * - VertexBuffer.MatricesWeightsExtraKind
  32753. * @param data defines the data source
  32754. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32755. * @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)
  32756. * @returns the current mesh
  32757. */
  32758. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32759. /**
  32760. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32761. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32762. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32763. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32764. * @returns the current mesh
  32765. */
  32766. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32767. /**
  32768. * Creates a un-shared specific occurence of the geometry for the mesh.
  32769. * @returns the current mesh
  32770. */
  32771. makeGeometryUnique(): Mesh;
  32772. /**
  32773. * Set the index buffer of this mesh
  32774. * @param indices defines the source data
  32775. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32776. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32777. * @returns the current mesh
  32778. */
  32779. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32780. /**
  32781. * Update the current index buffer
  32782. * @param indices defines the source data
  32783. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32784. * @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)
  32785. * @returns the current mesh
  32786. */
  32787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32788. /**
  32789. * Invert the geometry to move from a right handed system to a left handed one.
  32790. * @returns the current mesh
  32791. */
  32792. toLeftHanded(): Mesh;
  32793. /** @hidden */
  32794. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32795. /** @hidden */
  32796. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32797. /**
  32798. * Registers for this mesh a javascript function called just before the rendering process
  32799. * @param func defines the function to call before rendering this mesh
  32800. * @returns the current mesh
  32801. */
  32802. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32803. /**
  32804. * Disposes a previously registered javascript function called before the rendering
  32805. * @param func defines the function to remove
  32806. * @returns the current mesh
  32807. */
  32808. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32809. /**
  32810. * Registers for this mesh a javascript function called just after the rendering is complete
  32811. * @param func defines the function to call after rendering this mesh
  32812. * @returns the current mesh
  32813. */
  32814. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32815. /**
  32816. * Disposes a previously registered javascript function called after the rendering.
  32817. * @param func defines the function to remove
  32818. * @returns the current mesh
  32819. */
  32820. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32821. /** @hidden */
  32822. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32823. /** @hidden */
  32824. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32825. /** @hidden */
  32826. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32827. /** @hidden */
  32828. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32829. /** @hidden */
  32830. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32831. /** @hidden */
  32832. _rebuild(): void;
  32833. /** @hidden */
  32834. _freeze(): void;
  32835. /** @hidden */
  32836. _unFreeze(): void;
  32837. /**
  32838. * 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
  32839. * @param subMesh defines the subMesh to render
  32840. * @param enableAlphaMode defines if alpha mode can be changed
  32841. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32842. * @returns the current mesh
  32843. */
  32844. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32845. private _onBeforeDraw;
  32846. /**
  32847. * Renormalize the mesh and patch it up if there are no weights
  32848. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32849. * However in the case of zero weights then we set just a single influence to 1.
  32850. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32851. */
  32852. cleanMatrixWeights(): void;
  32853. private normalizeSkinFourWeights;
  32854. private normalizeSkinWeightsAndExtra;
  32855. /**
  32856. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32857. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32858. * the user know there was an issue with importing the mesh
  32859. * @returns a validation object with skinned, valid and report string
  32860. */
  32861. validateSkinning(): {
  32862. skinned: boolean;
  32863. valid: boolean;
  32864. report: string;
  32865. };
  32866. /** @hidden */
  32867. _checkDelayState(): Mesh;
  32868. private _queueLoad;
  32869. /**
  32870. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32871. * A mesh is in the frustum if its bounding box intersects the frustum
  32872. * @param frustumPlanes defines the frustum to test
  32873. * @returns true if the mesh is in the frustum planes
  32874. */
  32875. isInFrustum(frustumPlanes: Plane[]): boolean;
  32876. /**
  32877. * Sets the mesh material by the material or multiMaterial `id` property
  32878. * @param id is a string identifying the material or the multiMaterial
  32879. * @returns the current mesh
  32880. */
  32881. setMaterialByID(id: string): Mesh;
  32882. /**
  32883. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32884. * @returns an array of IAnimatable
  32885. */
  32886. getAnimatables(): IAnimatable[];
  32887. /**
  32888. * Modifies the mesh geometry according to the passed transformation matrix.
  32889. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32890. * The mesh normals are modified using the same transformation.
  32891. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32892. * @param transform defines the transform matrix to use
  32893. * @see https://doc.babylonjs.com/resources/baking_transformations
  32894. * @returns the current mesh
  32895. */
  32896. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32897. /**
  32898. * Modifies the mesh geometry according to its own current World Matrix.
  32899. * The mesh World Matrix is then reset.
  32900. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32901. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32902. * @see https://doc.babylonjs.com/resources/baking_transformations
  32903. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32904. * @returns the current mesh
  32905. */
  32906. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32907. /** @hidden */
  32908. get _positions(): Nullable<Vector3[]>;
  32909. /** @hidden */
  32910. _resetPointsArrayCache(): Mesh;
  32911. /** @hidden */
  32912. _generatePointsArray(): boolean;
  32913. /**
  32914. * Returns a new Mesh object generated from the current mesh properties.
  32915. * This method must not get confused with createInstance()
  32916. * @param name is a string, the name given to the new mesh
  32917. * @param newParent can be any Node object (default `null`)
  32918. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32919. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32920. * @returns a new mesh
  32921. */
  32922. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32923. /**
  32924. * Releases resources associated with this mesh.
  32925. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32926. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32927. */
  32928. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32929. /** @hidden */
  32930. _disposeInstanceSpecificData(): void;
  32931. /** @hidden */
  32932. _disposeThinInstanceSpecificData(): void;
  32933. /**
  32934. * Modifies the mesh geometry according to a displacement map.
  32935. * 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.
  32936. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32937. * @param url is a string, the URL from the image file is to be downloaded.
  32938. * @param minHeight is the lower limit of the displacement.
  32939. * @param maxHeight is the upper limit of the displacement.
  32940. * @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.
  32941. * @param uvOffset is an optional vector2 used to offset UV.
  32942. * @param uvScale is an optional vector2 used to scale UV.
  32943. * @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.
  32944. * @returns the Mesh.
  32945. */
  32946. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32947. /**
  32948. * Modifies the mesh geometry according to a displacementMap buffer.
  32949. * 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.
  32950. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32951. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32952. * @param heightMapWidth is the width of the buffer image.
  32953. * @param heightMapHeight is the height of the buffer image.
  32954. * @param minHeight is the lower limit of the displacement.
  32955. * @param maxHeight is the upper limit of the displacement.
  32956. * @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.
  32957. * @param uvOffset is an optional vector2 used to offset UV.
  32958. * @param uvScale is an optional vector2 used to scale UV.
  32959. * @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.
  32960. * @returns the Mesh.
  32961. */
  32962. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32963. /**
  32964. * Modify the mesh to get a flat shading rendering.
  32965. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32966. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32967. * @returns current mesh
  32968. */
  32969. convertToFlatShadedMesh(): Mesh;
  32970. /**
  32971. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32972. * In other words, more vertices, no more indices and a single bigger VBO.
  32973. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32974. * @returns current mesh
  32975. */
  32976. convertToUnIndexedMesh(): Mesh;
  32977. /**
  32978. * Inverses facet orientations.
  32979. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32980. * @param flipNormals will also inverts the normals
  32981. * @returns current mesh
  32982. */
  32983. flipFaces(flipNormals?: boolean): Mesh;
  32984. /**
  32985. * Increase the number of facets and hence vertices in a mesh
  32986. * Vertex normals are interpolated from existing vertex normals
  32987. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32988. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32989. */
  32990. increaseVertices(numberPerEdge: number): void;
  32991. /**
  32992. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32993. * This will undo any application of covertToFlatShadedMesh
  32994. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32995. */
  32996. forceSharedVertices(): void;
  32997. /** @hidden */
  32998. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32999. /** @hidden */
  33000. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33001. /**
  33002. * Creates a new InstancedMesh object from the mesh model.
  33003. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33004. * @param name defines the name of the new instance
  33005. * @returns a new InstancedMesh
  33006. */
  33007. createInstance(name: string): InstancedMesh;
  33008. /**
  33009. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33010. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33011. * @returns the current mesh
  33012. */
  33013. synchronizeInstances(): Mesh;
  33014. /**
  33015. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33016. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33017. * This should be used together with the simplification to avoid disappearing triangles.
  33018. * @param successCallback an optional success callback to be called after the optimization finished.
  33019. * @returns the current mesh
  33020. */
  33021. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33022. /**
  33023. * Serialize current mesh
  33024. * @param serializationObject defines the object which will receive the serialization data
  33025. */
  33026. serialize(serializationObject: any): void;
  33027. /** @hidden */
  33028. _syncGeometryWithMorphTargetManager(): void;
  33029. /** @hidden */
  33030. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33031. /**
  33032. * Returns a new Mesh object parsed from the source provided.
  33033. * @param parsedMesh is the source
  33034. * @param scene defines the hosting scene
  33035. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33036. * @returns a new Mesh
  33037. */
  33038. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33039. /**
  33040. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33042. * @param name defines the name of the mesh to create
  33043. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33044. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33045. * @param closePath creates a seam between the first and the last points of each path of the path array
  33046. * @param offset is taken in account only if the `pathArray` is containing a single path
  33047. * @param scene defines the hosting scene
  33048. * @param updatable defines if the mesh must be flagged as updatable
  33049. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33050. * @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)
  33051. * @returns a new Mesh
  33052. */
  33053. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33054. /**
  33055. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33056. * @param name defines the name of the mesh to create
  33057. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33058. * @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
  33059. * @param scene defines the hosting scene
  33060. * @param updatable defines if the mesh must be flagged as updatable
  33061. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33062. * @returns a new Mesh
  33063. */
  33064. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33065. /**
  33066. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33067. * @param name defines the name of the mesh to create
  33068. * @param size sets the size (float) of each box side (default 1)
  33069. * @param scene defines the hosting scene
  33070. * @param updatable defines if the mesh must be flagged as updatable
  33071. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33072. * @returns a new Mesh
  33073. */
  33074. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33075. /**
  33076. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33077. * @param name defines the name of the mesh to create
  33078. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33079. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33080. * @param scene defines the hosting scene
  33081. * @param updatable defines if the mesh must be flagged as updatable
  33082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33083. * @returns a new Mesh
  33084. */
  33085. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33086. /**
  33087. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33088. * @param name defines the name of the mesh to create
  33089. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33090. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33091. * @param scene defines the hosting scene
  33092. * @returns a new Mesh
  33093. */
  33094. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33095. /**
  33096. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33097. * @param name defines the name of the mesh to create
  33098. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33099. * @param diameterTop set the top cap diameter (floats, default 1)
  33100. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33101. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33102. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33103. * @param scene defines the hosting scene
  33104. * @param updatable defines if the mesh must be flagged as updatable
  33105. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33106. * @returns a new Mesh
  33107. */
  33108. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33109. /**
  33110. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33111. * @param name defines the name of the mesh to create
  33112. * @param diameter sets the diameter size (float) of the torus (default 1)
  33113. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33114. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33115. * @param scene defines the hosting scene
  33116. * @param updatable defines if the mesh must be flagged as updatable
  33117. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33118. * @returns a new Mesh
  33119. */
  33120. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33121. /**
  33122. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33123. * @param name defines the name of the mesh to create
  33124. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33125. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33126. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33127. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33128. * @param p the number of windings on X axis (positive integers, default 2)
  33129. * @param q the number of windings on Y axis (positive integers, default 3)
  33130. * @param scene defines the hosting scene
  33131. * @param updatable defines if the mesh must be flagged as updatable
  33132. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33133. * @returns a new Mesh
  33134. */
  33135. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33136. /**
  33137. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33138. * @param name defines the name of the mesh to create
  33139. * @param points is an array successive Vector3
  33140. * @param scene defines the hosting scene
  33141. * @param updatable defines if the mesh must be flagged as updatable
  33142. * @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).
  33143. * @returns a new Mesh
  33144. */
  33145. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33146. /**
  33147. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33148. * @param name defines the name of the mesh to create
  33149. * @param points is an array successive Vector3
  33150. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33151. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33152. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33153. * @param scene defines the hosting scene
  33154. * @param updatable defines if the mesh must be flagged as updatable
  33155. * @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)
  33156. * @returns a new Mesh
  33157. */
  33158. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33159. /**
  33160. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33161. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33162. * 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.
  33163. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33164. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33165. * Remember you can only change the shape positions, not their number when updating a polygon.
  33166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33167. * @param name defines the name of the mesh to create
  33168. * @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
  33169. * @param scene defines the hosting scene
  33170. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33171. * @param updatable defines if the mesh must be flagged as updatable
  33172. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33173. * @param earcutInjection can be used to inject your own earcut reference
  33174. * @returns a new Mesh
  33175. */
  33176. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33177. /**
  33178. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33180. * @param name defines the name of the mesh to create
  33181. * @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
  33182. * @param depth defines the height of extrusion
  33183. * @param scene defines the hosting scene
  33184. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33185. * @param updatable defines if the mesh must be flagged as updatable
  33186. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33187. * @param earcutInjection can be used to inject your own earcut reference
  33188. * @returns a new Mesh
  33189. */
  33190. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33191. /**
  33192. * Creates an extruded shape mesh.
  33193. * 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
  33194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33196. * @param name defines the name of the mesh to create
  33197. * @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
  33198. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33199. * @param scale is the value to scale the shape
  33200. * @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
  33201. * @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
  33202. * @param scene defines the hosting scene
  33203. * @param updatable defines if the mesh must be flagged as updatable
  33204. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33205. * @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)
  33206. * @returns a new Mesh
  33207. */
  33208. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33209. /**
  33210. * Creates an custom extruded shape mesh.
  33211. * The custom extrusion is a parametric shape.
  33212. * It has no predefined shape. Its final shape will depend on the input parameters.
  33213. * Please consider using the same method from the MeshBuilder class instead
  33214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33215. * @param name defines the name of the mesh to create
  33216. * @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
  33217. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33218. * @param scaleFunction is a custom Javascript function called on each path point
  33219. * @param rotationFunction is a custom Javascript function called on each path point
  33220. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33221. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33222. * @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
  33223. * @param scene defines the hosting scene
  33224. * @param updatable defines if the mesh must be flagged as updatable
  33225. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33226. * @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)
  33227. * @returns a new Mesh
  33228. */
  33229. 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;
  33230. /**
  33231. * Creates lathe mesh.
  33232. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33233. * Please consider using the same method from the MeshBuilder class instead
  33234. * @param name defines the name of the mesh to create
  33235. * @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
  33236. * @param radius is the radius value of the lathe
  33237. * @param tessellation is the side number of the lathe.
  33238. * @param scene defines the hosting scene
  33239. * @param updatable defines if the mesh must be flagged as updatable
  33240. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33241. * @returns a new Mesh
  33242. */
  33243. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33244. /**
  33245. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33246. * @param name defines the name of the mesh to create
  33247. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33248. * @param scene defines the hosting scene
  33249. * @param updatable defines if the mesh must be flagged as updatable
  33250. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33251. * @returns a new Mesh
  33252. */
  33253. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33254. /**
  33255. * Creates a ground mesh.
  33256. * Please consider using the same method from the MeshBuilder class instead
  33257. * @param name defines the name of the mesh to create
  33258. * @param width set the width of the ground
  33259. * @param height set the height of the ground
  33260. * @param subdivisions sets the number of subdivisions per side
  33261. * @param scene defines the hosting scene
  33262. * @param updatable defines if the mesh must be flagged as updatable
  33263. * @returns a new Mesh
  33264. */
  33265. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33266. /**
  33267. * Creates a tiled ground mesh.
  33268. * Please consider using the same method from the MeshBuilder class instead
  33269. * @param name defines the name of the mesh to create
  33270. * @param xmin set the ground minimum X coordinate
  33271. * @param zmin set the ground minimum Y coordinate
  33272. * @param xmax set the ground maximum X coordinate
  33273. * @param zmax set the ground maximum Z coordinate
  33274. * @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
  33275. * @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
  33276. * @param scene defines the hosting scene
  33277. * @param updatable defines if the mesh must be flagged as updatable
  33278. * @returns a new Mesh
  33279. */
  33280. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33281. w: number;
  33282. h: number;
  33283. }, precision: {
  33284. w: number;
  33285. h: number;
  33286. }, scene: Scene, updatable?: boolean): Mesh;
  33287. /**
  33288. * Creates a ground mesh from a height map.
  33289. * Please consider using the same method from the MeshBuilder class instead
  33290. * @see https://doc.babylonjs.com/babylon101/height_map
  33291. * @param name defines the name of the mesh to create
  33292. * @param url sets the URL of the height map image resource
  33293. * @param width set the ground width size
  33294. * @param height set the ground height size
  33295. * @param subdivisions sets the number of subdivision per side
  33296. * @param minHeight is the minimum altitude on the ground
  33297. * @param maxHeight is the maximum altitude on the ground
  33298. * @param scene defines the hosting scene
  33299. * @param updatable defines if the mesh must be flagged as updatable
  33300. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33301. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33302. * @returns a new Mesh
  33303. */
  33304. 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;
  33305. /**
  33306. * Creates a tube mesh.
  33307. * The tube is a parametric shape.
  33308. * It has no predefined shape. Its final shape will depend on the input parameters.
  33309. * Please consider using the same method from the MeshBuilder class instead
  33310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33311. * @param name defines the name of the mesh to create
  33312. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33313. * @param radius sets the tube radius size
  33314. * @param tessellation is the number of sides on the tubular surface
  33315. * @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
  33316. * @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
  33317. * @param scene defines the hosting scene
  33318. * @param updatable defines if the mesh must be flagged as updatable
  33319. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33320. * @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)
  33321. * @returns a new Mesh
  33322. */
  33323. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33324. (i: number, distance: number): number;
  33325. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33326. /**
  33327. * Creates a polyhedron mesh.
  33328. * Please consider using the same method from the MeshBuilder class instead.
  33329. * * 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
  33330. * * The parameter `size` (positive float, default 1) sets the polygon size
  33331. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33332. * * 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`
  33333. * * 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
  33334. * * 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)`)
  33335. * * 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
  33336. * * 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
  33337. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33338. * * 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
  33339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33340. * @param name defines the name of the mesh to create
  33341. * @param options defines the options used to create the mesh
  33342. * @param scene defines the hosting scene
  33343. * @returns a new Mesh
  33344. */
  33345. static CreatePolyhedron(name: string, options: {
  33346. type?: number;
  33347. size?: number;
  33348. sizeX?: number;
  33349. sizeY?: number;
  33350. sizeZ?: number;
  33351. custom?: any;
  33352. faceUV?: Vector4[];
  33353. faceColors?: Color4[];
  33354. updatable?: boolean;
  33355. sideOrientation?: number;
  33356. }, scene: Scene): Mesh;
  33357. /**
  33358. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33359. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33360. * * 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`)
  33361. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33362. * * 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
  33363. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33364. * * 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
  33365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33366. * @param name defines the name of the mesh
  33367. * @param options defines the options used to create the mesh
  33368. * @param scene defines the hosting scene
  33369. * @returns a new Mesh
  33370. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33371. */
  33372. static CreateIcoSphere(name: string, options: {
  33373. radius?: number;
  33374. flat?: boolean;
  33375. subdivisions?: number;
  33376. sideOrientation?: number;
  33377. updatable?: boolean;
  33378. }, scene: Scene): Mesh;
  33379. /**
  33380. * Creates a decal mesh.
  33381. * Please consider using the same method from the MeshBuilder class instead.
  33382. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33383. * @param name defines the name of the mesh
  33384. * @param sourceMesh defines the mesh receiving the decal
  33385. * @param position sets the position of the decal in world coordinates
  33386. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33387. * @param size sets the decal scaling
  33388. * @param angle sets the angle to rotate the decal
  33389. * @returns a new Mesh
  33390. */
  33391. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33392. /** Creates a Capsule Mesh
  33393. * @param name defines the name of the mesh.
  33394. * @param options the constructors options used to shape the mesh.
  33395. * @param scene defines the scene the mesh is scoped to.
  33396. * @returns the capsule mesh
  33397. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33398. */
  33399. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33400. /**
  33401. * Prepare internal position array for software CPU skinning
  33402. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33403. */
  33404. setPositionsForCPUSkinning(): Float32Array;
  33405. /**
  33406. * Prepare internal normal array for software CPU skinning
  33407. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33408. */
  33409. setNormalsForCPUSkinning(): Float32Array;
  33410. /**
  33411. * Updates the vertex buffer by applying transformation from the bones
  33412. * @param skeleton defines the skeleton to apply to current mesh
  33413. * @returns the current mesh
  33414. */
  33415. applySkeleton(skeleton: Skeleton): Mesh;
  33416. /**
  33417. * 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
  33418. * @param meshes defines the list of meshes to scan
  33419. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33420. */
  33421. static MinMax(meshes: AbstractMesh[]): {
  33422. min: Vector3;
  33423. max: Vector3;
  33424. };
  33425. /**
  33426. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33427. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33428. * @returns a vector3
  33429. */
  33430. static Center(meshesOrMinMaxVector: {
  33431. min: Vector3;
  33432. max: Vector3;
  33433. } | AbstractMesh[]): Vector3;
  33434. /**
  33435. * Merge the array of meshes into a single mesh for performance reasons.
  33436. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33437. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33438. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33439. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33440. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33441. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33442. * @returns a new mesh
  33443. */
  33444. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33445. /** @hidden */
  33446. addInstance(instance: InstancedMesh): void;
  33447. /** @hidden */
  33448. removeInstance(instance: InstancedMesh): void;
  33449. }
  33450. }
  33451. declare module BABYLON {
  33452. /**
  33453. * The options Interface for creating a Capsule Mesh
  33454. */
  33455. export interface ICreateCapsuleOptions {
  33456. /** The Orientation of the capsule. Default : Vector3.Up() */
  33457. orientation?: Vector3;
  33458. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33459. subdivisions: number;
  33460. /** Number of cylindrical segments on the capsule. */
  33461. tessellation: number;
  33462. /** Height or Length of the capsule. */
  33463. height: number;
  33464. /** Radius of the capsule. */
  33465. radius: number;
  33466. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33467. capSubdivisions: number;
  33468. /** Overwrite for the top radius. */
  33469. radiusTop?: number;
  33470. /** Overwrite for the bottom radius. */
  33471. radiusBottom?: number;
  33472. /** Overwrite for the top capSubdivisions. */
  33473. topCapSubdivisions?: number;
  33474. /** Overwrite for the bottom capSubdivisions. */
  33475. bottomCapSubdivisions?: number;
  33476. }
  33477. /**
  33478. * Class containing static functions to help procedurally build meshes
  33479. */
  33480. export class CapsuleBuilder {
  33481. /**
  33482. * Creates a capsule or a pill mesh
  33483. * @param name defines the name of the mesh
  33484. * @param options The constructors options.
  33485. * @param scene The scene the mesh is scoped to.
  33486. * @returns Capsule Mesh
  33487. */
  33488. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33489. }
  33490. }
  33491. declare module BABYLON {
  33492. /**
  33493. * Define an interface for all classes that will get and set the data on vertices
  33494. */
  33495. export interface IGetSetVerticesData {
  33496. /**
  33497. * Gets a boolean indicating if specific vertex data is present
  33498. * @param kind defines the vertex data kind to use
  33499. * @returns true is data kind is present
  33500. */
  33501. isVerticesDataPresent(kind: string): boolean;
  33502. /**
  33503. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33504. * @param kind defines the data kind (Position, normal, etc...)
  33505. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33506. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33507. * @returns a float array containing vertex data
  33508. */
  33509. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33510. /**
  33511. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33512. * @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.
  33513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33514. * @returns the indices array or an empty array if the mesh has no geometry
  33515. */
  33516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33517. /**
  33518. * Set specific vertex data
  33519. * @param kind defines the data kind (Position, normal, etc...)
  33520. * @param data defines the vertex data to use
  33521. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33522. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33523. */
  33524. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33525. /**
  33526. * Update a specific associated vertex buffer
  33527. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33528. * - VertexBuffer.PositionKind
  33529. * - VertexBuffer.UVKind
  33530. * - VertexBuffer.UV2Kind
  33531. * - VertexBuffer.UV3Kind
  33532. * - VertexBuffer.UV4Kind
  33533. * - VertexBuffer.UV5Kind
  33534. * - VertexBuffer.UV6Kind
  33535. * - VertexBuffer.ColorKind
  33536. * - VertexBuffer.MatricesIndicesKind
  33537. * - VertexBuffer.MatricesIndicesExtraKind
  33538. * - VertexBuffer.MatricesWeightsKind
  33539. * - VertexBuffer.MatricesWeightsExtraKind
  33540. * @param data defines the data source
  33541. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33542. * @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)
  33543. */
  33544. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33545. /**
  33546. * Creates a new index buffer
  33547. * @param indices defines the indices to store in the index buffer
  33548. * @param totalVertices defines the total number of vertices (could be null)
  33549. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33550. */
  33551. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33552. }
  33553. /**
  33554. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33555. */
  33556. export class VertexData {
  33557. /**
  33558. * Mesh side orientation : usually the external or front surface
  33559. */
  33560. static readonly FRONTSIDE: number;
  33561. /**
  33562. * Mesh side orientation : usually the internal or back surface
  33563. */
  33564. static readonly BACKSIDE: number;
  33565. /**
  33566. * Mesh side orientation : both internal and external or front and back surfaces
  33567. */
  33568. static readonly DOUBLESIDE: number;
  33569. /**
  33570. * Mesh side orientation : by default, `FRONTSIDE`
  33571. */
  33572. static readonly DEFAULTSIDE: number;
  33573. /**
  33574. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33575. */
  33576. positions: Nullable<FloatArray>;
  33577. /**
  33578. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33579. */
  33580. normals: Nullable<FloatArray>;
  33581. /**
  33582. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33583. */
  33584. tangents: Nullable<FloatArray>;
  33585. /**
  33586. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33587. */
  33588. uvs: Nullable<FloatArray>;
  33589. /**
  33590. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33591. */
  33592. uvs2: Nullable<FloatArray>;
  33593. /**
  33594. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33595. */
  33596. uvs3: Nullable<FloatArray>;
  33597. /**
  33598. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33599. */
  33600. uvs4: Nullable<FloatArray>;
  33601. /**
  33602. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33603. */
  33604. uvs5: Nullable<FloatArray>;
  33605. /**
  33606. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33607. */
  33608. uvs6: Nullable<FloatArray>;
  33609. /**
  33610. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33611. */
  33612. colors: Nullable<FloatArray>;
  33613. /**
  33614. * 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).
  33615. */
  33616. matricesIndices: Nullable<FloatArray>;
  33617. /**
  33618. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33619. */
  33620. matricesWeights: Nullable<FloatArray>;
  33621. /**
  33622. * An array extending the number of possible indices
  33623. */
  33624. matricesIndicesExtra: Nullable<FloatArray>;
  33625. /**
  33626. * An array extending the number of possible weights when the number of indices is extended
  33627. */
  33628. matricesWeightsExtra: Nullable<FloatArray>;
  33629. /**
  33630. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33631. */
  33632. indices: Nullable<IndicesArray>;
  33633. /**
  33634. * Uses the passed data array to set the set the values for the specified kind of data
  33635. * @param data a linear array of floating numbers
  33636. * @param kind the type of data that is being set, eg positions, colors etc
  33637. */
  33638. set(data: FloatArray, kind: string): void;
  33639. /**
  33640. * Associates the vertexData to the passed Mesh.
  33641. * Sets it as updatable or not (default `false`)
  33642. * @param mesh the mesh the vertexData is applied to
  33643. * @param updatable when used and having the value true allows new data to update the vertexData
  33644. * @returns the VertexData
  33645. */
  33646. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33647. /**
  33648. * Associates the vertexData to the passed Geometry.
  33649. * Sets it as updatable or not (default `false`)
  33650. * @param geometry the geometry the vertexData is applied to
  33651. * @param updatable when used and having the value true allows new data to update the vertexData
  33652. * @returns VertexData
  33653. */
  33654. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33655. /**
  33656. * Updates the associated mesh
  33657. * @param mesh the mesh to be updated
  33658. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33659. * @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
  33660. * @returns VertexData
  33661. */
  33662. updateMesh(mesh: Mesh): VertexData;
  33663. /**
  33664. * Updates the associated geometry
  33665. * @param geometry the geometry to be updated
  33666. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33667. * @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
  33668. * @returns VertexData.
  33669. */
  33670. updateGeometry(geometry: Geometry): VertexData;
  33671. private _applyTo;
  33672. private _update;
  33673. /**
  33674. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33675. * @param matrix the transforming matrix
  33676. * @returns the VertexData
  33677. */
  33678. transform(matrix: Matrix): VertexData;
  33679. /**
  33680. * Merges the passed VertexData into the current one
  33681. * @param other the VertexData to be merged into the current one
  33682. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33683. * @returns the modified VertexData
  33684. */
  33685. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33686. private _mergeElement;
  33687. private _validate;
  33688. /**
  33689. * Serializes the VertexData
  33690. * @returns a serialized object
  33691. */
  33692. serialize(): any;
  33693. /**
  33694. * Extracts the vertexData from a mesh
  33695. * @param mesh the mesh from which to extract the VertexData
  33696. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33697. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33698. * @returns the object VertexData associated to the passed mesh
  33699. */
  33700. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33701. /**
  33702. * Extracts the vertexData from the geometry
  33703. * @param geometry the geometry from which to extract the VertexData
  33704. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33705. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33706. * @returns the object VertexData associated to the passed mesh
  33707. */
  33708. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33709. private static _ExtractFrom;
  33710. /**
  33711. * Creates the VertexData for a Ribbon
  33712. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33713. * * pathArray array of paths, each of which an array of successive Vector3
  33714. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33715. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33716. * * 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
  33717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33718. * * 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)
  33719. * * 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)
  33720. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33721. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33722. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33723. * @returns the VertexData of the ribbon
  33724. */
  33725. static CreateRibbon(options: {
  33726. pathArray: Vector3[][];
  33727. closeArray?: boolean;
  33728. closePath?: boolean;
  33729. offset?: number;
  33730. sideOrientation?: number;
  33731. frontUVs?: Vector4;
  33732. backUVs?: Vector4;
  33733. invertUV?: boolean;
  33734. uvs?: Vector2[];
  33735. colors?: Color4[];
  33736. }): VertexData;
  33737. /**
  33738. * Creates the VertexData for a box
  33739. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33740. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33741. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33742. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33743. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33744. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33745. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33747. * * 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)
  33748. * * 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)
  33749. * @returns the VertexData of the box
  33750. */
  33751. static CreateBox(options: {
  33752. size?: number;
  33753. width?: number;
  33754. height?: number;
  33755. depth?: number;
  33756. faceUV?: Vector4[];
  33757. faceColors?: Color4[];
  33758. sideOrientation?: number;
  33759. frontUVs?: Vector4;
  33760. backUVs?: Vector4;
  33761. }): VertexData;
  33762. /**
  33763. * Creates the VertexData for a tiled box
  33764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33765. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33766. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33767. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33769. * @returns the VertexData of the box
  33770. */
  33771. static CreateTiledBox(options: {
  33772. pattern?: number;
  33773. width?: number;
  33774. height?: number;
  33775. depth?: number;
  33776. tileSize?: number;
  33777. tileWidth?: number;
  33778. tileHeight?: number;
  33779. alignHorizontal?: number;
  33780. alignVertical?: number;
  33781. faceUV?: Vector4[];
  33782. faceColors?: Color4[];
  33783. sideOrientation?: number;
  33784. }): VertexData;
  33785. /**
  33786. * Creates the VertexData for a tiled plane
  33787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33788. * * pattern a limited pattern arrangement depending on the number
  33789. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33790. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33791. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33793. * * 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)
  33794. * * 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)
  33795. * @returns the VertexData of the tiled plane
  33796. */
  33797. static CreateTiledPlane(options: {
  33798. pattern?: number;
  33799. tileSize?: number;
  33800. tileWidth?: number;
  33801. tileHeight?: number;
  33802. size?: number;
  33803. width?: number;
  33804. height?: number;
  33805. alignHorizontal?: number;
  33806. alignVertical?: number;
  33807. sideOrientation?: number;
  33808. frontUVs?: Vector4;
  33809. backUVs?: Vector4;
  33810. }): VertexData;
  33811. /**
  33812. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33813. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33814. * * segments sets the number of horizontal strips optional, default 32
  33815. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33816. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33817. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33818. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33819. * * 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
  33820. * * 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
  33821. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33822. * * 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)
  33823. * * 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)
  33824. * @returns the VertexData of the ellipsoid
  33825. */
  33826. static CreateSphere(options: {
  33827. segments?: number;
  33828. diameter?: number;
  33829. diameterX?: number;
  33830. diameterY?: number;
  33831. diameterZ?: number;
  33832. arc?: number;
  33833. slice?: number;
  33834. sideOrientation?: number;
  33835. frontUVs?: Vector4;
  33836. backUVs?: Vector4;
  33837. }): VertexData;
  33838. /**
  33839. * Creates the VertexData for a cylinder, cone or prism
  33840. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33841. * * height sets the height (y direction) of the cylinder, optional, default 2
  33842. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33843. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33844. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33845. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33846. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33847. * * 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
  33848. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33849. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33850. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33851. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33853. * * 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)
  33854. * * 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)
  33855. * @returns the VertexData of the cylinder, cone or prism
  33856. */
  33857. static CreateCylinder(options: {
  33858. height?: number;
  33859. diameterTop?: number;
  33860. diameterBottom?: number;
  33861. diameter?: number;
  33862. tessellation?: number;
  33863. subdivisions?: number;
  33864. arc?: number;
  33865. faceColors?: Color4[];
  33866. faceUV?: Vector4[];
  33867. hasRings?: boolean;
  33868. enclose?: boolean;
  33869. sideOrientation?: number;
  33870. frontUVs?: Vector4;
  33871. backUVs?: Vector4;
  33872. }): VertexData;
  33873. /**
  33874. * Creates the VertexData for a torus
  33875. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33876. * * diameter the diameter of the torus, optional default 1
  33877. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33878. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33880. * * 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)
  33881. * * 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)
  33882. * @returns the VertexData of the torus
  33883. */
  33884. static CreateTorus(options: {
  33885. diameter?: number;
  33886. thickness?: number;
  33887. tessellation?: number;
  33888. sideOrientation?: number;
  33889. frontUVs?: Vector4;
  33890. backUVs?: Vector4;
  33891. }): VertexData;
  33892. /**
  33893. * Creates the VertexData of the LineSystem
  33894. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33895. * - lines an array of lines, each line being an array of successive Vector3
  33896. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33897. * @returns the VertexData of the LineSystem
  33898. */
  33899. static CreateLineSystem(options: {
  33900. lines: Vector3[][];
  33901. colors?: Nullable<Color4[][]>;
  33902. }): VertexData;
  33903. /**
  33904. * Create the VertexData for a DashedLines
  33905. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33906. * - points an array successive Vector3
  33907. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33908. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33909. * - dashNb the intended total number of dashes, optional, default 200
  33910. * @returns the VertexData for the DashedLines
  33911. */
  33912. static CreateDashedLines(options: {
  33913. points: Vector3[];
  33914. dashSize?: number;
  33915. gapSize?: number;
  33916. dashNb?: number;
  33917. }): VertexData;
  33918. /**
  33919. * Creates the VertexData for a Ground
  33920. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33921. * - width the width (x direction) of the ground, optional, default 1
  33922. * - height the height (z direction) of the ground, optional, default 1
  33923. * - subdivisions the number of subdivisions per side, optional, default 1
  33924. * @returns the VertexData of the Ground
  33925. */
  33926. static CreateGround(options: {
  33927. width?: number;
  33928. height?: number;
  33929. subdivisions?: number;
  33930. subdivisionsX?: number;
  33931. subdivisionsY?: number;
  33932. }): VertexData;
  33933. /**
  33934. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33935. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33936. * * xmin the ground minimum X coordinate, optional, default -1
  33937. * * zmin the ground minimum Z coordinate, optional, default -1
  33938. * * xmax the ground maximum X coordinate, optional, default 1
  33939. * * zmax the ground maximum Z coordinate, optional, default 1
  33940. * * 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}
  33941. * * 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}
  33942. * @returns the VertexData of the TiledGround
  33943. */
  33944. static CreateTiledGround(options: {
  33945. xmin: number;
  33946. zmin: number;
  33947. xmax: number;
  33948. zmax: number;
  33949. subdivisions?: {
  33950. w: number;
  33951. h: number;
  33952. };
  33953. precision?: {
  33954. w: number;
  33955. h: number;
  33956. };
  33957. }): VertexData;
  33958. /**
  33959. * Creates the VertexData of the Ground designed from a heightmap
  33960. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33961. * * width the width (x direction) of the ground
  33962. * * height the height (z direction) of the ground
  33963. * * subdivisions the number of subdivisions per side
  33964. * * minHeight the minimum altitude on the ground, optional, default 0
  33965. * * maxHeight the maximum altitude on the ground, optional default 1
  33966. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33967. * * buffer the array holding the image color data
  33968. * * bufferWidth the width of image
  33969. * * bufferHeight the height of image
  33970. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33971. * @returns the VertexData of the Ground designed from a heightmap
  33972. */
  33973. static CreateGroundFromHeightMap(options: {
  33974. width: number;
  33975. height: number;
  33976. subdivisions: number;
  33977. minHeight: number;
  33978. maxHeight: number;
  33979. colorFilter: Color3;
  33980. buffer: Uint8Array;
  33981. bufferWidth: number;
  33982. bufferHeight: number;
  33983. alphaFilter: number;
  33984. }): VertexData;
  33985. /**
  33986. * Creates the VertexData for a Plane
  33987. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33988. * * size sets the width and height of the plane to the value of size, optional default 1
  33989. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33990. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33992. * * 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)
  33993. * * 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)
  33994. * @returns the VertexData of the box
  33995. */
  33996. static CreatePlane(options: {
  33997. size?: number;
  33998. width?: number;
  33999. height?: number;
  34000. sideOrientation?: number;
  34001. frontUVs?: Vector4;
  34002. backUVs?: Vector4;
  34003. }): VertexData;
  34004. /**
  34005. * Creates the VertexData of the Disc or regular Polygon
  34006. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34007. * * radius the radius of the disc, optional default 0.5
  34008. * * tessellation the number of polygon sides, optional, default 64
  34009. * * 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
  34010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34011. * * 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)
  34012. * * 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)
  34013. * @returns the VertexData of the box
  34014. */
  34015. static CreateDisc(options: {
  34016. radius?: number;
  34017. tessellation?: number;
  34018. arc?: number;
  34019. sideOrientation?: number;
  34020. frontUVs?: Vector4;
  34021. backUVs?: Vector4;
  34022. }): VertexData;
  34023. /**
  34024. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34025. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34026. * @param polygon a mesh built from polygonTriangulation.build()
  34027. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34028. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34029. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34030. * @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)
  34031. * @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)
  34032. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34033. * @returns the VertexData of the Polygon
  34034. */
  34035. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34036. /**
  34037. * Creates the VertexData of the IcoSphere
  34038. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34039. * * radius the radius of the IcoSphere, optional default 1
  34040. * * radiusX allows stretching in the x direction, optional, default radius
  34041. * * radiusY allows stretching in the y direction, optional, default radius
  34042. * * radiusZ allows stretching in the z direction, optional, default radius
  34043. * * flat when true creates a flat shaded mesh, optional, default true
  34044. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34046. * * 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)
  34047. * * 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)
  34048. * @returns the VertexData of the IcoSphere
  34049. */
  34050. static CreateIcoSphere(options: {
  34051. radius?: number;
  34052. radiusX?: number;
  34053. radiusY?: number;
  34054. radiusZ?: number;
  34055. flat?: boolean;
  34056. subdivisions?: number;
  34057. sideOrientation?: number;
  34058. frontUVs?: Vector4;
  34059. backUVs?: Vector4;
  34060. }): VertexData;
  34061. /**
  34062. * Creates the VertexData for a Polyhedron
  34063. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34064. * * type provided types are:
  34065. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34066. * * 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)
  34067. * * size the size of the IcoSphere, optional default 1
  34068. * * sizeX allows stretching in the x direction, optional, default size
  34069. * * sizeY allows stretching in the y direction, optional, default size
  34070. * * sizeZ allows stretching in the z direction, optional, default size
  34071. * * 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
  34072. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34073. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34074. * * flat when true creates a flat shaded mesh, optional, default true
  34075. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34077. * * 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)
  34078. * * 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)
  34079. * @returns the VertexData of the Polyhedron
  34080. */
  34081. static CreatePolyhedron(options: {
  34082. type?: number;
  34083. size?: number;
  34084. sizeX?: number;
  34085. sizeY?: number;
  34086. sizeZ?: number;
  34087. custom?: any;
  34088. faceUV?: Vector4[];
  34089. faceColors?: Color4[];
  34090. flat?: boolean;
  34091. sideOrientation?: number;
  34092. frontUVs?: Vector4;
  34093. backUVs?: Vector4;
  34094. }): VertexData;
  34095. /**
  34096. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34097. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34098. * @returns the VertexData of the Capsule
  34099. */
  34100. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34101. /**
  34102. * Creates the VertexData for a TorusKnot
  34103. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34104. * * radius the radius of the torus knot, optional, default 2
  34105. * * tube the thickness of the tube, optional, default 0.5
  34106. * * radialSegments the number of sides on each tube segments, optional, default 32
  34107. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34108. * * p the number of windings around the z axis, optional, default 2
  34109. * * q the number of windings around the x axis, optional, default 3
  34110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34111. * * 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)
  34112. * * 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)
  34113. * @returns the VertexData of the Torus Knot
  34114. */
  34115. static CreateTorusKnot(options: {
  34116. radius?: number;
  34117. tube?: number;
  34118. radialSegments?: number;
  34119. tubularSegments?: number;
  34120. p?: number;
  34121. q?: number;
  34122. sideOrientation?: number;
  34123. frontUVs?: Vector4;
  34124. backUVs?: Vector4;
  34125. }): VertexData;
  34126. /**
  34127. * Compute normals for given positions and indices
  34128. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34129. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34130. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34131. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34132. * * facetNormals : optional array of facet normals (vector3)
  34133. * * facetPositions : optional array of facet positions (vector3)
  34134. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34135. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34136. * * bInfo : optional bounding info, required for facetPartitioning computation
  34137. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34138. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34139. * * useRightHandedSystem: optional boolean to for right handed system computation
  34140. * * depthSort : optional boolean to enable the facet depth sort computation
  34141. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34142. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34143. */
  34144. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34145. facetNormals?: any;
  34146. facetPositions?: any;
  34147. facetPartitioning?: any;
  34148. ratio?: number;
  34149. bInfo?: any;
  34150. bbSize?: Vector3;
  34151. subDiv?: any;
  34152. useRightHandedSystem?: boolean;
  34153. depthSort?: boolean;
  34154. distanceTo?: Vector3;
  34155. depthSortedFacets?: any;
  34156. }): void;
  34157. /** @hidden */
  34158. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34159. /**
  34160. * Applies VertexData created from the imported parameters to the geometry
  34161. * @param parsedVertexData the parsed data from an imported file
  34162. * @param geometry the geometry to apply the VertexData to
  34163. */
  34164. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34165. }
  34166. }
  34167. declare module BABYLON {
  34168. /**
  34169. * Class containing static functions to help procedurally build meshes
  34170. */
  34171. export class DiscBuilder {
  34172. /**
  34173. * Creates a plane polygonal mesh. By default, this is a disc
  34174. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34175. * * 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
  34176. * * 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
  34177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34178. * * 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
  34179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34180. * @param name defines the name of the mesh
  34181. * @param options defines the options used to create the mesh
  34182. * @param scene defines the hosting scene
  34183. * @returns the plane polygonal mesh
  34184. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34185. */
  34186. static CreateDisc(name: string, options: {
  34187. radius?: number;
  34188. tessellation?: number;
  34189. arc?: number;
  34190. updatable?: boolean;
  34191. sideOrientation?: number;
  34192. frontUVs?: Vector4;
  34193. backUVs?: Vector4;
  34194. }, scene?: Nullable<Scene>): Mesh;
  34195. }
  34196. }
  34197. declare module BABYLON {
  34198. /**
  34199. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34200. *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.
  34201. * The SPS is also a particle system. It provides some methods to manage the particles.
  34202. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34203. *
  34204. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34205. */
  34206. export class SolidParticleSystem implements IDisposable {
  34207. /**
  34208. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34209. * Example : var p = SPS.particles[i];
  34210. */
  34211. particles: SolidParticle[];
  34212. /**
  34213. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34214. */
  34215. nbParticles: number;
  34216. /**
  34217. * If the particles must ever face the camera (default false). Useful for planar particles.
  34218. */
  34219. billboard: boolean;
  34220. /**
  34221. * Recompute normals when adding a shape
  34222. */
  34223. recomputeNormals: boolean;
  34224. /**
  34225. * This a counter ofr your own usage. It's not set by any SPS functions.
  34226. */
  34227. counter: number;
  34228. /**
  34229. * The SPS name. This name is also given to the underlying mesh.
  34230. */
  34231. name: string;
  34232. /**
  34233. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34234. */
  34235. mesh: Mesh;
  34236. /**
  34237. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34238. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34239. */
  34240. vars: any;
  34241. /**
  34242. * This array is populated when the SPS is set as 'pickable'.
  34243. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34244. * Each element of this array is an object `{idx: int, faceId: int}`.
  34245. * `idx` is the picked particle index in the `SPS.particles` array
  34246. * `faceId` is the picked face index counted within this particle.
  34247. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34248. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34249. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34250. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34251. */
  34252. pickedParticles: {
  34253. idx: number;
  34254. faceId: number;
  34255. }[];
  34256. /**
  34257. * This array is populated when the SPS is set as 'pickable'
  34258. * Each key of this array is a submesh index.
  34259. * Each element of this array is a second array defined like this :
  34260. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34261. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34262. * `idx` is the picked particle index in the `SPS.particles` array
  34263. * `faceId` is the picked face index counted within this particle.
  34264. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34265. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34266. */
  34267. pickedBySubMesh: {
  34268. idx: number;
  34269. faceId: number;
  34270. }[][];
  34271. /**
  34272. * This array is populated when `enableDepthSort` is set to true.
  34273. * Each element of this array is an instance of the class DepthSortedParticle.
  34274. */
  34275. depthSortedParticles: DepthSortedParticle[];
  34276. /**
  34277. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34278. * @hidden
  34279. */
  34280. _bSphereOnly: boolean;
  34281. /**
  34282. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34283. * @hidden
  34284. */
  34285. _bSphereRadiusFactor: number;
  34286. private _scene;
  34287. private _positions;
  34288. private _indices;
  34289. private _normals;
  34290. private _colors;
  34291. private _uvs;
  34292. private _indices32;
  34293. private _positions32;
  34294. private _normals32;
  34295. private _fixedNormal32;
  34296. private _colors32;
  34297. private _uvs32;
  34298. private _index;
  34299. private _updatable;
  34300. private _pickable;
  34301. private _isVisibilityBoxLocked;
  34302. private _alwaysVisible;
  34303. private _depthSort;
  34304. private _expandable;
  34305. private _shapeCounter;
  34306. private _copy;
  34307. private _color;
  34308. private _computeParticleColor;
  34309. private _computeParticleTexture;
  34310. private _computeParticleRotation;
  34311. private _computeParticleVertex;
  34312. private _computeBoundingBox;
  34313. private _depthSortParticles;
  34314. private _camera;
  34315. private _mustUnrotateFixedNormals;
  34316. private _particlesIntersect;
  34317. private _needs32Bits;
  34318. private _isNotBuilt;
  34319. private _lastParticleId;
  34320. private _idxOfId;
  34321. private _multimaterialEnabled;
  34322. private _useModelMaterial;
  34323. private _indicesByMaterial;
  34324. private _materialIndexes;
  34325. private _depthSortFunction;
  34326. private _materialSortFunction;
  34327. private _materials;
  34328. private _multimaterial;
  34329. private _materialIndexesById;
  34330. private _defaultMaterial;
  34331. private _autoUpdateSubMeshes;
  34332. private _tmpVertex;
  34333. /**
  34334. * Creates a SPS (Solid Particle System) object.
  34335. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34336. * @param scene (Scene) is the scene in which the SPS is added.
  34337. * @param options defines the options of the sps e.g.
  34338. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34339. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34340. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34341. * * 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.
  34342. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34343. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34344. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34345. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34346. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34347. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34348. */
  34349. constructor(name: string, scene: Scene, options?: {
  34350. updatable?: boolean;
  34351. isPickable?: boolean;
  34352. enableDepthSort?: boolean;
  34353. particleIntersection?: boolean;
  34354. boundingSphereOnly?: boolean;
  34355. bSphereRadiusFactor?: number;
  34356. expandable?: boolean;
  34357. useModelMaterial?: boolean;
  34358. enableMultiMaterial?: boolean;
  34359. });
  34360. /**
  34361. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34362. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34363. * @returns the created mesh
  34364. */
  34365. buildMesh(): Mesh;
  34366. /**
  34367. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34368. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34369. * Thus the particles generated from `digest()` have their property `position` set yet.
  34370. * @param mesh ( Mesh ) is the mesh to be digested
  34371. * @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
  34372. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34373. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34374. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34375. * @returns the current SPS
  34376. */
  34377. digest(mesh: Mesh, options?: {
  34378. facetNb?: number;
  34379. number?: number;
  34380. delta?: number;
  34381. storage?: [];
  34382. }): SolidParticleSystem;
  34383. /**
  34384. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34385. * @hidden
  34386. */
  34387. private _unrotateFixedNormals;
  34388. /**
  34389. * Resets the temporary working copy particle
  34390. * @hidden
  34391. */
  34392. private _resetCopy;
  34393. /**
  34394. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34395. * @param p the current index in the positions array to be updated
  34396. * @param ind the current index in the indices array
  34397. * @param shape a Vector3 array, the shape geometry
  34398. * @param positions the positions array to be updated
  34399. * @param meshInd the shape indices array
  34400. * @param indices the indices array to be updated
  34401. * @param meshUV the shape uv array
  34402. * @param uvs the uv array to be updated
  34403. * @param meshCol the shape color array
  34404. * @param colors the color array to be updated
  34405. * @param meshNor the shape normals array
  34406. * @param normals the normals array to be updated
  34407. * @param idx the particle index
  34408. * @param idxInShape the particle index in its shape
  34409. * @param options the addShape() method passed options
  34410. * @model the particle model
  34411. * @hidden
  34412. */
  34413. private _meshBuilder;
  34414. /**
  34415. * Returns a shape Vector3 array from positions float array
  34416. * @param positions float array
  34417. * @returns a vector3 array
  34418. * @hidden
  34419. */
  34420. private _posToShape;
  34421. /**
  34422. * Returns a shapeUV array from a float uvs (array deep copy)
  34423. * @param uvs as a float array
  34424. * @returns a shapeUV array
  34425. * @hidden
  34426. */
  34427. private _uvsToShapeUV;
  34428. /**
  34429. * Adds a new particle object in the particles array
  34430. * @param idx particle index in particles array
  34431. * @param id particle id
  34432. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34433. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34434. * @param model particle ModelShape object
  34435. * @param shapeId model shape identifier
  34436. * @param idxInShape index of the particle in the current model
  34437. * @param bInfo model bounding info object
  34438. * @param storage target storage array, if any
  34439. * @hidden
  34440. */
  34441. private _addParticle;
  34442. /**
  34443. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34444. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34445. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34446. * @param nb (positive integer) the number of particles to be created from this model
  34447. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34448. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34449. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34450. * @returns the number of shapes in the system
  34451. */
  34452. addShape(mesh: Mesh, nb: number, options?: {
  34453. positionFunction?: any;
  34454. vertexFunction?: any;
  34455. storage?: [];
  34456. }): number;
  34457. /**
  34458. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34459. * @hidden
  34460. */
  34461. private _rebuildParticle;
  34462. /**
  34463. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34464. * @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.
  34465. * @returns the SPS.
  34466. */
  34467. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34468. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34469. * Returns an array with the removed particles.
  34470. * 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.
  34471. * The SPS can't be empty so at least one particle needs to remain in place.
  34472. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34473. * @param start index of the first particle to remove
  34474. * @param end index of the last particle to remove (included)
  34475. * @returns an array populated with the removed particles
  34476. */
  34477. removeParticles(start: number, end: number): SolidParticle[];
  34478. /**
  34479. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34480. * @param solidParticleArray an array populated with Solid Particles objects
  34481. * @returns the SPS
  34482. */
  34483. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34484. /**
  34485. * Creates a new particle and modifies the SPS mesh geometry :
  34486. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34487. * - calls _addParticle() to populate the particle array
  34488. * factorized code from addShape() and insertParticlesFromArray()
  34489. * @param idx particle index in the particles array
  34490. * @param i particle index in its shape
  34491. * @param modelShape particle ModelShape object
  34492. * @param shape shape vertex array
  34493. * @param meshInd shape indices array
  34494. * @param meshUV shape uv array
  34495. * @param meshCol shape color array
  34496. * @param meshNor shape normals array
  34497. * @param bbInfo shape bounding info
  34498. * @param storage target particle storage
  34499. * @options addShape() passed options
  34500. * @hidden
  34501. */
  34502. private _insertNewParticle;
  34503. /**
  34504. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34505. * This method calls `updateParticle()` for each particle of the SPS.
  34506. * For an animated SPS, it is usually called within the render loop.
  34507. * 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.
  34508. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34509. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34510. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34511. * @returns the SPS.
  34512. */
  34513. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34514. /**
  34515. * Disposes the SPS.
  34516. */
  34517. dispose(): void;
  34518. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34519. * idx is the particle index in the SPS
  34520. * faceId is the picked face index counted within this particle.
  34521. * Returns null if the pickInfo can't identify a picked particle.
  34522. * @param pickingInfo (PickingInfo object)
  34523. * @returns {idx: number, faceId: number} or null
  34524. */
  34525. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34526. idx: number;
  34527. faceId: number;
  34528. }>;
  34529. /**
  34530. * Returns a SolidParticle object from its identifier : particle.id
  34531. * @param id (integer) the particle Id
  34532. * @returns the searched particle or null if not found in the SPS.
  34533. */
  34534. getParticleById(id: number): Nullable<SolidParticle>;
  34535. /**
  34536. * Returns a new array populated with the particles having the passed shapeId.
  34537. * @param shapeId (integer) the shape identifier
  34538. * @returns a new solid particle array
  34539. */
  34540. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34541. /**
  34542. * Populates the passed array "ref" with the particles having the passed shapeId.
  34543. * @param shapeId the shape identifier
  34544. * @returns the SPS
  34545. * @param ref
  34546. */
  34547. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34548. /**
  34549. * Computes the required SubMeshes according the materials assigned to the particles.
  34550. * @returns the solid particle system.
  34551. * Does nothing if called before the SPS mesh is built.
  34552. */
  34553. computeSubMeshes(): SolidParticleSystem;
  34554. /**
  34555. * Sorts the solid particles by material when MultiMaterial is enabled.
  34556. * Updates the indices32 array.
  34557. * Updates the indicesByMaterial array.
  34558. * Updates the mesh indices array.
  34559. * @returns the SPS
  34560. * @hidden
  34561. */
  34562. private _sortParticlesByMaterial;
  34563. /**
  34564. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34565. * @hidden
  34566. */
  34567. private _setMaterialIndexesById;
  34568. /**
  34569. * Returns an array with unique values of Materials from the passed array
  34570. * @param array the material array to be checked and filtered
  34571. * @hidden
  34572. */
  34573. private _filterUniqueMaterialId;
  34574. /**
  34575. * Sets a new Standard Material as _defaultMaterial if not already set.
  34576. * @hidden
  34577. */
  34578. private _setDefaultMaterial;
  34579. /**
  34580. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34581. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34582. * @returns the SPS.
  34583. */
  34584. refreshVisibleSize(): SolidParticleSystem;
  34585. /**
  34586. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34587. * @param size the size (float) of the visibility box
  34588. * note : this doesn't lock the SPS mesh bounding box.
  34589. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34590. */
  34591. setVisibilityBox(size: number): void;
  34592. /**
  34593. * Gets whether the SPS as always visible or not
  34594. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34595. */
  34596. get isAlwaysVisible(): boolean;
  34597. /**
  34598. * Sets the SPS as always visible or not
  34599. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34600. */
  34601. set isAlwaysVisible(val: boolean);
  34602. /**
  34603. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34604. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34605. */
  34606. set isVisibilityBoxLocked(val: boolean);
  34607. /**
  34608. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34609. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34610. */
  34611. get isVisibilityBoxLocked(): boolean;
  34612. /**
  34613. * Tells to `setParticles()` to compute the particle rotations or not.
  34614. * Default value : true. The SPS is faster when it's set to false.
  34615. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34616. */
  34617. set computeParticleRotation(val: boolean);
  34618. /**
  34619. * Tells to `setParticles()` to compute the particle colors or not.
  34620. * Default value : true. The SPS is faster when it's set to false.
  34621. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34622. */
  34623. set computeParticleColor(val: boolean);
  34624. set computeParticleTexture(val: boolean);
  34625. /**
  34626. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34627. * Default value : false. The SPS is faster when it's set to false.
  34628. * Note : the particle custom vertex positions aren't stored values.
  34629. */
  34630. set computeParticleVertex(val: boolean);
  34631. /**
  34632. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34633. */
  34634. set computeBoundingBox(val: boolean);
  34635. /**
  34636. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34637. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34638. * Default : `true`
  34639. */
  34640. set depthSortParticles(val: boolean);
  34641. /**
  34642. * Gets if `setParticles()` computes the particle rotations or not.
  34643. * Default value : true. The SPS is faster when it's set to false.
  34644. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34645. */
  34646. get computeParticleRotation(): boolean;
  34647. /**
  34648. * Gets if `setParticles()` computes the particle colors or not.
  34649. * Default value : true. The SPS is faster when it's set to false.
  34650. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34651. */
  34652. get computeParticleColor(): boolean;
  34653. /**
  34654. * Gets if `setParticles()` computes the particle textures or not.
  34655. * Default value : true. The SPS is faster when it's set to false.
  34656. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34657. */
  34658. get computeParticleTexture(): boolean;
  34659. /**
  34660. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34661. * Default value : false. The SPS is faster when it's set to false.
  34662. * Note : the particle custom vertex positions aren't stored values.
  34663. */
  34664. get computeParticleVertex(): boolean;
  34665. /**
  34666. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34667. */
  34668. get computeBoundingBox(): boolean;
  34669. /**
  34670. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34671. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34672. * Default : `true`
  34673. */
  34674. get depthSortParticles(): boolean;
  34675. /**
  34676. * Gets if the SPS is created as expandable at construction time.
  34677. * Default : `false`
  34678. */
  34679. get expandable(): boolean;
  34680. /**
  34681. * Gets if the SPS supports the Multi Materials
  34682. */
  34683. get multimaterialEnabled(): boolean;
  34684. /**
  34685. * Gets if the SPS uses the model materials for its own multimaterial.
  34686. */
  34687. get useModelMaterial(): boolean;
  34688. /**
  34689. * The SPS used material array.
  34690. */
  34691. get materials(): Material[];
  34692. /**
  34693. * Sets the SPS MultiMaterial from the passed materials.
  34694. * Note : the passed array is internally copied and not used then by reference.
  34695. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34696. */
  34697. setMultiMaterial(materials: Material[]): void;
  34698. /**
  34699. * The SPS computed multimaterial object
  34700. */
  34701. get multimaterial(): MultiMaterial;
  34702. set multimaterial(mm: MultiMaterial);
  34703. /**
  34704. * If the subMeshes must be updated on the next call to setParticles()
  34705. */
  34706. get autoUpdateSubMeshes(): boolean;
  34707. set autoUpdateSubMeshes(val: boolean);
  34708. /**
  34709. * This function does nothing. It may be overwritten to set all the particle first values.
  34710. * The SPS doesn't call this function, you may have to call it by your own.
  34711. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34712. */
  34713. initParticles(): void;
  34714. /**
  34715. * This function does nothing. It may be overwritten to recycle a particle.
  34716. * The SPS doesn't call this function, you may have to call it by your own.
  34717. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34718. * @param particle The particle to recycle
  34719. * @returns the recycled particle
  34720. */
  34721. recycleParticle(particle: SolidParticle): SolidParticle;
  34722. /**
  34723. * Updates a particle : this function should be overwritten by the user.
  34724. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34725. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34726. * @example : just set a particle position or velocity and recycle conditions
  34727. * @param particle The particle to update
  34728. * @returns the updated particle
  34729. */
  34730. updateParticle(particle: SolidParticle): SolidParticle;
  34731. /**
  34732. * Updates a vertex of a particle : it can be overwritten by the user.
  34733. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34734. * @param particle the current particle
  34735. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34736. * @param pt the index of the current vertex in the particle shape
  34737. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34738. * @example : just set a vertex particle position or color
  34739. * @returns the sps
  34740. */
  34741. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34742. /**
  34743. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34744. * This does nothing and may be overwritten by the user.
  34745. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34746. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34747. * @param update the boolean update value actually passed to setParticles()
  34748. */
  34749. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34750. /**
  34751. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34752. * This will be passed three parameters.
  34753. * This does nothing and may be overwritten by the user.
  34754. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34755. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34756. * @param update the boolean update value actually passed to setParticles()
  34757. */
  34758. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34759. }
  34760. }
  34761. declare module BABYLON {
  34762. /**
  34763. * Represents one particle of a solid particle system.
  34764. */
  34765. export class SolidParticle {
  34766. /**
  34767. * particle global index
  34768. */
  34769. idx: number;
  34770. /**
  34771. * particle identifier
  34772. */
  34773. id: number;
  34774. /**
  34775. * The color of the particle
  34776. */
  34777. color: Nullable<Color4>;
  34778. /**
  34779. * The world space position of the particle.
  34780. */
  34781. position: Vector3;
  34782. /**
  34783. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34784. */
  34785. rotation: Vector3;
  34786. /**
  34787. * The world space rotation quaternion of the particle.
  34788. */
  34789. rotationQuaternion: Nullable<Quaternion>;
  34790. /**
  34791. * The scaling of the particle.
  34792. */
  34793. scaling: Vector3;
  34794. /**
  34795. * The uvs of the particle.
  34796. */
  34797. uvs: Vector4;
  34798. /**
  34799. * The current speed of the particle.
  34800. */
  34801. velocity: Vector3;
  34802. /**
  34803. * The pivot point in the particle local space.
  34804. */
  34805. pivot: Vector3;
  34806. /**
  34807. * Must the particle be translated from its pivot point in its local space ?
  34808. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34809. * Default : false
  34810. */
  34811. translateFromPivot: boolean;
  34812. /**
  34813. * Is the particle active or not ?
  34814. */
  34815. alive: boolean;
  34816. /**
  34817. * Is the particle visible or not ?
  34818. */
  34819. isVisible: boolean;
  34820. /**
  34821. * Index of this particle in the global "positions" array (Internal use)
  34822. * @hidden
  34823. */
  34824. _pos: number;
  34825. /**
  34826. * @hidden Index of this particle in the global "indices" array (Internal use)
  34827. */
  34828. _ind: number;
  34829. /**
  34830. * @hidden ModelShape of this particle (Internal use)
  34831. */
  34832. _model: ModelShape;
  34833. /**
  34834. * ModelShape id of this particle
  34835. */
  34836. shapeId: number;
  34837. /**
  34838. * Index of the particle in its shape id
  34839. */
  34840. idxInShape: number;
  34841. /**
  34842. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34843. */
  34844. _modelBoundingInfo: BoundingInfo;
  34845. /**
  34846. * @hidden Particle BoundingInfo object (Internal use)
  34847. */
  34848. _boundingInfo: BoundingInfo;
  34849. /**
  34850. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34851. */
  34852. _sps: SolidParticleSystem;
  34853. /**
  34854. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34855. */
  34856. _stillInvisible: boolean;
  34857. /**
  34858. * @hidden Last computed particle rotation matrix
  34859. */
  34860. _rotationMatrix: number[];
  34861. /**
  34862. * Parent particle Id, if any.
  34863. * Default null.
  34864. */
  34865. parentId: Nullable<number>;
  34866. /**
  34867. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34868. */
  34869. materialIndex: Nullable<number>;
  34870. /**
  34871. * Custom object or properties.
  34872. */
  34873. props: Nullable<any>;
  34874. /**
  34875. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34876. * The possible values are :
  34877. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34878. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34879. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34880. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34881. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34882. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34883. * */
  34884. cullingStrategy: number;
  34885. /**
  34886. * @hidden Internal global position in the SPS.
  34887. */
  34888. _globalPosition: Vector3;
  34889. /**
  34890. * Creates a Solid Particle object.
  34891. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34892. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34893. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34894. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34895. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34896. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34897. * @param shapeId (integer) is the model shape identifier in the SPS.
  34898. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34899. * @param sps defines the sps it is associated to
  34900. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34901. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34902. */
  34903. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34904. /**
  34905. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34906. * @param target the particle target
  34907. * @returns the current particle
  34908. */
  34909. copyToRef(target: SolidParticle): SolidParticle;
  34910. /**
  34911. * Legacy support, changed scale to scaling
  34912. */
  34913. get scale(): Vector3;
  34914. /**
  34915. * Legacy support, changed scale to scaling
  34916. */
  34917. set scale(scale: Vector3);
  34918. /**
  34919. * Legacy support, changed quaternion to rotationQuaternion
  34920. */
  34921. get quaternion(): Nullable<Quaternion>;
  34922. /**
  34923. * Legacy support, changed quaternion to rotationQuaternion
  34924. */
  34925. set quaternion(q: Nullable<Quaternion>);
  34926. /**
  34927. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34928. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34929. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34930. * @returns true if it intersects
  34931. */
  34932. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34933. /**
  34934. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34935. * A particle is in the frustum if its bounding box intersects the frustum
  34936. * @param frustumPlanes defines the frustum to test
  34937. * @returns true if the particle is in the frustum planes
  34938. */
  34939. isInFrustum(frustumPlanes: Plane[]): boolean;
  34940. /**
  34941. * get the rotation matrix of the particle
  34942. * @hidden
  34943. */
  34944. getRotationMatrix(m: Matrix): void;
  34945. }
  34946. /**
  34947. * Represents the shape of the model used by one particle of a solid particle system.
  34948. * SPS internal tool, don't use it manually.
  34949. */
  34950. export class ModelShape {
  34951. /**
  34952. * The shape id
  34953. * @hidden
  34954. */
  34955. shapeID: number;
  34956. /**
  34957. * flat array of model positions (internal use)
  34958. * @hidden
  34959. */
  34960. _shape: Vector3[];
  34961. /**
  34962. * flat array of model UVs (internal use)
  34963. * @hidden
  34964. */
  34965. _shapeUV: number[];
  34966. /**
  34967. * color array of the model
  34968. * @hidden
  34969. */
  34970. _shapeColors: number[];
  34971. /**
  34972. * indices array of the model
  34973. * @hidden
  34974. */
  34975. _indices: number[];
  34976. /**
  34977. * normals array of the model
  34978. * @hidden
  34979. */
  34980. _normals: number[];
  34981. /**
  34982. * length of the shape in the model indices array (internal use)
  34983. * @hidden
  34984. */
  34985. _indicesLength: number;
  34986. /**
  34987. * Custom position function (internal use)
  34988. * @hidden
  34989. */
  34990. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34991. /**
  34992. * Custom vertex function (internal use)
  34993. * @hidden
  34994. */
  34995. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34996. /**
  34997. * Model material (internal use)
  34998. * @hidden
  34999. */
  35000. _material: Nullable<Material>;
  35001. /**
  35002. * 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.
  35003. * SPS internal tool, don't use it manually.
  35004. * @hidden
  35005. */
  35006. 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>);
  35007. }
  35008. /**
  35009. * Represents a Depth Sorted Particle in the solid particle system.
  35010. * @hidden
  35011. */
  35012. export class DepthSortedParticle {
  35013. /**
  35014. * Particle index
  35015. */
  35016. idx: number;
  35017. /**
  35018. * Index of the particle in the "indices" array
  35019. */
  35020. ind: number;
  35021. /**
  35022. * Length of the particle shape in the "indices" array
  35023. */
  35024. indicesLength: number;
  35025. /**
  35026. * Squared distance from the particle to the camera
  35027. */
  35028. sqDistance: number;
  35029. /**
  35030. * Material index when used with MultiMaterials
  35031. */
  35032. materialIndex: number;
  35033. /**
  35034. * Creates a new sorted particle
  35035. * @param materialIndex
  35036. */
  35037. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35038. }
  35039. /**
  35040. * Represents a solid particle vertex
  35041. */
  35042. export class SolidParticleVertex {
  35043. /**
  35044. * Vertex position
  35045. */
  35046. position: Vector3;
  35047. /**
  35048. * Vertex color
  35049. */
  35050. color: Color4;
  35051. /**
  35052. * Vertex UV
  35053. */
  35054. uv: Vector2;
  35055. /**
  35056. * Creates a new solid particle vertex
  35057. */
  35058. constructor();
  35059. /** Vertex x coordinate */
  35060. get x(): number;
  35061. set x(val: number);
  35062. /** Vertex y coordinate */
  35063. get y(): number;
  35064. set y(val: number);
  35065. /** Vertex z coordinate */
  35066. get z(): number;
  35067. set z(val: number);
  35068. }
  35069. }
  35070. declare module BABYLON {
  35071. /**
  35072. * @hidden
  35073. */
  35074. export class _MeshCollisionData {
  35075. _checkCollisions: boolean;
  35076. _collisionMask: number;
  35077. _collisionGroup: number;
  35078. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35079. _collider: Nullable<Collider>;
  35080. _oldPositionForCollisions: Vector3;
  35081. _diffPositionForCollisions: Vector3;
  35082. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35083. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35084. _collisionResponse: boolean;
  35085. }
  35086. }
  35087. declare module BABYLON {
  35088. /** @hidden */
  35089. class _FacetDataStorage {
  35090. facetPositions: Vector3[];
  35091. facetNormals: Vector3[];
  35092. facetPartitioning: number[][];
  35093. facetNb: number;
  35094. partitioningSubdivisions: number;
  35095. partitioningBBoxRatio: number;
  35096. facetDataEnabled: boolean;
  35097. facetParameters: any;
  35098. bbSize: Vector3;
  35099. subDiv: {
  35100. max: number;
  35101. X: number;
  35102. Y: number;
  35103. Z: number;
  35104. };
  35105. facetDepthSort: boolean;
  35106. facetDepthSortEnabled: boolean;
  35107. depthSortedIndices: IndicesArray;
  35108. depthSortedFacets: {
  35109. ind: number;
  35110. sqDistance: number;
  35111. }[];
  35112. facetDepthSortFunction: (f1: {
  35113. ind: number;
  35114. sqDistance: number;
  35115. }, f2: {
  35116. ind: number;
  35117. sqDistance: number;
  35118. }) => number;
  35119. facetDepthSortFrom: Vector3;
  35120. facetDepthSortOrigin: Vector3;
  35121. invertedMatrix: Matrix;
  35122. }
  35123. /**
  35124. * @hidden
  35125. **/
  35126. class _InternalAbstractMeshDataInfo {
  35127. _hasVertexAlpha: boolean;
  35128. _useVertexColors: boolean;
  35129. _numBoneInfluencers: number;
  35130. _applyFog: boolean;
  35131. _receiveShadows: boolean;
  35132. _facetData: _FacetDataStorage;
  35133. _visibility: number;
  35134. _skeleton: Nullable<Skeleton>;
  35135. _layerMask: number;
  35136. _computeBonesUsingShaders: boolean;
  35137. _isActive: boolean;
  35138. _onlyForInstances: boolean;
  35139. _isActiveIntermediate: boolean;
  35140. _onlyForInstancesIntermediate: boolean;
  35141. _actAsRegularMesh: boolean;
  35142. _currentLOD: Nullable<AbstractMesh>;
  35143. _currentLODIsUpToDate: boolean;
  35144. }
  35145. /**
  35146. * Class used to store all common mesh properties
  35147. */
  35148. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35149. /** No occlusion */
  35150. static OCCLUSION_TYPE_NONE: number;
  35151. /** Occlusion set to optimisitic */
  35152. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35153. /** Occlusion set to strict */
  35154. static OCCLUSION_TYPE_STRICT: number;
  35155. /** Use an accurante occlusion algorithm */
  35156. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35157. /** Use a conservative occlusion algorithm */
  35158. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35159. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35160. * Test order :
  35161. * Is the bounding sphere outside the frustum ?
  35162. * If not, are the bounding box vertices outside the frustum ?
  35163. * It not, then the cullable object is in the frustum.
  35164. */
  35165. static readonly CULLINGSTRATEGY_STANDARD: number;
  35166. /** Culling strategy : Bounding Sphere Only.
  35167. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35168. * It's also less accurate than the standard because some not visible objects can still be selected.
  35169. * Test : is the bounding sphere outside the frustum ?
  35170. * If not, then the cullable object is in the frustum.
  35171. */
  35172. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35173. /** Culling strategy : Optimistic Inclusion.
  35174. * This in an inclusion test first, then the standard exclusion test.
  35175. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35176. * 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.
  35177. * Anyway, it's as accurate as the standard strategy.
  35178. * Test :
  35179. * Is the cullable object bounding sphere center in the frustum ?
  35180. * If not, apply the default culling strategy.
  35181. */
  35182. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35183. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35184. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35185. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35186. * 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.
  35187. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35188. * Test :
  35189. * Is the cullable object bounding sphere center in the frustum ?
  35190. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35191. */
  35192. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35193. /**
  35194. * No billboard
  35195. */
  35196. static get BILLBOARDMODE_NONE(): number;
  35197. /** Billboard on X axis */
  35198. static get BILLBOARDMODE_X(): number;
  35199. /** Billboard on Y axis */
  35200. static get BILLBOARDMODE_Y(): number;
  35201. /** Billboard on Z axis */
  35202. static get BILLBOARDMODE_Z(): number;
  35203. /** Billboard on all axes */
  35204. static get BILLBOARDMODE_ALL(): number;
  35205. /** Billboard on using position instead of orientation */
  35206. static get BILLBOARDMODE_USE_POSITION(): number;
  35207. /** @hidden */
  35208. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35209. /**
  35210. * The culling strategy to use to check whether the mesh must be rendered or not.
  35211. * This value can be changed at any time and will be used on the next render mesh selection.
  35212. * The possible values are :
  35213. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35214. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35215. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35216. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35217. * Please read each static variable documentation to get details about the culling process.
  35218. * */
  35219. cullingStrategy: number;
  35220. /**
  35221. * Gets the number of facets in the mesh
  35222. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35223. */
  35224. get facetNb(): number;
  35225. /**
  35226. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35227. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35228. */
  35229. get partitioningSubdivisions(): number;
  35230. set partitioningSubdivisions(nb: number);
  35231. /**
  35232. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35233. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35234. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35235. */
  35236. get partitioningBBoxRatio(): number;
  35237. set partitioningBBoxRatio(ratio: number);
  35238. /**
  35239. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35240. * Works only for updatable meshes.
  35241. * Doesn't work with multi-materials
  35242. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35243. */
  35244. get mustDepthSortFacets(): boolean;
  35245. set mustDepthSortFacets(sort: boolean);
  35246. /**
  35247. * The location (Vector3) where the facet depth sort must be computed from.
  35248. * By default, the active camera position.
  35249. * Used only when facet depth sort is enabled
  35250. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35251. */
  35252. get facetDepthSortFrom(): Vector3;
  35253. set facetDepthSortFrom(location: Vector3);
  35254. /**
  35255. * gets a boolean indicating if facetData is enabled
  35256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35257. */
  35258. get isFacetDataEnabled(): boolean;
  35259. /** @hidden */
  35260. _updateNonUniformScalingState(value: boolean): boolean;
  35261. /**
  35262. * An event triggered when this mesh collides with another one
  35263. */
  35264. onCollideObservable: Observable<AbstractMesh>;
  35265. /** Set a function to call when this mesh collides with another one */
  35266. set onCollide(callback: () => void);
  35267. /**
  35268. * An event triggered when the collision's position changes
  35269. */
  35270. onCollisionPositionChangeObservable: Observable<Vector3>;
  35271. /** Set a function to call when the collision's position changes */
  35272. set onCollisionPositionChange(callback: () => void);
  35273. /**
  35274. * An event triggered when material is changed
  35275. */
  35276. onMaterialChangedObservable: Observable<AbstractMesh>;
  35277. /**
  35278. * Gets or sets the orientation for POV movement & rotation
  35279. */
  35280. definedFacingForward: boolean;
  35281. /** @hidden */
  35282. _occlusionQuery: Nullable<WebGLQuery>;
  35283. /** @hidden */
  35284. _renderingGroup: Nullable<RenderingGroup>;
  35285. /**
  35286. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35287. */
  35288. get visibility(): number;
  35289. /**
  35290. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35291. */
  35292. set visibility(value: number);
  35293. /** Gets or sets the alpha index used to sort transparent meshes
  35294. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35295. */
  35296. alphaIndex: number;
  35297. /**
  35298. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35299. */
  35300. isVisible: boolean;
  35301. /**
  35302. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35303. */
  35304. isPickable: boolean;
  35305. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35306. showSubMeshesBoundingBox: boolean;
  35307. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35308. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35309. */
  35310. isBlocker: boolean;
  35311. /**
  35312. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35313. */
  35314. enablePointerMoveEvents: boolean;
  35315. private _renderingGroupId;
  35316. /**
  35317. * Specifies the rendering group id for this mesh (0 by default)
  35318. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35319. */
  35320. get renderingGroupId(): number;
  35321. set renderingGroupId(value: number);
  35322. private _material;
  35323. /** Gets or sets current material */
  35324. get material(): Nullable<Material>;
  35325. set material(value: Nullable<Material>);
  35326. /**
  35327. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35328. * @see https://doc.babylonjs.com/babylon101/shadows
  35329. */
  35330. get receiveShadows(): boolean;
  35331. set receiveShadows(value: boolean);
  35332. /** Defines color to use when rendering outline */
  35333. outlineColor: Color3;
  35334. /** Define width to use when rendering outline */
  35335. outlineWidth: number;
  35336. /** Defines color to use when rendering overlay */
  35337. overlayColor: Color3;
  35338. /** Defines alpha to use when rendering overlay */
  35339. overlayAlpha: number;
  35340. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35341. get hasVertexAlpha(): boolean;
  35342. set hasVertexAlpha(value: boolean);
  35343. /** 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) */
  35344. get useVertexColors(): boolean;
  35345. set useVertexColors(value: boolean);
  35346. /**
  35347. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35348. */
  35349. get computeBonesUsingShaders(): boolean;
  35350. set computeBonesUsingShaders(value: boolean);
  35351. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35352. get numBoneInfluencers(): number;
  35353. set numBoneInfluencers(value: number);
  35354. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35355. get applyFog(): boolean;
  35356. set applyFog(value: boolean);
  35357. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35358. useOctreeForRenderingSelection: boolean;
  35359. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35360. useOctreeForPicking: boolean;
  35361. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35362. useOctreeForCollisions: boolean;
  35363. /**
  35364. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35365. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35366. */
  35367. get layerMask(): number;
  35368. set layerMask(value: number);
  35369. /**
  35370. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35371. */
  35372. alwaysSelectAsActiveMesh: boolean;
  35373. /**
  35374. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35375. */
  35376. doNotSyncBoundingInfo: boolean;
  35377. /**
  35378. * Gets or sets the current action manager
  35379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35380. */
  35381. actionManager: Nullable<AbstractActionManager>;
  35382. private _meshCollisionData;
  35383. /**
  35384. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35385. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35386. */
  35387. ellipsoid: Vector3;
  35388. /**
  35389. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35390. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35391. */
  35392. ellipsoidOffset: Vector3;
  35393. /**
  35394. * Gets or sets a collision mask used to mask collisions (default is -1).
  35395. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35396. */
  35397. get collisionMask(): number;
  35398. set collisionMask(mask: number);
  35399. /**
  35400. * Gets or sets a collision response flag (default is true).
  35401. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35402. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35403. * to respond to the collision.
  35404. */
  35405. get collisionResponse(): boolean;
  35406. set collisionResponse(response: boolean);
  35407. /**
  35408. * Gets or sets the current collision group mask (-1 by default).
  35409. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35410. */
  35411. get collisionGroup(): number;
  35412. set collisionGroup(mask: number);
  35413. /**
  35414. * Gets or sets current surrounding meshes (null by default).
  35415. *
  35416. * By default collision detection is tested against every mesh in the scene.
  35417. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35418. * meshes will be tested for the collision.
  35419. *
  35420. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35421. */
  35422. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35423. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35424. /**
  35425. * Defines edge width used when edgesRenderer is enabled
  35426. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35427. */
  35428. edgesWidth: number;
  35429. /**
  35430. * Defines edge color used when edgesRenderer is enabled
  35431. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35432. */
  35433. edgesColor: Color4;
  35434. /** @hidden */
  35435. _edgesRenderer: Nullable<IEdgesRenderer>;
  35436. /** @hidden */
  35437. _masterMesh: Nullable<AbstractMesh>;
  35438. /** @hidden */
  35439. _boundingInfo: Nullable<BoundingInfo>;
  35440. /** @hidden */
  35441. _renderId: number;
  35442. /**
  35443. * Gets or sets the list of subMeshes
  35444. * @see https://doc.babylonjs.com/how_to/multi_materials
  35445. */
  35446. subMeshes: SubMesh[];
  35447. /** @hidden */
  35448. _intersectionsInProgress: AbstractMesh[];
  35449. /** @hidden */
  35450. _unIndexed: boolean;
  35451. /** @hidden */
  35452. _lightSources: Light[];
  35453. /** Gets the list of lights affecting that mesh */
  35454. get lightSources(): Light[];
  35455. /** @hidden */
  35456. get _positions(): Nullable<Vector3[]>;
  35457. /** @hidden */
  35458. _waitingData: {
  35459. lods: Nullable<any>;
  35460. actions: Nullable<any>;
  35461. freezeWorldMatrix: Nullable<boolean>;
  35462. };
  35463. /** @hidden */
  35464. _bonesTransformMatrices: Nullable<Float32Array>;
  35465. /** @hidden */
  35466. _transformMatrixTexture: Nullable<RawTexture>;
  35467. /**
  35468. * Gets or sets a skeleton to apply skining transformations
  35469. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35470. */
  35471. set skeleton(value: Nullable<Skeleton>);
  35472. get skeleton(): Nullable<Skeleton>;
  35473. /**
  35474. * An event triggered when the mesh is rebuilt.
  35475. */
  35476. onRebuildObservable: Observable<AbstractMesh>;
  35477. /**
  35478. * Creates a new AbstractMesh
  35479. * @param name defines the name of the mesh
  35480. * @param scene defines the hosting scene
  35481. */
  35482. constructor(name: string, scene?: Nullable<Scene>);
  35483. /**
  35484. * Returns the string "AbstractMesh"
  35485. * @returns "AbstractMesh"
  35486. */
  35487. getClassName(): string;
  35488. /**
  35489. * Gets a string representation of the current mesh
  35490. * @param fullDetails defines a boolean indicating if full details must be included
  35491. * @returns a string representation of the current mesh
  35492. */
  35493. toString(fullDetails?: boolean): string;
  35494. /**
  35495. * @hidden
  35496. */
  35497. protected _getEffectiveParent(): Nullable<Node>;
  35498. /** @hidden */
  35499. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35500. /** @hidden */
  35501. _rebuild(): void;
  35502. /** @hidden */
  35503. _resyncLightSources(): void;
  35504. /** @hidden */
  35505. _resyncLightSource(light: Light): void;
  35506. /** @hidden */
  35507. _unBindEffect(): void;
  35508. /** @hidden */
  35509. _removeLightSource(light: Light, dispose: boolean): void;
  35510. private _markSubMeshesAsDirty;
  35511. /** @hidden */
  35512. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35513. /** @hidden */
  35514. _markSubMeshesAsAttributesDirty(): void;
  35515. /** @hidden */
  35516. _markSubMeshesAsMiscDirty(): void;
  35517. /**
  35518. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35519. */
  35520. get scaling(): Vector3;
  35521. set scaling(newScaling: Vector3);
  35522. /**
  35523. * Returns true if the mesh is blocked. Implemented by child classes
  35524. */
  35525. get isBlocked(): boolean;
  35526. /**
  35527. * Returns the mesh itself by default. Implemented by child classes
  35528. * @param camera defines the camera to use to pick the right LOD level
  35529. * @returns the currentAbstractMesh
  35530. */
  35531. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35532. /**
  35533. * Returns 0 by default. Implemented by child classes
  35534. * @returns an integer
  35535. */
  35536. getTotalVertices(): number;
  35537. /**
  35538. * Returns a positive integer : the total number of indices in this mesh geometry.
  35539. * @returns the numner of indices or zero if the mesh has no geometry.
  35540. */
  35541. getTotalIndices(): number;
  35542. /**
  35543. * Returns null by default. Implemented by child classes
  35544. * @returns null
  35545. */
  35546. getIndices(): Nullable<IndicesArray>;
  35547. /**
  35548. * Returns the array of the requested vertex data kind. Implemented by child classes
  35549. * @param kind defines the vertex data kind to use
  35550. * @returns null
  35551. */
  35552. getVerticesData(kind: string): Nullable<FloatArray>;
  35553. /**
  35554. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35555. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35556. * Note that a new underlying VertexBuffer object is created each call.
  35557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35558. * @param kind defines vertex data kind:
  35559. * * VertexBuffer.PositionKind
  35560. * * VertexBuffer.UVKind
  35561. * * VertexBuffer.UV2Kind
  35562. * * VertexBuffer.UV3Kind
  35563. * * VertexBuffer.UV4Kind
  35564. * * VertexBuffer.UV5Kind
  35565. * * VertexBuffer.UV6Kind
  35566. * * VertexBuffer.ColorKind
  35567. * * VertexBuffer.MatricesIndicesKind
  35568. * * VertexBuffer.MatricesIndicesExtraKind
  35569. * * VertexBuffer.MatricesWeightsKind
  35570. * * VertexBuffer.MatricesWeightsExtraKind
  35571. * @param data defines the data source
  35572. * @param updatable defines if the data must be flagged as updatable (or static)
  35573. * @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
  35574. * @returns the current mesh
  35575. */
  35576. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35577. /**
  35578. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35579. * If the mesh has no geometry, it is simply returned as it is.
  35580. * @param kind defines vertex data kind:
  35581. * * VertexBuffer.PositionKind
  35582. * * VertexBuffer.UVKind
  35583. * * VertexBuffer.UV2Kind
  35584. * * VertexBuffer.UV3Kind
  35585. * * VertexBuffer.UV4Kind
  35586. * * VertexBuffer.UV5Kind
  35587. * * VertexBuffer.UV6Kind
  35588. * * VertexBuffer.ColorKind
  35589. * * VertexBuffer.MatricesIndicesKind
  35590. * * VertexBuffer.MatricesIndicesExtraKind
  35591. * * VertexBuffer.MatricesWeightsKind
  35592. * * VertexBuffer.MatricesWeightsExtraKind
  35593. * @param data defines the data source
  35594. * @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
  35595. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35596. * @returns the current mesh
  35597. */
  35598. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35599. /**
  35600. * Sets the mesh indices,
  35601. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35602. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35603. * @param totalVertices Defines the total number of vertices
  35604. * @returns the current mesh
  35605. */
  35606. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35607. /**
  35608. * Gets a boolean indicating if specific vertex data is present
  35609. * @param kind defines the vertex data kind to use
  35610. * @returns true is data kind is present
  35611. */
  35612. isVerticesDataPresent(kind: string): boolean;
  35613. /**
  35614. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35615. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35616. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35617. * @returns a BoundingInfo
  35618. */
  35619. getBoundingInfo(): BoundingInfo;
  35620. /**
  35621. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35622. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35623. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35624. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35625. * @returns the current mesh
  35626. */
  35627. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35628. /**
  35629. * Overwrite the current bounding info
  35630. * @param boundingInfo defines the new bounding info
  35631. * @returns the current mesh
  35632. */
  35633. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35634. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35635. get useBones(): boolean;
  35636. /** @hidden */
  35637. _preActivate(): void;
  35638. /** @hidden */
  35639. _preActivateForIntermediateRendering(renderId: number): void;
  35640. /** @hidden */
  35641. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35642. /** @hidden */
  35643. _postActivate(): void;
  35644. /** @hidden */
  35645. _freeze(): void;
  35646. /** @hidden */
  35647. _unFreeze(): void;
  35648. /**
  35649. * Gets the current world matrix
  35650. * @returns a Matrix
  35651. */
  35652. getWorldMatrix(): Matrix;
  35653. /** @hidden */
  35654. _getWorldMatrixDeterminant(): number;
  35655. /**
  35656. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35657. */
  35658. get isAnInstance(): boolean;
  35659. /**
  35660. * Gets a boolean indicating if this mesh has instances
  35661. */
  35662. get hasInstances(): boolean;
  35663. /**
  35664. * Gets a boolean indicating if this mesh has thin instances
  35665. */
  35666. get hasThinInstances(): boolean;
  35667. /**
  35668. * Perform relative position change from the point of view of behind the front of the mesh.
  35669. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35670. * Supports definition of mesh facing forward or backward
  35671. * @param amountRight defines the distance on the right axis
  35672. * @param amountUp defines the distance on the up axis
  35673. * @param amountForward defines the distance on the forward axis
  35674. * @returns the current mesh
  35675. */
  35676. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35677. /**
  35678. * Calculate relative position change from the point of view of behind the front of the mesh.
  35679. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35680. * Supports definition of mesh facing forward or backward
  35681. * @param amountRight defines the distance on the right axis
  35682. * @param amountUp defines the distance on the up axis
  35683. * @param amountForward defines the distance on the forward axis
  35684. * @returns the new displacement vector
  35685. */
  35686. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35687. /**
  35688. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35689. * Supports definition of mesh facing forward or backward
  35690. * @param flipBack defines the flip
  35691. * @param twirlClockwise defines the twirl
  35692. * @param tiltRight defines the tilt
  35693. * @returns the current mesh
  35694. */
  35695. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35696. /**
  35697. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35698. * Supports definition of mesh facing forward or backward.
  35699. * @param flipBack defines the flip
  35700. * @param twirlClockwise defines the twirl
  35701. * @param tiltRight defines the tilt
  35702. * @returns the new rotation vector
  35703. */
  35704. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35705. /**
  35706. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35707. * This means the mesh underlying bounding box and sphere are recomputed.
  35708. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35709. * @returns the current mesh
  35710. */
  35711. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35712. /** @hidden */
  35713. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35714. /** @hidden */
  35715. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35716. /** @hidden */
  35717. _updateBoundingInfo(): AbstractMesh;
  35718. /** @hidden */
  35719. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35720. /** @hidden */
  35721. protected _afterComputeWorldMatrix(): void;
  35722. /** @hidden */
  35723. get _effectiveMesh(): AbstractMesh;
  35724. /**
  35725. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35726. * A mesh is in the frustum if its bounding box intersects the frustum
  35727. * @param frustumPlanes defines the frustum to test
  35728. * @returns true if the mesh is in the frustum planes
  35729. */
  35730. isInFrustum(frustumPlanes: Plane[]): boolean;
  35731. /**
  35732. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35733. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35734. * @param frustumPlanes defines the frustum to test
  35735. * @returns true if the mesh is completely in the frustum planes
  35736. */
  35737. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35738. /**
  35739. * True if the mesh intersects another mesh or a SolidParticle object
  35740. * @param mesh defines a target mesh or SolidParticle to test
  35741. * @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)
  35742. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35743. * @returns true if there is an intersection
  35744. */
  35745. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35746. /**
  35747. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35748. * @param point defines the point to test
  35749. * @returns true if there is an intersection
  35750. */
  35751. intersectsPoint(point: Vector3): boolean;
  35752. /**
  35753. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35754. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35755. */
  35756. get checkCollisions(): boolean;
  35757. set checkCollisions(collisionEnabled: boolean);
  35758. /**
  35759. * Gets Collider object used to compute collisions (not physics)
  35760. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35761. */
  35762. get collider(): Nullable<Collider>;
  35763. /**
  35764. * Move the mesh using collision engine
  35765. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35766. * @param displacement defines the requested displacement vector
  35767. * @returns the current mesh
  35768. */
  35769. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35770. private _onCollisionPositionChange;
  35771. /** @hidden */
  35772. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35773. /** @hidden */
  35774. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35775. /** @hidden */
  35776. _checkCollision(collider: Collider): AbstractMesh;
  35777. /** @hidden */
  35778. _generatePointsArray(): boolean;
  35779. /**
  35780. * Checks if the passed Ray intersects with the mesh
  35781. * @param ray defines the ray to use
  35782. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35783. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35784. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35785. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35786. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35787. * @returns the picking info
  35788. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35789. */
  35790. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35791. /**
  35792. * Clones the current mesh
  35793. * @param name defines the mesh name
  35794. * @param newParent defines the new mesh parent
  35795. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35796. * @returns the new mesh
  35797. */
  35798. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35799. /**
  35800. * Disposes all the submeshes of the current meshnp
  35801. * @returns the current mesh
  35802. */
  35803. releaseSubMeshes(): AbstractMesh;
  35804. /**
  35805. * Releases resources associated with this abstract mesh.
  35806. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35807. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35808. */
  35809. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35810. /**
  35811. * Adds the passed mesh as a child to the current mesh
  35812. * @param mesh defines the child mesh
  35813. * @returns the current mesh
  35814. */
  35815. addChild(mesh: AbstractMesh): AbstractMesh;
  35816. /**
  35817. * Removes the passed mesh from the current mesh children list
  35818. * @param mesh defines the child mesh
  35819. * @returns the current mesh
  35820. */
  35821. removeChild(mesh: AbstractMesh): AbstractMesh;
  35822. /** @hidden */
  35823. private _initFacetData;
  35824. /**
  35825. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35826. * This method can be called within the render loop.
  35827. * 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
  35828. * @returns the current mesh
  35829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35830. */
  35831. updateFacetData(): AbstractMesh;
  35832. /**
  35833. * Returns the facetLocalNormals array.
  35834. * The normals are expressed in the mesh local spac
  35835. * @returns an array of Vector3
  35836. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35837. */
  35838. getFacetLocalNormals(): Vector3[];
  35839. /**
  35840. * Returns the facetLocalPositions array.
  35841. * The facet positions are expressed in the mesh local space
  35842. * @returns an array of Vector3
  35843. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35844. */
  35845. getFacetLocalPositions(): Vector3[];
  35846. /**
  35847. * Returns the facetLocalPartioning array
  35848. * @returns an array of array of numbers
  35849. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35850. */
  35851. getFacetLocalPartitioning(): number[][];
  35852. /**
  35853. * Returns the i-th facet position in the world system.
  35854. * This method allocates a new Vector3 per call
  35855. * @param i defines the facet index
  35856. * @returns a new Vector3
  35857. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35858. */
  35859. getFacetPosition(i: number): Vector3;
  35860. /**
  35861. * Sets the reference Vector3 with the i-th facet position in the world system
  35862. * @param i defines the facet index
  35863. * @param ref defines the target vector
  35864. * @returns the current mesh
  35865. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35866. */
  35867. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35868. /**
  35869. * Returns the i-th facet normal in the world system.
  35870. * This method allocates a new Vector3 per call
  35871. * @param i defines the facet index
  35872. * @returns a new Vector3
  35873. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35874. */
  35875. getFacetNormal(i: number): Vector3;
  35876. /**
  35877. * Sets the reference Vector3 with the i-th facet normal in the world system
  35878. * @param i defines the facet index
  35879. * @param ref defines the target vector
  35880. * @returns the current mesh
  35881. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35882. */
  35883. getFacetNormalToRef(i: number, ref: Vector3): this;
  35884. /**
  35885. * 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)
  35886. * @param x defines x coordinate
  35887. * @param y defines y coordinate
  35888. * @param z defines z coordinate
  35889. * @returns the array of facet indexes
  35890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35891. */
  35892. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35893. /**
  35894. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35895. * @param projected sets as the (x,y,z) world projection on the facet
  35896. * @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
  35897. * @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
  35898. * @param x defines x coordinate
  35899. * @param y defines y coordinate
  35900. * @param z defines z coordinate
  35901. * @returns the face index if found (or null instead)
  35902. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35903. */
  35904. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35905. /**
  35906. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35907. * @param projected sets as the (x,y,z) local projection on the facet
  35908. * @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
  35909. * @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
  35910. * @param x defines x coordinate
  35911. * @param y defines y coordinate
  35912. * @param z defines z coordinate
  35913. * @returns the face index if found (or null instead)
  35914. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35915. */
  35916. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35917. /**
  35918. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35919. * @returns the parameters
  35920. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35921. */
  35922. getFacetDataParameters(): any;
  35923. /**
  35924. * Disables the feature FacetData and frees the related memory
  35925. * @returns the current mesh
  35926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35927. */
  35928. disableFacetData(): AbstractMesh;
  35929. /**
  35930. * Updates the AbstractMesh indices array
  35931. * @param indices defines the data source
  35932. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35933. * @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)
  35934. * @returns the current mesh
  35935. */
  35936. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35937. /**
  35938. * Creates new normals data for the mesh
  35939. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35940. * @returns the current mesh
  35941. */
  35942. createNormals(updatable: boolean): AbstractMesh;
  35943. /**
  35944. * Align the mesh with a normal
  35945. * @param normal defines the normal to use
  35946. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35947. * @returns the current mesh
  35948. */
  35949. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35950. /** @hidden */
  35951. _checkOcclusionQuery(): boolean;
  35952. /**
  35953. * Disables the mesh edge rendering mode
  35954. * @returns the currentAbstractMesh
  35955. */
  35956. disableEdgesRendering(): AbstractMesh;
  35957. /**
  35958. * Enables the edge rendering mode on the mesh.
  35959. * This mode makes the mesh edges visible
  35960. * @param epsilon defines the maximal distance between two angles to detect a face
  35961. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35962. * @param options options to the edge renderer
  35963. * @returns the currentAbstractMesh
  35964. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35965. */
  35966. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35967. /**
  35968. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35969. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35970. */
  35971. getConnectedParticleSystems(): IParticleSystem[];
  35972. }
  35973. }
  35974. declare module BABYLON {
  35975. /**
  35976. * Interface used to define ActionEvent
  35977. */
  35978. export interface IActionEvent {
  35979. /** The mesh or sprite that triggered the action */
  35980. source: any;
  35981. /** The X mouse cursor position at the time of the event */
  35982. pointerX: number;
  35983. /** The Y mouse cursor position at the time of the event */
  35984. pointerY: number;
  35985. /** The mesh that is currently pointed at (can be null) */
  35986. meshUnderPointer: Nullable<AbstractMesh>;
  35987. /** the original (browser) event that triggered the ActionEvent */
  35988. sourceEvent?: any;
  35989. /** additional data for the event */
  35990. additionalData?: any;
  35991. }
  35992. /**
  35993. * ActionEvent is the event being sent when an action is triggered.
  35994. */
  35995. export class ActionEvent implements IActionEvent {
  35996. /** The mesh or sprite that triggered the action */
  35997. source: any;
  35998. /** The X mouse cursor position at the time of the event */
  35999. pointerX: number;
  36000. /** The Y mouse cursor position at the time of the event */
  36001. pointerY: number;
  36002. /** The mesh that is currently pointed at (can be null) */
  36003. meshUnderPointer: Nullable<AbstractMesh>;
  36004. /** the original (browser) event that triggered the ActionEvent */
  36005. sourceEvent?: any;
  36006. /** additional data for the event */
  36007. additionalData?: any;
  36008. /**
  36009. * Creates a new ActionEvent
  36010. * @param source The mesh or sprite that triggered the action
  36011. * @param pointerX The X mouse cursor position at the time of the event
  36012. * @param pointerY The Y mouse cursor position at the time of the event
  36013. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36014. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36015. * @param additionalData additional data for the event
  36016. */
  36017. constructor(
  36018. /** The mesh or sprite that triggered the action */
  36019. source: any,
  36020. /** The X mouse cursor position at the time of the event */
  36021. pointerX: number,
  36022. /** The Y mouse cursor position at the time of the event */
  36023. pointerY: number,
  36024. /** The mesh that is currently pointed at (can be null) */
  36025. meshUnderPointer: Nullable<AbstractMesh>,
  36026. /** the original (browser) event that triggered the ActionEvent */
  36027. sourceEvent?: any,
  36028. /** additional data for the event */
  36029. additionalData?: any);
  36030. /**
  36031. * Helper function to auto-create an ActionEvent from a source mesh.
  36032. * @param source The source mesh that triggered the event
  36033. * @param evt The original (browser) event
  36034. * @param additionalData additional data for the event
  36035. * @returns the new ActionEvent
  36036. */
  36037. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36038. /**
  36039. * Helper function to auto-create an ActionEvent from a source sprite
  36040. * @param source The source sprite that triggered the event
  36041. * @param scene Scene associated with the sprite
  36042. * @param evt The original (browser) event
  36043. * @param additionalData additional data for the event
  36044. * @returns the new ActionEvent
  36045. */
  36046. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36047. /**
  36048. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36049. * @param scene the scene where the event occurred
  36050. * @param evt The original (browser) event
  36051. * @returns the new ActionEvent
  36052. */
  36053. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36054. /**
  36055. * Helper function to auto-create an ActionEvent from a primitive
  36056. * @param prim defines the target primitive
  36057. * @param pointerPos defines the pointer position
  36058. * @param evt The original (browser) event
  36059. * @param additionalData additional data for the event
  36060. * @returns the new ActionEvent
  36061. */
  36062. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36063. }
  36064. }
  36065. declare module BABYLON {
  36066. /**
  36067. * Abstract class used to decouple action Manager from scene and meshes.
  36068. * Do not instantiate.
  36069. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36070. */
  36071. export abstract class AbstractActionManager implements IDisposable {
  36072. /** Gets the list of active triggers */
  36073. static Triggers: {
  36074. [key: string]: number;
  36075. };
  36076. /** Gets the cursor to use when hovering items */
  36077. hoverCursor: string;
  36078. /** Gets the list of actions */
  36079. actions: IAction[];
  36080. /**
  36081. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36082. */
  36083. isRecursive: boolean;
  36084. /**
  36085. * Releases all associated resources
  36086. */
  36087. abstract dispose(): void;
  36088. /**
  36089. * Does this action manager has pointer triggers
  36090. */
  36091. abstract get hasPointerTriggers(): boolean;
  36092. /**
  36093. * Does this action manager has pick triggers
  36094. */
  36095. abstract get hasPickTriggers(): boolean;
  36096. /**
  36097. * Process a specific trigger
  36098. * @param trigger defines the trigger to process
  36099. * @param evt defines the event details to be processed
  36100. */
  36101. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36102. /**
  36103. * Does this action manager handles actions of any of the given triggers
  36104. * @param triggers defines the triggers to be tested
  36105. * @return a boolean indicating whether one (or more) of the triggers is handled
  36106. */
  36107. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36108. /**
  36109. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36110. * speed.
  36111. * @param triggerA defines the trigger to be tested
  36112. * @param triggerB defines the trigger to be tested
  36113. * @return a boolean indicating whether one (or more) of the triggers is handled
  36114. */
  36115. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36116. /**
  36117. * Does this action manager handles actions of a given trigger
  36118. * @param trigger defines the trigger to be tested
  36119. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36120. * @return whether the trigger is handled
  36121. */
  36122. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36123. /**
  36124. * Serialize this manager to a JSON object
  36125. * @param name defines the property name to store this manager
  36126. * @returns a JSON representation of this manager
  36127. */
  36128. abstract serialize(name: string): any;
  36129. /**
  36130. * Registers an action to this action manager
  36131. * @param action defines the action to be registered
  36132. * @return the action amended (prepared) after registration
  36133. */
  36134. abstract registerAction(action: IAction): Nullable<IAction>;
  36135. /**
  36136. * Unregisters an action to this action manager
  36137. * @param action defines the action to be unregistered
  36138. * @return a boolean indicating whether the action has been unregistered
  36139. */
  36140. abstract unregisterAction(action: IAction): Boolean;
  36141. /**
  36142. * Does exist one action manager with at least one trigger
  36143. **/
  36144. static get HasTriggers(): boolean;
  36145. /**
  36146. * Does exist one action manager with at least one pick trigger
  36147. **/
  36148. static get HasPickTriggers(): boolean;
  36149. /**
  36150. * Does exist one action manager that handles actions of a given trigger
  36151. * @param trigger defines the trigger to be tested
  36152. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36153. **/
  36154. static HasSpecificTrigger(trigger: number): boolean;
  36155. }
  36156. }
  36157. declare module BABYLON {
  36158. /**
  36159. * Defines how a node can be built from a string name.
  36160. */
  36161. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36162. /**
  36163. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36164. */
  36165. export class Node implements IBehaviorAware<Node> {
  36166. /** @hidden */
  36167. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36168. private static _NodeConstructors;
  36169. /**
  36170. * Add a new node constructor
  36171. * @param type defines the type name of the node to construct
  36172. * @param constructorFunc defines the constructor function
  36173. */
  36174. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36175. /**
  36176. * Returns a node constructor based on type name
  36177. * @param type defines the type name
  36178. * @param name defines the new node name
  36179. * @param scene defines the hosting scene
  36180. * @param options defines optional options to transmit to constructors
  36181. * @returns the new constructor or null
  36182. */
  36183. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36184. /**
  36185. * Gets or sets the name of the node
  36186. */
  36187. name: string;
  36188. /**
  36189. * Gets or sets the id of the node
  36190. */
  36191. id: string;
  36192. /**
  36193. * Gets or sets the unique id of the node
  36194. */
  36195. uniqueId: number;
  36196. /**
  36197. * Gets or sets a string used to store user defined state for the node
  36198. */
  36199. state: string;
  36200. /**
  36201. * Gets or sets an object used to store user defined information for the node
  36202. */
  36203. metadata: any;
  36204. /**
  36205. * For internal use only. Please do not use.
  36206. */
  36207. reservedDataStore: any;
  36208. /**
  36209. * List of inspectable custom properties (used by the Inspector)
  36210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36211. */
  36212. inspectableCustomProperties: IInspectable[];
  36213. private _doNotSerialize;
  36214. /**
  36215. * Gets or sets a boolean used to define if the node must be serialized
  36216. */
  36217. get doNotSerialize(): boolean;
  36218. set doNotSerialize(value: boolean);
  36219. /** @hidden */
  36220. _isDisposed: boolean;
  36221. /**
  36222. * Gets a list of Animations associated with the node
  36223. */
  36224. animations: Animation[];
  36225. protected _ranges: {
  36226. [name: string]: Nullable<AnimationRange>;
  36227. };
  36228. /**
  36229. * Callback raised when the node is ready to be used
  36230. */
  36231. onReady: Nullable<(node: Node) => void>;
  36232. private _isEnabled;
  36233. private _isParentEnabled;
  36234. private _isReady;
  36235. /** @hidden */
  36236. _currentRenderId: number;
  36237. private _parentUpdateId;
  36238. /** @hidden */
  36239. _childUpdateId: number;
  36240. /** @hidden */
  36241. _waitingParentId: Nullable<string>;
  36242. /** @hidden */
  36243. _scene: Scene;
  36244. /** @hidden */
  36245. _cache: any;
  36246. private _parentNode;
  36247. private _children;
  36248. /** @hidden */
  36249. _worldMatrix: Matrix;
  36250. /** @hidden */
  36251. _worldMatrixDeterminant: number;
  36252. /** @hidden */
  36253. _worldMatrixDeterminantIsDirty: boolean;
  36254. /** @hidden */
  36255. private _sceneRootNodesIndex;
  36256. /**
  36257. * Gets a boolean indicating if the node has been disposed
  36258. * @returns true if the node was disposed
  36259. */
  36260. isDisposed(): boolean;
  36261. /**
  36262. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36263. * @see https://doc.babylonjs.com/how_to/parenting
  36264. */
  36265. set parent(parent: Nullable<Node>);
  36266. get parent(): Nullable<Node>;
  36267. /** @hidden */
  36268. _addToSceneRootNodes(): void;
  36269. /** @hidden */
  36270. _removeFromSceneRootNodes(): void;
  36271. private _animationPropertiesOverride;
  36272. /**
  36273. * Gets or sets the animation properties override
  36274. */
  36275. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36276. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36277. /**
  36278. * Gets a string identifying the name of the class
  36279. * @returns "Node" string
  36280. */
  36281. getClassName(): string;
  36282. /** @hidden */
  36283. readonly _isNode: boolean;
  36284. /**
  36285. * An event triggered when the mesh is disposed
  36286. */
  36287. onDisposeObservable: Observable<Node>;
  36288. private _onDisposeObserver;
  36289. /**
  36290. * Sets a callback that will be raised when the node will be disposed
  36291. */
  36292. set onDispose(callback: () => void);
  36293. /**
  36294. * Creates a new Node
  36295. * @param name the name and id to be given to this node
  36296. * @param scene the scene this node will be added to
  36297. */
  36298. constructor(name: string, scene?: Nullable<Scene>);
  36299. /**
  36300. * Gets the scene of the node
  36301. * @returns a scene
  36302. */
  36303. getScene(): Scene;
  36304. /**
  36305. * Gets the engine of the node
  36306. * @returns a Engine
  36307. */
  36308. getEngine(): Engine;
  36309. private _behaviors;
  36310. /**
  36311. * Attach a behavior to the node
  36312. * @see https://doc.babylonjs.com/features/behaviour
  36313. * @param behavior defines the behavior to attach
  36314. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36315. * @returns the current Node
  36316. */
  36317. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36318. /**
  36319. * Remove an attached behavior
  36320. * @see https://doc.babylonjs.com/features/behaviour
  36321. * @param behavior defines the behavior to attach
  36322. * @returns the current Node
  36323. */
  36324. removeBehavior(behavior: Behavior<Node>): Node;
  36325. /**
  36326. * Gets the list of attached behaviors
  36327. * @see https://doc.babylonjs.com/features/behaviour
  36328. */
  36329. get behaviors(): Behavior<Node>[];
  36330. /**
  36331. * Gets an attached behavior by name
  36332. * @param name defines the name of the behavior to look for
  36333. * @see https://doc.babylonjs.com/features/behaviour
  36334. * @returns null if behavior was not found else the requested behavior
  36335. */
  36336. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36337. /**
  36338. * Returns the latest update of the World matrix
  36339. * @returns a Matrix
  36340. */
  36341. getWorldMatrix(): Matrix;
  36342. /** @hidden */
  36343. _getWorldMatrixDeterminant(): number;
  36344. /**
  36345. * Returns directly the latest state of the mesh World matrix.
  36346. * A Matrix is returned.
  36347. */
  36348. get worldMatrixFromCache(): Matrix;
  36349. /** @hidden */
  36350. _initCache(): void;
  36351. /** @hidden */
  36352. updateCache(force?: boolean): void;
  36353. /** @hidden */
  36354. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36355. /** @hidden */
  36356. _updateCache(ignoreParentClass?: boolean): void;
  36357. /** @hidden */
  36358. _isSynchronized(): boolean;
  36359. /** @hidden */
  36360. _markSyncedWithParent(): void;
  36361. /** @hidden */
  36362. isSynchronizedWithParent(): boolean;
  36363. /** @hidden */
  36364. isSynchronized(): boolean;
  36365. /**
  36366. * Is this node ready to be used/rendered
  36367. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36368. * @return true if the node is ready
  36369. */
  36370. isReady(completeCheck?: boolean): boolean;
  36371. /**
  36372. * Is this node enabled?
  36373. * 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
  36374. * @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
  36375. * @return whether this node (and its parent) is enabled
  36376. */
  36377. isEnabled(checkAncestors?: boolean): boolean;
  36378. /** @hidden */
  36379. protected _syncParentEnabledState(): void;
  36380. /**
  36381. * Set the enabled state of this node
  36382. * @param value defines the new enabled state
  36383. */
  36384. setEnabled(value: boolean): void;
  36385. /**
  36386. * Is this node a descendant of the given node?
  36387. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36388. * @param ancestor defines the parent node to inspect
  36389. * @returns a boolean indicating if this node is a descendant of the given node
  36390. */
  36391. isDescendantOf(ancestor: Node): boolean;
  36392. /** @hidden */
  36393. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36394. /**
  36395. * Will return all nodes that have this node as ascendant
  36396. * @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
  36397. * @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
  36398. * @return all children nodes of all types
  36399. */
  36400. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36401. /**
  36402. * Get all child-meshes of this node
  36403. * @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)
  36404. * @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
  36405. * @returns an array of AbstractMesh
  36406. */
  36407. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36408. /**
  36409. * Get all direct children of this node
  36410. * @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
  36411. * @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)
  36412. * @returns an array of Node
  36413. */
  36414. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36415. /** @hidden */
  36416. _setReady(state: boolean): void;
  36417. /**
  36418. * Get an animation by name
  36419. * @param name defines the name of the animation to look for
  36420. * @returns null if not found else the requested animation
  36421. */
  36422. getAnimationByName(name: string): Nullable<Animation>;
  36423. /**
  36424. * Creates an animation range for this node
  36425. * @param name defines the name of the range
  36426. * @param from defines the starting key
  36427. * @param to defines the end key
  36428. */
  36429. createAnimationRange(name: string, from: number, to: number): void;
  36430. /**
  36431. * Delete a specific animation range
  36432. * @param name defines the name of the range to delete
  36433. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36434. */
  36435. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36436. /**
  36437. * Get an animation range by name
  36438. * @param name defines the name of the animation range to look for
  36439. * @returns null if not found else the requested animation range
  36440. */
  36441. getAnimationRange(name: string): Nullable<AnimationRange>;
  36442. /**
  36443. * Gets the list of all animation ranges defined on this node
  36444. * @returns an array
  36445. */
  36446. getAnimationRanges(): Nullable<AnimationRange>[];
  36447. /**
  36448. * Will start the animation sequence
  36449. * @param name defines the range frames for animation sequence
  36450. * @param loop defines if the animation should loop (false by default)
  36451. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36452. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36453. * @returns the object created for this animation. If range does not exist, it will return null
  36454. */
  36455. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36456. /**
  36457. * Serialize animation ranges into a JSON compatible object
  36458. * @returns serialization object
  36459. */
  36460. serializeAnimationRanges(): any;
  36461. /**
  36462. * Computes the world matrix of the node
  36463. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36464. * @returns the world matrix
  36465. */
  36466. computeWorldMatrix(force?: boolean): Matrix;
  36467. /**
  36468. * Releases resources associated with this node.
  36469. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36470. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36471. */
  36472. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36473. /**
  36474. * Parse animation range data from a serialization object and store them into a given node
  36475. * @param node defines where to store the animation ranges
  36476. * @param parsedNode defines the serialization object to read data from
  36477. * @param scene defines the hosting scene
  36478. */
  36479. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36480. /**
  36481. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36482. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36483. * @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
  36484. * @returns the new bounding vectors
  36485. */
  36486. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36487. min: Vector3;
  36488. max: Vector3;
  36489. };
  36490. }
  36491. }
  36492. declare module BABYLON {
  36493. /**
  36494. * @hidden
  36495. */
  36496. export class _IAnimationState {
  36497. key: number;
  36498. repeatCount: number;
  36499. workValue?: any;
  36500. loopMode?: number;
  36501. offsetValue?: any;
  36502. highLimitValue?: any;
  36503. }
  36504. /**
  36505. * Class used to store any kind of animation
  36506. */
  36507. export class Animation {
  36508. /**Name of the animation */
  36509. name: string;
  36510. /**Property to animate */
  36511. targetProperty: string;
  36512. /**The frames per second of the animation */
  36513. framePerSecond: number;
  36514. /**The data type of the animation */
  36515. dataType: number;
  36516. /**The loop mode of the animation */
  36517. loopMode?: number | undefined;
  36518. /**Specifies if blending should be enabled */
  36519. enableBlending?: boolean | undefined;
  36520. /**
  36521. * Use matrix interpolation instead of using direct key value when animating matrices
  36522. */
  36523. static AllowMatricesInterpolation: boolean;
  36524. /**
  36525. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36526. */
  36527. static AllowMatrixDecomposeForInterpolation: boolean;
  36528. /** Define the Url to load snippets */
  36529. static SnippetUrl: string;
  36530. /** Snippet ID if the animation was created from the snippet server */
  36531. snippetId: string;
  36532. /**
  36533. * Stores the key frames of the animation
  36534. */
  36535. private _keys;
  36536. /**
  36537. * Stores the easing function of the animation
  36538. */
  36539. private _easingFunction;
  36540. /**
  36541. * @hidden Internal use only
  36542. */
  36543. _runtimeAnimations: RuntimeAnimation[];
  36544. /**
  36545. * The set of event that will be linked to this animation
  36546. */
  36547. private _events;
  36548. /**
  36549. * Stores an array of target property paths
  36550. */
  36551. targetPropertyPath: string[];
  36552. /**
  36553. * Stores the blending speed of the animation
  36554. */
  36555. blendingSpeed: number;
  36556. /**
  36557. * Stores the animation ranges for the animation
  36558. */
  36559. private _ranges;
  36560. /**
  36561. * @hidden Internal use
  36562. */
  36563. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36564. /**
  36565. * Sets up an animation
  36566. * @param property The property to animate
  36567. * @param animationType The animation type to apply
  36568. * @param framePerSecond The frames per second of the animation
  36569. * @param easingFunction The easing function used in the animation
  36570. * @returns The created animation
  36571. */
  36572. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36573. /**
  36574. * Create and start an animation on a node
  36575. * @param name defines the name of the global animation that will be run on all nodes
  36576. * @param node defines the root node where the animation will take place
  36577. * @param targetProperty defines property to animate
  36578. * @param framePerSecond defines the number of frame per second yo use
  36579. * @param totalFrame defines the number of frames in total
  36580. * @param from defines the initial value
  36581. * @param to defines the final value
  36582. * @param loopMode defines which loop mode you want to use (off by default)
  36583. * @param easingFunction defines the easing function to use (linear by default)
  36584. * @param onAnimationEnd defines the callback to call when animation end
  36585. * @returns the animatable created for this animation
  36586. */
  36587. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36588. /**
  36589. * Create and start an animation on a node and its descendants
  36590. * @param name defines the name of the global animation that will be run on all nodes
  36591. * @param node defines the root node where the animation will take place
  36592. * @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
  36593. * @param targetProperty defines property to animate
  36594. * @param framePerSecond defines the number of frame per second to use
  36595. * @param totalFrame defines the number of frames in total
  36596. * @param from defines the initial value
  36597. * @param to defines the final value
  36598. * @param loopMode defines which loop mode you want to use (off by default)
  36599. * @param easingFunction defines the easing function to use (linear by default)
  36600. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36601. * @returns the list of animatables created for all nodes
  36602. * @example https://www.babylonjs-playground.com/#MH0VLI
  36603. */
  36604. 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[]>;
  36605. /**
  36606. * Creates a new animation, merges it with the existing animations and starts it
  36607. * @param name Name of the animation
  36608. * @param node Node which contains the scene that begins the animations
  36609. * @param targetProperty Specifies which property to animate
  36610. * @param framePerSecond The frames per second of the animation
  36611. * @param totalFrame The total number of frames
  36612. * @param from The frame at the beginning of the animation
  36613. * @param to The frame at the end of the animation
  36614. * @param loopMode Specifies the loop mode of the animation
  36615. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36616. * @param onAnimationEnd Callback to run once the animation is complete
  36617. * @returns Nullable animation
  36618. */
  36619. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36620. /**
  36621. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36622. * @param sourceAnimation defines the Animation containing keyframes to convert
  36623. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36624. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36625. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36626. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36627. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36628. */
  36629. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36630. /**
  36631. * Transition property of an host to the target Value
  36632. * @param property The property to transition
  36633. * @param targetValue The target Value of the property
  36634. * @param host The object where the property to animate belongs
  36635. * @param scene Scene used to run the animation
  36636. * @param frameRate Framerate (in frame/s) to use
  36637. * @param transition The transition type we want to use
  36638. * @param duration The duration of the animation, in milliseconds
  36639. * @param onAnimationEnd Callback trigger at the end of the animation
  36640. * @returns Nullable animation
  36641. */
  36642. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36643. /**
  36644. * Return the array of runtime animations currently using this animation
  36645. */
  36646. get runtimeAnimations(): RuntimeAnimation[];
  36647. /**
  36648. * Specifies if any of the runtime animations are currently running
  36649. */
  36650. get hasRunningRuntimeAnimations(): boolean;
  36651. /**
  36652. * Initializes the animation
  36653. * @param name Name of the animation
  36654. * @param targetProperty Property to animate
  36655. * @param framePerSecond The frames per second of the animation
  36656. * @param dataType The data type of the animation
  36657. * @param loopMode The loop mode of the animation
  36658. * @param enableBlending Specifies if blending should be enabled
  36659. */
  36660. constructor(
  36661. /**Name of the animation */
  36662. name: string,
  36663. /**Property to animate */
  36664. targetProperty: string,
  36665. /**The frames per second of the animation */
  36666. framePerSecond: number,
  36667. /**The data type of the animation */
  36668. dataType: number,
  36669. /**The loop mode of the animation */
  36670. loopMode?: number | undefined,
  36671. /**Specifies if blending should be enabled */
  36672. enableBlending?: boolean | undefined);
  36673. /**
  36674. * Converts the animation to a string
  36675. * @param fullDetails support for multiple levels of logging within scene loading
  36676. * @returns String form of the animation
  36677. */
  36678. toString(fullDetails?: boolean): string;
  36679. /**
  36680. * Add an event to this animation
  36681. * @param event Event to add
  36682. */
  36683. addEvent(event: AnimationEvent): void;
  36684. /**
  36685. * Remove all events found at the given frame
  36686. * @param frame The frame to remove events from
  36687. */
  36688. removeEvents(frame: number): void;
  36689. /**
  36690. * Retrieves all the events from the animation
  36691. * @returns Events from the animation
  36692. */
  36693. getEvents(): AnimationEvent[];
  36694. /**
  36695. * Creates an animation range
  36696. * @param name Name of the animation range
  36697. * @param from Starting frame of the animation range
  36698. * @param to Ending frame of the animation
  36699. */
  36700. createRange(name: string, from: number, to: number): void;
  36701. /**
  36702. * Deletes an animation range by name
  36703. * @param name Name of the animation range to delete
  36704. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36705. */
  36706. deleteRange(name: string, deleteFrames?: boolean): void;
  36707. /**
  36708. * Gets the animation range by name, or null if not defined
  36709. * @param name Name of the animation range
  36710. * @returns Nullable animation range
  36711. */
  36712. getRange(name: string): Nullable<AnimationRange>;
  36713. /**
  36714. * Gets the key frames from the animation
  36715. * @returns The key frames of the animation
  36716. */
  36717. getKeys(): Array<IAnimationKey>;
  36718. /**
  36719. * Gets the highest frame rate of the animation
  36720. * @returns Highest frame rate of the animation
  36721. */
  36722. getHighestFrame(): number;
  36723. /**
  36724. * Gets the easing function of the animation
  36725. * @returns Easing function of the animation
  36726. */
  36727. getEasingFunction(): IEasingFunction;
  36728. /**
  36729. * Sets the easing function of the animation
  36730. * @param easingFunction A custom mathematical formula for animation
  36731. */
  36732. setEasingFunction(easingFunction: EasingFunction): void;
  36733. /**
  36734. * Interpolates a scalar linearly
  36735. * @param startValue Start value of the animation curve
  36736. * @param endValue End value of the animation curve
  36737. * @param gradient Scalar amount to interpolate
  36738. * @returns Interpolated scalar value
  36739. */
  36740. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36741. /**
  36742. * Interpolates a scalar cubically
  36743. * @param startValue Start value of the animation curve
  36744. * @param outTangent End tangent of the animation
  36745. * @param endValue End value of the animation curve
  36746. * @param inTangent Start tangent of the animation curve
  36747. * @param gradient Scalar amount to interpolate
  36748. * @returns Interpolated scalar value
  36749. */
  36750. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36751. /**
  36752. * Interpolates a quaternion using a spherical linear interpolation
  36753. * @param startValue Start value of the animation curve
  36754. * @param endValue End value of the animation curve
  36755. * @param gradient Scalar amount to interpolate
  36756. * @returns Interpolated quaternion value
  36757. */
  36758. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36759. /**
  36760. * Interpolates a quaternion cubically
  36761. * @param startValue Start value of the animation curve
  36762. * @param outTangent End tangent of the animation curve
  36763. * @param endValue End value of the animation curve
  36764. * @param inTangent Start tangent of the animation curve
  36765. * @param gradient Scalar amount to interpolate
  36766. * @returns Interpolated quaternion value
  36767. */
  36768. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36769. /**
  36770. * Interpolates a Vector3 linearl
  36771. * @param startValue Start value of the animation curve
  36772. * @param endValue End value of the animation curve
  36773. * @param gradient Scalar amount to interpolate
  36774. * @returns Interpolated scalar value
  36775. */
  36776. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36777. /**
  36778. * Interpolates a Vector3 cubically
  36779. * @param startValue Start value of the animation curve
  36780. * @param outTangent End tangent of the animation
  36781. * @param endValue End value of the animation curve
  36782. * @param inTangent Start tangent of the animation curve
  36783. * @param gradient Scalar amount to interpolate
  36784. * @returns InterpolatedVector3 value
  36785. */
  36786. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36787. /**
  36788. * Interpolates a Vector2 linearly
  36789. * @param startValue Start value of the animation curve
  36790. * @param endValue End value of the animation curve
  36791. * @param gradient Scalar amount to interpolate
  36792. * @returns Interpolated Vector2 value
  36793. */
  36794. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36795. /**
  36796. * Interpolates a Vector2 cubically
  36797. * @param startValue Start value of the animation curve
  36798. * @param outTangent End tangent of the animation
  36799. * @param endValue End value of the animation curve
  36800. * @param inTangent Start tangent of the animation curve
  36801. * @param gradient Scalar amount to interpolate
  36802. * @returns Interpolated Vector2 value
  36803. */
  36804. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36805. /**
  36806. * Interpolates a size linearly
  36807. * @param startValue Start value of the animation curve
  36808. * @param endValue End value of the animation curve
  36809. * @param gradient Scalar amount to interpolate
  36810. * @returns Interpolated Size value
  36811. */
  36812. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36813. /**
  36814. * Interpolates a Color3 linearly
  36815. * @param startValue Start value of the animation curve
  36816. * @param endValue End value of the animation curve
  36817. * @param gradient Scalar amount to interpolate
  36818. * @returns Interpolated Color3 value
  36819. */
  36820. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36821. /**
  36822. * Interpolates a Color4 linearly
  36823. * @param startValue Start value of the animation curve
  36824. * @param endValue End value of the animation curve
  36825. * @param gradient Scalar amount to interpolate
  36826. * @returns Interpolated Color3 value
  36827. */
  36828. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36829. /**
  36830. * @hidden Internal use only
  36831. */
  36832. _getKeyValue(value: any): any;
  36833. /**
  36834. * @hidden Internal use only
  36835. */
  36836. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36837. /**
  36838. * Defines the function to use to interpolate matrices
  36839. * @param startValue defines the start matrix
  36840. * @param endValue defines the end matrix
  36841. * @param gradient defines the gradient between both matrices
  36842. * @param result defines an optional target matrix where to store the interpolation
  36843. * @returns the interpolated matrix
  36844. */
  36845. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36846. /**
  36847. * Makes a copy of the animation
  36848. * @returns Cloned animation
  36849. */
  36850. clone(): Animation;
  36851. /**
  36852. * Sets the key frames of the animation
  36853. * @param values The animation key frames to set
  36854. */
  36855. setKeys(values: Array<IAnimationKey>): void;
  36856. /**
  36857. * Serializes the animation to an object
  36858. * @returns Serialized object
  36859. */
  36860. serialize(): any;
  36861. /**
  36862. * Float animation type
  36863. */
  36864. static readonly ANIMATIONTYPE_FLOAT: number;
  36865. /**
  36866. * Vector3 animation type
  36867. */
  36868. static readonly ANIMATIONTYPE_VECTOR3: number;
  36869. /**
  36870. * Quaternion animation type
  36871. */
  36872. static readonly ANIMATIONTYPE_QUATERNION: number;
  36873. /**
  36874. * Matrix animation type
  36875. */
  36876. static readonly ANIMATIONTYPE_MATRIX: number;
  36877. /**
  36878. * Color3 animation type
  36879. */
  36880. static readonly ANIMATIONTYPE_COLOR3: number;
  36881. /**
  36882. * Color3 animation type
  36883. */
  36884. static readonly ANIMATIONTYPE_COLOR4: number;
  36885. /**
  36886. * Vector2 animation type
  36887. */
  36888. static readonly ANIMATIONTYPE_VECTOR2: number;
  36889. /**
  36890. * Size animation type
  36891. */
  36892. static readonly ANIMATIONTYPE_SIZE: number;
  36893. /**
  36894. * Relative Loop Mode
  36895. */
  36896. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36897. /**
  36898. * Cycle Loop Mode
  36899. */
  36900. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36901. /**
  36902. * Constant Loop Mode
  36903. */
  36904. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36905. /** @hidden */
  36906. static _UniversalLerp(left: any, right: any, amount: number): any;
  36907. /**
  36908. * Parses an animation object and creates an animation
  36909. * @param parsedAnimation Parsed animation object
  36910. * @returns Animation object
  36911. */
  36912. static Parse(parsedAnimation: any): Animation;
  36913. /**
  36914. * Appends the serialized animations from the source animations
  36915. * @param source Source containing the animations
  36916. * @param destination Target to store the animations
  36917. */
  36918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36919. /**
  36920. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36921. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36922. * @param url defines the url to load from
  36923. * @returns a promise that will resolve to the new animation or an array of animations
  36924. */
  36925. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36926. /**
  36927. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36928. * @param snippetId defines the snippet to load
  36929. * @returns a promise that will resolve to the new animation or a new array of animations
  36930. */
  36931. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36932. }
  36933. }
  36934. declare module BABYLON {
  36935. /**
  36936. * Interface containing an array of animations
  36937. */
  36938. export interface IAnimatable {
  36939. /**
  36940. * Array of animations
  36941. */
  36942. animations: Nullable<Array<Animation>>;
  36943. }
  36944. }
  36945. declare module BABYLON {
  36946. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36947. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36948. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36949. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36950. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36951. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36952. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36953. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36954. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36955. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36956. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36957. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36958. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. /**
  36960. * Decorator used to define property that can be serialized as reference to a camera
  36961. * @param sourceName defines the name of the property to decorate
  36962. */
  36963. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36964. /**
  36965. * Class used to help serialization objects
  36966. */
  36967. export class SerializationHelper {
  36968. /** @hidden */
  36969. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36970. /** @hidden */
  36971. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36972. /** @hidden */
  36973. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36974. /** @hidden */
  36975. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36976. /**
  36977. * Appends the serialized animations from the source animations
  36978. * @param source Source containing the animations
  36979. * @param destination Target to store the animations
  36980. */
  36981. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36982. /**
  36983. * Static function used to serialized a specific entity
  36984. * @param entity defines the entity to serialize
  36985. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36986. * @returns a JSON compatible object representing the serialization of the entity
  36987. */
  36988. static Serialize<T>(entity: T, serializationObject?: any): any;
  36989. /**
  36990. * Creates a new entity from a serialization data object
  36991. * @param creationFunction defines a function used to instanciated the new entity
  36992. * @param source defines the source serialization data
  36993. * @param scene defines the hosting scene
  36994. * @param rootUrl defines the root url for resources
  36995. * @returns a new entity
  36996. */
  36997. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36998. /**
  36999. * Clones an object
  37000. * @param creationFunction defines the function used to instanciate the new object
  37001. * @param source defines the source object
  37002. * @returns the cloned object
  37003. */
  37004. static Clone<T>(creationFunction: () => T, source: T): T;
  37005. /**
  37006. * Instanciates a new object based on a source one (some data will be shared between both object)
  37007. * @param creationFunction defines the function used to instanciate the new object
  37008. * @param source defines the source object
  37009. * @returns the new object
  37010. */
  37011. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37012. }
  37013. }
  37014. declare module BABYLON {
  37015. /**
  37016. * This is the base class of all the camera used in the application.
  37017. * @see https://doc.babylonjs.com/features/cameras
  37018. */
  37019. export class Camera extends Node {
  37020. /** @hidden */
  37021. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37022. /**
  37023. * This is the default projection mode used by the cameras.
  37024. * It helps recreating a feeling of perspective and better appreciate depth.
  37025. * This is the best way to simulate real life cameras.
  37026. */
  37027. static readonly PERSPECTIVE_CAMERA: number;
  37028. /**
  37029. * This helps creating camera with an orthographic mode.
  37030. * 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.
  37031. */
  37032. static readonly ORTHOGRAPHIC_CAMERA: number;
  37033. /**
  37034. * This is the default FOV mode for perspective cameras.
  37035. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37036. */
  37037. static readonly FOVMODE_VERTICAL_FIXED: number;
  37038. /**
  37039. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37040. */
  37041. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37042. /**
  37043. * This specifies ther is no need for a camera rig.
  37044. * Basically only one eye is rendered corresponding to the camera.
  37045. */
  37046. static readonly RIG_MODE_NONE: number;
  37047. /**
  37048. * Simulates a camera Rig with one blue eye and one red eye.
  37049. * This can be use with 3d blue and red glasses.
  37050. */
  37051. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37052. /**
  37053. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37054. */
  37055. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37056. /**
  37057. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37058. */
  37059. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37060. /**
  37061. * Defines that both eyes of the camera will be rendered over under each other.
  37062. */
  37063. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37064. /**
  37065. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37066. */
  37067. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37068. /**
  37069. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37070. */
  37071. static readonly RIG_MODE_VR: number;
  37072. /**
  37073. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37074. */
  37075. static readonly RIG_MODE_WEBVR: number;
  37076. /**
  37077. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37078. */
  37079. static readonly RIG_MODE_CUSTOM: number;
  37080. /**
  37081. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37082. */
  37083. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37084. /**
  37085. * Define the input manager associated with the camera.
  37086. */
  37087. inputs: CameraInputsManager<Camera>;
  37088. /** @hidden */
  37089. _position: Vector3;
  37090. /**
  37091. * Define the current local position of the camera in the scene
  37092. */
  37093. get position(): Vector3;
  37094. set position(newPosition: Vector3);
  37095. protected _upVector: Vector3;
  37096. /**
  37097. * The vector the camera should consider as up.
  37098. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37099. */
  37100. set upVector(vec: Vector3);
  37101. get upVector(): Vector3;
  37102. /**
  37103. * Define the current limit on the left side for an orthographic camera
  37104. * In scene unit
  37105. */
  37106. orthoLeft: Nullable<number>;
  37107. /**
  37108. * Define the current limit on the right side for an orthographic camera
  37109. * In scene unit
  37110. */
  37111. orthoRight: Nullable<number>;
  37112. /**
  37113. * Define the current limit on the bottom side for an orthographic camera
  37114. * In scene unit
  37115. */
  37116. orthoBottom: Nullable<number>;
  37117. /**
  37118. * Define the current limit on the top side for an orthographic camera
  37119. * In scene unit
  37120. */
  37121. orthoTop: Nullable<number>;
  37122. /**
  37123. * Field Of View is set in Radians. (default is 0.8)
  37124. */
  37125. fov: number;
  37126. /**
  37127. * Define the minimum distance the camera can see from.
  37128. * This is important to note that the depth buffer are not infinite and the closer it starts
  37129. * the more your scene might encounter depth fighting issue.
  37130. */
  37131. minZ: number;
  37132. /**
  37133. * Define the maximum distance the camera can see to.
  37134. * This is important to note that the depth buffer are not infinite and the further it end
  37135. * the more your scene might encounter depth fighting issue.
  37136. */
  37137. maxZ: number;
  37138. /**
  37139. * Define the default inertia of the camera.
  37140. * This helps giving a smooth feeling to the camera movement.
  37141. */
  37142. inertia: number;
  37143. /**
  37144. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37145. */
  37146. mode: number;
  37147. /**
  37148. * Define whether the camera is intermediate.
  37149. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37150. */
  37151. isIntermediate: boolean;
  37152. /**
  37153. * Define the viewport of the camera.
  37154. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37155. */
  37156. viewport: Viewport;
  37157. /**
  37158. * Restricts the camera to viewing objects with the same layerMask.
  37159. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37160. */
  37161. layerMask: number;
  37162. /**
  37163. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37164. */
  37165. fovMode: number;
  37166. /**
  37167. * Rig mode of the camera.
  37168. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37169. * This is normally controlled byt the camera themselves as internal use.
  37170. */
  37171. cameraRigMode: number;
  37172. /**
  37173. * Defines the distance between both "eyes" in case of a RIG
  37174. */
  37175. interaxialDistance: number;
  37176. /**
  37177. * Defines if stereoscopic rendering is done side by side or over under.
  37178. */
  37179. isStereoscopicSideBySide: boolean;
  37180. /**
  37181. * 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
  37182. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37183. * else in the scene. (Eg. security camera)
  37184. *
  37185. * 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)
  37186. */
  37187. customRenderTargets: RenderTargetTexture[];
  37188. /**
  37189. * When set, the camera will render to this render target instead of the default canvas
  37190. *
  37191. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37192. */
  37193. outputRenderTarget: Nullable<RenderTargetTexture>;
  37194. /**
  37195. * Observable triggered when the camera view matrix has changed.
  37196. */
  37197. onViewMatrixChangedObservable: Observable<Camera>;
  37198. /**
  37199. * Observable triggered when the camera Projection matrix has changed.
  37200. */
  37201. onProjectionMatrixChangedObservable: Observable<Camera>;
  37202. /**
  37203. * Observable triggered when the inputs have been processed.
  37204. */
  37205. onAfterCheckInputsObservable: Observable<Camera>;
  37206. /**
  37207. * Observable triggered when reset has been called and applied to the camera.
  37208. */
  37209. onRestoreStateObservable: Observable<Camera>;
  37210. /**
  37211. * Is this camera a part of a rig system?
  37212. */
  37213. isRigCamera: boolean;
  37214. /**
  37215. * If isRigCamera set to true this will be set with the parent camera.
  37216. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37217. */
  37218. rigParent?: Camera;
  37219. /** @hidden */
  37220. _cameraRigParams: any;
  37221. /** @hidden */
  37222. _rigCameras: Camera[];
  37223. /** @hidden */
  37224. _rigPostProcess: Nullable<PostProcess>;
  37225. protected _webvrViewMatrix: Matrix;
  37226. /** @hidden */
  37227. _skipRendering: boolean;
  37228. /** @hidden */
  37229. _projectionMatrix: Matrix;
  37230. /** @hidden */
  37231. _postProcesses: Nullable<PostProcess>[];
  37232. /** @hidden */
  37233. _activeMeshes: SmartArray<AbstractMesh>;
  37234. protected _globalPosition: Vector3;
  37235. /** @hidden */
  37236. _computedViewMatrix: Matrix;
  37237. private _doNotComputeProjectionMatrix;
  37238. private _transformMatrix;
  37239. private _frustumPlanes;
  37240. private _refreshFrustumPlanes;
  37241. private _storedFov;
  37242. private _stateStored;
  37243. /**
  37244. * Instantiates a new camera object.
  37245. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37246. * @see https://doc.babylonjs.com/features/cameras
  37247. * @param name Defines the name of the camera in the scene
  37248. * @param position Defines the position of the camera
  37249. * @param scene Defines the scene the camera belongs too
  37250. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37251. */
  37252. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37253. /**
  37254. * Store current camera state (fov, position, etc..)
  37255. * @returns the camera
  37256. */
  37257. storeState(): Camera;
  37258. /**
  37259. * Restores the camera state values if it has been stored. You must call storeState() first
  37260. */
  37261. protected _restoreStateValues(): boolean;
  37262. /**
  37263. * Restored camera state. You must call storeState() first.
  37264. * @returns true if restored and false otherwise
  37265. */
  37266. restoreState(): boolean;
  37267. /**
  37268. * Gets the class name of the camera.
  37269. * @returns the class name
  37270. */
  37271. getClassName(): string;
  37272. /** @hidden */
  37273. readonly _isCamera: boolean;
  37274. /**
  37275. * Gets a string representation of the camera useful for debug purpose.
  37276. * @param fullDetails Defines that a more verboe level of logging is required
  37277. * @returns the string representation
  37278. */
  37279. toString(fullDetails?: boolean): string;
  37280. /**
  37281. * Gets the current world space position of the camera.
  37282. */
  37283. get globalPosition(): Vector3;
  37284. /**
  37285. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37286. * @returns the active meshe list
  37287. */
  37288. getActiveMeshes(): SmartArray<AbstractMesh>;
  37289. /**
  37290. * Check whether a mesh is part of the current active mesh list of the camera
  37291. * @param mesh Defines the mesh to check
  37292. * @returns true if active, false otherwise
  37293. */
  37294. isActiveMesh(mesh: Mesh): boolean;
  37295. /**
  37296. * Is this camera ready to be used/rendered
  37297. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37298. * @return true if the camera is ready
  37299. */
  37300. isReady(completeCheck?: boolean): boolean;
  37301. /** @hidden */
  37302. _initCache(): void;
  37303. /** @hidden */
  37304. _updateCache(ignoreParentClass?: boolean): void;
  37305. /** @hidden */
  37306. _isSynchronized(): boolean;
  37307. /** @hidden */
  37308. _isSynchronizedViewMatrix(): boolean;
  37309. /** @hidden */
  37310. _isSynchronizedProjectionMatrix(): boolean;
  37311. /**
  37312. * Attach the input controls to a specific dom element to get the input from.
  37313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37314. */
  37315. attachControl(noPreventDefault?: boolean): void;
  37316. /**
  37317. * Attach the input controls to a specific dom element to get the input from.
  37318. * @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
  37319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37320. * BACK COMPAT SIGNATURE ONLY.
  37321. */
  37322. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37323. /**
  37324. * Detach the current controls from the specified dom element.
  37325. */
  37326. detachControl(): void;
  37327. /**
  37328. * Detach the current controls from the specified dom element.
  37329. * @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
  37330. */
  37331. detachControl(ignored: any): void;
  37332. /**
  37333. * Update the camera state according to the different inputs gathered during the frame.
  37334. */
  37335. update(): void;
  37336. /** @hidden */
  37337. _checkInputs(): void;
  37338. /** @hidden */
  37339. get rigCameras(): Camera[];
  37340. /**
  37341. * Gets the post process used by the rig cameras
  37342. */
  37343. get rigPostProcess(): Nullable<PostProcess>;
  37344. /**
  37345. * Internal, gets the first post proces.
  37346. * @returns the first post process to be run on this camera.
  37347. */
  37348. _getFirstPostProcess(): Nullable<PostProcess>;
  37349. private _cascadePostProcessesToRigCams;
  37350. /**
  37351. * Attach a post process to the camera.
  37352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37353. * @param postProcess The post process to attach to the camera
  37354. * @param insertAt The position of the post process in case several of them are in use in the scene
  37355. * @returns the position the post process has been inserted at
  37356. */
  37357. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37358. /**
  37359. * Detach a post process to the camera.
  37360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37361. * @param postProcess The post process to detach from the camera
  37362. */
  37363. detachPostProcess(postProcess: PostProcess): void;
  37364. /**
  37365. * Gets the current world matrix of the camera
  37366. */
  37367. getWorldMatrix(): Matrix;
  37368. /** @hidden */
  37369. _getViewMatrix(): Matrix;
  37370. /**
  37371. * Gets the current view matrix of the camera.
  37372. * @param force forces the camera to recompute the matrix without looking at the cached state
  37373. * @returns the view matrix
  37374. */
  37375. getViewMatrix(force?: boolean): Matrix;
  37376. /**
  37377. * Freeze the projection matrix.
  37378. * It will prevent the cache check of the camera projection compute and can speed up perf
  37379. * if no parameter of the camera are meant to change
  37380. * @param projection Defines manually a projection if necessary
  37381. */
  37382. freezeProjectionMatrix(projection?: Matrix): void;
  37383. /**
  37384. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37385. */
  37386. unfreezeProjectionMatrix(): void;
  37387. /**
  37388. * Gets the current projection matrix of the camera.
  37389. * @param force forces the camera to recompute the matrix without looking at the cached state
  37390. * @returns the projection matrix
  37391. */
  37392. getProjectionMatrix(force?: boolean): Matrix;
  37393. /**
  37394. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37395. * @returns a Matrix
  37396. */
  37397. getTransformationMatrix(): Matrix;
  37398. private _updateFrustumPlanes;
  37399. /**
  37400. * Checks if a cullable object (mesh...) is in the camera frustum
  37401. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37402. * @param target The object to check
  37403. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37404. * @returns true if the object is in frustum otherwise false
  37405. */
  37406. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37407. /**
  37408. * Checks if a cullable object (mesh...) is in the camera frustum
  37409. * Unlike isInFrustum this cheks the full bounding box
  37410. * @param target The object to check
  37411. * @returns true if the object is in frustum otherwise false
  37412. */
  37413. isCompletelyInFrustum(target: ICullable): boolean;
  37414. /**
  37415. * Gets a ray in the forward direction from the camera.
  37416. * @param length Defines the length of the ray to create
  37417. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37418. * @param origin Defines the start point of the ray which defaults to the camera position
  37419. * @returns the forward ray
  37420. */
  37421. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37422. /**
  37423. * Gets a ray in the forward direction from the camera.
  37424. * @param refRay the ray to (re)use when setting the values
  37425. * @param length Defines the length of the ray to create
  37426. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37427. * @param origin Defines the start point of the ray which defaults to the camera position
  37428. * @returns the forward ray
  37429. */
  37430. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37431. /**
  37432. * Releases resources associated with this node.
  37433. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37434. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37435. */
  37436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37437. /** @hidden */
  37438. _isLeftCamera: boolean;
  37439. /**
  37440. * Gets the left camera of a rig setup in case of Rigged Camera
  37441. */
  37442. get isLeftCamera(): boolean;
  37443. /** @hidden */
  37444. _isRightCamera: boolean;
  37445. /**
  37446. * Gets the right camera of a rig setup in case of Rigged Camera
  37447. */
  37448. get isRightCamera(): boolean;
  37449. /**
  37450. * Gets the left camera of a rig setup in case of Rigged Camera
  37451. */
  37452. get leftCamera(): Nullable<FreeCamera>;
  37453. /**
  37454. * Gets the right camera of a rig setup in case of Rigged Camera
  37455. */
  37456. get rightCamera(): Nullable<FreeCamera>;
  37457. /**
  37458. * Gets the left camera target of a rig setup in case of Rigged Camera
  37459. * @returns the target position
  37460. */
  37461. getLeftTarget(): Nullable<Vector3>;
  37462. /**
  37463. * Gets the right camera target of a rig setup in case of Rigged Camera
  37464. * @returns the target position
  37465. */
  37466. getRightTarget(): Nullable<Vector3>;
  37467. /**
  37468. * @hidden
  37469. */
  37470. setCameraRigMode(mode: number, rigParams: any): void;
  37471. /** @hidden */
  37472. static _setStereoscopicRigMode(camera: Camera): void;
  37473. /** @hidden */
  37474. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37475. /** @hidden */
  37476. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37477. /** @hidden */
  37478. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37479. /** @hidden */
  37480. _getVRProjectionMatrix(): Matrix;
  37481. protected _updateCameraRotationMatrix(): void;
  37482. protected _updateWebVRCameraRotationMatrix(): void;
  37483. /**
  37484. * This function MUST be overwritten by the different WebVR cameras available.
  37485. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37486. * @hidden
  37487. */
  37488. _getWebVRProjectionMatrix(): Matrix;
  37489. /**
  37490. * This function MUST be overwritten by the different WebVR cameras available.
  37491. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37492. * @hidden
  37493. */
  37494. _getWebVRViewMatrix(): Matrix;
  37495. /** @hidden */
  37496. setCameraRigParameter(name: string, value: any): void;
  37497. /**
  37498. * needs to be overridden by children so sub has required properties to be copied
  37499. * @hidden
  37500. */
  37501. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37502. /**
  37503. * May need to be overridden by children
  37504. * @hidden
  37505. */
  37506. _updateRigCameras(): void;
  37507. /** @hidden */
  37508. _setupInputs(): void;
  37509. /**
  37510. * Serialiaze the camera setup to a json represention
  37511. * @returns the JSON representation
  37512. */
  37513. serialize(): any;
  37514. /**
  37515. * Clones the current camera.
  37516. * @param name The cloned camera name
  37517. * @returns the cloned camera
  37518. */
  37519. clone(name: string): Camera;
  37520. /**
  37521. * Gets the direction of the camera relative to a given local axis.
  37522. * @param localAxis Defines the reference axis to provide a relative direction.
  37523. * @return the direction
  37524. */
  37525. getDirection(localAxis: Vector3): Vector3;
  37526. /**
  37527. * Returns the current camera absolute rotation
  37528. */
  37529. get absoluteRotation(): Quaternion;
  37530. /**
  37531. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37532. * @param localAxis Defines the reference axis to provide a relative direction.
  37533. * @param result Defines the vector to store the result in
  37534. */
  37535. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37536. /**
  37537. * Gets a camera constructor for a given camera type
  37538. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37539. * @param name The name of the camera the result will be able to instantiate
  37540. * @param scene The scene the result will construct the camera in
  37541. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37542. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37543. * @returns a factory method to construc the camera
  37544. */
  37545. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37546. /**
  37547. * Compute the world matrix of the camera.
  37548. * @returns the camera world matrix
  37549. */
  37550. computeWorldMatrix(): Matrix;
  37551. /**
  37552. * Parse a JSON and creates the camera from the parsed information
  37553. * @param parsedCamera The JSON to parse
  37554. * @param scene The scene to instantiate the camera in
  37555. * @returns the newly constructed camera
  37556. */
  37557. static Parse(parsedCamera: any, scene: Scene): Camera;
  37558. }
  37559. }
  37560. declare module BABYLON {
  37561. /**
  37562. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37563. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37564. */
  37565. export class PostProcessManager {
  37566. private _scene;
  37567. private _indexBuffer;
  37568. private _vertexBuffers;
  37569. /**
  37570. * Creates a new instance PostProcess
  37571. * @param scene The scene that the post process is associated with.
  37572. */
  37573. constructor(scene: Scene);
  37574. private _prepareBuffers;
  37575. private _buildIndexBuffer;
  37576. /**
  37577. * Rebuilds the vertex buffers of the manager.
  37578. * @hidden
  37579. */
  37580. _rebuild(): void;
  37581. /**
  37582. * Prepares a frame to be run through a post process.
  37583. * @param sourceTexture The input texture to the post procesess. (default: null)
  37584. * @param postProcesses An array of post processes to be run. (default: null)
  37585. * @returns True if the post processes were able to be run.
  37586. * @hidden
  37587. */
  37588. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37589. /**
  37590. * Manually render a set of post processes to a texture.
  37591. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37592. * @param postProcesses An array of post processes to be run.
  37593. * @param targetTexture The target texture to render to.
  37594. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37595. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37596. * @param lodLevel defines which lod of the texture to render to
  37597. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37598. */
  37599. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37600. /**
  37601. * Finalize the result of the output of the postprocesses.
  37602. * @param doNotPresent If true the result will not be displayed to the screen.
  37603. * @param targetTexture The target texture to render to.
  37604. * @param faceIndex The index of the face to bind the target texture to.
  37605. * @param postProcesses The array of post processes to render.
  37606. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37607. * @hidden
  37608. */
  37609. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37610. /**
  37611. * Disposes of the post process manager.
  37612. */
  37613. dispose(): void;
  37614. }
  37615. }
  37616. declare module BABYLON {
  37617. /**
  37618. * This Helps creating a texture that will be created from a camera in your scene.
  37619. * It is basically a dynamic texture that could be used to create special effects for instance.
  37620. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37621. */
  37622. export class RenderTargetTexture extends Texture {
  37623. /**
  37624. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37625. */
  37626. static readonly REFRESHRATE_RENDER_ONCE: number;
  37627. /**
  37628. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37629. */
  37630. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37631. /**
  37632. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37633. * the central point of your effect and can save a lot of performances.
  37634. */
  37635. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37636. /**
  37637. * Use this predicate to dynamically define the list of mesh you want to render.
  37638. * If set, the renderList property will be overwritten.
  37639. */
  37640. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37641. private _renderList;
  37642. /**
  37643. * Use this list to define the list of mesh you want to render.
  37644. */
  37645. get renderList(): Nullable<Array<AbstractMesh>>;
  37646. set renderList(value: Nullable<Array<AbstractMesh>>);
  37647. /**
  37648. * Use this function to overload the renderList array at rendering time.
  37649. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37650. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37651. * the cube (if the RTT is a cube, else layerOrFace=0).
  37652. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37653. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37654. * hold dummy elements!
  37655. */
  37656. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37657. private _hookArray;
  37658. /**
  37659. * Define if particles should be rendered in your texture.
  37660. */
  37661. renderParticles: boolean;
  37662. /**
  37663. * Define if sprites should be rendered in your texture.
  37664. */
  37665. renderSprites: boolean;
  37666. /**
  37667. * Define the camera used to render the texture.
  37668. */
  37669. activeCamera: Nullable<Camera>;
  37670. /**
  37671. * Override the mesh isReady function with your own one.
  37672. */
  37673. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37674. /**
  37675. * Override the render function of the texture with your own one.
  37676. */
  37677. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37678. /**
  37679. * Define if camera post processes should be use while rendering the texture.
  37680. */
  37681. useCameraPostProcesses: boolean;
  37682. /**
  37683. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37684. */
  37685. ignoreCameraViewport: boolean;
  37686. private _postProcessManager;
  37687. private _postProcesses;
  37688. private _resizeObserver;
  37689. /**
  37690. * An event triggered when the texture is unbind.
  37691. */
  37692. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37693. /**
  37694. * An event triggered when the texture is unbind.
  37695. */
  37696. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37697. private _onAfterUnbindObserver;
  37698. /**
  37699. * Set a after unbind callback in the texture.
  37700. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37701. */
  37702. set onAfterUnbind(callback: () => void);
  37703. /**
  37704. * An event triggered before rendering the texture
  37705. */
  37706. onBeforeRenderObservable: Observable<number>;
  37707. private _onBeforeRenderObserver;
  37708. /**
  37709. * Set a before render callback in the texture.
  37710. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37711. */
  37712. set onBeforeRender(callback: (faceIndex: number) => void);
  37713. /**
  37714. * An event triggered after rendering the texture
  37715. */
  37716. onAfterRenderObservable: Observable<number>;
  37717. private _onAfterRenderObserver;
  37718. /**
  37719. * Set a after render callback in the texture.
  37720. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37721. */
  37722. set onAfterRender(callback: (faceIndex: number) => void);
  37723. /**
  37724. * An event triggered after the texture clear
  37725. */
  37726. onClearObservable: Observable<Engine>;
  37727. private _onClearObserver;
  37728. /**
  37729. * Set a clear callback in the texture.
  37730. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37731. */
  37732. set onClear(callback: (Engine: Engine) => void);
  37733. /**
  37734. * An event triggered when the texture is resized.
  37735. */
  37736. onResizeObservable: Observable<RenderTargetTexture>;
  37737. /**
  37738. * Define the clear color of the Render Target if it should be different from the scene.
  37739. */
  37740. clearColor: Color4;
  37741. protected _size: number | {
  37742. width: number;
  37743. height: number;
  37744. layers?: number;
  37745. };
  37746. protected _initialSizeParameter: number | {
  37747. width: number;
  37748. height: number;
  37749. } | {
  37750. ratio: number;
  37751. };
  37752. protected _sizeRatio: Nullable<number>;
  37753. /** @hidden */
  37754. _generateMipMaps: boolean;
  37755. protected _renderingManager: RenderingManager;
  37756. /** @hidden */
  37757. _waitingRenderList?: string[];
  37758. protected _doNotChangeAspectRatio: boolean;
  37759. protected _currentRefreshId: number;
  37760. protected _refreshRate: number;
  37761. protected _textureMatrix: Matrix;
  37762. protected _samples: number;
  37763. protected _renderTargetOptions: RenderTargetCreationOptions;
  37764. /**
  37765. * Gets render target creation options that were used.
  37766. */
  37767. get renderTargetOptions(): RenderTargetCreationOptions;
  37768. protected _onRatioRescale(): void;
  37769. /**
  37770. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37771. * It must define where the camera used to render the texture is set
  37772. */
  37773. boundingBoxPosition: Vector3;
  37774. private _boundingBoxSize;
  37775. /**
  37776. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37777. * When defined, the cubemap will switch to local mode
  37778. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37779. * @example https://www.babylonjs-playground.com/#RNASML
  37780. */
  37781. set boundingBoxSize(value: Vector3);
  37782. get boundingBoxSize(): Vector3;
  37783. /**
  37784. * In case the RTT has been created with a depth texture, get the associated
  37785. * depth texture.
  37786. * Otherwise, return null.
  37787. */
  37788. get depthStencilTexture(): Nullable<InternalTexture>;
  37789. /**
  37790. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37791. * or used a shadow, depth texture...
  37792. * @param name The friendly name of the texture
  37793. * @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)
  37794. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37795. * @param generateMipMaps True if mip maps need to be generated after render.
  37796. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37797. * @param type The type of the buffer in the RTT (int, half float, float...)
  37798. * @param isCube True if a cube texture needs to be created
  37799. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37800. * @param generateDepthBuffer True to generate a depth buffer
  37801. * @param generateStencilBuffer True to generate a stencil buffer
  37802. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37803. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37804. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37805. */
  37806. constructor(name: string, size: number | {
  37807. width: number;
  37808. height: number;
  37809. layers?: number;
  37810. } | {
  37811. ratio: number;
  37812. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37813. /**
  37814. * Creates a depth stencil texture.
  37815. * This is only available in WebGL 2 or with the depth texture extension available.
  37816. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37817. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37818. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37819. */
  37820. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37821. private _processSizeParameter;
  37822. /**
  37823. * Define the number of samples to use in case of MSAA.
  37824. * It defaults to one meaning no MSAA has been enabled.
  37825. */
  37826. get samples(): number;
  37827. set samples(value: number);
  37828. /**
  37829. * Resets the refresh counter of the texture and start bak from scratch.
  37830. * Could be useful to regenerate the texture if it is setup to render only once.
  37831. */
  37832. resetRefreshCounter(): void;
  37833. /**
  37834. * Define the refresh rate of the texture or the rendering frequency.
  37835. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37836. */
  37837. get refreshRate(): number;
  37838. set refreshRate(value: number);
  37839. /**
  37840. * Adds a post process to the render target rendering passes.
  37841. * @param postProcess define the post process to add
  37842. */
  37843. addPostProcess(postProcess: PostProcess): void;
  37844. /**
  37845. * Clear all the post processes attached to the render target
  37846. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37847. */
  37848. clearPostProcesses(dispose?: boolean): void;
  37849. /**
  37850. * Remove one of the post process from the list of attached post processes to the texture
  37851. * @param postProcess define the post process to remove from the list
  37852. */
  37853. removePostProcess(postProcess: PostProcess): void;
  37854. /** @hidden */
  37855. _shouldRender(): boolean;
  37856. /**
  37857. * Gets the actual render size of the texture.
  37858. * @returns the width of the render size
  37859. */
  37860. getRenderSize(): number;
  37861. /**
  37862. * Gets the actual render width of the texture.
  37863. * @returns the width of the render size
  37864. */
  37865. getRenderWidth(): number;
  37866. /**
  37867. * Gets the actual render height of the texture.
  37868. * @returns the height of the render size
  37869. */
  37870. getRenderHeight(): number;
  37871. /**
  37872. * Gets the actual number of layers of the texture.
  37873. * @returns the number of layers
  37874. */
  37875. getRenderLayers(): number;
  37876. /**
  37877. * Get if the texture can be rescaled or not.
  37878. */
  37879. get canRescale(): boolean;
  37880. /**
  37881. * Resize the texture using a ratio.
  37882. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37883. */
  37884. scale(ratio: number): void;
  37885. /**
  37886. * Get the texture reflection matrix used to rotate/transform the reflection.
  37887. * @returns the reflection matrix
  37888. */
  37889. getReflectionTextureMatrix(): Matrix;
  37890. /**
  37891. * Resize the texture to a new desired size.
  37892. * Be carrefull as it will recreate all the data in the new texture.
  37893. * @param size Define the new size. It can be:
  37894. * - a number for squared texture,
  37895. * - an object containing { width: number, height: number }
  37896. * - or an object containing a ratio { ratio: number }
  37897. */
  37898. resize(size: number | {
  37899. width: number;
  37900. height: number;
  37901. } | {
  37902. ratio: number;
  37903. }): void;
  37904. private _defaultRenderListPrepared;
  37905. /**
  37906. * Renders all the objects from the render list into the texture.
  37907. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37908. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37909. */
  37910. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37911. private _bestReflectionRenderTargetDimension;
  37912. private _prepareRenderingManager;
  37913. /**
  37914. * @hidden
  37915. * @param faceIndex face index to bind to if this is a cubetexture
  37916. * @param layer defines the index of the texture to bind in the array
  37917. */
  37918. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37919. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37920. private renderToTarget;
  37921. /**
  37922. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37923. * This allowed control for front to back rendering or reversly depending of the special needs.
  37924. *
  37925. * @param renderingGroupId The rendering group id corresponding to its index
  37926. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37927. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37928. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37929. */
  37930. 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;
  37931. /**
  37932. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37933. *
  37934. * @param renderingGroupId The rendering group id corresponding to its index
  37935. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37936. */
  37937. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37938. /**
  37939. * Clones the texture.
  37940. * @returns the cloned texture
  37941. */
  37942. clone(): RenderTargetTexture;
  37943. /**
  37944. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37945. * @returns The JSON representation of the texture
  37946. */
  37947. serialize(): any;
  37948. /**
  37949. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37950. */
  37951. disposeFramebufferObjects(): void;
  37952. /**
  37953. * Dispose the texture and release its associated resources.
  37954. */
  37955. dispose(): void;
  37956. /** @hidden */
  37957. _rebuild(): void;
  37958. /**
  37959. * Clear the info related to rendering groups preventing retention point in material dispose.
  37960. */
  37961. freeRenderingGroups(): void;
  37962. /**
  37963. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37964. * @returns the view count
  37965. */
  37966. getViewCount(): number;
  37967. }
  37968. }
  37969. declare module BABYLON {
  37970. /**
  37971. * Options to be used when creating an effect.
  37972. */
  37973. export interface IEffectCreationOptions {
  37974. /**
  37975. * Atrributes that will be used in the shader.
  37976. */
  37977. attributes: string[];
  37978. /**
  37979. * Uniform varible names that will be set in the shader.
  37980. */
  37981. uniformsNames: string[];
  37982. /**
  37983. * Uniform buffer variable names that will be set in the shader.
  37984. */
  37985. uniformBuffersNames: string[];
  37986. /**
  37987. * Sampler texture variable names that will be set in the shader.
  37988. */
  37989. samplers: string[];
  37990. /**
  37991. * Define statements that will be set in the shader.
  37992. */
  37993. defines: any;
  37994. /**
  37995. * Possible fallbacks for this effect to improve performance when needed.
  37996. */
  37997. fallbacks: Nullable<IEffectFallbacks>;
  37998. /**
  37999. * Callback that will be called when the shader is compiled.
  38000. */
  38001. onCompiled: Nullable<(effect: Effect) => void>;
  38002. /**
  38003. * Callback that will be called if an error occurs during shader compilation.
  38004. */
  38005. onError: Nullable<(effect: Effect, errors: string) => void>;
  38006. /**
  38007. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38008. */
  38009. indexParameters?: any;
  38010. /**
  38011. * Max number of lights that can be used in the shader.
  38012. */
  38013. maxSimultaneousLights?: number;
  38014. /**
  38015. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38016. */
  38017. transformFeedbackVaryings?: Nullable<string[]>;
  38018. /**
  38019. * 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
  38020. */
  38021. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38022. /**
  38023. * Is this effect rendering to several color attachments ?
  38024. */
  38025. multiTarget?: boolean;
  38026. }
  38027. /**
  38028. * Effect containing vertex and fragment shader that can be executed on an object.
  38029. */
  38030. export class Effect implements IDisposable {
  38031. /**
  38032. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38033. */
  38034. static ShadersRepository: string;
  38035. /**
  38036. * Enable logging of the shader code when a compilation error occurs
  38037. */
  38038. static LogShaderCodeOnCompilationError: boolean;
  38039. /**
  38040. * Name of the effect.
  38041. */
  38042. name: any;
  38043. /**
  38044. * String container all the define statements that should be set on the shader.
  38045. */
  38046. defines: string;
  38047. /**
  38048. * Callback that will be called when the shader is compiled.
  38049. */
  38050. onCompiled: Nullable<(effect: Effect) => void>;
  38051. /**
  38052. * Callback that will be called if an error occurs during shader compilation.
  38053. */
  38054. onError: Nullable<(effect: Effect, errors: string) => void>;
  38055. /**
  38056. * Callback that will be called when effect is bound.
  38057. */
  38058. onBind: Nullable<(effect: Effect) => void>;
  38059. /**
  38060. * Unique ID of the effect.
  38061. */
  38062. uniqueId: number;
  38063. /**
  38064. * Observable that will be called when the shader is compiled.
  38065. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38066. */
  38067. onCompileObservable: Observable<Effect>;
  38068. /**
  38069. * Observable that will be called if an error occurs during shader compilation.
  38070. */
  38071. onErrorObservable: Observable<Effect>;
  38072. /** @hidden */
  38073. _onBindObservable: Nullable<Observable<Effect>>;
  38074. /**
  38075. * @hidden
  38076. * Specifies if the effect was previously ready
  38077. */
  38078. _wasPreviouslyReady: boolean;
  38079. /**
  38080. * Observable that will be called when effect is bound.
  38081. */
  38082. get onBindObservable(): Observable<Effect>;
  38083. /** @hidden */
  38084. _bonesComputationForcedToCPU: boolean;
  38085. /** @hidden */
  38086. _multiTarget: boolean;
  38087. private static _uniqueIdSeed;
  38088. private _engine;
  38089. private _uniformBuffersNames;
  38090. private _uniformBuffersNamesList;
  38091. private _uniformsNames;
  38092. private _samplerList;
  38093. private _samplers;
  38094. private _isReady;
  38095. private _compilationError;
  38096. private _allFallbacksProcessed;
  38097. private _attributesNames;
  38098. private _attributes;
  38099. private _attributeLocationByName;
  38100. private _uniforms;
  38101. /**
  38102. * Key for the effect.
  38103. * @hidden
  38104. */
  38105. _key: string;
  38106. private _indexParameters;
  38107. private _fallbacks;
  38108. private _vertexSourceCode;
  38109. private _fragmentSourceCode;
  38110. private _vertexSourceCodeOverride;
  38111. private _fragmentSourceCodeOverride;
  38112. private _transformFeedbackVaryings;
  38113. private _rawVertexSourceCode;
  38114. private _rawFragmentSourceCode;
  38115. /**
  38116. * Compiled shader to webGL program.
  38117. * @hidden
  38118. */
  38119. _pipelineContext: Nullable<IPipelineContext>;
  38120. private _valueCache;
  38121. private static _baseCache;
  38122. /**
  38123. * Instantiates an effect.
  38124. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38125. * @param baseName Name of the effect.
  38126. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38127. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38128. * @param samplers List of sampler variables that will be passed to the shader.
  38129. * @param engine Engine to be used to render the effect
  38130. * @param defines Define statements to be added to the shader.
  38131. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38132. * @param onCompiled Callback that will be called when the shader is compiled.
  38133. * @param onError Callback that will be called if an error occurs during shader compilation.
  38134. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38135. */
  38136. 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);
  38137. private _useFinalCode;
  38138. /**
  38139. * Unique key for this effect
  38140. */
  38141. get key(): string;
  38142. /**
  38143. * If the effect has been compiled and prepared.
  38144. * @returns if the effect is compiled and prepared.
  38145. */
  38146. isReady(): boolean;
  38147. private _isReadyInternal;
  38148. /**
  38149. * The engine the effect was initialized with.
  38150. * @returns the engine.
  38151. */
  38152. getEngine(): Engine;
  38153. /**
  38154. * The pipeline context for this effect
  38155. * @returns the associated pipeline context
  38156. */
  38157. getPipelineContext(): Nullable<IPipelineContext>;
  38158. /**
  38159. * The set of names of attribute variables for the shader.
  38160. * @returns An array of attribute names.
  38161. */
  38162. getAttributesNames(): string[];
  38163. /**
  38164. * Returns the attribute at the given index.
  38165. * @param index The index of the attribute.
  38166. * @returns The location of the attribute.
  38167. */
  38168. getAttributeLocation(index: number): number;
  38169. /**
  38170. * Returns the attribute based on the name of the variable.
  38171. * @param name of the attribute to look up.
  38172. * @returns the attribute location.
  38173. */
  38174. getAttributeLocationByName(name: string): number;
  38175. /**
  38176. * The number of attributes.
  38177. * @returns the numnber of attributes.
  38178. */
  38179. getAttributesCount(): number;
  38180. /**
  38181. * Gets the index of a uniform variable.
  38182. * @param uniformName of the uniform to look up.
  38183. * @returns the index.
  38184. */
  38185. getUniformIndex(uniformName: string): number;
  38186. /**
  38187. * Returns the attribute based on the name of the variable.
  38188. * @param uniformName of the uniform to look up.
  38189. * @returns the location of the uniform.
  38190. */
  38191. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38192. /**
  38193. * Returns an array of sampler variable names
  38194. * @returns The array of sampler variable names.
  38195. */
  38196. getSamplers(): string[];
  38197. /**
  38198. * Returns an array of uniform variable names
  38199. * @returns The array of uniform variable names.
  38200. */
  38201. getUniformNames(): string[];
  38202. /**
  38203. * Returns an array of uniform buffer variable names
  38204. * @returns The array of uniform buffer variable names.
  38205. */
  38206. getUniformBuffersNames(): string[];
  38207. /**
  38208. * Returns the index parameters used to create the effect
  38209. * @returns The index parameters object
  38210. */
  38211. getIndexParameters(): any;
  38212. /**
  38213. * The error from the last compilation.
  38214. * @returns the error string.
  38215. */
  38216. getCompilationError(): string;
  38217. /**
  38218. * Gets a boolean indicating that all fallbacks were used during compilation
  38219. * @returns true if all fallbacks were used
  38220. */
  38221. allFallbacksProcessed(): boolean;
  38222. /**
  38223. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38224. * @param func The callback to be used.
  38225. */
  38226. executeWhenCompiled(func: (effect: Effect) => void): void;
  38227. private _checkIsReady;
  38228. private _loadShader;
  38229. /**
  38230. * Gets the vertex shader source code of this effect
  38231. */
  38232. get vertexSourceCode(): string;
  38233. /**
  38234. * Gets the fragment shader source code of this effect
  38235. */
  38236. get fragmentSourceCode(): string;
  38237. /**
  38238. * Gets the vertex shader source code before it has been processed by the preprocessor
  38239. */
  38240. get rawVertexSourceCode(): string;
  38241. /**
  38242. * Gets the fragment shader source code before it has been processed by the preprocessor
  38243. */
  38244. get rawFragmentSourceCode(): string;
  38245. /**
  38246. * Recompiles the webGL program
  38247. * @param vertexSourceCode The source code for the vertex shader.
  38248. * @param fragmentSourceCode The source code for the fragment shader.
  38249. * @param onCompiled Callback called when completed.
  38250. * @param onError Callback called on error.
  38251. * @hidden
  38252. */
  38253. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38254. /**
  38255. * Prepares the effect
  38256. * @hidden
  38257. */
  38258. _prepareEffect(): void;
  38259. private _getShaderCodeAndErrorLine;
  38260. private _processCompilationErrors;
  38261. /**
  38262. * Checks if the effect is supported. (Must be called after compilation)
  38263. */
  38264. get isSupported(): boolean;
  38265. /**
  38266. * Binds a texture to the engine to be used as output of the shader.
  38267. * @param channel Name of the output variable.
  38268. * @param texture Texture to bind.
  38269. * @hidden
  38270. */
  38271. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38272. /**
  38273. * Sets a texture on the engine to be used in the shader.
  38274. * @param channel Name of the sampler variable.
  38275. * @param texture Texture to set.
  38276. */
  38277. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38278. /**
  38279. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38280. * @param channel Name of the sampler variable.
  38281. * @param texture Texture to set.
  38282. */
  38283. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38284. /**
  38285. * Sets an array of textures on the engine to be used in the shader.
  38286. * @param channel Name of the variable.
  38287. * @param textures Textures to set.
  38288. */
  38289. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38290. /**
  38291. * 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)
  38292. * @param channel Name of the sampler variable.
  38293. * @param postProcess Post process to get the input texture from.
  38294. */
  38295. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38296. /**
  38297. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38298. * 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)
  38299. * @param channel Name of the sampler variable.
  38300. * @param postProcess Post process to get the output texture from.
  38301. */
  38302. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38303. /** @hidden */
  38304. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38305. /** @hidden */
  38306. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38307. /** @hidden */
  38308. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38309. /** @hidden */
  38310. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38311. /**
  38312. * Binds a buffer to a uniform.
  38313. * @param buffer Buffer to bind.
  38314. * @param name Name of the uniform variable to bind to.
  38315. */
  38316. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38317. /**
  38318. * Binds block to a uniform.
  38319. * @param blockName Name of the block to bind.
  38320. * @param index Index to bind.
  38321. */
  38322. bindUniformBlock(blockName: string, index: number): void;
  38323. /**
  38324. * Sets an interger value on a uniform variable.
  38325. * @param uniformName Name of the variable.
  38326. * @param value Value to be set.
  38327. * @returns this effect.
  38328. */
  38329. setInt(uniformName: string, value: number): Effect;
  38330. /**
  38331. * Sets an int array on a uniform variable.
  38332. * @param uniformName Name of the variable.
  38333. * @param array array to be set.
  38334. * @returns this effect.
  38335. */
  38336. setIntArray(uniformName: string, array: Int32Array): Effect;
  38337. /**
  38338. * 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)
  38339. * @param uniformName Name of the variable.
  38340. * @param array array to be set.
  38341. * @returns this effect.
  38342. */
  38343. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38344. /**
  38345. * 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)
  38346. * @param uniformName Name of the variable.
  38347. * @param array array to be set.
  38348. * @returns this effect.
  38349. */
  38350. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38351. /**
  38352. * 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)
  38353. * @param uniformName Name of the variable.
  38354. * @param array array to be set.
  38355. * @returns this effect.
  38356. */
  38357. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38358. /**
  38359. * Sets an float array on a uniform variable.
  38360. * @param uniformName Name of the variable.
  38361. * @param array array to be set.
  38362. * @returns this effect.
  38363. */
  38364. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38365. /**
  38366. * 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)
  38367. * @param uniformName Name of the variable.
  38368. * @param array array to be set.
  38369. * @returns this effect.
  38370. */
  38371. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38372. /**
  38373. * 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)
  38374. * @param uniformName Name of the variable.
  38375. * @param array array to be set.
  38376. * @returns this effect.
  38377. */
  38378. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38379. /**
  38380. * 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)
  38381. * @param uniformName Name of the variable.
  38382. * @param array array to be set.
  38383. * @returns this effect.
  38384. */
  38385. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38386. /**
  38387. * Sets an array on a uniform variable.
  38388. * @param uniformName Name of the variable.
  38389. * @param array array to be set.
  38390. * @returns this effect.
  38391. */
  38392. setArray(uniformName: string, array: number[]): Effect;
  38393. /**
  38394. * 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)
  38395. * @param uniformName Name of the variable.
  38396. * @param array array to be set.
  38397. * @returns this effect.
  38398. */
  38399. setArray2(uniformName: string, array: number[]): Effect;
  38400. /**
  38401. * 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)
  38402. * @param uniformName Name of the variable.
  38403. * @param array array to be set.
  38404. * @returns this effect.
  38405. */
  38406. setArray3(uniformName: string, array: number[]): Effect;
  38407. /**
  38408. * 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)
  38409. * @param uniformName Name of the variable.
  38410. * @param array array to be set.
  38411. * @returns this effect.
  38412. */
  38413. setArray4(uniformName: string, array: number[]): Effect;
  38414. /**
  38415. * Sets matrices on a uniform variable.
  38416. * @param uniformName Name of the variable.
  38417. * @param matrices matrices to be set.
  38418. * @returns this effect.
  38419. */
  38420. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38421. /**
  38422. * Sets matrix on a uniform variable.
  38423. * @param uniformName Name of the variable.
  38424. * @param matrix matrix to be set.
  38425. * @returns this effect.
  38426. */
  38427. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38428. /**
  38429. * 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)
  38430. * @param uniformName Name of the variable.
  38431. * @param matrix matrix to be set.
  38432. * @returns this effect.
  38433. */
  38434. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38435. /**
  38436. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38437. * @param uniformName Name of the variable.
  38438. * @param matrix matrix to be set.
  38439. * @returns this effect.
  38440. */
  38441. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38442. /**
  38443. * Sets a float on a uniform variable.
  38444. * @param uniformName Name of the variable.
  38445. * @param value value to be set.
  38446. * @returns this effect.
  38447. */
  38448. setFloat(uniformName: string, value: number): Effect;
  38449. /**
  38450. * Sets a boolean on a uniform variable.
  38451. * @param uniformName Name of the variable.
  38452. * @param bool value to be set.
  38453. * @returns this effect.
  38454. */
  38455. setBool(uniformName: string, bool: boolean): Effect;
  38456. /**
  38457. * Sets a Vector2 on a uniform variable.
  38458. * @param uniformName Name of the variable.
  38459. * @param vector2 vector2 to be set.
  38460. * @returns this effect.
  38461. */
  38462. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38463. /**
  38464. * Sets a float2 on a uniform variable.
  38465. * @param uniformName Name of the variable.
  38466. * @param x First float in float2.
  38467. * @param y Second float in float2.
  38468. * @returns this effect.
  38469. */
  38470. setFloat2(uniformName: string, x: number, y: number): Effect;
  38471. /**
  38472. * Sets a Vector3 on a uniform variable.
  38473. * @param uniformName Name of the variable.
  38474. * @param vector3 Value to be set.
  38475. * @returns this effect.
  38476. */
  38477. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38478. /**
  38479. * Sets a float3 on a uniform variable.
  38480. * @param uniformName Name of the variable.
  38481. * @param x First float in float3.
  38482. * @param y Second float in float3.
  38483. * @param z Third float in float3.
  38484. * @returns this effect.
  38485. */
  38486. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38487. /**
  38488. * Sets a Vector4 on a uniform variable.
  38489. * @param uniformName Name of the variable.
  38490. * @param vector4 Value to be set.
  38491. * @returns this effect.
  38492. */
  38493. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38494. /**
  38495. * Sets a float4 on a uniform variable.
  38496. * @param uniformName Name of the variable.
  38497. * @param x First float in float4.
  38498. * @param y Second float in float4.
  38499. * @param z Third float in float4.
  38500. * @param w Fourth float in float4.
  38501. * @returns this effect.
  38502. */
  38503. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38504. /**
  38505. * Sets a Color3 on a uniform variable.
  38506. * @param uniformName Name of the variable.
  38507. * @param color3 Value to be set.
  38508. * @returns this effect.
  38509. */
  38510. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38511. /**
  38512. * Sets a Color4 on a uniform variable.
  38513. * @param uniformName Name of the variable.
  38514. * @param color3 Value to be set.
  38515. * @param alpha Alpha value to be set.
  38516. * @returns this effect.
  38517. */
  38518. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38519. /**
  38520. * Sets a Color4 on a uniform variable
  38521. * @param uniformName defines the name of the variable
  38522. * @param color4 defines the value to be set
  38523. * @returns this effect.
  38524. */
  38525. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38526. /** Release all associated resources */
  38527. dispose(): void;
  38528. /**
  38529. * This function will add a new shader to the shader store
  38530. * @param name the name of the shader
  38531. * @param pixelShader optional pixel shader content
  38532. * @param vertexShader optional vertex shader content
  38533. */
  38534. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38535. /**
  38536. * Store of each shader (The can be looked up using effect.key)
  38537. */
  38538. static ShadersStore: {
  38539. [key: string]: string;
  38540. };
  38541. /**
  38542. * Store of each included file for a shader (The can be looked up using effect.key)
  38543. */
  38544. static IncludesShadersStore: {
  38545. [key: string]: string;
  38546. };
  38547. /**
  38548. * Resets the cache of effects.
  38549. */
  38550. static ResetCache(): void;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. /**
  38555. * Interface used to describe the capabilities of the engine relatively to the current browser
  38556. */
  38557. export interface EngineCapabilities {
  38558. /** Maximum textures units per fragment shader */
  38559. maxTexturesImageUnits: number;
  38560. /** Maximum texture units per vertex shader */
  38561. maxVertexTextureImageUnits: number;
  38562. /** Maximum textures units in the entire pipeline */
  38563. maxCombinedTexturesImageUnits: number;
  38564. /** Maximum texture size */
  38565. maxTextureSize: number;
  38566. /** Maximum texture samples */
  38567. maxSamples?: number;
  38568. /** Maximum cube texture size */
  38569. maxCubemapTextureSize: number;
  38570. /** Maximum render texture size */
  38571. maxRenderTextureSize: number;
  38572. /** Maximum number of vertex attributes */
  38573. maxVertexAttribs: number;
  38574. /** Maximum number of varyings */
  38575. maxVaryingVectors: number;
  38576. /** Maximum number of uniforms per vertex shader */
  38577. maxVertexUniformVectors: number;
  38578. /** Maximum number of uniforms per fragment shader */
  38579. maxFragmentUniformVectors: number;
  38580. /** Defines if standard derivates (dx/dy) are supported */
  38581. standardDerivatives: boolean;
  38582. /** Defines if s3tc texture compression is supported */
  38583. s3tc?: WEBGL_compressed_texture_s3tc;
  38584. /** Defines if pvrtc texture compression is supported */
  38585. pvrtc: any;
  38586. /** Defines if etc1 texture compression is supported */
  38587. etc1: any;
  38588. /** Defines if etc2 texture compression is supported */
  38589. etc2: any;
  38590. /** Defines if astc texture compression is supported */
  38591. astc: any;
  38592. /** Defines if bptc texture compression is supported */
  38593. bptc: any;
  38594. /** Defines if float textures are supported */
  38595. textureFloat: boolean;
  38596. /** Defines if vertex array objects are supported */
  38597. vertexArrayObject: boolean;
  38598. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38599. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38600. /** Gets the maximum level of anisotropy supported */
  38601. maxAnisotropy: number;
  38602. /** Defines if instancing is supported */
  38603. instancedArrays: boolean;
  38604. /** Defines if 32 bits indices are supported */
  38605. uintIndices: boolean;
  38606. /** Defines if high precision shaders are supported */
  38607. highPrecisionShaderSupported: boolean;
  38608. /** Defines if depth reading in the fragment shader is supported */
  38609. fragmentDepthSupported: boolean;
  38610. /** Defines if float texture linear filtering is supported*/
  38611. textureFloatLinearFiltering: boolean;
  38612. /** Defines if rendering to float textures is supported */
  38613. textureFloatRender: boolean;
  38614. /** Defines if half float textures are supported*/
  38615. textureHalfFloat: boolean;
  38616. /** Defines if half float texture linear filtering is supported*/
  38617. textureHalfFloatLinearFiltering: boolean;
  38618. /** Defines if rendering to half float textures is supported */
  38619. textureHalfFloatRender: boolean;
  38620. /** Defines if textureLOD shader command is supported */
  38621. textureLOD: boolean;
  38622. /** Defines if draw buffers extension is supported */
  38623. drawBuffersExtension: boolean;
  38624. /** Defines if depth textures are supported */
  38625. depthTextureExtension: boolean;
  38626. /** Defines if float color buffer are supported */
  38627. colorBufferFloat: boolean;
  38628. /** Gets disjoint timer query extension (null if not supported) */
  38629. timerQuery?: EXT_disjoint_timer_query;
  38630. /** Defines if timestamp can be used with timer query */
  38631. canUseTimestampForTimerQuery: boolean;
  38632. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38633. multiview?: any;
  38634. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38635. oculusMultiview?: any;
  38636. /** Function used to let the system compiles shaders in background */
  38637. parallelShaderCompile?: {
  38638. COMPLETION_STATUS_KHR: number;
  38639. };
  38640. /** Max number of texture samples for MSAA */
  38641. maxMSAASamples: number;
  38642. /** Defines if the blend min max extension is supported */
  38643. blendMinMax: boolean;
  38644. }
  38645. }
  38646. declare module BABYLON {
  38647. /**
  38648. * @hidden
  38649. **/
  38650. export class DepthCullingState {
  38651. private _isDepthTestDirty;
  38652. private _isDepthMaskDirty;
  38653. private _isDepthFuncDirty;
  38654. private _isCullFaceDirty;
  38655. private _isCullDirty;
  38656. private _isZOffsetDirty;
  38657. private _isFrontFaceDirty;
  38658. private _depthTest;
  38659. private _depthMask;
  38660. private _depthFunc;
  38661. private _cull;
  38662. private _cullFace;
  38663. private _zOffset;
  38664. private _frontFace;
  38665. /**
  38666. * Initializes the state.
  38667. */
  38668. constructor();
  38669. get isDirty(): boolean;
  38670. get zOffset(): number;
  38671. set zOffset(value: number);
  38672. get cullFace(): Nullable<number>;
  38673. set cullFace(value: Nullable<number>);
  38674. get cull(): Nullable<boolean>;
  38675. set cull(value: Nullable<boolean>);
  38676. get depthFunc(): Nullable<number>;
  38677. set depthFunc(value: Nullable<number>);
  38678. get depthMask(): boolean;
  38679. set depthMask(value: boolean);
  38680. get depthTest(): boolean;
  38681. set depthTest(value: boolean);
  38682. get frontFace(): Nullable<number>;
  38683. set frontFace(value: Nullable<number>);
  38684. reset(): void;
  38685. apply(gl: WebGLRenderingContext): void;
  38686. }
  38687. }
  38688. declare module BABYLON {
  38689. /**
  38690. * @hidden
  38691. **/
  38692. export class StencilState {
  38693. /** 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 */
  38694. static readonly ALWAYS: number;
  38695. /** Passed to stencilOperation to specify that stencil value must be kept */
  38696. static readonly KEEP: number;
  38697. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38698. static readonly REPLACE: number;
  38699. private _isStencilTestDirty;
  38700. private _isStencilMaskDirty;
  38701. private _isStencilFuncDirty;
  38702. private _isStencilOpDirty;
  38703. private _stencilTest;
  38704. private _stencilMask;
  38705. private _stencilFunc;
  38706. private _stencilFuncRef;
  38707. private _stencilFuncMask;
  38708. private _stencilOpStencilFail;
  38709. private _stencilOpDepthFail;
  38710. private _stencilOpStencilDepthPass;
  38711. get isDirty(): boolean;
  38712. get stencilFunc(): number;
  38713. set stencilFunc(value: number);
  38714. get stencilFuncRef(): number;
  38715. set stencilFuncRef(value: number);
  38716. get stencilFuncMask(): number;
  38717. set stencilFuncMask(value: number);
  38718. get stencilOpStencilFail(): number;
  38719. set stencilOpStencilFail(value: number);
  38720. get stencilOpDepthFail(): number;
  38721. set stencilOpDepthFail(value: number);
  38722. get stencilOpStencilDepthPass(): number;
  38723. set stencilOpStencilDepthPass(value: number);
  38724. get stencilMask(): number;
  38725. set stencilMask(value: number);
  38726. get stencilTest(): boolean;
  38727. set stencilTest(value: boolean);
  38728. constructor();
  38729. reset(): void;
  38730. apply(gl: WebGLRenderingContext): void;
  38731. }
  38732. }
  38733. declare module BABYLON {
  38734. /**
  38735. * @hidden
  38736. **/
  38737. export class AlphaState {
  38738. private _isAlphaBlendDirty;
  38739. private _isBlendFunctionParametersDirty;
  38740. private _isBlendEquationParametersDirty;
  38741. private _isBlendConstantsDirty;
  38742. private _alphaBlend;
  38743. private _blendFunctionParameters;
  38744. private _blendEquationParameters;
  38745. private _blendConstants;
  38746. /**
  38747. * Initializes the state.
  38748. */
  38749. constructor();
  38750. get isDirty(): boolean;
  38751. get alphaBlend(): boolean;
  38752. set alphaBlend(value: boolean);
  38753. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38754. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38755. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38756. reset(): void;
  38757. apply(gl: WebGLRenderingContext): void;
  38758. }
  38759. }
  38760. declare module BABYLON {
  38761. /** @hidden */
  38762. export class WebGLShaderProcessor implements IShaderProcessor {
  38763. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /** @hidden */
  38768. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38769. attributeProcessor(attribute: string): string;
  38770. varyingProcessor(varying: string, isFragment: boolean): string;
  38771. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38772. }
  38773. }
  38774. declare module BABYLON {
  38775. /**
  38776. * Interface for attribute information associated with buffer instanciation
  38777. */
  38778. export interface InstancingAttributeInfo {
  38779. /**
  38780. * Name of the GLSL attribute
  38781. * if attribute index is not specified, this is used to retrieve the index from the effect
  38782. */
  38783. attributeName: string;
  38784. /**
  38785. * Index/offset of the attribute in the vertex shader
  38786. * if not specified, this will be computes from the name.
  38787. */
  38788. index?: number;
  38789. /**
  38790. * size of the attribute, 1, 2, 3 or 4
  38791. */
  38792. attributeSize: number;
  38793. /**
  38794. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38795. */
  38796. offset: number;
  38797. /**
  38798. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38799. * default to 1
  38800. */
  38801. divisor?: number;
  38802. /**
  38803. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38804. * default is FLOAT
  38805. */
  38806. attributeType?: number;
  38807. /**
  38808. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38809. */
  38810. normalized?: boolean;
  38811. }
  38812. }
  38813. declare module BABYLON {
  38814. interface ThinEngine {
  38815. /**
  38816. * Update a video texture
  38817. * @param texture defines the texture to update
  38818. * @param video defines the video element to use
  38819. * @param invertY defines if data must be stored with Y axis inverted
  38820. */
  38821. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38822. }
  38823. }
  38824. declare module BABYLON {
  38825. interface ThinEngine {
  38826. /**
  38827. * Creates a dynamic texture
  38828. * @param width defines the width of the texture
  38829. * @param height defines the height of the texture
  38830. * @param generateMipMaps defines if the engine should generate the mip levels
  38831. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38832. * @returns the dynamic texture inside an InternalTexture
  38833. */
  38834. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38835. /**
  38836. * Update the content of a dynamic texture
  38837. * @param texture defines the texture to update
  38838. * @param source defines the source containing the data
  38839. * @param invertY defines if data must be stored with Y axis inverted
  38840. * @param premulAlpha defines if alpha is stored as premultiplied
  38841. * @param format defines the format of the data
  38842. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38843. */
  38844. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38845. }
  38846. }
  38847. declare module BABYLON {
  38848. /**
  38849. * Settings for finer control over video usage
  38850. */
  38851. export interface VideoTextureSettings {
  38852. /**
  38853. * Applies `autoplay` to video, if specified
  38854. */
  38855. autoPlay?: boolean;
  38856. /**
  38857. * Applies `muted` to video, if specified
  38858. */
  38859. muted?: boolean;
  38860. /**
  38861. * Applies `loop` to video, if specified
  38862. */
  38863. loop?: boolean;
  38864. /**
  38865. * Automatically updates internal texture from video at every frame in the render loop
  38866. */
  38867. autoUpdateTexture: boolean;
  38868. /**
  38869. * Image src displayed during the video loading or until the user interacts with the video.
  38870. */
  38871. poster?: string;
  38872. }
  38873. /**
  38874. * If you want to display a video in your scene, this is the special texture for that.
  38875. * This special texture works similar to other textures, with the exception of a few parameters.
  38876. * @see https://doc.babylonjs.com/how_to/video_texture
  38877. */
  38878. export class VideoTexture extends Texture {
  38879. /**
  38880. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38881. */
  38882. readonly autoUpdateTexture: boolean;
  38883. /**
  38884. * The video instance used by the texture internally
  38885. */
  38886. readonly video: HTMLVideoElement;
  38887. private _onUserActionRequestedObservable;
  38888. /**
  38889. * Event triggerd when a dom action is required by the user to play the video.
  38890. * This happens due to recent changes in browser policies preventing video to auto start.
  38891. */
  38892. get onUserActionRequestedObservable(): Observable<Texture>;
  38893. private _generateMipMaps;
  38894. private _stillImageCaptured;
  38895. private _displayingPosterTexture;
  38896. private _settings;
  38897. private _createInternalTextureOnEvent;
  38898. private _frameId;
  38899. private _currentSrc;
  38900. /**
  38901. * Creates a video texture.
  38902. * If you want to display a video in your scene, this is the special texture for that.
  38903. * This special texture works similar to other textures, with the exception of a few parameters.
  38904. * @see https://doc.babylonjs.com/how_to/video_texture
  38905. * @param name optional name, will detect from video source, if not defined
  38906. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38907. * @param scene is obviously the current scene.
  38908. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38909. * @param invertY is false by default but can be used to invert video on Y axis
  38910. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38911. * @param settings allows finer control over video usage
  38912. */
  38913. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38914. private _getName;
  38915. private _getVideo;
  38916. private _createInternalTexture;
  38917. private reset;
  38918. /**
  38919. * @hidden Internal method to initiate `update`.
  38920. */
  38921. _rebuild(): void;
  38922. /**
  38923. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38924. */
  38925. update(): void;
  38926. /**
  38927. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38928. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38929. */
  38930. updateTexture(isVisible: boolean): void;
  38931. protected _updateInternalTexture: () => void;
  38932. /**
  38933. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38934. * @param url New url.
  38935. */
  38936. updateURL(url: string): void;
  38937. /**
  38938. * Clones the texture.
  38939. * @returns the cloned texture
  38940. */
  38941. clone(): VideoTexture;
  38942. /**
  38943. * Dispose the texture and release its associated resources.
  38944. */
  38945. dispose(): void;
  38946. /**
  38947. * Creates a video texture straight from a stream.
  38948. * @param scene Define the scene the texture should be created in
  38949. * @param stream Define the stream the texture should be created from
  38950. * @returns The created video texture as a promise
  38951. */
  38952. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38953. /**
  38954. * Creates a video texture straight from your WebCam video feed.
  38955. * @param scene Define the scene the texture should be created in
  38956. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38957. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38958. * @returns The created video texture as a promise
  38959. */
  38960. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38961. minWidth: number;
  38962. maxWidth: number;
  38963. minHeight: number;
  38964. maxHeight: number;
  38965. deviceId: string;
  38966. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38967. /**
  38968. * Creates a video texture straight from your WebCam video feed.
  38969. * @param scene Define the scene the texture should be created in
  38970. * @param onReady Define a callback to triggered once the texture will be ready
  38971. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38972. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38973. */
  38974. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38975. minWidth: number;
  38976. maxWidth: number;
  38977. minHeight: number;
  38978. maxHeight: number;
  38979. deviceId: string;
  38980. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38981. }
  38982. }
  38983. declare module BABYLON {
  38984. /**
  38985. * Defines the interface used by objects working like Scene
  38986. * @hidden
  38987. */
  38988. export interface ISceneLike {
  38989. _addPendingData(data: any): void;
  38990. _removePendingData(data: any): void;
  38991. offlineProvider: IOfflineProvider;
  38992. }
  38993. /**
  38994. * Information about the current host
  38995. */
  38996. export interface HostInformation {
  38997. /**
  38998. * Defines if the current host is a mobile
  38999. */
  39000. isMobile: boolean;
  39001. }
  39002. /** Interface defining initialization parameters for Engine class */
  39003. export interface EngineOptions extends WebGLContextAttributes {
  39004. /**
  39005. * Defines if the engine should no exceed a specified device ratio
  39006. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39007. */
  39008. limitDeviceRatio?: number;
  39009. /**
  39010. * Defines if webvr should be enabled automatically
  39011. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39012. */
  39013. autoEnableWebVR?: boolean;
  39014. /**
  39015. * Defines if webgl2 should be turned off even if supported
  39016. * @see https://doc.babylonjs.com/features/webgl2
  39017. */
  39018. disableWebGL2Support?: boolean;
  39019. /**
  39020. * Defines if webaudio should be initialized as well
  39021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39022. */
  39023. audioEngine?: boolean;
  39024. /**
  39025. * Defines if animations should run using a deterministic lock step
  39026. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39027. */
  39028. deterministicLockstep?: boolean;
  39029. /** Defines the maximum steps to use with deterministic lock step mode */
  39030. lockstepMaxSteps?: number;
  39031. /** Defines the seconds between each deterministic lock step */
  39032. timeStep?: number;
  39033. /**
  39034. * Defines that engine should ignore context lost events
  39035. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39036. */
  39037. doNotHandleContextLost?: boolean;
  39038. /**
  39039. * Defines that engine should ignore modifying touch action attribute and style
  39040. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39041. */
  39042. doNotHandleTouchAction?: boolean;
  39043. /**
  39044. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39045. */
  39046. useHighPrecisionFloats?: boolean;
  39047. /**
  39048. * Make the canvas XR Compatible for XR sessions
  39049. */
  39050. xrCompatible?: boolean;
  39051. /**
  39052. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39053. */
  39054. useHighPrecisionMatrix?: boolean;
  39055. /**
  39056. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39057. */
  39058. failIfMajorPerformanceCaveat?: boolean;
  39059. }
  39060. /**
  39061. * The base engine class (root of all engines)
  39062. */
  39063. export class ThinEngine {
  39064. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39065. static ExceptionList: ({
  39066. key: string;
  39067. capture: string;
  39068. captureConstraint: number;
  39069. targets: string[];
  39070. } | {
  39071. key: string;
  39072. capture: null;
  39073. captureConstraint: null;
  39074. targets: string[];
  39075. })[];
  39076. /** @hidden */
  39077. static _TextureLoaders: IInternalTextureLoader[];
  39078. /**
  39079. * Returns the current npm package of the sdk
  39080. */
  39081. static get NpmPackage(): string;
  39082. /**
  39083. * Returns the current version of the framework
  39084. */
  39085. static get Version(): string;
  39086. /**
  39087. * Returns a string describing the current engine
  39088. */
  39089. get description(): string;
  39090. /**
  39091. * Gets or sets the epsilon value used by collision engine
  39092. */
  39093. static CollisionsEpsilon: number;
  39094. /**
  39095. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39096. */
  39097. static get ShadersRepository(): string;
  39098. static set ShadersRepository(value: string);
  39099. /** @hidden */
  39100. _shaderProcessor: IShaderProcessor;
  39101. /**
  39102. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39103. */
  39104. forcePOTTextures: boolean;
  39105. /**
  39106. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39107. */
  39108. isFullscreen: boolean;
  39109. /**
  39110. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39111. */
  39112. cullBackFaces: boolean;
  39113. /**
  39114. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39115. */
  39116. renderEvenInBackground: boolean;
  39117. /**
  39118. * Gets or sets a boolean indicating that cache can be kept between frames
  39119. */
  39120. preventCacheWipeBetweenFrames: boolean;
  39121. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39122. validateShaderPrograms: boolean;
  39123. /**
  39124. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39125. * This can provide greater z depth for distant objects.
  39126. */
  39127. useReverseDepthBuffer: boolean;
  39128. /**
  39129. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39130. */
  39131. disableUniformBuffers: boolean;
  39132. /** @hidden */
  39133. _uniformBuffers: UniformBuffer[];
  39134. /**
  39135. * Gets a boolean indicating that the engine supports uniform buffers
  39136. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39137. */
  39138. get supportsUniformBuffers(): boolean;
  39139. /** @hidden */
  39140. _gl: WebGLRenderingContext;
  39141. /** @hidden */
  39142. _webGLVersion: number;
  39143. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39144. protected _windowIsBackground: boolean;
  39145. protected _creationOptions: EngineOptions;
  39146. protected _highPrecisionShadersAllowed: boolean;
  39147. /** @hidden */
  39148. get _shouldUseHighPrecisionShader(): boolean;
  39149. /**
  39150. * Gets a boolean indicating that only power of 2 textures are supported
  39151. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39152. */
  39153. get needPOTTextures(): boolean;
  39154. /** @hidden */
  39155. _badOS: boolean;
  39156. /** @hidden */
  39157. _badDesktopOS: boolean;
  39158. private _hardwareScalingLevel;
  39159. /** @hidden */
  39160. _caps: EngineCapabilities;
  39161. private _isStencilEnable;
  39162. private _glVersion;
  39163. private _glRenderer;
  39164. private _glVendor;
  39165. /** @hidden */
  39166. _videoTextureSupported: boolean;
  39167. protected _renderingQueueLaunched: boolean;
  39168. protected _activeRenderLoops: (() => void)[];
  39169. /**
  39170. * Observable signaled when a context lost event is raised
  39171. */
  39172. onContextLostObservable: Observable<ThinEngine>;
  39173. /**
  39174. * Observable signaled when a context restored event is raised
  39175. */
  39176. onContextRestoredObservable: Observable<ThinEngine>;
  39177. private _onContextLost;
  39178. private _onContextRestored;
  39179. protected _contextWasLost: boolean;
  39180. /** @hidden */
  39181. _doNotHandleContextLost: boolean;
  39182. /**
  39183. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39184. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39185. */
  39186. get doNotHandleContextLost(): boolean;
  39187. set doNotHandleContextLost(value: boolean);
  39188. /**
  39189. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39190. */
  39191. disableVertexArrayObjects: boolean;
  39192. /** @hidden */
  39193. protected _colorWrite: boolean;
  39194. /** @hidden */
  39195. protected _colorWriteChanged: boolean;
  39196. /** @hidden */
  39197. protected _depthCullingState: DepthCullingState;
  39198. /** @hidden */
  39199. protected _stencilState: StencilState;
  39200. /** @hidden */
  39201. _alphaState: AlphaState;
  39202. /** @hidden */
  39203. _alphaMode: number;
  39204. /** @hidden */
  39205. _alphaEquation: number;
  39206. /** @hidden */
  39207. _internalTexturesCache: InternalTexture[];
  39208. /** @hidden */
  39209. protected _activeChannel: number;
  39210. private _currentTextureChannel;
  39211. /** @hidden */
  39212. protected _boundTexturesCache: {
  39213. [key: string]: Nullable<InternalTexture>;
  39214. };
  39215. /** @hidden */
  39216. protected _currentEffect: Nullable<Effect>;
  39217. /** @hidden */
  39218. protected _currentProgram: Nullable<WebGLProgram>;
  39219. private _compiledEffects;
  39220. private _vertexAttribArraysEnabled;
  39221. /** @hidden */
  39222. protected _cachedViewport: Nullable<IViewportLike>;
  39223. private _cachedVertexArrayObject;
  39224. /** @hidden */
  39225. protected _cachedVertexBuffers: any;
  39226. /** @hidden */
  39227. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39228. /** @hidden */
  39229. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39230. /** @hidden */
  39231. _currentRenderTarget: Nullable<InternalTexture>;
  39232. private _uintIndicesCurrentlySet;
  39233. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39234. /** @hidden */
  39235. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39236. /** @hidden */
  39237. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39238. private _currentBufferPointers;
  39239. private _currentInstanceLocations;
  39240. private _currentInstanceBuffers;
  39241. private _textureUnits;
  39242. /** @hidden */
  39243. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39244. /** @hidden */
  39245. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39246. /** @hidden */
  39247. _boundRenderFunction: any;
  39248. private _vaoRecordInProgress;
  39249. private _mustWipeVertexAttributes;
  39250. private _emptyTexture;
  39251. private _emptyCubeTexture;
  39252. private _emptyTexture3D;
  39253. private _emptyTexture2DArray;
  39254. /** @hidden */
  39255. _frameHandler: number;
  39256. private _nextFreeTextureSlots;
  39257. private _maxSimultaneousTextures;
  39258. private _activeRequests;
  39259. /** @hidden */
  39260. _transformTextureUrl: Nullable<(url: string) => string>;
  39261. /**
  39262. * Gets information about the current host
  39263. */
  39264. hostInformation: HostInformation;
  39265. protected get _supportsHardwareTextureRescaling(): boolean;
  39266. private _framebufferDimensionsObject;
  39267. /**
  39268. * sets the object from which width and height will be taken from when getting render width and height
  39269. * Will fallback to the gl object
  39270. * @param dimensions the framebuffer width and height that will be used.
  39271. */
  39272. set framebufferDimensionsObject(dimensions: Nullable<{
  39273. framebufferWidth: number;
  39274. framebufferHeight: number;
  39275. }>);
  39276. /**
  39277. * Gets the current viewport
  39278. */
  39279. get currentViewport(): Nullable<IViewportLike>;
  39280. /**
  39281. * Gets the default empty texture
  39282. */
  39283. get emptyTexture(): InternalTexture;
  39284. /**
  39285. * Gets the default empty 3D texture
  39286. */
  39287. get emptyTexture3D(): InternalTexture;
  39288. /**
  39289. * Gets the default empty 2D array texture
  39290. */
  39291. get emptyTexture2DArray(): InternalTexture;
  39292. /**
  39293. * Gets the default empty cube texture
  39294. */
  39295. get emptyCubeTexture(): InternalTexture;
  39296. /**
  39297. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39298. */
  39299. readonly premultipliedAlpha: boolean;
  39300. /**
  39301. * Observable event triggered before each texture is initialized
  39302. */
  39303. onBeforeTextureInitObservable: Observable<Texture>;
  39304. /**
  39305. * Creates a new engine
  39306. * @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
  39307. * @param antialias defines enable antialiasing (default: false)
  39308. * @param options defines further options to be sent to the getContext() function
  39309. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39310. */
  39311. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39312. private _rebuildInternalTextures;
  39313. private _rebuildEffects;
  39314. /**
  39315. * Gets a boolean indicating if all created effects are ready
  39316. * @returns true if all effects are ready
  39317. */
  39318. areAllEffectsReady(): boolean;
  39319. protected _rebuildBuffers(): void;
  39320. protected _initGLContext(): void;
  39321. /**
  39322. * Gets version of the current webGL context
  39323. */
  39324. get webGLVersion(): number;
  39325. /**
  39326. * Gets a string identifying the name of the class
  39327. * @returns "Engine" string
  39328. */
  39329. getClassName(): string;
  39330. /**
  39331. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39332. */
  39333. get isStencilEnable(): boolean;
  39334. /** @hidden */
  39335. _prepareWorkingCanvas(): void;
  39336. /**
  39337. * Reset the texture cache to empty state
  39338. */
  39339. resetTextureCache(): void;
  39340. /**
  39341. * Gets an object containing information about the current webGL context
  39342. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39343. */
  39344. getGlInfo(): {
  39345. vendor: string;
  39346. renderer: string;
  39347. version: string;
  39348. };
  39349. /**
  39350. * Defines the hardware scaling level.
  39351. * By default the hardware scaling level is computed from the window device ratio.
  39352. * 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.
  39353. * @param level defines the level to use
  39354. */
  39355. setHardwareScalingLevel(level: number): void;
  39356. /**
  39357. * Gets the current hardware scaling level.
  39358. * By default the hardware scaling level is computed from the window device ratio.
  39359. * 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.
  39360. * @returns a number indicating the current hardware scaling level
  39361. */
  39362. getHardwareScalingLevel(): number;
  39363. /**
  39364. * Gets the list of loaded textures
  39365. * @returns an array containing all loaded textures
  39366. */
  39367. getLoadedTexturesCache(): InternalTexture[];
  39368. /**
  39369. * Gets the object containing all engine capabilities
  39370. * @returns the EngineCapabilities object
  39371. */
  39372. getCaps(): EngineCapabilities;
  39373. /**
  39374. * stop executing a render loop function and remove it from the execution array
  39375. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39376. */
  39377. stopRenderLoop(renderFunction?: () => void): void;
  39378. /** @hidden */
  39379. _renderLoop(): void;
  39380. /**
  39381. * Gets the HTML canvas attached with the current webGL context
  39382. * @returns a HTML canvas
  39383. */
  39384. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39385. /**
  39386. * Gets host window
  39387. * @returns the host window object
  39388. */
  39389. getHostWindow(): Nullable<Window>;
  39390. /**
  39391. * Gets the current render width
  39392. * @param useScreen defines if screen size must be used (or the current render target if any)
  39393. * @returns a number defining the current render width
  39394. */
  39395. getRenderWidth(useScreen?: boolean): number;
  39396. /**
  39397. * Gets the current render height
  39398. * @param useScreen defines if screen size must be used (or the current render target if any)
  39399. * @returns a number defining the current render height
  39400. */
  39401. getRenderHeight(useScreen?: boolean): number;
  39402. /**
  39403. * Can be used to override the current requestAnimationFrame requester.
  39404. * @hidden
  39405. */
  39406. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39407. /**
  39408. * Register and execute a render loop. The engine can have more than one render function
  39409. * @param renderFunction defines the function to continuously execute
  39410. */
  39411. runRenderLoop(renderFunction: () => void): void;
  39412. /**
  39413. * Clear the current render buffer or the current render target (if any is set up)
  39414. * @param color defines the color to use
  39415. * @param backBuffer defines if the back buffer must be cleared
  39416. * @param depth defines if the depth buffer must be cleared
  39417. * @param stencil defines if the stencil buffer must be cleared
  39418. */
  39419. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39420. private _viewportCached;
  39421. /** @hidden */
  39422. _viewport(x: number, y: number, width: number, height: number): void;
  39423. /**
  39424. * Set the WebGL's viewport
  39425. * @param viewport defines the viewport element to be used
  39426. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39427. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39428. */
  39429. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39430. /**
  39431. * Begin a new frame
  39432. */
  39433. beginFrame(): void;
  39434. /**
  39435. * Enf the current frame
  39436. */
  39437. endFrame(): void;
  39438. /**
  39439. * Resize the view according to the canvas' size
  39440. */
  39441. resize(): void;
  39442. /**
  39443. * Force a specific size of the canvas
  39444. * @param width defines the new canvas' width
  39445. * @param height defines the new canvas' height
  39446. * @returns true if the size was changed
  39447. */
  39448. setSize(width: number, height: number): boolean;
  39449. /**
  39450. * Binds the frame buffer to the specified texture.
  39451. * @param texture The texture to render to or null for the default canvas
  39452. * @param faceIndex The face of the texture to render to in case of cube texture
  39453. * @param requiredWidth The width of the target to render to
  39454. * @param requiredHeight The height of the target to render to
  39455. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39456. * @param lodLevel defines the lod level to bind to the frame buffer
  39457. * @param layer defines the 2d array index to bind to frame buffer to
  39458. */
  39459. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39460. /** @hidden */
  39461. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39462. /**
  39463. * Unbind the current render target texture from the webGL context
  39464. * @param texture defines the render target texture to unbind
  39465. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39466. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39467. */
  39468. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39469. /**
  39470. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39471. */
  39472. flushFramebuffer(): void;
  39473. /**
  39474. * Unbind the current render target and bind the default framebuffer
  39475. */
  39476. restoreDefaultFramebuffer(): void;
  39477. /** @hidden */
  39478. protected _resetVertexBufferBinding(): void;
  39479. /**
  39480. * Creates a vertex buffer
  39481. * @param data the data for the vertex buffer
  39482. * @returns the new WebGL static buffer
  39483. */
  39484. createVertexBuffer(data: DataArray): DataBuffer;
  39485. private _createVertexBuffer;
  39486. /**
  39487. * Creates a dynamic vertex buffer
  39488. * @param data the data for the dynamic vertex buffer
  39489. * @returns the new WebGL dynamic buffer
  39490. */
  39491. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39492. protected _resetIndexBufferBinding(): void;
  39493. /**
  39494. * Creates a new index buffer
  39495. * @param indices defines the content of the index buffer
  39496. * @param updatable defines if the index buffer must be updatable
  39497. * @returns a new webGL buffer
  39498. */
  39499. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39500. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39501. /**
  39502. * Bind a webGL buffer to the webGL context
  39503. * @param buffer defines the buffer to bind
  39504. */
  39505. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39506. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39507. private bindBuffer;
  39508. /**
  39509. * update the bound buffer with the given data
  39510. * @param data defines the data to update
  39511. */
  39512. updateArrayBuffer(data: Float32Array): void;
  39513. private _vertexAttribPointer;
  39514. /** @hidden */
  39515. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39516. private _bindVertexBuffersAttributes;
  39517. /**
  39518. * Records a vertex array object
  39519. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39520. * @param vertexBuffers defines the list of vertex buffers to store
  39521. * @param indexBuffer defines the index buffer to store
  39522. * @param effect defines the effect to store
  39523. * @returns the new vertex array object
  39524. */
  39525. recordVertexArrayObject(vertexBuffers: {
  39526. [key: string]: VertexBuffer;
  39527. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39528. /**
  39529. * Bind a specific vertex array object
  39530. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39531. * @param vertexArrayObject defines the vertex array object to bind
  39532. * @param indexBuffer defines the index buffer to bind
  39533. */
  39534. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39535. /**
  39536. * Bind webGl buffers directly to the webGL context
  39537. * @param vertexBuffer defines the vertex buffer to bind
  39538. * @param indexBuffer defines the index buffer to bind
  39539. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39540. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39541. * @param effect defines the effect associated with the vertex buffer
  39542. */
  39543. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39544. private _unbindVertexArrayObject;
  39545. /**
  39546. * Bind a list of vertex buffers to the webGL context
  39547. * @param vertexBuffers defines the list of vertex buffers to bind
  39548. * @param indexBuffer defines the index buffer to bind
  39549. * @param effect defines the effect associated with the vertex buffers
  39550. */
  39551. bindBuffers(vertexBuffers: {
  39552. [key: string]: Nullable<VertexBuffer>;
  39553. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39554. /**
  39555. * Unbind all instance attributes
  39556. */
  39557. unbindInstanceAttributes(): void;
  39558. /**
  39559. * Release and free the memory of a vertex array object
  39560. * @param vao defines the vertex array object to delete
  39561. */
  39562. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39563. /** @hidden */
  39564. _releaseBuffer(buffer: DataBuffer): boolean;
  39565. protected _deleteBuffer(buffer: DataBuffer): void;
  39566. /**
  39567. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39568. * @param instancesBuffer defines the webGL buffer to update and bind
  39569. * @param data defines the data to store in the buffer
  39570. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39571. */
  39572. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39573. /**
  39574. * Bind the content of a webGL buffer used with instantiation
  39575. * @param instancesBuffer defines the webGL buffer to bind
  39576. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39577. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39578. */
  39579. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39580. /**
  39581. * Disable the instance attribute corresponding to the name in parameter
  39582. * @param name defines the name of the attribute to disable
  39583. */
  39584. disableInstanceAttributeByName(name: string): void;
  39585. /**
  39586. * Disable the instance attribute corresponding to the location in parameter
  39587. * @param attributeLocation defines the attribute location of the attribute to disable
  39588. */
  39589. disableInstanceAttribute(attributeLocation: number): void;
  39590. /**
  39591. * Disable the attribute corresponding to the location in parameter
  39592. * @param attributeLocation defines the attribute location of the attribute to disable
  39593. */
  39594. disableAttributeByIndex(attributeLocation: number): void;
  39595. /**
  39596. * Send a draw order
  39597. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39598. * @param indexStart defines the starting index
  39599. * @param indexCount defines the number of index to draw
  39600. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39601. */
  39602. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39603. /**
  39604. * Draw a list of points
  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. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39610. /**
  39611. * Draw a list of unindexed primitives
  39612. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39613. * @param verticesStart defines the index of first vertex to draw
  39614. * @param verticesCount defines the count of vertices to draw
  39615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39616. */
  39617. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39618. /**
  39619. * Draw a list of indexed primitives
  39620. * @param fillMode defines the primitive to use
  39621. * @param indexStart defines the starting index
  39622. * @param indexCount defines the number of index to draw
  39623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39624. */
  39625. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39626. /**
  39627. * Draw a list of unindexed primitives
  39628. * @param fillMode defines the primitive to use
  39629. * @param verticesStart defines the index of first vertex to draw
  39630. * @param verticesCount defines the count of vertices to draw
  39631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39632. */
  39633. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39634. private _drawMode;
  39635. /** @hidden */
  39636. protected _reportDrawCall(): void;
  39637. /** @hidden */
  39638. _releaseEffect(effect: Effect): void;
  39639. /** @hidden */
  39640. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39641. /**
  39642. * Create a new effect (used to store vertex/fragment shaders)
  39643. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39644. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39645. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39646. * @param samplers defines an array of string used to represent textures
  39647. * @param defines defines the string containing the defines to use to compile the shaders
  39648. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39649. * @param onCompiled defines a function to call when the effect creation is successful
  39650. * @param onError defines a function to call when the effect creation has failed
  39651. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39652. * @returns the new Effect
  39653. */
  39654. 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;
  39655. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39656. private _compileShader;
  39657. private _compileRawShader;
  39658. /** @hidden */
  39659. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39660. /**
  39661. * Directly creates a webGL program
  39662. * @param pipelineContext defines the pipeline context to attach to
  39663. * @param vertexCode defines the vertex shader code to use
  39664. * @param fragmentCode defines the fragment shader code to use
  39665. * @param context defines the webGL context to use (if not set, the current one will be used)
  39666. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39667. * @returns the new webGL program
  39668. */
  39669. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39670. /**
  39671. * Creates a webGL program
  39672. * @param pipelineContext defines the pipeline context to attach to
  39673. * @param vertexCode defines the vertex shader code to use
  39674. * @param fragmentCode defines the fragment shader code to use
  39675. * @param defines defines the string containing the defines to use to compile the shaders
  39676. * @param context defines the webGL context to use (if not set, the current one will be used)
  39677. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39678. * @returns the new webGL program
  39679. */
  39680. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39681. /**
  39682. * Creates a new pipeline context
  39683. * @returns the new pipeline
  39684. */
  39685. createPipelineContext(): IPipelineContext;
  39686. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39687. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39688. /** @hidden */
  39689. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39690. /** @hidden */
  39691. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39692. /** @hidden */
  39693. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39694. /**
  39695. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39696. * @param pipelineContext defines the pipeline context to use
  39697. * @param uniformsNames defines the list of uniform names
  39698. * @returns an array of webGL uniform locations
  39699. */
  39700. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39701. /**
  39702. * Gets the lsit of active attributes for a given webGL program
  39703. * @param pipelineContext defines the pipeline context to use
  39704. * @param attributesNames defines the list of attribute names to get
  39705. * @returns an array of indices indicating the offset of each attribute
  39706. */
  39707. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39708. /**
  39709. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39710. * @param effect defines the effect to activate
  39711. */
  39712. enableEffect(effect: Nullable<Effect>): void;
  39713. /**
  39714. * Set the value of an uniform to a number (int)
  39715. * @param uniform defines the webGL uniform location where to store the value
  39716. * @param value defines the int number to store
  39717. * @returns true if the value was set
  39718. */
  39719. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39720. /**
  39721. * Set the value of an uniform to an array of int32
  39722. * @param uniform defines the webGL uniform location where to store the value
  39723. * @param array defines the array of int32 to store
  39724. * @returns true if the value was set
  39725. */
  39726. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39727. /**
  39728. * Set the value of an uniform to an array of int32 (stored as vec2)
  39729. * @param uniform defines the webGL uniform location where to store the value
  39730. * @param array defines the array of int32 to store
  39731. * @returns true if the value was set
  39732. */
  39733. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39734. /**
  39735. * Set the value of an uniform to an array of int32 (stored as vec3)
  39736. * @param uniform defines the webGL uniform location where to store the value
  39737. * @param array defines the array of int32 to store
  39738. * @returns true if the value was set
  39739. */
  39740. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39741. /**
  39742. * Set the value of an uniform to an array of int32 (stored as vec4)
  39743. * @param uniform defines the webGL uniform location where to store the value
  39744. * @param array defines the array of int32 to store
  39745. * @returns true if the value was set
  39746. */
  39747. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39748. /**
  39749. * Set the value of an uniform to an array of number
  39750. * @param uniform defines the webGL uniform location where to store the value
  39751. * @param array defines the array of number to store
  39752. * @returns true if the value was set
  39753. */
  39754. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39755. /**
  39756. * Set the value of an uniform to an array of number (stored as vec2)
  39757. * @param uniform defines the webGL uniform location where to store the value
  39758. * @param array defines the array of number to store
  39759. * @returns true if the value was set
  39760. */
  39761. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39762. /**
  39763. * Set the value of an uniform to an array of number (stored as vec3)
  39764. * @param uniform defines the webGL uniform location where to store the value
  39765. * @param array defines the array of number to store
  39766. * @returns true if the value was set
  39767. */
  39768. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39769. /**
  39770. * Set the value of an uniform to an array of number (stored as vec4)
  39771. * @param uniform defines the webGL uniform location where to store the value
  39772. * @param array defines the array of number to store
  39773. * @returns true if the value was set
  39774. */
  39775. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39776. /**
  39777. * Set the value of an uniform to an array of float32 (stored as matrices)
  39778. * @param uniform defines the webGL uniform location where to store the value
  39779. * @param matrices defines the array of float32 to store
  39780. * @returns true if the value was set
  39781. */
  39782. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39783. /**
  39784. * Set the value of an uniform to a matrix (3x3)
  39785. * @param uniform defines the webGL uniform location where to store the value
  39786. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39787. * @returns true if the value was set
  39788. */
  39789. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39790. /**
  39791. * Set the value of an uniform to a matrix (2x2)
  39792. * @param uniform defines the webGL uniform location where to store the value
  39793. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39794. * @returns true if the value was set
  39795. */
  39796. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39797. /**
  39798. * Set the value of an uniform to a number (float)
  39799. * @param uniform defines the webGL uniform location where to store the value
  39800. * @param value defines the float number to store
  39801. * @returns true if the value was transfered
  39802. */
  39803. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39804. /**
  39805. * Set the value of an uniform to a vec2
  39806. * @param uniform defines the webGL uniform location where to store the value
  39807. * @param x defines the 1st component of the value
  39808. * @param y defines the 2nd component of the value
  39809. * @returns true if the value was set
  39810. */
  39811. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39812. /**
  39813. * Set the value of an uniform to a vec3
  39814. * @param uniform defines the webGL uniform location where to store the value
  39815. * @param x defines the 1st component of the value
  39816. * @param y defines the 2nd component of the value
  39817. * @param z defines the 3rd component of the value
  39818. * @returns true if the value was set
  39819. */
  39820. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39821. /**
  39822. * Set the value of an uniform to a vec4
  39823. * @param uniform defines the webGL uniform location where to store the value
  39824. * @param x defines the 1st component of the value
  39825. * @param y defines the 2nd component of the value
  39826. * @param z defines the 3rd component of the value
  39827. * @param w defines the 4th component of the value
  39828. * @returns true if the value was set
  39829. */
  39830. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39831. /**
  39832. * Apply all cached states (depth, culling, stencil and alpha)
  39833. */
  39834. applyStates(): void;
  39835. /**
  39836. * Enable or disable color writing
  39837. * @param enable defines the state to set
  39838. */
  39839. setColorWrite(enable: boolean): void;
  39840. /**
  39841. * Gets a boolean indicating if color writing is enabled
  39842. * @returns the current color writing state
  39843. */
  39844. getColorWrite(): boolean;
  39845. /**
  39846. * Gets the depth culling state manager
  39847. */
  39848. get depthCullingState(): DepthCullingState;
  39849. /**
  39850. * Gets the alpha state manager
  39851. */
  39852. get alphaState(): AlphaState;
  39853. /**
  39854. * Gets the stencil state manager
  39855. */
  39856. get stencilState(): StencilState;
  39857. /**
  39858. * Clears the list of texture accessible through engine.
  39859. * This can help preventing texture load conflict due to name collision.
  39860. */
  39861. clearInternalTexturesCache(): void;
  39862. /**
  39863. * Force the entire cache to be cleared
  39864. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39865. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39866. */
  39867. wipeCaches(bruteForce?: boolean): void;
  39868. /** @hidden */
  39869. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39870. min: number;
  39871. mag: number;
  39872. };
  39873. /** @hidden */
  39874. _createTexture(): WebGLTexture;
  39875. /**
  39876. * Usually called from Texture.ts.
  39877. * Passed information to create a WebGLTexture
  39878. * @param url defines a value which contains one of the following:
  39879. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39880. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39881. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39882. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39883. * @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)
  39884. * @param scene needed for loading to the correct scene
  39885. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39886. * @param onLoad optional callback to be called upon successful completion
  39887. * @param onError optional callback to be called upon failure
  39888. * @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
  39889. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39890. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39891. * @param forcedExtension defines the extension to use to pick the right loader
  39892. * @param mimeType defines an optional mime type
  39893. * @param loaderOptions options to be passed to the loader
  39894. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39895. */
  39896. 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;
  39897. /**
  39898. * Loads an image as an HTMLImageElement.
  39899. * @param input url string, ArrayBuffer, or Blob to load
  39900. * @param onLoad callback called when the image successfully loads
  39901. * @param onError callback called when the image fails to load
  39902. * @param offlineProvider offline provider for caching
  39903. * @param mimeType optional mime type
  39904. * @returns the HTMLImageElement of the loaded image
  39905. * @hidden
  39906. */
  39907. 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>;
  39908. /**
  39909. * @hidden
  39910. */
  39911. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39912. private _unpackFlipYCached;
  39913. /**
  39914. * In case you are sharing the context with other applications, it might
  39915. * be interested to not cache the unpack flip y state to ensure a consistent
  39916. * value would be set.
  39917. */
  39918. enableUnpackFlipYCached: boolean;
  39919. /** @hidden */
  39920. _unpackFlipY(value: boolean): void;
  39921. /** @hidden */
  39922. _getUnpackAlignement(): number;
  39923. private _getTextureTarget;
  39924. /**
  39925. * Update the sampling mode of a given texture
  39926. * @param samplingMode defines the required sampling mode
  39927. * @param texture defines the texture to update
  39928. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39929. */
  39930. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39931. /**
  39932. * Update the sampling mode of a given texture
  39933. * @param texture defines the texture to update
  39934. * @param wrapU defines the texture wrap mode of the u coordinates
  39935. * @param wrapV defines the texture wrap mode of the v coordinates
  39936. * @param wrapR defines the texture wrap mode of the r coordinates
  39937. */
  39938. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39939. /** @hidden */
  39940. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39941. width: number;
  39942. height: number;
  39943. layers?: number;
  39944. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39945. /** @hidden */
  39946. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39947. /** @hidden */
  39948. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39949. /**
  39950. * Update a portion of an internal texture
  39951. * @param texture defines the texture to update
  39952. * @param imageData defines the data to store into the texture
  39953. * @param xOffset defines the x coordinates of the update rectangle
  39954. * @param yOffset defines the y coordinates of the update rectangle
  39955. * @param width defines the width of the update rectangle
  39956. * @param height defines the height of the update rectangle
  39957. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39958. * @param lod defines the lod level to update (0 by default)
  39959. */
  39960. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39961. /** @hidden */
  39962. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39963. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39964. private _prepareWebGLTexture;
  39965. /** @hidden */
  39966. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39967. private _getDepthStencilBuffer;
  39968. /** @hidden */
  39969. _releaseFramebufferObjects(texture: InternalTexture): void;
  39970. /** @hidden */
  39971. _releaseTexture(texture: InternalTexture): void;
  39972. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39973. protected _setProgram(program: WebGLProgram): void;
  39974. protected _boundUniforms: {
  39975. [key: number]: WebGLUniformLocation;
  39976. };
  39977. /**
  39978. * Binds an effect to the webGL context
  39979. * @param effect defines the effect to bind
  39980. */
  39981. bindSamplers(effect: Effect): void;
  39982. private _activateCurrentTexture;
  39983. /** @hidden */
  39984. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39985. /** @hidden */
  39986. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39987. /**
  39988. * Unbind all textures from the webGL context
  39989. */
  39990. unbindAllTextures(): void;
  39991. /**
  39992. * Sets a texture to the according uniform.
  39993. * @param channel The texture channel
  39994. * @param uniform The uniform to set
  39995. * @param texture The texture to apply
  39996. */
  39997. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39998. private _bindSamplerUniformToChannel;
  39999. private _getTextureWrapMode;
  40000. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40001. /**
  40002. * Sets an array of texture to the webGL context
  40003. * @param channel defines the channel where the texture array must be set
  40004. * @param uniform defines the associated uniform location
  40005. * @param textures defines the array of textures to bind
  40006. */
  40007. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  40008. /** @hidden */
  40009. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40010. private _setTextureParameterFloat;
  40011. private _setTextureParameterInteger;
  40012. /**
  40013. * Unbind all vertex attributes from the webGL context
  40014. */
  40015. unbindAllAttributes(): void;
  40016. /**
  40017. * 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
  40018. */
  40019. releaseEffects(): void;
  40020. /**
  40021. * Dispose and release all associated resources
  40022. */
  40023. dispose(): void;
  40024. /**
  40025. * Attach a new callback raised when context lost event is fired
  40026. * @param callback defines the callback to call
  40027. */
  40028. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40029. /**
  40030. * Attach a new callback raised when context restored event is fired
  40031. * @param callback defines the callback to call
  40032. */
  40033. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40034. /**
  40035. * Get the current error code of the webGL context
  40036. * @returns the error code
  40037. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40038. */
  40039. getError(): number;
  40040. private _canRenderToFloatFramebuffer;
  40041. private _canRenderToHalfFloatFramebuffer;
  40042. private _canRenderToFramebuffer;
  40043. /** @hidden */
  40044. _getWebGLTextureType(type: number): number;
  40045. /** @hidden */
  40046. _getInternalFormat(format: number): number;
  40047. /** @hidden */
  40048. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40049. /** @hidden */
  40050. _getRGBAMultiSampleBufferFormat(type: number): number;
  40051. /** @hidden */
  40052. _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;
  40053. /**
  40054. * Loads a file from a url
  40055. * @param url url to load
  40056. * @param onSuccess callback called when the file successfully loads
  40057. * @param onProgress callback called while file is loading (if the server supports this mode)
  40058. * @param offlineProvider defines the offline provider for caching
  40059. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40060. * @param onError callback called when the file fails to load
  40061. * @returns a file request object
  40062. * @hidden
  40063. */
  40064. 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;
  40065. /**
  40066. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40067. * @param x defines the x coordinate of the rectangle where pixels must be read
  40068. * @param y defines the y coordinate of the rectangle where pixels must be read
  40069. * @param width defines the width of the rectangle where pixels must be read
  40070. * @param height defines the height of the rectangle where pixels must be read
  40071. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40072. * @returns a Uint8Array containing RGBA colors
  40073. */
  40074. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40075. private static _IsSupported;
  40076. private static _HasMajorPerformanceCaveat;
  40077. /**
  40078. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40079. */
  40080. static get IsSupported(): boolean;
  40081. /**
  40082. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40083. * @returns true if the engine can be created
  40084. * @ignorenaming
  40085. */
  40086. static isSupported(): boolean;
  40087. /**
  40088. * 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)
  40089. */
  40090. static get HasMajorPerformanceCaveat(): boolean;
  40091. /**
  40092. * Find the next highest power of two.
  40093. * @param x Number to start search from.
  40094. * @return Next highest power of two.
  40095. */
  40096. static CeilingPOT(x: number): number;
  40097. /**
  40098. * Find the next lowest power of two.
  40099. * @param x Number to start search from.
  40100. * @return Next lowest power of two.
  40101. */
  40102. static FloorPOT(x: number): number;
  40103. /**
  40104. * Find the nearest power of two.
  40105. * @param x Number to start search from.
  40106. * @return Next nearest power of two.
  40107. */
  40108. static NearestPOT(x: number): number;
  40109. /**
  40110. * Get the closest exponent of two
  40111. * @param value defines the value to approximate
  40112. * @param max defines the maximum value to return
  40113. * @param mode defines how to define the closest value
  40114. * @returns closest exponent of two of the given value
  40115. */
  40116. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40117. /**
  40118. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40119. * @param func - the function to be called
  40120. * @param requester - the object that will request the next frame. Falls back to window.
  40121. * @returns frame number
  40122. */
  40123. static QueueNewFrame(func: () => void, requester?: any): number;
  40124. /**
  40125. * Gets host document
  40126. * @returns the host document object
  40127. */
  40128. getHostDocument(): Nullable<Document>;
  40129. }
  40130. }
  40131. declare module BABYLON {
  40132. /**
  40133. * Defines the source of the internal texture
  40134. */
  40135. export enum InternalTextureSource {
  40136. /**
  40137. * The source of the texture data is unknown
  40138. */
  40139. Unknown = 0,
  40140. /**
  40141. * Texture data comes from an URL
  40142. */
  40143. Url = 1,
  40144. /**
  40145. * Texture data is only used for temporary storage
  40146. */
  40147. Temp = 2,
  40148. /**
  40149. * Texture data comes from raw data (ArrayBuffer)
  40150. */
  40151. Raw = 3,
  40152. /**
  40153. * Texture content is dynamic (video or dynamic texture)
  40154. */
  40155. Dynamic = 4,
  40156. /**
  40157. * Texture content is generated by rendering to it
  40158. */
  40159. RenderTarget = 5,
  40160. /**
  40161. * Texture content is part of a multi render target process
  40162. */
  40163. MultiRenderTarget = 6,
  40164. /**
  40165. * Texture data comes from a cube data file
  40166. */
  40167. Cube = 7,
  40168. /**
  40169. * Texture data comes from a raw cube data
  40170. */
  40171. CubeRaw = 8,
  40172. /**
  40173. * Texture data come from a prefiltered cube data file
  40174. */
  40175. CubePrefiltered = 9,
  40176. /**
  40177. * Texture content is raw 3D data
  40178. */
  40179. Raw3D = 10,
  40180. /**
  40181. * Texture content is raw 2D array data
  40182. */
  40183. Raw2DArray = 11,
  40184. /**
  40185. * Texture content is a depth texture
  40186. */
  40187. Depth = 12,
  40188. /**
  40189. * Texture data comes from a raw cube data encoded with RGBD
  40190. */
  40191. CubeRawRGBD = 13
  40192. }
  40193. /**
  40194. * Class used to store data associated with WebGL texture data for the engine
  40195. * This class should not be used directly
  40196. */
  40197. export class InternalTexture {
  40198. /** @hidden */
  40199. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40200. /**
  40201. * Defines if the texture is ready
  40202. */
  40203. isReady: boolean;
  40204. /**
  40205. * Defines if the texture is a cube texture
  40206. */
  40207. isCube: boolean;
  40208. /**
  40209. * Defines if the texture contains 3D data
  40210. */
  40211. is3D: boolean;
  40212. /**
  40213. * Defines if the texture contains 2D array data
  40214. */
  40215. is2DArray: boolean;
  40216. /**
  40217. * Defines if the texture contains multiview data
  40218. */
  40219. isMultiview: boolean;
  40220. /**
  40221. * Gets the URL used to load this texture
  40222. */
  40223. url: string;
  40224. /** @hidden */
  40225. _originalUrl: string;
  40226. /**
  40227. * Gets the sampling mode of the texture
  40228. */
  40229. samplingMode: number;
  40230. /**
  40231. * Gets a boolean indicating if the texture needs mipmaps generation
  40232. */
  40233. generateMipMaps: boolean;
  40234. /**
  40235. * Gets the number of samples used by the texture (WebGL2+ only)
  40236. */
  40237. samples: number;
  40238. /**
  40239. * Gets the type of the texture (int, float...)
  40240. */
  40241. type: number;
  40242. /**
  40243. * Gets the format of the texture (RGB, RGBA...)
  40244. */
  40245. format: number;
  40246. /**
  40247. * Observable called when the texture is loaded
  40248. */
  40249. onLoadedObservable: Observable<InternalTexture>;
  40250. /**
  40251. * Gets the width of the texture
  40252. */
  40253. width: number;
  40254. /**
  40255. * Gets the height of the texture
  40256. */
  40257. height: number;
  40258. /**
  40259. * Gets the depth of the texture
  40260. */
  40261. depth: number;
  40262. /**
  40263. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40264. */
  40265. baseWidth: number;
  40266. /**
  40267. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40268. */
  40269. baseHeight: number;
  40270. /**
  40271. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40272. */
  40273. baseDepth: number;
  40274. /**
  40275. * Gets a boolean indicating if the texture is inverted on Y axis
  40276. */
  40277. invertY: boolean;
  40278. /** @hidden */
  40279. _invertVScale: boolean;
  40280. /** @hidden */
  40281. _associatedChannel: number;
  40282. /** @hidden */
  40283. _source: InternalTextureSource;
  40284. /** @hidden */
  40285. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40286. /** @hidden */
  40287. _bufferView: Nullable<ArrayBufferView>;
  40288. /** @hidden */
  40289. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40290. /** @hidden */
  40291. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40292. /** @hidden */
  40293. _size: number;
  40294. /** @hidden */
  40295. _extension: string;
  40296. /** @hidden */
  40297. _files: Nullable<string[]>;
  40298. /** @hidden */
  40299. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40300. /** @hidden */
  40301. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40302. /** @hidden */
  40303. _framebuffer: Nullable<WebGLFramebuffer>;
  40304. /** @hidden */
  40305. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40306. /** @hidden */
  40307. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40308. /** @hidden */
  40309. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40310. /** @hidden */
  40311. _attachments: Nullable<number[]>;
  40312. /** @hidden */
  40313. _textureArray: Nullable<InternalTexture[]>;
  40314. /** @hidden */
  40315. _cachedCoordinatesMode: Nullable<number>;
  40316. /** @hidden */
  40317. _cachedWrapU: Nullable<number>;
  40318. /** @hidden */
  40319. _cachedWrapV: Nullable<number>;
  40320. /** @hidden */
  40321. _cachedWrapR: Nullable<number>;
  40322. /** @hidden */
  40323. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40324. /** @hidden */
  40325. _isDisabled: boolean;
  40326. /** @hidden */
  40327. _compression: Nullable<string>;
  40328. /** @hidden */
  40329. _generateStencilBuffer: boolean;
  40330. /** @hidden */
  40331. _generateDepthBuffer: boolean;
  40332. /** @hidden */
  40333. _comparisonFunction: number;
  40334. /** @hidden */
  40335. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40336. /** @hidden */
  40337. _lodGenerationScale: number;
  40338. /** @hidden */
  40339. _lodGenerationOffset: number;
  40340. /** @hidden */
  40341. _depthStencilTexture: Nullable<InternalTexture>;
  40342. /** @hidden */
  40343. _colorTextureArray: Nullable<WebGLTexture>;
  40344. /** @hidden */
  40345. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40346. /** @hidden */
  40347. _lodTextureHigh: Nullable<BaseTexture>;
  40348. /** @hidden */
  40349. _lodTextureMid: Nullable<BaseTexture>;
  40350. /** @hidden */
  40351. _lodTextureLow: Nullable<BaseTexture>;
  40352. /** @hidden */
  40353. _isRGBD: boolean;
  40354. /** @hidden */
  40355. _linearSpecularLOD: boolean;
  40356. /** @hidden */
  40357. _irradianceTexture: Nullable<BaseTexture>;
  40358. /** @hidden */
  40359. _webGLTexture: Nullable<WebGLTexture>;
  40360. /** @hidden */
  40361. _references: number;
  40362. /** @hidden */
  40363. _gammaSpace: Nullable<boolean>;
  40364. private _engine;
  40365. /**
  40366. * Gets the Engine the texture belongs to.
  40367. * @returns The babylon engine
  40368. */
  40369. getEngine(): ThinEngine;
  40370. /**
  40371. * Gets the data source type of the texture
  40372. */
  40373. get source(): InternalTextureSource;
  40374. /**
  40375. * Creates a new InternalTexture
  40376. * @param engine defines the engine to use
  40377. * @param source defines the type of data that will be used
  40378. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40379. */
  40380. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40381. /**
  40382. * Increments the number of references (ie. the number of Texture that point to it)
  40383. */
  40384. incrementReferences(): void;
  40385. /**
  40386. * Change the size of the texture (not the size of the content)
  40387. * @param width defines the new width
  40388. * @param height defines the new height
  40389. * @param depth defines the new depth (1 by default)
  40390. */
  40391. updateSize(width: int, height: int, depth?: int): void;
  40392. /** @hidden */
  40393. _rebuild(): void;
  40394. /** @hidden */
  40395. _swapAndDie(target: InternalTexture): void;
  40396. /**
  40397. * Dispose the current allocated resources
  40398. */
  40399. dispose(): void;
  40400. }
  40401. }
  40402. declare module BABYLON {
  40403. /**
  40404. * Interface used to present a loading screen while loading a scene
  40405. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40406. */
  40407. export interface ILoadingScreen {
  40408. /**
  40409. * Function called to display the loading screen
  40410. */
  40411. displayLoadingUI: () => void;
  40412. /**
  40413. * Function called to hide the loading screen
  40414. */
  40415. hideLoadingUI: () => void;
  40416. /**
  40417. * Gets or sets the color to use for the background
  40418. */
  40419. loadingUIBackgroundColor: string;
  40420. /**
  40421. * Gets or sets the text to display while loading
  40422. */
  40423. loadingUIText: string;
  40424. }
  40425. /**
  40426. * Class used for the default loading screen
  40427. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40428. */
  40429. export class DefaultLoadingScreen implements ILoadingScreen {
  40430. private _renderingCanvas;
  40431. private _loadingText;
  40432. private _loadingDivBackgroundColor;
  40433. private _loadingDiv;
  40434. private _loadingTextDiv;
  40435. /** Gets or sets the logo url to use for the default loading screen */
  40436. static DefaultLogoUrl: string;
  40437. /** Gets or sets the spinner url to use for the default loading screen */
  40438. static DefaultSpinnerUrl: string;
  40439. /**
  40440. * Creates a new default loading screen
  40441. * @param _renderingCanvas defines the canvas used to render the scene
  40442. * @param _loadingText defines the default text to display
  40443. * @param _loadingDivBackgroundColor defines the default background color
  40444. */
  40445. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40446. /**
  40447. * Function called to display the loading screen
  40448. */
  40449. displayLoadingUI(): void;
  40450. /**
  40451. * Function called to hide the loading screen
  40452. */
  40453. hideLoadingUI(): void;
  40454. /**
  40455. * Gets or sets the text to display while loading
  40456. */
  40457. set loadingUIText(text: string);
  40458. get loadingUIText(): string;
  40459. /**
  40460. * Gets or sets the color to use for the background
  40461. */
  40462. get loadingUIBackgroundColor(): string;
  40463. set loadingUIBackgroundColor(color: string);
  40464. private _resizeLoadingUI;
  40465. }
  40466. }
  40467. declare module BABYLON {
  40468. /**
  40469. * Interface for any object that can request an animation frame
  40470. */
  40471. export interface ICustomAnimationFrameRequester {
  40472. /**
  40473. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40474. */
  40475. renderFunction?: Function;
  40476. /**
  40477. * Called to request the next frame to render to
  40478. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40479. */
  40480. requestAnimationFrame: Function;
  40481. /**
  40482. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40483. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40484. */
  40485. requestID?: number;
  40486. }
  40487. }
  40488. declare module BABYLON {
  40489. /**
  40490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40491. */
  40492. export class PerformanceMonitor {
  40493. private _enabled;
  40494. private _rollingFrameTime;
  40495. private _lastFrameTimeMs;
  40496. /**
  40497. * constructor
  40498. * @param frameSampleSize The number of samples required to saturate the sliding window
  40499. */
  40500. constructor(frameSampleSize?: number);
  40501. /**
  40502. * Samples current frame
  40503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40504. */
  40505. sampleFrame(timeMs?: number): void;
  40506. /**
  40507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40508. */
  40509. get averageFrameTime(): number;
  40510. /**
  40511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40512. */
  40513. get averageFrameTimeVariance(): number;
  40514. /**
  40515. * Returns the frame time of the most recent frame
  40516. */
  40517. get instantaneousFrameTime(): number;
  40518. /**
  40519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40520. */
  40521. get averageFPS(): number;
  40522. /**
  40523. * Returns the average framerate in frames per second using the most recent frame time
  40524. */
  40525. get instantaneousFPS(): number;
  40526. /**
  40527. * Returns true if enough samples have been taken to completely fill the sliding window
  40528. */
  40529. get isSaturated(): boolean;
  40530. /**
  40531. * Enables contributions to the sliding window sample set
  40532. */
  40533. enable(): void;
  40534. /**
  40535. * Disables contributions to the sliding window sample set
  40536. * Samples will not be interpolated over the disabled period
  40537. */
  40538. disable(): void;
  40539. /**
  40540. * Returns true if sampling is enabled
  40541. */
  40542. get isEnabled(): boolean;
  40543. /**
  40544. * Resets performance monitor
  40545. */
  40546. reset(): void;
  40547. }
  40548. /**
  40549. * RollingAverage
  40550. *
  40551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40552. */
  40553. export class RollingAverage {
  40554. /**
  40555. * Current average
  40556. */
  40557. average: number;
  40558. /**
  40559. * Current variance
  40560. */
  40561. variance: number;
  40562. protected _samples: Array<number>;
  40563. protected _sampleCount: number;
  40564. protected _pos: number;
  40565. protected _m2: number;
  40566. /**
  40567. * constructor
  40568. * @param length The number of samples required to saturate the sliding window
  40569. */
  40570. constructor(length: number);
  40571. /**
  40572. * Adds a sample to the sample set
  40573. * @param v The sample value
  40574. */
  40575. add(v: number): void;
  40576. /**
  40577. * Returns previously added values or null if outside of history or outside the sliding window domain
  40578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40579. * @return Value previously recorded with add() or null if outside of range
  40580. */
  40581. history(i: number): number;
  40582. /**
  40583. * Returns true if enough samples have been taken to completely fill the sliding window
  40584. * @return true if sample-set saturated
  40585. */
  40586. isSaturated(): boolean;
  40587. /**
  40588. * Resets the rolling average (equivalent to 0 samples taken so far)
  40589. */
  40590. reset(): void;
  40591. /**
  40592. * Wraps a value around the sample range boundaries
  40593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40594. * @return Wrapped position in sample range
  40595. */
  40596. protected _wrapPosition(i: number): number;
  40597. }
  40598. }
  40599. declare module BABYLON {
  40600. /**
  40601. * This class is used to track a performance counter which is number based.
  40602. * The user has access to many properties which give statistics of different nature.
  40603. *
  40604. * The implementer can track two kinds of Performance Counter: time and count.
  40605. * 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.
  40606. * 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.
  40607. */
  40608. export class PerfCounter {
  40609. /**
  40610. * Gets or sets a global boolean to turn on and off all the counters
  40611. */
  40612. static Enabled: boolean;
  40613. /**
  40614. * Returns the smallest value ever
  40615. */
  40616. get min(): number;
  40617. /**
  40618. * Returns the biggest value ever
  40619. */
  40620. get max(): number;
  40621. /**
  40622. * Returns the average value since the performance counter is running
  40623. */
  40624. get average(): number;
  40625. /**
  40626. * Returns the average value of the last second the counter was monitored
  40627. */
  40628. get lastSecAverage(): number;
  40629. /**
  40630. * Returns the current value
  40631. */
  40632. get current(): number;
  40633. /**
  40634. * Gets the accumulated total
  40635. */
  40636. get total(): number;
  40637. /**
  40638. * Gets the total value count
  40639. */
  40640. get count(): number;
  40641. /**
  40642. * Creates a new counter
  40643. */
  40644. constructor();
  40645. /**
  40646. * Call this method to start monitoring a new frame.
  40647. * 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.
  40648. */
  40649. fetchNewFrame(): void;
  40650. /**
  40651. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40652. * @param newCount the count value to add to the monitored count
  40653. * @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.
  40654. */
  40655. addCount(newCount: number, fetchResult: boolean): void;
  40656. /**
  40657. * Start monitoring this performance counter
  40658. */
  40659. beginMonitoring(): void;
  40660. /**
  40661. * Compute the time lapsed since the previous beginMonitoring() call.
  40662. * @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
  40663. */
  40664. endMonitoring(newFrame?: boolean): void;
  40665. private _fetchResult;
  40666. private _startMonitoringTime;
  40667. private _min;
  40668. private _max;
  40669. private _average;
  40670. private _current;
  40671. private _totalValueCount;
  40672. private _totalAccumulated;
  40673. private _lastSecAverage;
  40674. private _lastSecAccumulated;
  40675. private _lastSecTime;
  40676. private _lastSecValueCount;
  40677. }
  40678. }
  40679. declare module BABYLON {
  40680. interface ThinEngine {
  40681. /** @hidden */
  40682. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40683. }
  40684. }
  40685. declare module BABYLON {
  40686. /**
  40687. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40688. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40689. */
  40690. export class Analyser {
  40691. /**
  40692. * Gets or sets the smoothing
  40693. * @ignorenaming
  40694. */
  40695. SMOOTHING: number;
  40696. /**
  40697. * Gets or sets the FFT table size
  40698. * @ignorenaming
  40699. */
  40700. FFT_SIZE: number;
  40701. /**
  40702. * Gets or sets the bar graph amplitude
  40703. * @ignorenaming
  40704. */
  40705. BARGRAPHAMPLITUDE: number;
  40706. /**
  40707. * Gets or sets the position of the debug canvas
  40708. * @ignorenaming
  40709. */
  40710. DEBUGCANVASPOS: {
  40711. x: number;
  40712. y: number;
  40713. };
  40714. /**
  40715. * Gets or sets the debug canvas size
  40716. * @ignorenaming
  40717. */
  40718. DEBUGCANVASSIZE: {
  40719. width: number;
  40720. height: number;
  40721. };
  40722. private _byteFreqs;
  40723. private _byteTime;
  40724. private _floatFreqs;
  40725. private _webAudioAnalyser;
  40726. private _debugCanvas;
  40727. private _debugCanvasContext;
  40728. private _scene;
  40729. private _registerFunc;
  40730. private _audioEngine;
  40731. /**
  40732. * Creates a new analyser
  40733. * @param scene defines hosting scene
  40734. */
  40735. constructor(scene: Scene);
  40736. /**
  40737. * Get the number of data values you will have to play with for the visualization
  40738. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40739. * @returns a number
  40740. */
  40741. getFrequencyBinCount(): number;
  40742. /**
  40743. * Gets the current frequency data as a byte array
  40744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40745. * @returns a Uint8Array
  40746. */
  40747. getByteFrequencyData(): Uint8Array;
  40748. /**
  40749. * Gets the current waveform as a byte array
  40750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40751. * @returns a Uint8Array
  40752. */
  40753. getByteTimeDomainData(): Uint8Array;
  40754. /**
  40755. * Gets the current frequency data as a float array
  40756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40757. * @returns a Float32Array
  40758. */
  40759. getFloatFrequencyData(): Float32Array;
  40760. /**
  40761. * Renders the debug canvas
  40762. */
  40763. drawDebugCanvas(): void;
  40764. /**
  40765. * Stops rendering the debug canvas and removes it
  40766. */
  40767. stopDebugCanvas(): void;
  40768. /**
  40769. * Connects two audio nodes
  40770. * @param inputAudioNode defines first node to connect
  40771. * @param outputAudioNode defines second node to connect
  40772. */
  40773. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40774. /**
  40775. * Releases all associated resources
  40776. */
  40777. dispose(): void;
  40778. }
  40779. }
  40780. declare module BABYLON {
  40781. /**
  40782. * This represents an audio engine and it is responsible
  40783. * to play, synchronize and analyse sounds throughout the application.
  40784. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40785. */
  40786. export interface IAudioEngine extends IDisposable {
  40787. /**
  40788. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40789. */
  40790. readonly canUseWebAudio: boolean;
  40791. /**
  40792. * Gets the current AudioContext if available.
  40793. */
  40794. readonly audioContext: Nullable<AudioContext>;
  40795. /**
  40796. * The master gain node defines the global audio volume of your audio engine.
  40797. */
  40798. readonly masterGain: GainNode;
  40799. /**
  40800. * Gets whether or not mp3 are supported by your browser.
  40801. */
  40802. readonly isMP3supported: boolean;
  40803. /**
  40804. * Gets whether or not ogg are supported by your browser.
  40805. */
  40806. readonly isOGGsupported: boolean;
  40807. /**
  40808. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40809. * @ignoreNaming
  40810. */
  40811. WarnedWebAudioUnsupported: boolean;
  40812. /**
  40813. * Defines if the audio engine relies on a custom unlocked button.
  40814. * In this case, the embedded button will not be displayed.
  40815. */
  40816. useCustomUnlockedButton: boolean;
  40817. /**
  40818. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40819. */
  40820. readonly unlocked: boolean;
  40821. /**
  40822. * Event raised when audio has been unlocked on the browser.
  40823. */
  40824. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40825. /**
  40826. * Event raised when audio has been locked on the browser.
  40827. */
  40828. onAudioLockedObservable: Observable<IAudioEngine>;
  40829. /**
  40830. * Flags the audio engine in Locked state.
  40831. * This happens due to new browser policies preventing audio to autoplay.
  40832. */
  40833. lock(): void;
  40834. /**
  40835. * Unlocks the audio engine once a user action has been done on the dom.
  40836. * This is helpful to resume play once browser policies have been satisfied.
  40837. */
  40838. unlock(): void;
  40839. /**
  40840. * Gets the global volume sets on the master gain.
  40841. * @returns the global volume if set or -1 otherwise
  40842. */
  40843. getGlobalVolume(): number;
  40844. /**
  40845. * Sets the global volume of your experience (sets on the master gain).
  40846. * @param newVolume Defines the new global volume of the application
  40847. */
  40848. setGlobalVolume(newVolume: number): void;
  40849. /**
  40850. * Connect the audio engine to an audio analyser allowing some amazing
  40851. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40853. * @param analyser The analyser to connect to the engine
  40854. */
  40855. connectToAnalyser(analyser: Analyser): void;
  40856. }
  40857. }
  40858. declare module BABYLON {
  40859. /**
  40860. * Defines the interface used by display changed events
  40861. */
  40862. export interface IDisplayChangedEventArgs {
  40863. /** Gets the vrDisplay object (if any) */
  40864. vrDisplay: Nullable<any>;
  40865. /** Gets a boolean indicating if webVR is supported */
  40866. vrSupported: boolean;
  40867. }
  40868. /**
  40869. * Defines the interface used by objects containing a viewport (like a camera)
  40870. */
  40871. interface IViewportOwnerLike {
  40872. /**
  40873. * Gets or sets the viewport
  40874. */
  40875. viewport: IViewportLike;
  40876. }
  40877. /**
  40878. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40879. */
  40880. export class Engine extends ThinEngine {
  40881. /** Defines that alpha blending is disabled */
  40882. static readonly ALPHA_DISABLE: number;
  40883. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40884. static readonly ALPHA_ADD: number;
  40885. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40886. static readonly ALPHA_COMBINE: number;
  40887. /** Defines that alpha blending to DEST - SRC * DEST */
  40888. static readonly ALPHA_SUBTRACT: number;
  40889. /** Defines that alpha blending to SRC * DEST */
  40890. static readonly ALPHA_MULTIPLY: number;
  40891. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40892. static readonly ALPHA_MAXIMIZED: number;
  40893. /** Defines that alpha blending to SRC + DEST */
  40894. static readonly ALPHA_ONEONE: number;
  40895. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40896. static readonly ALPHA_PREMULTIPLIED: number;
  40897. /**
  40898. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40899. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40900. */
  40901. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40902. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40903. static readonly ALPHA_INTERPOLATE: number;
  40904. /**
  40905. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40906. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40907. */
  40908. static readonly ALPHA_SCREENMODE: number;
  40909. /** Defines that the ressource is not delayed*/
  40910. static readonly DELAYLOADSTATE_NONE: number;
  40911. /** Defines that the ressource was successfully delay loaded */
  40912. static readonly DELAYLOADSTATE_LOADED: number;
  40913. /** Defines that the ressource is currently delay loading */
  40914. static readonly DELAYLOADSTATE_LOADING: number;
  40915. /** Defines that the ressource is delayed and has not started loading */
  40916. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40917. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40918. static readonly NEVER: number;
  40919. /** 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 */
  40920. static readonly ALWAYS: number;
  40921. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40922. static readonly LESS: number;
  40923. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40924. static readonly EQUAL: number;
  40925. /** 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 */
  40926. static readonly LEQUAL: number;
  40927. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40928. static readonly GREATER: number;
  40929. /** 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 */
  40930. static readonly GEQUAL: number;
  40931. /** 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 */
  40932. static readonly NOTEQUAL: number;
  40933. /** Passed to stencilOperation to specify that stencil value must be kept */
  40934. static readonly KEEP: number;
  40935. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40936. static readonly REPLACE: number;
  40937. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40938. static readonly INCR: number;
  40939. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40940. static readonly DECR: number;
  40941. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40942. static readonly INVERT: number;
  40943. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40944. static readonly INCR_WRAP: number;
  40945. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40946. static readonly DECR_WRAP: number;
  40947. /** Texture is not repeating outside of 0..1 UVs */
  40948. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40949. /** Texture is repeating outside of 0..1 UVs */
  40950. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40951. /** Texture is repeating and mirrored */
  40952. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40953. /** ALPHA */
  40954. static readonly TEXTUREFORMAT_ALPHA: number;
  40955. /** LUMINANCE */
  40956. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40957. /** LUMINANCE_ALPHA */
  40958. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40959. /** RGB */
  40960. static readonly TEXTUREFORMAT_RGB: number;
  40961. /** RGBA */
  40962. static readonly TEXTUREFORMAT_RGBA: number;
  40963. /** RED */
  40964. static readonly TEXTUREFORMAT_RED: number;
  40965. /** RED (2nd reference) */
  40966. static readonly TEXTUREFORMAT_R: number;
  40967. /** RG */
  40968. static readonly TEXTUREFORMAT_RG: number;
  40969. /** RED_INTEGER */
  40970. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40971. /** RED_INTEGER (2nd reference) */
  40972. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40973. /** RG_INTEGER */
  40974. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40975. /** RGB_INTEGER */
  40976. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40977. /** RGBA_INTEGER */
  40978. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40979. /** UNSIGNED_BYTE */
  40980. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40981. /** UNSIGNED_BYTE (2nd reference) */
  40982. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40983. /** FLOAT */
  40984. static readonly TEXTURETYPE_FLOAT: number;
  40985. /** HALF_FLOAT */
  40986. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40987. /** BYTE */
  40988. static readonly TEXTURETYPE_BYTE: number;
  40989. /** SHORT */
  40990. static readonly TEXTURETYPE_SHORT: number;
  40991. /** UNSIGNED_SHORT */
  40992. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40993. /** INT */
  40994. static readonly TEXTURETYPE_INT: number;
  40995. /** UNSIGNED_INT */
  40996. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40997. /** UNSIGNED_SHORT_4_4_4_4 */
  40998. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40999. /** UNSIGNED_SHORT_5_5_5_1 */
  41000. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41001. /** UNSIGNED_SHORT_5_6_5 */
  41002. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41003. /** UNSIGNED_INT_2_10_10_10_REV */
  41004. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41005. /** UNSIGNED_INT_24_8 */
  41006. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41007. /** UNSIGNED_INT_10F_11F_11F_REV */
  41008. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41009. /** UNSIGNED_INT_5_9_9_9_REV */
  41010. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41011. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41012. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41013. /** nearest is mag = nearest and min = nearest and mip = linear */
  41014. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41015. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41016. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41017. /** Trilinear is mag = linear and min = linear and mip = linear */
  41018. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41019. /** nearest is mag = nearest and min = nearest and mip = linear */
  41020. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41021. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41022. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41023. /** Trilinear is mag = linear and min = linear and mip = linear */
  41024. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41025. /** mag = nearest and min = nearest and mip = nearest */
  41026. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41027. /** mag = nearest and min = linear and mip = nearest */
  41028. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41029. /** mag = nearest and min = linear and mip = linear */
  41030. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41031. /** mag = nearest and min = linear and mip = none */
  41032. static readonly TEXTURE_NEAREST_LINEAR: number;
  41033. /** mag = nearest and min = nearest and mip = none */
  41034. static readonly TEXTURE_NEAREST_NEAREST: number;
  41035. /** mag = linear and min = nearest and mip = nearest */
  41036. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41037. /** mag = linear and min = nearest and mip = linear */
  41038. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41039. /** mag = linear and min = linear and mip = none */
  41040. static readonly TEXTURE_LINEAR_LINEAR: number;
  41041. /** mag = linear and min = nearest and mip = none */
  41042. static readonly TEXTURE_LINEAR_NEAREST: number;
  41043. /** Explicit coordinates mode */
  41044. static readonly TEXTURE_EXPLICIT_MODE: number;
  41045. /** Spherical coordinates mode */
  41046. static readonly TEXTURE_SPHERICAL_MODE: number;
  41047. /** Planar coordinates mode */
  41048. static readonly TEXTURE_PLANAR_MODE: number;
  41049. /** Cubic coordinates mode */
  41050. static readonly TEXTURE_CUBIC_MODE: number;
  41051. /** Projection coordinates mode */
  41052. static readonly TEXTURE_PROJECTION_MODE: number;
  41053. /** Skybox coordinates mode */
  41054. static readonly TEXTURE_SKYBOX_MODE: number;
  41055. /** Inverse Cubic coordinates mode */
  41056. static readonly TEXTURE_INVCUBIC_MODE: number;
  41057. /** Equirectangular coordinates mode */
  41058. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41059. /** Equirectangular Fixed coordinates mode */
  41060. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41061. /** Equirectangular Fixed Mirrored coordinates mode */
  41062. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41063. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41064. static readonly SCALEMODE_FLOOR: number;
  41065. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41066. static readonly SCALEMODE_NEAREST: number;
  41067. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41068. static readonly SCALEMODE_CEILING: number;
  41069. /**
  41070. * Returns the current npm package of the sdk
  41071. */
  41072. static get NpmPackage(): string;
  41073. /**
  41074. * Returns the current version of the framework
  41075. */
  41076. static get Version(): string;
  41077. /** Gets the list of created engines */
  41078. static get Instances(): Engine[];
  41079. /**
  41080. * Gets the latest created engine
  41081. */
  41082. static get LastCreatedEngine(): Nullable<Engine>;
  41083. /**
  41084. * Gets the latest created scene
  41085. */
  41086. static get LastCreatedScene(): Nullable<Scene>;
  41087. /**
  41088. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41089. * @param flag defines which part of the materials must be marked as dirty
  41090. * @param predicate defines a predicate used to filter which materials should be affected
  41091. */
  41092. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41093. /**
  41094. * Method called to create the default loading screen.
  41095. * This can be overriden in your own app.
  41096. * @param canvas The rendering canvas element
  41097. * @returns The loading screen
  41098. */
  41099. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41100. /**
  41101. * Method called to create the default rescale post process on each engine.
  41102. */
  41103. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41104. /**
  41105. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41106. **/
  41107. enableOfflineSupport: boolean;
  41108. /**
  41109. * 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)
  41110. **/
  41111. disableManifestCheck: boolean;
  41112. /**
  41113. * Gets the list of created scenes
  41114. */
  41115. scenes: Scene[];
  41116. /**
  41117. * Event raised when a new scene is created
  41118. */
  41119. onNewSceneAddedObservable: Observable<Scene>;
  41120. /**
  41121. * Gets the list of created postprocesses
  41122. */
  41123. postProcesses: PostProcess[];
  41124. /**
  41125. * Gets a boolean indicating if the pointer is currently locked
  41126. */
  41127. isPointerLock: boolean;
  41128. /**
  41129. * Observable event triggered each time the rendering canvas is resized
  41130. */
  41131. onResizeObservable: Observable<Engine>;
  41132. /**
  41133. * Observable event triggered each time the canvas loses focus
  41134. */
  41135. onCanvasBlurObservable: Observable<Engine>;
  41136. /**
  41137. * Observable event triggered each time the canvas gains focus
  41138. */
  41139. onCanvasFocusObservable: Observable<Engine>;
  41140. /**
  41141. * Observable event triggered each time the canvas receives pointerout event
  41142. */
  41143. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41144. /**
  41145. * Observable raised when the engine begins a new frame
  41146. */
  41147. onBeginFrameObservable: Observable<Engine>;
  41148. /**
  41149. * If set, will be used to request the next animation frame for the render loop
  41150. */
  41151. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41152. /**
  41153. * Observable raised when the engine ends the current frame
  41154. */
  41155. onEndFrameObservable: Observable<Engine>;
  41156. /**
  41157. * Observable raised when the engine is about to compile a shader
  41158. */
  41159. onBeforeShaderCompilationObservable: Observable<Engine>;
  41160. /**
  41161. * Observable raised when the engine has jsut compiled a shader
  41162. */
  41163. onAfterShaderCompilationObservable: Observable<Engine>;
  41164. /**
  41165. * Gets the audio engine
  41166. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41167. * @ignorenaming
  41168. */
  41169. static audioEngine: IAudioEngine;
  41170. /**
  41171. * Default AudioEngine factory responsible of creating the Audio Engine.
  41172. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41173. */
  41174. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41175. /**
  41176. * Default offline support factory responsible of creating a tool used to store data locally.
  41177. * By default, this will create a Database object if the workload has been embedded.
  41178. */
  41179. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41180. private _loadingScreen;
  41181. private _pointerLockRequested;
  41182. private _rescalePostProcess;
  41183. private _deterministicLockstep;
  41184. private _lockstepMaxSteps;
  41185. private _timeStep;
  41186. protected get _supportsHardwareTextureRescaling(): boolean;
  41187. private _fps;
  41188. private _deltaTime;
  41189. /** @hidden */
  41190. _drawCalls: PerfCounter;
  41191. /** 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 */
  41192. canvasTabIndex: number;
  41193. /**
  41194. * Turn this value on if you want to pause FPS computation when in background
  41195. */
  41196. disablePerformanceMonitorInBackground: boolean;
  41197. private _performanceMonitor;
  41198. /**
  41199. * Gets the performance monitor attached to this engine
  41200. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41201. */
  41202. get performanceMonitor(): PerformanceMonitor;
  41203. private _onFocus;
  41204. private _onBlur;
  41205. private _onCanvasPointerOut;
  41206. private _onCanvasBlur;
  41207. private _onCanvasFocus;
  41208. private _onFullscreenChange;
  41209. private _onPointerLockChange;
  41210. /**
  41211. * Gets the HTML element used to attach event listeners
  41212. * @returns a HTML element
  41213. */
  41214. getInputElement(): Nullable<HTMLElement>;
  41215. /**
  41216. * Creates a new engine
  41217. * @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
  41218. * @param antialias defines enable antialiasing (default: false)
  41219. * @param options defines further options to be sent to the getContext() function
  41220. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41221. */
  41222. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41223. /**
  41224. * Gets current aspect ratio
  41225. * @param viewportOwner defines the camera to use to get the aspect ratio
  41226. * @param useScreen defines if screen size must be used (or the current render target if any)
  41227. * @returns a number defining the aspect ratio
  41228. */
  41229. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41230. /**
  41231. * Gets current screen aspect ratio
  41232. * @returns a number defining the aspect ratio
  41233. */
  41234. getScreenAspectRatio(): number;
  41235. /**
  41236. * Gets the client rect of the HTML canvas attached with the current webGL context
  41237. * @returns a client rectanglee
  41238. */
  41239. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41240. /**
  41241. * Gets the client rect of the HTML element used for events
  41242. * @returns a client rectanglee
  41243. */
  41244. getInputElementClientRect(): Nullable<ClientRect>;
  41245. /**
  41246. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41247. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41248. * @returns true if engine is in deterministic lock step mode
  41249. */
  41250. isDeterministicLockStep(): boolean;
  41251. /**
  41252. * Gets the max steps when engine is running in deterministic lock step
  41253. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41254. * @returns the max steps
  41255. */
  41256. getLockstepMaxSteps(): number;
  41257. /**
  41258. * Returns the time in ms between steps when using deterministic lock step.
  41259. * @returns time step in (ms)
  41260. */
  41261. getTimeStep(): number;
  41262. /**
  41263. * Force the mipmap generation for the given render target texture
  41264. * @param texture defines the render target texture to use
  41265. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41266. */
  41267. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41268. /** States */
  41269. /**
  41270. * Set various states to the webGL context
  41271. * @param culling defines backface culling state
  41272. * @param zOffset defines the value to apply to zOffset (0 by default)
  41273. * @param force defines if states must be applied even if cache is up to date
  41274. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41275. */
  41276. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41277. /**
  41278. * Set the z offset to apply to current rendering
  41279. * @param value defines the offset to apply
  41280. */
  41281. setZOffset(value: number): void;
  41282. /**
  41283. * Gets the current value of the zOffset
  41284. * @returns the current zOffset state
  41285. */
  41286. getZOffset(): number;
  41287. /**
  41288. * Enable or disable depth buffering
  41289. * @param enable defines the state to set
  41290. */
  41291. setDepthBuffer(enable: boolean): void;
  41292. /**
  41293. * Gets a boolean indicating if depth writing is enabled
  41294. * @returns the current depth writing state
  41295. */
  41296. getDepthWrite(): boolean;
  41297. /**
  41298. * Enable or disable depth writing
  41299. * @param enable defines the state to set
  41300. */
  41301. setDepthWrite(enable: boolean): void;
  41302. /**
  41303. * Gets a boolean indicating if stencil buffer is enabled
  41304. * @returns the current stencil buffer state
  41305. */
  41306. getStencilBuffer(): boolean;
  41307. /**
  41308. * Enable or disable the stencil buffer
  41309. * @param enable defines if the stencil buffer must be enabled or disabled
  41310. */
  41311. setStencilBuffer(enable: boolean): void;
  41312. /**
  41313. * Gets the current stencil mask
  41314. * @returns a number defining the new stencil mask to use
  41315. */
  41316. getStencilMask(): number;
  41317. /**
  41318. * Sets the current stencil mask
  41319. * @param mask defines the new stencil mask to use
  41320. */
  41321. setStencilMask(mask: number): void;
  41322. /**
  41323. * Gets the current stencil function
  41324. * @returns a number defining the stencil function to use
  41325. */
  41326. getStencilFunction(): number;
  41327. /**
  41328. * Gets the current stencil reference value
  41329. * @returns a number defining the stencil reference value to use
  41330. */
  41331. getStencilFunctionReference(): number;
  41332. /**
  41333. * Gets the current stencil mask
  41334. * @returns a number defining the stencil mask to use
  41335. */
  41336. getStencilFunctionMask(): number;
  41337. /**
  41338. * Sets the current stencil function
  41339. * @param stencilFunc defines the new stencil function to use
  41340. */
  41341. setStencilFunction(stencilFunc: number): void;
  41342. /**
  41343. * Sets the current stencil reference
  41344. * @param reference defines the new stencil reference to use
  41345. */
  41346. setStencilFunctionReference(reference: number): void;
  41347. /**
  41348. * Sets the current stencil mask
  41349. * @param mask defines the new stencil mask to use
  41350. */
  41351. setStencilFunctionMask(mask: number): void;
  41352. /**
  41353. * Gets the current stencil operation when stencil fails
  41354. * @returns a number defining stencil operation to use when stencil fails
  41355. */
  41356. getStencilOperationFail(): number;
  41357. /**
  41358. * Gets the current stencil operation when depth fails
  41359. * @returns a number defining stencil operation to use when depth fails
  41360. */
  41361. getStencilOperationDepthFail(): number;
  41362. /**
  41363. * Gets the current stencil operation when stencil passes
  41364. * @returns a number defining stencil operation to use when stencil passes
  41365. */
  41366. getStencilOperationPass(): number;
  41367. /**
  41368. * Sets the stencil operation to use when stencil fails
  41369. * @param operation defines the stencil operation to use when stencil fails
  41370. */
  41371. setStencilOperationFail(operation: number): void;
  41372. /**
  41373. * Sets the stencil operation to use when depth fails
  41374. * @param operation defines the stencil operation to use when depth fails
  41375. */
  41376. setStencilOperationDepthFail(operation: number): void;
  41377. /**
  41378. * Sets the stencil operation to use when stencil passes
  41379. * @param operation defines the stencil operation to use when stencil passes
  41380. */
  41381. setStencilOperationPass(operation: number): void;
  41382. /**
  41383. * Sets a boolean indicating if the dithering state is enabled or disabled
  41384. * @param value defines the dithering state
  41385. */
  41386. setDitheringState(value: boolean): void;
  41387. /**
  41388. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41389. * @param value defines the rasterizer state
  41390. */
  41391. setRasterizerState(value: boolean): void;
  41392. /**
  41393. * Gets the current depth function
  41394. * @returns a number defining the depth function
  41395. */
  41396. getDepthFunction(): Nullable<number>;
  41397. /**
  41398. * Sets the current depth function
  41399. * @param depthFunc defines the function to use
  41400. */
  41401. setDepthFunction(depthFunc: number): void;
  41402. /**
  41403. * Sets the current depth function to GREATER
  41404. */
  41405. setDepthFunctionToGreater(): void;
  41406. /**
  41407. * Sets the current depth function to GEQUAL
  41408. */
  41409. setDepthFunctionToGreaterOrEqual(): void;
  41410. /**
  41411. * Sets the current depth function to LESS
  41412. */
  41413. setDepthFunctionToLess(): void;
  41414. /**
  41415. * Sets the current depth function to LEQUAL
  41416. */
  41417. setDepthFunctionToLessOrEqual(): void;
  41418. private _cachedStencilBuffer;
  41419. private _cachedStencilFunction;
  41420. private _cachedStencilMask;
  41421. private _cachedStencilOperationPass;
  41422. private _cachedStencilOperationFail;
  41423. private _cachedStencilOperationDepthFail;
  41424. private _cachedStencilReference;
  41425. /**
  41426. * Caches the the state of the stencil buffer
  41427. */
  41428. cacheStencilState(): void;
  41429. /**
  41430. * Restores the state of the stencil buffer
  41431. */
  41432. restoreStencilState(): void;
  41433. /**
  41434. * Directly set the WebGL Viewport
  41435. * @param x defines the x coordinate of the viewport (in screen space)
  41436. * @param y defines the y coordinate of the viewport (in screen space)
  41437. * @param width defines the width of the viewport (in screen space)
  41438. * @param height defines the height of the viewport (in screen space)
  41439. * @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
  41440. */
  41441. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41442. /**
  41443. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41444. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41445. * @param y defines the y-coordinate of the corner of the clear rectangle
  41446. * @param width defines the width of the clear rectangle
  41447. * @param height defines the height of the clear rectangle
  41448. * @param clearColor defines the clear color
  41449. */
  41450. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41451. /**
  41452. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41453. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41454. * @param y defines the y-coordinate of the corner of the clear rectangle
  41455. * @param width defines the width of the clear rectangle
  41456. * @param height defines the height of the clear rectangle
  41457. */
  41458. enableScissor(x: number, y: number, width: number, height: number): void;
  41459. /**
  41460. * Disable previously set scissor test rectangle
  41461. */
  41462. disableScissor(): void;
  41463. protected _reportDrawCall(): void;
  41464. /**
  41465. * Initializes a webVR display and starts listening to display change events
  41466. * The onVRDisplayChangedObservable will be notified upon these changes
  41467. * @returns The onVRDisplayChangedObservable
  41468. */
  41469. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41470. /** @hidden */
  41471. _prepareVRComponent(): void;
  41472. /** @hidden */
  41473. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41474. /** @hidden */
  41475. _submitVRFrame(): void;
  41476. /**
  41477. * Call this function to leave webVR mode
  41478. * Will do nothing if webVR is not supported or if there is no webVR device
  41479. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41480. */
  41481. disableVR(): void;
  41482. /**
  41483. * Gets a boolean indicating that the system is in VR mode and is presenting
  41484. * @returns true if VR mode is engaged
  41485. */
  41486. isVRPresenting(): boolean;
  41487. /** @hidden */
  41488. _requestVRFrame(): void;
  41489. /** @hidden */
  41490. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41491. /**
  41492. * Gets the source code of the vertex shader associated with a specific webGL program
  41493. * @param program defines the program to use
  41494. * @returns a string containing the source code of the vertex shader associated with the program
  41495. */
  41496. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41497. /**
  41498. * Gets the source code of the fragment shader associated with a specific webGL program
  41499. * @param program defines the program to use
  41500. * @returns a string containing the source code of the fragment shader associated with the program
  41501. */
  41502. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41503. /**
  41504. * Sets a depth stencil texture from a render target to the according uniform.
  41505. * @param channel The texture channel
  41506. * @param uniform The uniform to set
  41507. * @param texture The render target texture containing the depth stencil texture to apply
  41508. */
  41509. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41510. /**
  41511. * Sets a texture to the webGL context from a postprocess
  41512. * @param channel defines the channel to use
  41513. * @param postProcess defines the source postprocess
  41514. */
  41515. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41516. /**
  41517. * Binds the output of the passed in post process to the texture channel specified
  41518. * @param channel The channel the texture should be bound to
  41519. * @param postProcess The post process which's output should be bound
  41520. */
  41521. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41522. protected _rebuildBuffers(): void;
  41523. /** @hidden */
  41524. _renderFrame(): void;
  41525. _renderLoop(): void;
  41526. /** @hidden */
  41527. _renderViews(): boolean;
  41528. /**
  41529. * Toggle full screen mode
  41530. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41531. */
  41532. switchFullscreen(requestPointerLock: boolean): void;
  41533. /**
  41534. * Enters full screen mode
  41535. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41536. */
  41537. enterFullscreen(requestPointerLock: boolean): void;
  41538. /**
  41539. * Exits full screen mode
  41540. */
  41541. exitFullscreen(): void;
  41542. /**
  41543. * Enters Pointerlock mode
  41544. */
  41545. enterPointerlock(): void;
  41546. /**
  41547. * Exits Pointerlock mode
  41548. */
  41549. exitPointerlock(): void;
  41550. /**
  41551. * Begin a new frame
  41552. */
  41553. beginFrame(): void;
  41554. /**
  41555. * Enf the current frame
  41556. */
  41557. endFrame(): void;
  41558. resize(): void;
  41559. /**
  41560. * Force a specific size of the canvas
  41561. * @param width defines the new canvas' width
  41562. * @param height defines the new canvas' height
  41563. * @returns true if the size was changed
  41564. */
  41565. setSize(width: number, height: number): boolean;
  41566. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41567. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41568. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41569. _releaseTexture(texture: InternalTexture): void;
  41570. /**
  41571. * @hidden
  41572. * Rescales a texture
  41573. * @param source input texutre
  41574. * @param destination destination texture
  41575. * @param scene scene to use to render the resize
  41576. * @param internalFormat format to use when resizing
  41577. * @param onComplete callback to be called when resize has completed
  41578. */
  41579. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41580. /**
  41581. * Gets the current framerate
  41582. * @returns a number representing the framerate
  41583. */
  41584. getFps(): number;
  41585. /**
  41586. * Gets the time spent between current and previous frame
  41587. * @returns a number representing the delta time in ms
  41588. */
  41589. getDeltaTime(): number;
  41590. private _measureFps;
  41591. /** @hidden */
  41592. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41593. /**
  41594. * Updates the sample count of a render target texture
  41595. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41596. * @param texture defines the texture to update
  41597. * @param samples defines the sample count to set
  41598. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41599. */
  41600. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41601. /**
  41602. * Updates a depth texture Comparison Mode and Function.
  41603. * If the comparison Function is equal to 0, the mode will be set to none.
  41604. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41605. * @param texture The texture to set the comparison function for
  41606. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41607. */
  41608. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41609. /**
  41610. * Creates a webGL buffer to use with instanciation
  41611. * @param capacity defines the size of the buffer
  41612. * @returns the webGL buffer
  41613. */
  41614. createInstancesBuffer(capacity: number): DataBuffer;
  41615. /**
  41616. * Delete a webGL buffer used with instanciation
  41617. * @param buffer defines the webGL buffer to delete
  41618. */
  41619. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41620. private _clientWaitAsync;
  41621. /** @hidden */
  41622. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41623. dispose(): void;
  41624. private _disableTouchAction;
  41625. /**
  41626. * Display the loading screen
  41627. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41628. */
  41629. displayLoadingUI(): void;
  41630. /**
  41631. * Hide the loading screen
  41632. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41633. */
  41634. hideLoadingUI(): void;
  41635. /**
  41636. * Gets the current loading screen object
  41637. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41638. */
  41639. get loadingScreen(): ILoadingScreen;
  41640. /**
  41641. * Sets the current loading screen object
  41642. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41643. */
  41644. set loadingScreen(loadingScreen: ILoadingScreen);
  41645. /**
  41646. * Sets the current loading screen text
  41647. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41648. */
  41649. set loadingUIText(text: string);
  41650. /**
  41651. * Sets the current loading screen background color
  41652. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41653. */
  41654. set loadingUIBackgroundColor(color: string);
  41655. /** Pointerlock and fullscreen */
  41656. /**
  41657. * Ask the browser to promote the current element to pointerlock mode
  41658. * @param element defines the DOM element to promote
  41659. */
  41660. static _RequestPointerlock(element: HTMLElement): void;
  41661. /**
  41662. * Asks the browser to exit pointerlock mode
  41663. */
  41664. static _ExitPointerlock(): void;
  41665. /**
  41666. * Ask the browser to promote the current element to fullscreen rendering mode
  41667. * @param element defines the DOM element to promote
  41668. */
  41669. static _RequestFullscreen(element: HTMLElement): void;
  41670. /**
  41671. * Asks the browser to exit fullscreen mode
  41672. */
  41673. static _ExitFullscreen(): void;
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41679. * during the life time of the application.
  41680. */
  41681. export class EngineStore {
  41682. /** Gets the list of created engines */
  41683. static Instances: Engine[];
  41684. /** @hidden */
  41685. static _LastCreatedScene: Nullable<Scene>;
  41686. /**
  41687. * Gets the latest created engine
  41688. */
  41689. static get LastCreatedEngine(): Nullable<Engine>;
  41690. /**
  41691. * Gets the latest created scene
  41692. */
  41693. static get LastCreatedScene(): Nullable<Scene>;
  41694. /**
  41695. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41696. * @ignorenaming
  41697. */
  41698. static UseFallbackTexture: boolean;
  41699. /**
  41700. * Texture content used if a texture cannot loaded
  41701. * @ignorenaming
  41702. */
  41703. static FallbackTexture: string;
  41704. }
  41705. }
  41706. declare module BABYLON {
  41707. /**
  41708. * Helper class that provides a small promise polyfill
  41709. */
  41710. export class PromisePolyfill {
  41711. /**
  41712. * Static function used to check if the polyfill is required
  41713. * If this is the case then the function will inject the polyfill to window.Promise
  41714. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41715. */
  41716. static Apply(force?: boolean): void;
  41717. }
  41718. }
  41719. declare module BABYLON {
  41720. /**
  41721. * Interface for screenshot methods with describe argument called `size` as object with options
  41722. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41723. */
  41724. export interface IScreenshotSize {
  41725. /**
  41726. * number in pixels for canvas height
  41727. */
  41728. height?: number;
  41729. /**
  41730. * multiplier allowing render at a higher or lower resolution
  41731. * If value is defined then height and width will be ignored and taken from camera
  41732. */
  41733. precision?: number;
  41734. /**
  41735. * number in pixels for canvas width
  41736. */
  41737. width?: number;
  41738. }
  41739. }
  41740. declare module BABYLON {
  41741. interface IColor4Like {
  41742. r: float;
  41743. g: float;
  41744. b: float;
  41745. a: float;
  41746. }
  41747. /**
  41748. * Class containing a set of static utilities functions
  41749. */
  41750. export class Tools {
  41751. /**
  41752. * Gets or sets the base URL to use to load assets
  41753. */
  41754. static get BaseUrl(): string;
  41755. static set BaseUrl(value: string);
  41756. /**
  41757. * Enable/Disable Custom HTTP Request Headers globally.
  41758. * default = false
  41759. * @see CustomRequestHeaders
  41760. */
  41761. static UseCustomRequestHeaders: boolean;
  41762. /**
  41763. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41764. * i.e. when loading files, where the server/service expects an Authorization header
  41765. */
  41766. static CustomRequestHeaders: {
  41767. [key: string]: string;
  41768. };
  41769. /**
  41770. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41771. */
  41772. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41773. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41774. /**
  41775. * Default behaviour for cors in the application.
  41776. * It can be a string if the expected behavior is identical in the entire app.
  41777. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41778. */
  41779. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41780. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41781. /**
  41782. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41783. * @ignorenaming
  41784. */
  41785. static get UseFallbackTexture(): boolean;
  41786. static set UseFallbackTexture(value: boolean);
  41787. /**
  41788. * Use this object to register external classes like custom textures or material
  41789. * to allow the laoders to instantiate them
  41790. */
  41791. static get RegisteredExternalClasses(): {
  41792. [key: string]: Object;
  41793. };
  41794. static set RegisteredExternalClasses(classes: {
  41795. [key: string]: Object;
  41796. });
  41797. /**
  41798. * Texture content used if a texture cannot loaded
  41799. * @ignorenaming
  41800. */
  41801. static get fallbackTexture(): string;
  41802. static set fallbackTexture(value: string);
  41803. /**
  41804. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41805. * @param u defines the coordinate on X axis
  41806. * @param v defines the coordinate on Y axis
  41807. * @param width defines the width of the source data
  41808. * @param height defines the height of the source data
  41809. * @param pixels defines the source byte array
  41810. * @param color defines the output color
  41811. */
  41812. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41813. /**
  41814. * Interpolates between a and b via alpha
  41815. * @param a The lower value (returned when alpha = 0)
  41816. * @param b The upper value (returned when alpha = 1)
  41817. * @param alpha The interpolation-factor
  41818. * @return The mixed value
  41819. */
  41820. static Mix(a: number, b: number, alpha: number): number;
  41821. /**
  41822. * Tries to instantiate a new object from a given class name
  41823. * @param className defines the class name to instantiate
  41824. * @returns the new object or null if the system was not able to do the instantiation
  41825. */
  41826. static Instantiate(className: string): any;
  41827. /**
  41828. * Provides a slice function that will work even on IE
  41829. * @param data defines the array to slice
  41830. * @param start defines the start of the data (optional)
  41831. * @param end defines the end of the data (optional)
  41832. * @returns the new sliced array
  41833. */
  41834. static Slice<T>(data: T, start?: number, end?: number): T;
  41835. /**
  41836. * Provides a slice function that will work even on IE
  41837. * The difference between this and Slice is that this will force-convert to array
  41838. * @param data defines the array to slice
  41839. * @param start defines the start of the data (optional)
  41840. * @param end defines the end of the data (optional)
  41841. * @returns the new sliced array
  41842. */
  41843. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41844. /**
  41845. * Polyfill for setImmediate
  41846. * @param action defines the action to execute after the current execution block
  41847. */
  41848. static SetImmediate(action: () => void): void;
  41849. /**
  41850. * Function indicating if a number is an exponent of 2
  41851. * @param value defines the value to test
  41852. * @returns true if the value is an exponent of 2
  41853. */
  41854. static IsExponentOfTwo(value: number): boolean;
  41855. private static _tmpFloatArray;
  41856. /**
  41857. * Returns the nearest 32-bit single precision float representation of a Number
  41858. * @param value A Number. If the parameter is of a different type, it will get converted
  41859. * to a number or to NaN if it cannot be converted
  41860. * @returns number
  41861. */
  41862. static FloatRound(value: number): number;
  41863. /**
  41864. * Extracts the filename from a path
  41865. * @param path defines the path to use
  41866. * @returns the filename
  41867. */
  41868. static GetFilename(path: string): string;
  41869. /**
  41870. * Extracts the "folder" part of a path (everything before the filename).
  41871. * @param uri The URI to extract the info from
  41872. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41873. * @returns The "folder" part of the path
  41874. */
  41875. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41876. /**
  41877. * Extracts text content from a DOM element hierarchy
  41878. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41879. */
  41880. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41881. /**
  41882. * Convert an angle in radians to degrees
  41883. * @param angle defines the angle to convert
  41884. * @returns the angle in degrees
  41885. */
  41886. static ToDegrees(angle: number): number;
  41887. /**
  41888. * Convert an angle in degrees to radians
  41889. * @param angle defines the angle to convert
  41890. * @returns the angle in radians
  41891. */
  41892. static ToRadians(angle: number): number;
  41893. /**
  41894. * Returns an array if obj is not an array
  41895. * @param obj defines the object to evaluate as an array
  41896. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41897. * @returns either obj directly if obj is an array or a new array containing obj
  41898. */
  41899. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41900. /**
  41901. * Gets the pointer prefix to use
  41902. * @param engine defines the engine we are finding the prefix for
  41903. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41904. */
  41905. static GetPointerPrefix(engine: Engine): string;
  41906. /**
  41907. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41908. * @param url define the url we are trying
  41909. * @param element define the dom element where to configure the cors policy
  41910. */
  41911. static SetCorsBehavior(url: string | string[], element: {
  41912. crossOrigin: string | null;
  41913. }): void;
  41914. /**
  41915. * Removes unwanted characters from an url
  41916. * @param url defines the url to clean
  41917. * @returns the cleaned url
  41918. */
  41919. static CleanUrl(url: string): string;
  41920. /**
  41921. * Gets or sets a function used to pre-process url before using them to load assets
  41922. */
  41923. static get PreprocessUrl(): (url: string) => string;
  41924. static set PreprocessUrl(processor: (url: string) => string);
  41925. /**
  41926. * Loads an image as an HTMLImageElement.
  41927. * @param input url string, ArrayBuffer, or Blob to load
  41928. * @param onLoad callback called when the image successfully loads
  41929. * @param onError callback called when the image fails to load
  41930. * @param offlineProvider offline provider for caching
  41931. * @param mimeType optional mime type
  41932. * @returns the HTMLImageElement of the loaded image
  41933. */
  41934. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41935. /**
  41936. * Loads a file from a url
  41937. * @param url url string, ArrayBuffer, or Blob to load
  41938. * @param onSuccess callback called when the file successfully loads
  41939. * @param onProgress callback called while file is loading (if the server supports this mode)
  41940. * @param offlineProvider defines the offline provider for caching
  41941. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41942. * @param onError callback called when the file fails to load
  41943. * @returns a file request object
  41944. */
  41945. 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;
  41946. /**
  41947. * Loads a file from a url
  41948. * @param url the file url to load
  41949. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41950. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41951. */
  41952. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41953. /**
  41954. * Load a script (identified by an url). When the url returns, the
  41955. * content of this file is added into a new script element, attached to the DOM (body element)
  41956. * @param scriptUrl defines the url of the script to laod
  41957. * @param onSuccess defines the callback called when the script is loaded
  41958. * @param onError defines the callback to call if an error occurs
  41959. * @param scriptId defines the id of the script element
  41960. */
  41961. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41962. /**
  41963. * Load an asynchronous script (identified by an url). When the url returns, the
  41964. * content of this file is added into a new script element, attached to the DOM (body element)
  41965. * @param scriptUrl defines the url of the script to laod
  41966. * @param scriptId defines the id of the script element
  41967. * @returns a promise request object
  41968. */
  41969. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41970. /**
  41971. * Loads a file from a blob
  41972. * @param fileToLoad defines the blob to use
  41973. * @param callback defines the callback to call when data is loaded
  41974. * @param progressCallback defines the callback to call during loading process
  41975. * @returns a file request object
  41976. */
  41977. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41978. /**
  41979. * Reads a file from a File object
  41980. * @param file defines the file to load
  41981. * @param onSuccess defines the callback to call when data is loaded
  41982. * @param onProgress defines the callback to call during loading process
  41983. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41984. * @param onError defines the callback to call when an error occurs
  41985. * @returns a file request object
  41986. */
  41987. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41988. /**
  41989. * Creates a data url from a given string content
  41990. * @param content defines the content to convert
  41991. * @returns the new data url link
  41992. */
  41993. static FileAsURL(content: string): string;
  41994. /**
  41995. * Format the given number to a specific decimal format
  41996. * @param value defines the number to format
  41997. * @param decimals defines the number of decimals to use
  41998. * @returns the formatted string
  41999. */
  42000. static Format(value: number, decimals?: number): string;
  42001. /**
  42002. * Tries to copy an object by duplicating every property
  42003. * @param source defines the source object
  42004. * @param destination defines the target object
  42005. * @param doNotCopyList defines a list of properties to avoid
  42006. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42007. */
  42008. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42009. /**
  42010. * Gets a boolean indicating if the given object has no own property
  42011. * @param obj defines the object to test
  42012. * @returns true if object has no own property
  42013. */
  42014. static IsEmpty(obj: any): boolean;
  42015. /**
  42016. * Function used to register events at window level
  42017. * @param windowElement defines the Window object to use
  42018. * @param events defines the events to register
  42019. */
  42020. static RegisterTopRootEvents(windowElement: Window, events: {
  42021. name: string;
  42022. handler: Nullable<(e: FocusEvent) => any>;
  42023. }[]): void;
  42024. /**
  42025. * Function used to unregister events from window level
  42026. * @param windowElement defines the Window object to use
  42027. * @param events defines the events to unregister
  42028. */
  42029. static UnregisterTopRootEvents(windowElement: Window, events: {
  42030. name: string;
  42031. handler: Nullable<(e: FocusEvent) => any>;
  42032. }[]): void;
  42033. /**
  42034. * @ignore
  42035. */
  42036. static _ScreenshotCanvas: HTMLCanvasElement;
  42037. /**
  42038. * Dumps the current bound framebuffer
  42039. * @param width defines the rendering width
  42040. * @param height defines the rendering height
  42041. * @param engine defines the hosting engine
  42042. * @param successCallback defines the callback triggered once the data are available
  42043. * @param mimeType defines the mime type of the result
  42044. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42045. */
  42046. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42047. /**
  42048. * Converts the canvas data to blob.
  42049. * This acts as a polyfill for browsers not supporting the to blob function.
  42050. * @param canvas Defines the canvas to extract the data from
  42051. * @param successCallback Defines the callback triggered once the data are available
  42052. * @param mimeType Defines the mime type of the result
  42053. */
  42054. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42055. /**
  42056. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42057. * @param successCallback defines the callback triggered once the data are available
  42058. * @param mimeType defines the mime type of the result
  42059. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42060. */
  42061. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42062. /**
  42063. * Downloads a blob in the browser
  42064. * @param blob defines the blob to download
  42065. * @param fileName defines the name of the downloaded file
  42066. */
  42067. static Download(blob: Blob, fileName: string): void;
  42068. /**
  42069. * Will return the right value of the noPreventDefault variable
  42070. * Needed to keep backwards compatibility to the old API.
  42071. *
  42072. * @param args arguments passed to the attachControl function
  42073. * @returns the correct value for noPreventDefault
  42074. */
  42075. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42076. /**
  42077. * Captures a screenshot of the current rendering
  42078. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42079. * @param engine defines the rendering engine
  42080. * @param camera defines the source camera
  42081. * @param size This parameter can be set to a single number or to an object with the
  42082. * following (optional) properties: precision, width, height. If a single number is passed,
  42083. * it will be used for both width and height. If an object is passed, the screenshot size
  42084. * will be derived from the parameters. The precision property is a multiplier allowing
  42085. * rendering at a higher or lower resolution
  42086. * @param successCallback defines the callback receives a single parameter which contains the
  42087. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42088. * src parameter of an <img> to display it
  42089. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42090. * Check your browser for supported MIME types
  42091. */
  42092. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42093. /**
  42094. * Captures a screenshot of the current rendering
  42095. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42096. * @param engine defines the rendering engine
  42097. * @param camera defines the source camera
  42098. * @param size This parameter can be set to a single number or to an object with the
  42099. * following (optional) properties: precision, width, height. If a single number is passed,
  42100. * it will be used for both width and height. If an object is passed, the screenshot size
  42101. * will be derived from the parameters. The precision property is a multiplier allowing
  42102. * rendering at a higher or lower resolution
  42103. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42104. * Check your browser for supported MIME types
  42105. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42106. * to the src parameter of an <img> to display it
  42107. */
  42108. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42109. /**
  42110. * Generates an image screenshot from the specified camera.
  42111. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42112. * @param engine The engine to use for rendering
  42113. * @param camera The camera to use for rendering
  42114. * @param size This parameter can be set to a single number or to an object with the
  42115. * following (optional) properties: precision, width, height. If a single number is passed,
  42116. * it will be used for both width and height. If an object is passed, the screenshot size
  42117. * will be derived from the parameters. The precision property is a multiplier allowing
  42118. * rendering at a higher or lower resolution
  42119. * @param successCallback The callback receives a single parameter which contains the
  42120. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42121. * src parameter of an <img> to display it
  42122. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42123. * Check your browser for supported MIME types
  42124. * @param samples Texture samples (default: 1)
  42125. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42126. * @param fileName A name for for the downloaded file.
  42127. */
  42128. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42129. /**
  42130. * Generates an image screenshot from the specified camera.
  42131. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42132. * @param engine The engine to use for rendering
  42133. * @param camera The camera to use for rendering
  42134. * @param size This parameter can be set to a single number or to an object with the
  42135. * following (optional) properties: precision, width, height. If a single number is passed,
  42136. * it will be used for both width and height. If an object is passed, the screenshot size
  42137. * will be derived from the parameters. The precision property is a multiplier allowing
  42138. * rendering at a higher or lower resolution
  42139. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42140. * Check your browser for supported MIME types
  42141. * @param samples Texture samples (default: 1)
  42142. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42143. * @param fileName A name for for the downloaded file.
  42144. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42145. * to the src parameter of an <img> to display it
  42146. */
  42147. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42148. /**
  42149. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42150. * Be aware Math.random() could cause collisions, but:
  42151. * "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"
  42152. * @returns a pseudo random id
  42153. */
  42154. static RandomId(): string;
  42155. /**
  42156. * Test if the given uri is a base64 string
  42157. * @param uri The uri to test
  42158. * @return True if the uri is a base64 string or false otherwise
  42159. */
  42160. static IsBase64(uri: string): boolean;
  42161. /**
  42162. * Decode the given base64 uri.
  42163. * @param uri The uri to decode
  42164. * @return The decoded base64 data.
  42165. */
  42166. static DecodeBase64(uri: string): ArrayBuffer;
  42167. /**
  42168. * Gets the absolute url.
  42169. * @param url the input url
  42170. * @return the absolute url
  42171. */
  42172. static GetAbsoluteUrl(url: string): string;
  42173. /**
  42174. * No log
  42175. */
  42176. static readonly NoneLogLevel: number;
  42177. /**
  42178. * Only message logs
  42179. */
  42180. static readonly MessageLogLevel: number;
  42181. /**
  42182. * Only warning logs
  42183. */
  42184. static readonly WarningLogLevel: number;
  42185. /**
  42186. * Only error logs
  42187. */
  42188. static readonly ErrorLogLevel: number;
  42189. /**
  42190. * All logs
  42191. */
  42192. static readonly AllLogLevel: number;
  42193. /**
  42194. * Gets a value indicating the number of loading errors
  42195. * @ignorenaming
  42196. */
  42197. static get errorsCount(): number;
  42198. /**
  42199. * Callback called when a new log is added
  42200. */
  42201. static OnNewCacheEntry: (entry: string) => void;
  42202. /**
  42203. * Log a message to the console
  42204. * @param message defines the message to log
  42205. */
  42206. static Log(message: string): void;
  42207. /**
  42208. * Write a warning message to the console
  42209. * @param message defines the message to log
  42210. */
  42211. static Warn(message: string): void;
  42212. /**
  42213. * Write an error message to the console
  42214. * @param message defines the message to log
  42215. */
  42216. static Error(message: string): void;
  42217. /**
  42218. * Gets current log cache (list of logs)
  42219. */
  42220. static get LogCache(): string;
  42221. /**
  42222. * Clears the log cache
  42223. */
  42224. static ClearLogCache(): void;
  42225. /**
  42226. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42227. */
  42228. static set LogLevels(level: number);
  42229. /**
  42230. * Checks if the window object exists
  42231. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42232. */
  42233. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42234. /**
  42235. * No performance log
  42236. */
  42237. static readonly PerformanceNoneLogLevel: number;
  42238. /**
  42239. * Use user marks to log performance
  42240. */
  42241. static readonly PerformanceUserMarkLogLevel: number;
  42242. /**
  42243. * Log performance to the console
  42244. */
  42245. static readonly PerformanceConsoleLogLevel: number;
  42246. private static _performance;
  42247. /**
  42248. * Sets the current performance log level
  42249. */
  42250. static set PerformanceLogLevel(level: number);
  42251. private static _StartPerformanceCounterDisabled;
  42252. private static _EndPerformanceCounterDisabled;
  42253. private static _StartUserMark;
  42254. private static _EndUserMark;
  42255. private static _StartPerformanceConsole;
  42256. private static _EndPerformanceConsole;
  42257. /**
  42258. * Starts a performance counter
  42259. */
  42260. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42261. /**
  42262. * Ends a specific performance coutner
  42263. */
  42264. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42265. /**
  42266. * Gets either window.performance.now() if supported or Date.now() else
  42267. */
  42268. static get Now(): number;
  42269. /**
  42270. * This method will return the name of the class used to create the instance of the given object.
  42271. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42272. * @param object the object to get the class name from
  42273. * @param isType defines if the object is actually a type
  42274. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42275. */
  42276. static GetClassName(object: any, isType?: boolean): string;
  42277. /**
  42278. * Gets the first element of an array satisfying a given predicate
  42279. * @param array defines the array to browse
  42280. * @param predicate defines the predicate to use
  42281. * @returns null if not found or the element
  42282. */
  42283. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42284. /**
  42285. * This method will return the name of the full name of the class, including its owning module (if any).
  42286. * 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).
  42287. * @param object the object to get the class name from
  42288. * @param isType defines if the object is actually a type
  42289. * @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.
  42290. * @ignorenaming
  42291. */
  42292. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42293. /**
  42294. * Returns a promise that resolves after the given amount of time.
  42295. * @param delay Number of milliseconds to delay
  42296. * @returns Promise that resolves after the given amount of time
  42297. */
  42298. static DelayAsync(delay: number): Promise<void>;
  42299. /**
  42300. * Utility function to detect if the current user agent is Safari
  42301. * @returns whether or not the current user agent is safari
  42302. */
  42303. static IsSafari(): boolean;
  42304. }
  42305. /**
  42306. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42307. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42308. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42309. * @param name The name of the class, case should be preserved
  42310. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42311. */
  42312. export function className(name: string, module?: string): (target: Object) => void;
  42313. /**
  42314. * An implementation of a loop for asynchronous functions.
  42315. */
  42316. export class AsyncLoop {
  42317. /**
  42318. * Defines the number of iterations for the loop
  42319. */
  42320. iterations: number;
  42321. /**
  42322. * Defines the current index of the loop.
  42323. */
  42324. index: number;
  42325. private _done;
  42326. private _fn;
  42327. private _successCallback;
  42328. /**
  42329. * Constructor.
  42330. * @param iterations the number of iterations.
  42331. * @param func the function to run each iteration
  42332. * @param successCallback the callback that will be called upon succesful execution
  42333. * @param offset starting offset.
  42334. */
  42335. constructor(
  42336. /**
  42337. * Defines the number of iterations for the loop
  42338. */
  42339. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42340. /**
  42341. * Execute the next iteration. Must be called after the last iteration was finished.
  42342. */
  42343. executeNext(): void;
  42344. /**
  42345. * Break the loop and run the success callback.
  42346. */
  42347. breakLoop(): void;
  42348. /**
  42349. * Create and run an async loop.
  42350. * @param iterations the number of iterations.
  42351. * @param fn the function to run each iteration
  42352. * @param successCallback the callback that will be called upon succesful execution
  42353. * @param offset starting offset.
  42354. * @returns the created async loop object
  42355. */
  42356. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42357. /**
  42358. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42359. * @param iterations total number of iterations
  42360. * @param syncedIterations number of synchronous iterations in each async iteration.
  42361. * @param fn the function to call each iteration.
  42362. * @param callback a success call back that will be called when iterating stops.
  42363. * @param breakFunction a break condition (optional)
  42364. * @param timeout timeout settings for the setTimeout function. default - 0.
  42365. * @returns the created async loop object
  42366. */
  42367. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42368. }
  42369. }
  42370. declare module BABYLON {
  42371. /**
  42372. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42373. * The underlying implementation relies on an associative array to ensure the best performances.
  42374. * The value can be anything including 'null' but except 'undefined'
  42375. */
  42376. export class StringDictionary<T> {
  42377. /**
  42378. * This will clear this dictionary and copy the content from the 'source' one.
  42379. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42380. * @param source the dictionary to take the content from and copy to this dictionary
  42381. */
  42382. copyFrom(source: StringDictionary<T>): void;
  42383. /**
  42384. * Get a value based from its key
  42385. * @param key the given key to get the matching value from
  42386. * @return the value if found, otherwise undefined is returned
  42387. */
  42388. get(key: string): T | undefined;
  42389. /**
  42390. * Get a value from its key or add it if it doesn't exist.
  42391. * This method will ensure you that a given key/data will be present in the dictionary.
  42392. * @param key the given key to get the matching value from
  42393. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42394. * The factory will only be invoked if there's no data for the given key.
  42395. * @return the value corresponding to the key.
  42396. */
  42397. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42398. /**
  42399. * Get a value from its key if present in the dictionary otherwise add it
  42400. * @param key the key to get the value from
  42401. * @param val if there's no such key/value pair in the dictionary add it with this value
  42402. * @return the value corresponding to the key
  42403. */
  42404. getOrAdd(key: string, val: T): T;
  42405. /**
  42406. * Check if there's a given key in the dictionary
  42407. * @param key the key to check for
  42408. * @return true if the key is present, false otherwise
  42409. */
  42410. contains(key: string): boolean;
  42411. /**
  42412. * Add a new key and its corresponding value
  42413. * @param key the key to add
  42414. * @param value the value corresponding to the key
  42415. * @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
  42416. */
  42417. add(key: string, value: T): boolean;
  42418. /**
  42419. * Update a specific value associated to a key
  42420. * @param key defines the key to use
  42421. * @param value defines the value to store
  42422. * @returns true if the value was updated (or false if the key was not found)
  42423. */
  42424. set(key: string, value: T): boolean;
  42425. /**
  42426. * Get the element of the given key and remove it from the dictionary
  42427. * @param key defines the key to search
  42428. * @returns the value associated with the key or null if not found
  42429. */
  42430. getAndRemove(key: string): Nullable<T>;
  42431. /**
  42432. * Remove a key/value from the dictionary.
  42433. * @param key the key to remove
  42434. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42435. */
  42436. remove(key: string): boolean;
  42437. /**
  42438. * Clear the whole content of the dictionary
  42439. */
  42440. clear(): void;
  42441. /**
  42442. * Gets the current count
  42443. */
  42444. get count(): number;
  42445. /**
  42446. * Execute a callback on each key/val of the dictionary.
  42447. * Note that you can remove any element in this dictionary in the callback implementation
  42448. * @param callback the callback to execute on a given key/value pair
  42449. */
  42450. forEach(callback: (key: string, val: T) => void): void;
  42451. /**
  42452. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42453. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42454. * Note that you can remove any element in this dictionary in the callback implementation
  42455. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42456. * @returns the first item
  42457. */
  42458. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42459. private _count;
  42460. private _data;
  42461. }
  42462. }
  42463. declare module BABYLON {
  42464. /** @hidden */
  42465. export interface ICollisionCoordinator {
  42466. createCollider(): Collider;
  42467. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42468. init(scene: Scene): void;
  42469. }
  42470. /** @hidden */
  42471. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42472. private _scene;
  42473. private _scaledPosition;
  42474. private _scaledVelocity;
  42475. private _finalPosition;
  42476. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42477. createCollider(): Collider;
  42478. init(scene: Scene): void;
  42479. private _collideWithWorld;
  42480. }
  42481. }
  42482. declare module BABYLON {
  42483. /**
  42484. * Class used to manage all inputs for the scene.
  42485. */
  42486. export class InputManager {
  42487. /** The distance in pixel that you have to move to prevent some events */
  42488. static DragMovementThreshold: number;
  42489. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42490. static LongPressDelay: number;
  42491. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42492. static DoubleClickDelay: number;
  42493. /** If you need to check double click without raising a single click at first click, enable this flag */
  42494. static ExclusiveDoubleClickMode: boolean;
  42495. /** 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. */
  42496. private _alreadyAttached;
  42497. private _alreadyAttachedTo;
  42498. private _wheelEventName;
  42499. private _onPointerMove;
  42500. private _onPointerDown;
  42501. private _onPointerUp;
  42502. private _initClickEvent;
  42503. private _initActionManager;
  42504. private _delayedSimpleClick;
  42505. private _delayedSimpleClickTimeout;
  42506. private _previousDelayedSimpleClickTimeout;
  42507. private _meshPickProceed;
  42508. private _previousButtonPressed;
  42509. private _currentPickResult;
  42510. private _previousPickResult;
  42511. private _totalPointersPressed;
  42512. private _doubleClickOccured;
  42513. private _pointerOverMesh;
  42514. private _pickedDownMesh;
  42515. private _pickedUpMesh;
  42516. private _pointerX;
  42517. private _pointerY;
  42518. private _unTranslatedPointerX;
  42519. private _unTranslatedPointerY;
  42520. private _startingPointerPosition;
  42521. private _previousStartingPointerPosition;
  42522. private _startingPointerTime;
  42523. private _previousStartingPointerTime;
  42524. private _pointerCaptures;
  42525. private _meshUnderPointerId;
  42526. private _onKeyDown;
  42527. private _onKeyUp;
  42528. private _keyboardIsAttached;
  42529. private _onCanvasFocusObserver;
  42530. private _onCanvasBlurObserver;
  42531. private _scene;
  42532. /**
  42533. * Creates a new InputManager
  42534. * @param scene defines the hosting scene
  42535. */
  42536. constructor(scene: Scene);
  42537. /**
  42538. * Gets the mesh that is currently under the pointer
  42539. */
  42540. get meshUnderPointer(): Nullable<AbstractMesh>;
  42541. /**
  42542. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42543. * @param pointerId the pointer id to use
  42544. * @returns The mesh under this pointer id or null if not found
  42545. */
  42546. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42547. /**
  42548. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42549. */
  42550. get unTranslatedPointer(): Vector2;
  42551. /**
  42552. * Gets or sets the current on-screen X position of the pointer
  42553. */
  42554. get pointerX(): number;
  42555. set pointerX(value: number);
  42556. /**
  42557. * Gets or sets the current on-screen Y position of the pointer
  42558. */
  42559. get pointerY(): number;
  42560. set pointerY(value: number);
  42561. private _updatePointerPosition;
  42562. private _processPointerMove;
  42563. private _setRayOnPointerInfo;
  42564. private _checkPrePointerObservable;
  42565. /**
  42566. * Use this method to simulate a pointer move on a mesh
  42567. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42568. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42569. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42570. */
  42571. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42572. /**
  42573. * Use this method to simulate a pointer down on a mesh
  42574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42577. */
  42578. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42579. private _processPointerDown;
  42580. /** @hidden */
  42581. _isPointerSwiping(): boolean;
  42582. /**
  42583. * Use this method to simulate a pointer up on a mesh
  42584. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42585. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42586. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42587. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42588. */
  42589. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42590. private _processPointerUp;
  42591. /**
  42592. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42593. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42594. * @returns true if the pointer was captured
  42595. */
  42596. isPointerCaptured(pointerId?: number): boolean;
  42597. /**
  42598. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42599. * @param attachUp defines if you want to attach events to pointerup
  42600. * @param attachDown defines if you want to attach events to pointerdown
  42601. * @param attachMove defines if you want to attach events to pointermove
  42602. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42603. */
  42604. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42605. /**
  42606. * Detaches all event handlers
  42607. */
  42608. detachControl(): void;
  42609. /**
  42610. * Force the value of meshUnderPointer
  42611. * @param mesh defines the mesh to use
  42612. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42613. */
  42614. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42615. /**
  42616. * Gets the mesh under the pointer
  42617. * @returns a Mesh or null if no mesh is under the pointer
  42618. */
  42619. getPointerOverMesh(): Nullable<AbstractMesh>;
  42620. }
  42621. }
  42622. declare module BABYLON {
  42623. /**
  42624. * This class defines the direct association between an animation and a target
  42625. */
  42626. export class TargetedAnimation {
  42627. /**
  42628. * Animation to perform
  42629. */
  42630. animation: Animation;
  42631. /**
  42632. * Target to animate
  42633. */
  42634. target: any;
  42635. /**
  42636. * Returns the string "TargetedAnimation"
  42637. * @returns "TargetedAnimation"
  42638. */
  42639. getClassName(): string;
  42640. /**
  42641. * Serialize the object
  42642. * @returns the JSON object representing the current entity
  42643. */
  42644. serialize(): any;
  42645. }
  42646. /**
  42647. * Use this class to create coordinated animations on multiple targets
  42648. */
  42649. export class AnimationGroup implements IDisposable {
  42650. /** The name of the animation group */
  42651. name: string;
  42652. private _scene;
  42653. private _targetedAnimations;
  42654. private _animatables;
  42655. private _from;
  42656. private _to;
  42657. private _isStarted;
  42658. private _isPaused;
  42659. private _speedRatio;
  42660. private _loopAnimation;
  42661. private _isAdditive;
  42662. /**
  42663. * Gets or sets the unique id of the node
  42664. */
  42665. uniqueId: number;
  42666. /**
  42667. * This observable will notify when one animation have ended
  42668. */
  42669. onAnimationEndObservable: Observable<TargetedAnimation>;
  42670. /**
  42671. * Observer raised when one animation loops
  42672. */
  42673. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42674. /**
  42675. * Observer raised when all animations have looped
  42676. */
  42677. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42678. /**
  42679. * This observable will notify when all animations have ended.
  42680. */
  42681. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42682. /**
  42683. * This observable will notify when all animations have paused.
  42684. */
  42685. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42686. /**
  42687. * This observable will notify when all animations are playing.
  42688. */
  42689. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42690. /**
  42691. * Gets the first frame
  42692. */
  42693. get from(): number;
  42694. /**
  42695. * Gets the last frame
  42696. */
  42697. get to(): number;
  42698. /**
  42699. * Define if the animations are started
  42700. */
  42701. get isStarted(): boolean;
  42702. /**
  42703. * Gets a value indicating that the current group is playing
  42704. */
  42705. get isPlaying(): boolean;
  42706. /**
  42707. * Gets or sets the speed ratio to use for all animations
  42708. */
  42709. get speedRatio(): number;
  42710. /**
  42711. * Gets or sets the speed ratio to use for all animations
  42712. */
  42713. set speedRatio(value: number);
  42714. /**
  42715. * Gets or sets if all animations should loop or not
  42716. */
  42717. get loopAnimation(): boolean;
  42718. set loopAnimation(value: boolean);
  42719. /**
  42720. * Gets or sets if all animations should be evaluated additively
  42721. */
  42722. get isAdditive(): boolean;
  42723. set isAdditive(value: boolean);
  42724. /**
  42725. * Gets the targeted animations for this animation group
  42726. */
  42727. get targetedAnimations(): Array<TargetedAnimation>;
  42728. /**
  42729. * returning the list of animatables controlled by this animation group.
  42730. */
  42731. get animatables(): Array<Animatable>;
  42732. /**
  42733. * Gets the list of target animations
  42734. */
  42735. get children(): TargetedAnimation[];
  42736. /**
  42737. * Instantiates a new Animation Group.
  42738. * This helps managing several animations at once.
  42739. * @see https://doc.babylonjs.com/how_to/group
  42740. * @param name Defines the name of the group
  42741. * @param scene Defines the scene the group belongs to
  42742. */
  42743. constructor(
  42744. /** The name of the animation group */
  42745. name: string, scene?: Nullable<Scene>);
  42746. /**
  42747. * Add an animation (with its target) in the group
  42748. * @param animation defines the animation we want to add
  42749. * @param target defines the target of the animation
  42750. * @returns the TargetedAnimation object
  42751. */
  42752. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42753. /**
  42754. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42755. * It can add constant keys at begin or end
  42756. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42757. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42758. * @returns the animation group
  42759. */
  42760. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42761. private _animationLoopCount;
  42762. private _animationLoopFlags;
  42763. private _processLoop;
  42764. /**
  42765. * Start all animations on given targets
  42766. * @param loop defines if animations must loop
  42767. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42768. * @param from defines the from key (optional)
  42769. * @param to defines the to key (optional)
  42770. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42771. * @returns the current animation group
  42772. */
  42773. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42774. /**
  42775. * Pause all animations
  42776. * @returns the animation group
  42777. */
  42778. pause(): AnimationGroup;
  42779. /**
  42780. * Play all animations to initial state
  42781. * This function will start() the animations if they were not started or will restart() them if they were paused
  42782. * @param loop defines if animations must loop
  42783. * @returns the animation group
  42784. */
  42785. play(loop?: boolean): AnimationGroup;
  42786. /**
  42787. * Reset all animations to initial state
  42788. * @returns the animation group
  42789. */
  42790. reset(): AnimationGroup;
  42791. /**
  42792. * Restart animations from key 0
  42793. * @returns the animation group
  42794. */
  42795. restart(): AnimationGroup;
  42796. /**
  42797. * Stop all animations
  42798. * @returns the animation group
  42799. */
  42800. stop(): AnimationGroup;
  42801. /**
  42802. * Set animation weight for all animatables
  42803. * @param weight defines the weight to use
  42804. * @return the animationGroup
  42805. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42806. */
  42807. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42808. /**
  42809. * Synchronize and normalize all animatables with a source animatable
  42810. * @param root defines the root animatable to synchronize with
  42811. * @return the animationGroup
  42812. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42813. */
  42814. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42815. /**
  42816. * Goes to a specific frame in this animation group
  42817. * @param frame the frame number to go to
  42818. * @return the animationGroup
  42819. */
  42820. goToFrame(frame: number): AnimationGroup;
  42821. /**
  42822. * Dispose all associated resources
  42823. */
  42824. dispose(): void;
  42825. private _checkAnimationGroupEnded;
  42826. /**
  42827. * Clone the current animation group and returns a copy
  42828. * @param newName defines the name of the new group
  42829. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42830. * @returns the new aniamtion group
  42831. */
  42832. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42833. /**
  42834. * Serializes the animationGroup to an object
  42835. * @returns Serialized object
  42836. */
  42837. serialize(): any;
  42838. /**
  42839. * Returns a new AnimationGroup object parsed from the source provided.
  42840. * @param parsedAnimationGroup defines the source
  42841. * @param scene defines the scene that will receive the animationGroup
  42842. * @returns a new AnimationGroup
  42843. */
  42844. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42845. /**
  42846. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42847. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42848. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42849. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42850. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42851. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42852. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42853. */
  42854. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42855. /**
  42856. * Returns the string "AnimationGroup"
  42857. * @returns "AnimationGroup"
  42858. */
  42859. getClassName(): string;
  42860. /**
  42861. * Creates a detailled string about the object
  42862. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42863. * @returns a string representing the object
  42864. */
  42865. toString(fullDetails?: boolean): string;
  42866. }
  42867. }
  42868. declare module BABYLON {
  42869. /**
  42870. * Define an interface for all classes that will hold resources
  42871. */
  42872. export interface IDisposable {
  42873. /**
  42874. * Releases all held resources
  42875. */
  42876. dispose(): void;
  42877. }
  42878. /** Interface defining initialization parameters for Scene class */
  42879. export interface SceneOptions {
  42880. /**
  42881. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42882. * It will improve performance when the number of geometries becomes important.
  42883. */
  42884. useGeometryUniqueIdsMap?: boolean;
  42885. /**
  42886. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42887. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42888. */
  42889. useMaterialMeshMap?: boolean;
  42890. /**
  42891. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42892. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42893. */
  42894. useClonedMeshMap?: boolean;
  42895. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42896. virtual?: boolean;
  42897. }
  42898. /**
  42899. * Represents a scene to be rendered by the engine.
  42900. * @see https://doc.babylonjs.com/features/scene
  42901. */
  42902. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42903. /** The fog is deactivated */
  42904. static readonly FOGMODE_NONE: number;
  42905. /** The fog density is following an exponential function */
  42906. static readonly FOGMODE_EXP: number;
  42907. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42908. static readonly FOGMODE_EXP2: number;
  42909. /** The fog density is following a linear function. */
  42910. static readonly FOGMODE_LINEAR: number;
  42911. /**
  42912. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42913. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42914. */
  42915. static MinDeltaTime: number;
  42916. /**
  42917. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42918. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42919. */
  42920. static MaxDeltaTime: number;
  42921. /**
  42922. * Factory used to create the default material.
  42923. * @param name The name of the material to create
  42924. * @param scene The scene to create the material for
  42925. * @returns The default material
  42926. */
  42927. static DefaultMaterialFactory(scene: Scene): Material;
  42928. /**
  42929. * Factory used to create the a collision coordinator.
  42930. * @returns The collision coordinator
  42931. */
  42932. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42933. /** @hidden */
  42934. _inputManager: InputManager;
  42935. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42936. cameraToUseForPointers: Nullable<Camera>;
  42937. /** @hidden */
  42938. readonly _isScene: boolean;
  42939. /** @hidden */
  42940. _blockEntityCollection: boolean;
  42941. /**
  42942. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42943. */
  42944. autoClear: boolean;
  42945. /**
  42946. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42947. */
  42948. autoClearDepthAndStencil: boolean;
  42949. /**
  42950. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42951. */
  42952. clearColor: Color4;
  42953. /**
  42954. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42955. */
  42956. ambientColor: Color3;
  42957. /**
  42958. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42959. * It should only be one of the following (if not the default embedded one):
  42960. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42961. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42962. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42963. * The material properties need to be setup according to the type of texture in use.
  42964. */
  42965. environmentBRDFTexture: BaseTexture;
  42966. /**
  42967. * Texture used in all pbr material as the reflection texture.
  42968. * As in the majority of the scene they are the same (exception for multi room and so on),
  42969. * this is easier to reference from here than from all the materials.
  42970. */
  42971. get environmentTexture(): Nullable<BaseTexture>;
  42972. /**
  42973. * Texture used in all pbr material as the reflection texture.
  42974. * As in the majority of the scene they are the same (exception for multi room and so on),
  42975. * this is easier to set here than in all the materials.
  42976. */
  42977. set environmentTexture(value: Nullable<BaseTexture>);
  42978. /** @hidden */
  42979. protected _environmentIntensity: number;
  42980. /**
  42981. * Intensity of the environment in all pbr material.
  42982. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42983. * As in the majority of the scene they are the same (exception for multi room and so on),
  42984. * this is easier to reference from here than from all the materials.
  42985. */
  42986. get environmentIntensity(): number;
  42987. /**
  42988. * Intensity of the environment in all pbr material.
  42989. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42990. * As in the majority of the scene they are the same (exception for multi room and so on),
  42991. * this is easier to set here than in all the materials.
  42992. */
  42993. set environmentIntensity(value: number);
  42994. /** @hidden */
  42995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42996. /**
  42997. * Default image processing configuration used either in the rendering
  42998. * Forward main pass or through the imageProcessingPostProcess if present.
  42999. * As in the majority of the scene they are the same (exception for multi camera),
  43000. * this is easier to reference from here than from all the materials and post process.
  43001. *
  43002. * No setter as we it is a shared configuration, you can set the values instead.
  43003. */
  43004. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43005. private _forceWireframe;
  43006. /**
  43007. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43008. */
  43009. set forceWireframe(value: boolean);
  43010. get forceWireframe(): boolean;
  43011. private _skipFrustumClipping;
  43012. /**
  43013. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43014. */
  43015. set skipFrustumClipping(value: boolean);
  43016. get skipFrustumClipping(): boolean;
  43017. private _forcePointsCloud;
  43018. /**
  43019. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43020. */
  43021. set forcePointsCloud(value: boolean);
  43022. get forcePointsCloud(): boolean;
  43023. /**
  43024. * Gets or sets the active clipplane 1
  43025. */
  43026. clipPlane: Nullable<Plane>;
  43027. /**
  43028. * Gets or sets the active clipplane 2
  43029. */
  43030. clipPlane2: Nullable<Plane>;
  43031. /**
  43032. * Gets or sets the active clipplane 3
  43033. */
  43034. clipPlane3: Nullable<Plane>;
  43035. /**
  43036. * Gets or sets the active clipplane 4
  43037. */
  43038. clipPlane4: Nullable<Plane>;
  43039. /**
  43040. * Gets or sets the active clipplane 5
  43041. */
  43042. clipPlane5: Nullable<Plane>;
  43043. /**
  43044. * Gets or sets the active clipplane 6
  43045. */
  43046. clipPlane6: Nullable<Plane>;
  43047. /**
  43048. * Gets or sets a boolean indicating if animations are enabled
  43049. */
  43050. animationsEnabled: boolean;
  43051. private _animationPropertiesOverride;
  43052. /**
  43053. * Gets or sets the animation properties override
  43054. */
  43055. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43056. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43057. /**
  43058. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43059. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43060. */
  43061. useConstantAnimationDeltaTime: boolean;
  43062. /**
  43063. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43064. * Please note that it requires to run a ray cast through the scene on every frame
  43065. */
  43066. constantlyUpdateMeshUnderPointer: boolean;
  43067. /**
  43068. * Defines the HTML cursor to use when hovering over interactive elements
  43069. */
  43070. hoverCursor: string;
  43071. /**
  43072. * Defines the HTML default cursor to use (empty by default)
  43073. */
  43074. defaultCursor: string;
  43075. /**
  43076. * Defines whether cursors are handled by the scene.
  43077. */
  43078. doNotHandleCursors: boolean;
  43079. /**
  43080. * This is used to call preventDefault() on pointer down
  43081. * in order to block unwanted artifacts like system double clicks
  43082. */
  43083. preventDefaultOnPointerDown: boolean;
  43084. /**
  43085. * This is used to call preventDefault() on pointer up
  43086. * in order to block unwanted artifacts like system double clicks
  43087. */
  43088. preventDefaultOnPointerUp: boolean;
  43089. /**
  43090. * Gets or sets user defined metadata
  43091. */
  43092. metadata: any;
  43093. /**
  43094. * For internal use only. Please do not use.
  43095. */
  43096. reservedDataStore: any;
  43097. /**
  43098. * Gets the name of the plugin used to load this scene (null by default)
  43099. */
  43100. loadingPluginName: string;
  43101. /**
  43102. * Use this array to add regular expressions used to disable offline support for specific urls
  43103. */
  43104. disableOfflineSupportExceptionRules: RegExp[];
  43105. /**
  43106. * An event triggered when the scene is disposed.
  43107. */
  43108. onDisposeObservable: Observable<Scene>;
  43109. private _onDisposeObserver;
  43110. /** Sets a function to be executed when this scene is disposed. */
  43111. set onDispose(callback: () => void);
  43112. /**
  43113. * An event triggered before rendering the scene (right after animations and physics)
  43114. */
  43115. onBeforeRenderObservable: Observable<Scene>;
  43116. private _onBeforeRenderObserver;
  43117. /** Sets a function to be executed before rendering this scene */
  43118. set beforeRender(callback: Nullable<() => void>);
  43119. /**
  43120. * An event triggered after rendering the scene
  43121. */
  43122. onAfterRenderObservable: Observable<Scene>;
  43123. /**
  43124. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43125. */
  43126. onAfterRenderCameraObservable: Observable<Camera>;
  43127. private _onAfterRenderObserver;
  43128. /** Sets a function to be executed after rendering this scene */
  43129. set afterRender(callback: Nullable<() => void>);
  43130. /**
  43131. * An event triggered before animating the scene
  43132. */
  43133. onBeforeAnimationsObservable: Observable<Scene>;
  43134. /**
  43135. * An event triggered after animations processing
  43136. */
  43137. onAfterAnimationsObservable: Observable<Scene>;
  43138. /**
  43139. * An event triggered before draw calls are ready to be sent
  43140. */
  43141. onBeforeDrawPhaseObservable: Observable<Scene>;
  43142. /**
  43143. * An event triggered after draw calls have been sent
  43144. */
  43145. onAfterDrawPhaseObservable: Observable<Scene>;
  43146. /**
  43147. * An event triggered when the scene is ready
  43148. */
  43149. onReadyObservable: Observable<Scene>;
  43150. /**
  43151. * An event triggered before rendering a camera
  43152. */
  43153. onBeforeCameraRenderObservable: Observable<Camera>;
  43154. private _onBeforeCameraRenderObserver;
  43155. /** Sets a function to be executed before rendering a camera*/
  43156. set beforeCameraRender(callback: () => void);
  43157. /**
  43158. * An event triggered after rendering a camera
  43159. */
  43160. onAfterCameraRenderObservable: Observable<Camera>;
  43161. private _onAfterCameraRenderObserver;
  43162. /** Sets a function to be executed after rendering a camera*/
  43163. set afterCameraRender(callback: () => void);
  43164. /**
  43165. * An event triggered when active meshes evaluation is about to start
  43166. */
  43167. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43168. /**
  43169. * An event triggered when active meshes evaluation is done
  43170. */
  43171. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43172. /**
  43173. * An event triggered when particles rendering is about to start
  43174. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43175. */
  43176. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43177. /**
  43178. * An event triggered when particles rendering is done
  43179. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43180. */
  43181. onAfterParticlesRenderingObservable: Observable<Scene>;
  43182. /**
  43183. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43184. */
  43185. onDataLoadedObservable: Observable<Scene>;
  43186. /**
  43187. * An event triggered when a camera is created
  43188. */
  43189. onNewCameraAddedObservable: Observable<Camera>;
  43190. /**
  43191. * An event triggered when a camera is removed
  43192. */
  43193. onCameraRemovedObservable: Observable<Camera>;
  43194. /**
  43195. * An event triggered when a light is created
  43196. */
  43197. onNewLightAddedObservable: Observable<Light>;
  43198. /**
  43199. * An event triggered when a light is removed
  43200. */
  43201. onLightRemovedObservable: Observable<Light>;
  43202. /**
  43203. * An event triggered when a geometry is created
  43204. */
  43205. onNewGeometryAddedObservable: Observable<Geometry>;
  43206. /**
  43207. * An event triggered when a geometry is removed
  43208. */
  43209. onGeometryRemovedObservable: Observable<Geometry>;
  43210. /**
  43211. * An event triggered when a transform node is created
  43212. */
  43213. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43214. /**
  43215. * An event triggered when a transform node is removed
  43216. */
  43217. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43218. /**
  43219. * An event triggered when a mesh is created
  43220. */
  43221. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43222. /**
  43223. * An event triggered when a mesh is removed
  43224. */
  43225. onMeshRemovedObservable: Observable<AbstractMesh>;
  43226. /**
  43227. * An event triggered when a skeleton is created
  43228. */
  43229. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43230. /**
  43231. * An event triggered when a skeleton is removed
  43232. */
  43233. onSkeletonRemovedObservable: Observable<Skeleton>;
  43234. /**
  43235. * An event triggered when a material is created
  43236. */
  43237. onNewMaterialAddedObservable: Observable<Material>;
  43238. /**
  43239. * An event triggered when a multi material is created
  43240. */
  43241. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43242. /**
  43243. * An event triggered when a material is removed
  43244. */
  43245. onMaterialRemovedObservable: Observable<Material>;
  43246. /**
  43247. * An event triggered when a multi material is removed
  43248. */
  43249. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43250. /**
  43251. * An event triggered when a texture is created
  43252. */
  43253. onNewTextureAddedObservable: Observable<BaseTexture>;
  43254. /**
  43255. * An event triggered when a texture is removed
  43256. */
  43257. onTextureRemovedObservable: Observable<BaseTexture>;
  43258. /**
  43259. * An event triggered when render targets are about to be rendered
  43260. * Can happen multiple times per frame.
  43261. */
  43262. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43263. /**
  43264. * An event triggered when render targets were rendered.
  43265. * Can happen multiple times per frame.
  43266. */
  43267. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43268. /**
  43269. * An event triggered before calculating deterministic simulation step
  43270. */
  43271. onBeforeStepObservable: Observable<Scene>;
  43272. /**
  43273. * An event triggered after calculating deterministic simulation step
  43274. */
  43275. onAfterStepObservable: Observable<Scene>;
  43276. /**
  43277. * An event triggered when the activeCamera property is updated
  43278. */
  43279. onActiveCameraChanged: Observable<Scene>;
  43280. /**
  43281. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43282. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43283. * 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)
  43284. */
  43285. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43286. /**
  43287. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43288. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43289. * 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)
  43290. */
  43291. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43292. /**
  43293. * This Observable will when a mesh has been imported into the scene.
  43294. */
  43295. onMeshImportedObservable: Observable<AbstractMesh>;
  43296. /**
  43297. * This Observable will when an animation file has been imported into the scene.
  43298. */
  43299. onAnimationFileImportedObservable: Observable<Scene>;
  43300. /**
  43301. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43302. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43303. */
  43304. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43305. /** @hidden */
  43306. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43307. /**
  43308. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43309. */
  43310. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43311. /**
  43312. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43313. */
  43314. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43315. /**
  43316. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43317. */
  43318. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43319. /** Callback called when a pointer move is detected */
  43320. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43321. /** Callback called when a pointer down is detected */
  43322. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43323. /** Callback called when a pointer up is detected */
  43324. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43325. /** Callback called when a pointer pick is detected */
  43326. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43327. /**
  43328. * 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).
  43329. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43330. */
  43331. onPrePointerObservable: Observable<PointerInfoPre>;
  43332. /**
  43333. * Observable event triggered each time an input event is received from the rendering canvas
  43334. */
  43335. onPointerObservable: Observable<PointerInfo>;
  43336. /**
  43337. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43338. */
  43339. get unTranslatedPointer(): Vector2;
  43340. /**
  43341. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43342. */
  43343. static get DragMovementThreshold(): number;
  43344. static set DragMovementThreshold(value: number);
  43345. /**
  43346. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43347. */
  43348. static get LongPressDelay(): number;
  43349. static set LongPressDelay(value: number);
  43350. /**
  43351. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43352. */
  43353. static get DoubleClickDelay(): number;
  43354. static set DoubleClickDelay(value: number);
  43355. /** If you need to check double click without raising a single click at first click, enable this flag */
  43356. static get ExclusiveDoubleClickMode(): boolean;
  43357. static set ExclusiveDoubleClickMode(value: boolean);
  43358. /** @hidden */
  43359. _mirroredCameraPosition: Nullable<Vector3>;
  43360. /**
  43361. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43362. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43363. */
  43364. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43365. /**
  43366. * Observable event triggered each time an keyboard event is received from the hosting window
  43367. */
  43368. onKeyboardObservable: Observable<KeyboardInfo>;
  43369. private _useRightHandedSystem;
  43370. /**
  43371. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43372. */
  43373. set useRightHandedSystem(value: boolean);
  43374. get useRightHandedSystem(): boolean;
  43375. private _timeAccumulator;
  43376. private _currentStepId;
  43377. private _currentInternalStep;
  43378. /**
  43379. * Sets the step Id used by deterministic lock step
  43380. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43381. * @param newStepId defines the step Id
  43382. */
  43383. setStepId(newStepId: number): void;
  43384. /**
  43385. * Gets the step Id used by deterministic lock step
  43386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43387. * @returns the step Id
  43388. */
  43389. getStepId(): number;
  43390. /**
  43391. * Gets the internal step used by deterministic lock step
  43392. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43393. * @returns the internal step
  43394. */
  43395. getInternalStep(): number;
  43396. private _fogEnabled;
  43397. /**
  43398. * Gets or sets a boolean indicating if fog is enabled on this scene
  43399. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43400. * (Default is true)
  43401. */
  43402. set fogEnabled(value: boolean);
  43403. get fogEnabled(): boolean;
  43404. private _fogMode;
  43405. /**
  43406. * Gets or sets the fog mode to use
  43407. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43408. * | mode | value |
  43409. * | --- | --- |
  43410. * | FOGMODE_NONE | 0 |
  43411. * | FOGMODE_EXP | 1 |
  43412. * | FOGMODE_EXP2 | 2 |
  43413. * | FOGMODE_LINEAR | 3 |
  43414. */
  43415. set fogMode(value: number);
  43416. get fogMode(): number;
  43417. /**
  43418. * Gets or sets the fog color to use
  43419. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43420. * (Default is Color3(0.2, 0.2, 0.3))
  43421. */
  43422. fogColor: Color3;
  43423. /**
  43424. * Gets or sets the fog density to use
  43425. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43426. * (Default is 0.1)
  43427. */
  43428. fogDensity: number;
  43429. /**
  43430. * Gets or sets the fog start distance to use
  43431. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43432. * (Default is 0)
  43433. */
  43434. fogStart: number;
  43435. /**
  43436. * Gets or sets the fog end distance to use
  43437. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43438. * (Default is 1000)
  43439. */
  43440. fogEnd: number;
  43441. /**
  43442. * Flag indicating that the frame buffer binding is handled by another component
  43443. */
  43444. prePass: boolean;
  43445. private _shadowsEnabled;
  43446. /**
  43447. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43448. */
  43449. set shadowsEnabled(value: boolean);
  43450. get shadowsEnabled(): boolean;
  43451. private _lightsEnabled;
  43452. /**
  43453. * Gets or sets a boolean indicating if lights are enabled on this scene
  43454. */
  43455. set lightsEnabled(value: boolean);
  43456. get lightsEnabled(): boolean;
  43457. /** All of the active cameras added to this scene. */
  43458. activeCameras: Nullable<Camera[]>;
  43459. /** @hidden */
  43460. _activeCamera: Nullable<Camera>;
  43461. /** Gets or sets the current active camera */
  43462. get activeCamera(): Nullable<Camera>;
  43463. set activeCamera(value: Nullable<Camera>);
  43464. private _defaultMaterial;
  43465. /** The default material used on meshes when no material is affected */
  43466. get defaultMaterial(): Material;
  43467. /** The default material used on meshes when no material is affected */
  43468. set defaultMaterial(value: Material);
  43469. private _texturesEnabled;
  43470. /**
  43471. * Gets or sets a boolean indicating if textures are enabled on this scene
  43472. */
  43473. set texturesEnabled(value: boolean);
  43474. get texturesEnabled(): boolean;
  43475. /**
  43476. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43477. */
  43478. physicsEnabled: boolean;
  43479. /**
  43480. * Gets or sets a boolean indicating if particles are enabled on this scene
  43481. */
  43482. particlesEnabled: boolean;
  43483. /**
  43484. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43485. */
  43486. spritesEnabled: boolean;
  43487. private _skeletonsEnabled;
  43488. /**
  43489. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43490. */
  43491. set skeletonsEnabled(value: boolean);
  43492. get skeletonsEnabled(): boolean;
  43493. /**
  43494. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43495. */
  43496. lensFlaresEnabled: boolean;
  43497. /**
  43498. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43499. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43500. */
  43501. collisionsEnabled: boolean;
  43502. private _collisionCoordinator;
  43503. /** @hidden */
  43504. get collisionCoordinator(): ICollisionCoordinator;
  43505. /**
  43506. * Defines the gravity applied to this scene (used only for collisions)
  43507. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43508. */
  43509. gravity: Vector3;
  43510. /**
  43511. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43512. */
  43513. postProcessesEnabled: boolean;
  43514. /**
  43515. * Gets the current postprocess manager
  43516. */
  43517. postProcessManager: PostProcessManager;
  43518. /**
  43519. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43520. */
  43521. renderTargetsEnabled: boolean;
  43522. /**
  43523. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43524. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43525. */
  43526. dumpNextRenderTargets: boolean;
  43527. /**
  43528. * The list of user defined render targets added to the scene
  43529. */
  43530. customRenderTargets: RenderTargetTexture[];
  43531. /**
  43532. * Defines if texture loading must be delayed
  43533. * If true, textures will only be loaded when they need to be rendered
  43534. */
  43535. useDelayedTextureLoading: boolean;
  43536. /**
  43537. * Gets the list of meshes imported to the scene through SceneLoader
  43538. */
  43539. importedMeshesFiles: String[];
  43540. /**
  43541. * Gets or sets a boolean indicating if probes are enabled on this scene
  43542. */
  43543. probesEnabled: boolean;
  43544. /**
  43545. * Gets or sets the current offline provider to use to store scene data
  43546. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43547. */
  43548. offlineProvider: IOfflineProvider;
  43549. /**
  43550. * Gets or sets the action manager associated with the scene
  43551. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43552. */
  43553. actionManager: AbstractActionManager;
  43554. private _meshesForIntersections;
  43555. /**
  43556. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43557. */
  43558. proceduralTexturesEnabled: boolean;
  43559. private _engine;
  43560. private _totalVertices;
  43561. /** @hidden */
  43562. _activeIndices: PerfCounter;
  43563. /** @hidden */
  43564. _activeParticles: PerfCounter;
  43565. /** @hidden */
  43566. _activeBones: PerfCounter;
  43567. private _animationRatio;
  43568. /** @hidden */
  43569. _animationTimeLast: number;
  43570. /** @hidden */
  43571. _animationTime: number;
  43572. /**
  43573. * Gets or sets a general scale for animation speed
  43574. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43575. */
  43576. animationTimeScale: number;
  43577. /** @hidden */
  43578. _cachedMaterial: Nullable<Material>;
  43579. /** @hidden */
  43580. _cachedEffect: Nullable<Effect>;
  43581. /** @hidden */
  43582. _cachedVisibility: Nullable<number>;
  43583. private _renderId;
  43584. private _frameId;
  43585. private _executeWhenReadyTimeoutId;
  43586. private _intermediateRendering;
  43587. private _viewUpdateFlag;
  43588. private _projectionUpdateFlag;
  43589. /** @hidden */
  43590. _toBeDisposed: Nullable<IDisposable>[];
  43591. private _activeRequests;
  43592. /** @hidden */
  43593. _pendingData: any[];
  43594. private _isDisposed;
  43595. /**
  43596. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43597. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43598. */
  43599. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43600. private _activeMeshes;
  43601. private _processedMaterials;
  43602. private _renderTargets;
  43603. /** @hidden */
  43604. _activeParticleSystems: SmartArray<IParticleSystem>;
  43605. private _activeSkeletons;
  43606. private _softwareSkinnedMeshes;
  43607. private _renderingManager;
  43608. /** @hidden */
  43609. _activeAnimatables: Animatable[];
  43610. private _transformMatrix;
  43611. private _sceneUbo;
  43612. /** @hidden */
  43613. _viewMatrix: Matrix;
  43614. private _projectionMatrix;
  43615. /** @hidden */
  43616. _forcedViewPosition: Nullable<Vector3>;
  43617. /** @hidden */
  43618. _frustumPlanes: Plane[];
  43619. /**
  43620. * Gets the list of frustum planes (built from the active camera)
  43621. */
  43622. get frustumPlanes(): Plane[];
  43623. /**
  43624. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43625. * This is useful if there are more lights that the maximum simulteanous authorized
  43626. */
  43627. requireLightSorting: boolean;
  43628. /** @hidden */
  43629. readonly useMaterialMeshMap: boolean;
  43630. /** @hidden */
  43631. readonly useClonedMeshMap: boolean;
  43632. private _externalData;
  43633. private _uid;
  43634. /**
  43635. * @hidden
  43636. * Backing store of defined scene components.
  43637. */
  43638. _components: ISceneComponent[];
  43639. /**
  43640. * @hidden
  43641. * Backing store of defined scene components.
  43642. */
  43643. _serializableComponents: ISceneSerializableComponent[];
  43644. /**
  43645. * List of components to register on the next registration step.
  43646. */
  43647. private _transientComponents;
  43648. /**
  43649. * Registers the transient components if needed.
  43650. */
  43651. private _registerTransientComponents;
  43652. /**
  43653. * @hidden
  43654. * Add a component to the scene.
  43655. * Note that the ccomponent could be registered on th next frame if this is called after
  43656. * the register component stage.
  43657. * @param component Defines the component to add to the scene
  43658. */
  43659. _addComponent(component: ISceneComponent): void;
  43660. /**
  43661. * @hidden
  43662. * Gets a component from the scene.
  43663. * @param name defines the name of the component to retrieve
  43664. * @returns the component or null if not present
  43665. */
  43666. _getComponent(name: string): Nullable<ISceneComponent>;
  43667. /**
  43668. * @hidden
  43669. * Defines the actions happening before camera updates.
  43670. */
  43671. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43672. /**
  43673. * @hidden
  43674. * Defines the actions happening before clear the canvas.
  43675. */
  43676. _beforeClearStage: Stage<SimpleStageAction>;
  43677. /**
  43678. * @hidden
  43679. * Defines the actions when collecting render targets for the frame.
  43680. */
  43681. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43682. /**
  43683. * @hidden
  43684. * Defines the actions happening for one camera in the frame.
  43685. */
  43686. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43687. /**
  43688. * @hidden
  43689. * Defines the actions happening during the per mesh ready checks.
  43690. */
  43691. _isReadyForMeshStage: Stage<MeshStageAction>;
  43692. /**
  43693. * @hidden
  43694. * Defines the actions happening before evaluate active mesh checks.
  43695. */
  43696. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43697. /**
  43698. * @hidden
  43699. * Defines the actions happening during the evaluate sub mesh checks.
  43700. */
  43701. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43702. /**
  43703. * @hidden
  43704. * Defines the actions happening during the active mesh stage.
  43705. */
  43706. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43707. /**
  43708. * @hidden
  43709. * Defines the actions happening during the per camera render target step.
  43710. */
  43711. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43712. /**
  43713. * @hidden
  43714. * Defines the actions happening just before the active camera is drawing.
  43715. */
  43716. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43717. /**
  43718. * @hidden
  43719. * Defines the actions happening just before a render target is drawing.
  43720. */
  43721. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43722. /**
  43723. * @hidden
  43724. * Defines the actions happening just before a rendering group is drawing.
  43725. */
  43726. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43727. /**
  43728. * @hidden
  43729. * Defines the actions happening just before a mesh is drawing.
  43730. */
  43731. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43732. /**
  43733. * @hidden
  43734. * Defines the actions happening just after a mesh has been drawn.
  43735. */
  43736. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43737. /**
  43738. * @hidden
  43739. * Defines the actions happening just after a rendering group has been drawn.
  43740. */
  43741. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43742. /**
  43743. * @hidden
  43744. * Defines the actions happening just after the active camera has been drawn.
  43745. */
  43746. _afterCameraDrawStage: Stage<CameraStageAction>;
  43747. /**
  43748. * @hidden
  43749. * Defines the actions happening just after a render target has been drawn.
  43750. */
  43751. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43752. /**
  43753. * @hidden
  43754. * Defines the actions happening just after rendering all cameras and computing intersections.
  43755. */
  43756. _afterRenderStage: Stage<SimpleStageAction>;
  43757. /**
  43758. * @hidden
  43759. * Defines the actions happening when a pointer move event happens.
  43760. */
  43761. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43762. /**
  43763. * @hidden
  43764. * Defines the actions happening when a pointer down event happens.
  43765. */
  43766. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43767. /**
  43768. * @hidden
  43769. * Defines the actions happening when a pointer up event happens.
  43770. */
  43771. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43772. /**
  43773. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43774. */
  43775. private geometriesByUniqueId;
  43776. /**
  43777. * Creates a new Scene
  43778. * @param engine defines the engine to use to render this scene
  43779. * @param options defines the scene options
  43780. */
  43781. constructor(engine: Engine, options?: SceneOptions);
  43782. /**
  43783. * Gets a string identifying the name of the class
  43784. * @returns "Scene" string
  43785. */
  43786. getClassName(): string;
  43787. private _defaultMeshCandidates;
  43788. /**
  43789. * @hidden
  43790. */
  43791. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43792. private _defaultSubMeshCandidates;
  43793. /**
  43794. * @hidden
  43795. */
  43796. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43797. /**
  43798. * Sets the default candidate providers for the scene.
  43799. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43800. * and getCollidingSubMeshCandidates to their default function
  43801. */
  43802. setDefaultCandidateProviders(): void;
  43803. /**
  43804. * Gets the mesh that is currently under the pointer
  43805. */
  43806. get meshUnderPointer(): Nullable<AbstractMesh>;
  43807. /**
  43808. * Gets or sets the current on-screen X position of the pointer
  43809. */
  43810. get pointerX(): number;
  43811. set pointerX(value: number);
  43812. /**
  43813. * Gets or sets the current on-screen Y position of the pointer
  43814. */
  43815. get pointerY(): number;
  43816. set pointerY(value: number);
  43817. /**
  43818. * Gets the cached material (ie. the latest rendered one)
  43819. * @returns the cached material
  43820. */
  43821. getCachedMaterial(): Nullable<Material>;
  43822. /**
  43823. * Gets the cached effect (ie. the latest rendered one)
  43824. * @returns the cached effect
  43825. */
  43826. getCachedEffect(): Nullable<Effect>;
  43827. /**
  43828. * Gets the cached visibility state (ie. the latest rendered one)
  43829. * @returns the cached visibility state
  43830. */
  43831. getCachedVisibility(): Nullable<number>;
  43832. /**
  43833. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43834. * @param material defines the current material
  43835. * @param effect defines the current effect
  43836. * @param visibility defines the current visibility state
  43837. * @returns true if one parameter is not cached
  43838. */
  43839. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43840. /**
  43841. * Gets the engine associated with the scene
  43842. * @returns an Engine
  43843. */
  43844. getEngine(): Engine;
  43845. /**
  43846. * Gets the total number of vertices rendered per frame
  43847. * @returns the total number of vertices rendered per frame
  43848. */
  43849. getTotalVertices(): number;
  43850. /**
  43851. * Gets the performance counter for total vertices
  43852. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43853. */
  43854. get totalVerticesPerfCounter(): PerfCounter;
  43855. /**
  43856. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43857. * @returns the total number of active indices rendered per frame
  43858. */
  43859. getActiveIndices(): number;
  43860. /**
  43861. * Gets the performance counter for active indices
  43862. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43863. */
  43864. get totalActiveIndicesPerfCounter(): PerfCounter;
  43865. /**
  43866. * Gets the total number of active particles rendered per frame
  43867. * @returns the total number of active particles rendered per frame
  43868. */
  43869. getActiveParticles(): number;
  43870. /**
  43871. * Gets the performance counter for active particles
  43872. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43873. */
  43874. get activeParticlesPerfCounter(): PerfCounter;
  43875. /**
  43876. * Gets the total number of active bones rendered per frame
  43877. * @returns the total number of active bones rendered per frame
  43878. */
  43879. getActiveBones(): number;
  43880. /**
  43881. * Gets the performance counter for active bones
  43882. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43883. */
  43884. get activeBonesPerfCounter(): PerfCounter;
  43885. /**
  43886. * Gets the array of active meshes
  43887. * @returns an array of AbstractMesh
  43888. */
  43889. getActiveMeshes(): SmartArray<AbstractMesh>;
  43890. /**
  43891. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43892. * @returns a number
  43893. */
  43894. getAnimationRatio(): number;
  43895. /**
  43896. * Gets an unique Id for the current render phase
  43897. * @returns a number
  43898. */
  43899. getRenderId(): number;
  43900. /**
  43901. * Gets an unique Id for the current frame
  43902. * @returns a number
  43903. */
  43904. getFrameId(): number;
  43905. /** Call this function if you want to manually increment the render Id*/
  43906. incrementRenderId(): void;
  43907. private _createUbo;
  43908. /**
  43909. * Use this method to simulate a pointer move on a mesh
  43910. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43911. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43912. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43913. * @returns the current scene
  43914. */
  43915. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43916. /**
  43917. * Use this method to simulate a pointer down on a mesh
  43918. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43919. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43920. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43921. * @returns the current scene
  43922. */
  43923. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43924. /**
  43925. * Use this method to simulate a pointer up on a mesh
  43926. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43927. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43928. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43929. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43930. * @returns the current scene
  43931. */
  43932. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43933. /**
  43934. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43935. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43936. * @returns true if the pointer was captured
  43937. */
  43938. isPointerCaptured(pointerId?: number): boolean;
  43939. /**
  43940. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43941. * @param attachUp defines if you want to attach events to pointerup
  43942. * @param attachDown defines if you want to attach events to pointerdown
  43943. * @param attachMove defines if you want to attach events to pointermove
  43944. */
  43945. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43946. /** Detaches all event handlers*/
  43947. detachControl(): void;
  43948. /**
  43949. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43950. * Delay loaded resources are not taking in account
  43951. * @return true if all required resources are ready
  43952. */
  43953. isReady(): boolean;
  43954. /** Resets all cached information relative to material (including effect and visibility) */
  43955. resetCachedMaterial(): void;
  43956. /**
  43957. * Registers a function to be called before every frame render
  43958. * @param func defines the function to register
  43959. */
  43960. registerBeforeRender(func: () => void): void;
  43961. /**
  43962. * Unregisters a function called before every frame render
  43963. * @param func defines the function to unregister
  43964. */
  43965. unregisterBeforeRender(func: () => void): void;
  43966. /**
  43967. * Registers a function to be called after every frame render
  43968. * @param func defines the function to register
  43969. */
  43970. registerAfterRender(func: () => void): void;
  43971. /**
  43972. * Unregisters a function called after every frame render
  43973. * @param func defines the function to unregister
  43974. */
  43975. unregisterAfterRender(func: () => void): void;
  43976. private _executeOnceBeforeRender;
  43977. /**
  43978. * The provided function will run before render once and will be disposed afterwards.
  43979. * A timeout delay can be provided so that the function will be executed in N ms.
  43980. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43981. * @param func The function to be executed.
  43982. * @param timeout optional delay in ms
  43983. */
  43984. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43985. /** @hidden */
  43986. _addPendingData(data: any): void;
  43987. /** @hidden */
  43988. _removePendingData(data: any): void;
  43989. /**
  43990. * Returns the number of items waiting to be loaded
  43991. * @returns the number of items waiting to be loaded
  43992. */
  43993. getWaitingItemsCount(): number;
  43994. /**
  43995. * Returns a boolean indicating if the scene is still loading data
  43996. */
  43997. get isLoading(): boolean;
  43998. /**
  43999. * Registers a function to be executed when the scene is ready
  44000. * @param {Function} func - the function to be executed
  44001. */
  44002. executeWhenReady(func: () => void): void;
  44003. /**
  44004. * Returns a promise that resolves when the scene is ready
  44005. * @returns A promise that resolves when the scene is ready
  44006. */
  44007. whenReadyAsync(): Promise<void>;
  44008. /** @hidden */
  44009. _checkIsReady(): void;
  44010. /**
  44011. * Gets all animatable attached to the scene
  44012. */
  44013. get animatables(): Animatable[];
  44014. /**
  44015. * Resets the last animation time frame.
  44016. * Useful to override when animations start running when loading a scene for the first time.
  44017. */
  44018. resetLastAnimationTimeFrame(): void;
  44019. /**
  44020. * Gets the current view matrix
  44021. * @returns a Matrix
  44022. */
  44023. getViewMatrix(): Matrix;
  44024. /**
  44025. * Gets the current projection matrix
  44026. * @returns a Matrix
  44027. */
  44028. getProjectionMatrix(): Matrix;
  44029. /**
  44030. * Gets the current transform matrix
  44031. * @returns a Matrix made of View * Projection
  44032. */
  44033. getTransformMatrix(): Matrix;
  44034. /**
  44035. * Sets the current transform matrix
  44036. * @param viewL defines the View matrix to use
  44037. * @param projectionL defines the Projection matrix to use
  44038. * @param viewR defines the right View matrix to use (if provided)
  44039. * @param projectionR defines the right Projection matrix to use (if provided)
  44040. */
  44041. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44042. /**
  44043. * Gets the uniform buffer used to store scene data
  44044. * @returns a UniformBuffer
  44045. */
  44046. getSceneUniformBuffer(): UniformBuffer;
  44047. /**
  44048. * Gets an unique (relatively to the current scene) Id
  44049. * @returns an unique number for the scene
  44050. */
  44051. getUniqueId(): number;
  44052. /**
  44053. * Add a mesh to the list of scene's meshes
  44054. * @param newMesh defines the mesh to add
  44055. * @param recursive if all child meshes should also be added to the scene
  44056. */
  44057. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44058. /**
  44059. * Remove a mesh for the list of scene's meshes
  44060. * @param toRemove defines the mesh to remove
  44061. * @param recursive if all child meshes should also be removed from the scene
  44062. * @returns the index where the mesh was in the mesh list
  44063. */
  44064. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44065. /**
  44066. * Add a transform node to the list of scene's transform nodes
  44067. * @param newTransformNode defines the transform node to add
  44068. */
  44069. addTransformNode(newTransformNode: TransformNode): void;
  44070. /**
  44071. * Remove a transform node for the list of scene's transform nodes
  44072. * @param toRemove defines the transform node to remove
  44073. * @returns the index where the transform node was in the transform node list
  44074. */
  44075. removeTransformNode(toRemove: TransformNode): number;
  44076. /**
  44077. * Remove a skeleton for the list of scene's skeletons
  44078. * @param toRemove defines the skeleton to remove
  44079. * @returns the index where the skeleton was in the skeleton list
  44080. */
  44081. removeSkeleton(toRemove: Skeleton): number;
  44082. /**
  44083. * Remove a morph target for the list of scene's morph targets
  44084. * @param toRemove defines the morph target to remove
  44085. * @returns the index where the morph target was in the morph target list
  44086. */
  44087. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44088. /**
  44089. * Remove a light for the list of scene's lights
  44090. * @param toRemove defines the light to remove
  44091. * @returns the index where the light was in the light list
  44092. */
  44093. removeLight(toRemove: Light): number;
  44094. /**
  44095. * Remove a camera for the list of scene's cameras
  44096. * @param toRemove defines the camera to remove
  44097. * @returns the index where the camera was in the camera list
  44098. */
  44099. removeCamera(toRemove: Camera): number;
  44100. /**
  44101. * Remove a particle system for the list of scene's particle systems
  44102. * @param toRemove defines the particle system to remove
  44103. * @returns the index where the particle system was in the particle system list
  44104. */
  44105. removeParticleSystem(toRemove: IParticleSystem): number;
  44106. /**
  44107. * Remove a animation for the list of scene's animations
  44108. * @param toRemove defines the animation to remove
  44109. * @returns the index where the animation was in the animation list
  44110. */
  44111. removeAnimation(toRemove: Animation): number;
  44112. /**
  44113. * Will stop the animation of the given target
  44114. * @param target - the target
  44115. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44116. * @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)
  44117. */
  44118. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44119. /**
  44120. * Removes the given animation group from this scene.
  44121. * @param toRemove The animation group to remove
  44122. * @returns The index of the removed animation group
  44123. */
  44124. removeAnimationGroup(toRemove: AnimationGroup): number;
  44125. /**
  44126. * Removes the given multi-material from this scene.
  44127. * @param toRemove The multi-material to remove
  44128. * @returns The index of the removed multi-material
  44129. */
  44130. removeMultiMaterial(toRemove: MultiMaterial): number;
  44131. /**
  44132. * Removes the given material from this scene.
  44133. * @param toRemove The material to remove
  44134. * @returns The index of the removed material
  44135. */
  44136. removeMaterial(toRemove: Material): number;
  44137. /**
  44138. * Removes the given action manager from this scene.
  44139. * @param toRemove The action manager to remove
  44140. * @returns The index of the removed action manager
  44141. */
  44142. removeActionManager(toRemove: AbstractActionManager): number;
  44143. /**
  44144. * Removes the given texture from this scene.
  44145. * @param toRemove The texture to remove
  44146. * @returns The index of the removed texture
  44147. */
  44148. removeTexture(toRemove: BaseTexture): number;
  44149. /**
  44150. * Adds the given light to this scene
  44151. * @param newLight The light to add
  44152. */
  44153. addLight(newLight: Light): void;
  44154. /**
  44155. * Sorts the list list based on light priorities
  44156. */
  44157. sortLightsByPriority(): void;
  44158. /**
  44159. * Adds the given camera to this scene
  44160. * @param newCamera The camera to add
  44161. */
  44162. addCamera(newCamera: Camera): void;
  44163. /**
  44164. * Adds the given skeleton to this scene
  44165. * @param newSkeleton The skeleton to add
  44166. */
  44167. addSkeleton(newSkeleton: Skeleton): void;
  44168. /**
  44169. * Adds the given particle system to this scene
  44170. * @param newParticleSystem The particle system to add
  44171. */
  44172. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44173. /**
  44174. * Adds the given animation to this scene
  44175. * @param newAnimation The animation to add
  44176. */
  44177. addAnimation(newAnimation: Animation): void;
  44178. /**
  44179. * Adds the given animation group to this scene.
  44180. * @param newAnimationGroup The animation group to add
  44181. */
  44182. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44183. /**
  44184. * Adds the given multi-material to this scene
  44185. * @param newMultiMaterial The multi-material to add
  44186. */
  44187. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44188. /**
  44189. * Adds the given material to this scene
  44190. * @param newMaterial The material to add
  44191. */
  44192. addMaterial(newMaterial: Material): void;
  44193. /**
  44194. * Adds the given morph target to this scene
  44195. * @param newMorphTargetManager The morph target to add
  44196. */
  44197. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44198. /**
  44199. * Adds the given geometry to this scene
  44200. * @param newGeometry The geometry to add
  44201. */
  44202. addGeometry(newGeometry: Geometry): void;
  44203. /**
  44204. * Adds the given action manager to this scene
  44205. * @param newActionManager The action manager to add
  44206. */
  44207. addActionManager(newActionManager: AbstractActionManager): void;
  44208. /**
  44209. * Adds the given texture to this scene.
  44210. * @param newTexture The texture to add
  44211. */
  44212. addTexture(newTexture: BaseTexture): void;
  44213. /**
  44214. * Switch active camera
  44215. * @param newCamera defines the new active camera
  44216. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44217. */
  44218. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44219. /**
  44220. * sets the active camera of the scene using its ID
  44221. * @param id defines the camera's ID
  44222. * @return the new active camera or null if none found.
  44223. */
  44224. setActiveCameraByID(id: string): Nullable<Camera>;
  44225. /**
  44226. * sets the active camera of the scene using its name
  44227. * @param name defines the camera's name
  44228. * @returns the new active camera or null if none found.
  44229. */
  44230. setActiveCameraByName(name: string): Nullable<Camera>;
  44231. /**
  44232. * get an animation group using its name
  44233. * @param name defines the material's name
  44234. * @return the animation group or null if none found.
  44235. */
  44236. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44237. /**
  44238. * Get a material using its unique id
  44239. * @param uniqueId defines the material's unique id
  44240. * @return the material or null if none found.
  44241. */
  44242. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44243. /**
  44244. * get a material using its id
  44245. * @param id defines the material's ID
  44246. * @return the material or null if none found.
  44247. */
  44248. getMaterialByID(id: string): Nullable<Material>;
  44249. /**
  44250. * Gets a the last added material using a given id
  44251. * @param id defines the material's ID
  44252. * @return the last material with the given id or null if none found.
  44253. */
  44254. getLastMaterialByID(id: string): Nullable<Material>;
  44255. /**
  44256. * Gets a material using its name
  44257. * @param name defines the material's name
  44258. * @return the material or null if none found.
  44259. */
  44260. getMaterialByName(name: string): Nullable<Material>;
  44261. /**
  44262. * Get a texture using its unique id
  44263. * @param uniqueId defines the texture's unique id
  44264. * @return the texture or null if none found.
  44265. */
  44266. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44267. /**
  44268. * Gets a camera using its id
  44269. * @param id defines the id to look for
  44270. * @returns the camera or null if not found
  44271. */
  44272. getCameraByID(id: string): Nullable<Camera>;
  44273. /**
  44274. * Gets a camera using its unique id
  44275. * @param uniqueId defines the unique id to look for
  44276. * @returns the camera or null if not found
  44277. */
  44278. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44279. /**
  44280. * Gets a camera using its name
  44281. * @param name defines the camera's name
  44282. * @return the camera or null if none found.
  44283. */
  44284. getCameraByName(name: string): Nullable<Camera>;
  44285. /**
  44286. * Gets a bone using its id
  44287. * @param id defines the bone's id
  44288. * @return the bone or null if not found
  44289. */
  44290. getBoneByID(id: string): Nullable<Bone>;
  44291. /**
  44292. * Gets a bone using its id
  44293. * @param name defines the bone's name
  44294. * @return the bone or null if not found
  44295. */
  44296. getBoneByName(name: string): Nullable<Bone>;
  44297. /**
  44298. * Gets a light node using its name
  44299. * @param name defines the the light's name
  44300. * @return the light or null if none found.
  44301. */
  44302. getLightByName(name: string): Nullable<Light>;
  44303. /**
  44304. * Gets a light node using its id
  44305. * @param id defines the light's id
  44306. * @return the light or null if none found.
  44307. */
  44308. getLightByID(id: string): Nullable<Light>;
  44309. /**
  44310. * Gets a light node using its scene-generated unique ID
  44311. * @param uniqueId defines the light's unique id
  44312. * @return the light or null if none found.
  44313. */
  44314. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44315. /**
  44316. * Gets a particle system by id
  44317. * @param id defines the particle system id
  44318. * @return the corresponding system or null if none found
  44319. */
  44320. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44321. /**
  44322. * Gets a geometry using its ID
  44323. * @param id defines the geometry's id
  44324. * @return the geometry or null if none found.
  44325. */
  44326. getGeometryByID(id: string): Nullable<Geometry>;
  44327. private _getGeometryByUniqueID;
  44328. /**
  44329. * Add a new geometry to this scene
  44330. * @param geometry defines the geometry to be added to the scene.
  44331. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44332. * @return a boolean defining if the geometry was added or not
  44333. */
  44334. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44335. /**
  44336. * Removes an existing geometry
  44337. * @param geometry defines the geometry to be removed from the scene
  44338. * @return a boolean defining if the geometry was removed or not
  44339. */
  44340. removeGeometry(geometry: Geometry): boolean;
  44341. /**
  44342. * Gets the list of geometries attached to the scene
  44343. * @returns an array of Geometry
  44344. */
  44345. getGeometries(): Geometry[];
  44346. /**
  44347. * Gets the first added mesh found of a given ID
  44348. * @param id defines the id to search for
  44349. * @return the mesh found or null if not found at all
  44350. */
  44351. getMeshByID(id: string): Nullable<AbstractMesh>;
  44352. /**
  44353. * Gets a list of meshes using their id
  44354. * @param id defines the id to search for
  44355. * @returns a list of meshes
  44356. */
  44357. getMeshesByID(id: string): Array<AbstractMesh>;
  44358. /**
  44359. * Gets the first added transform node found of a given ID
  44360. * @param id defines the id to search for
  44361. * @return the found transform node or null if not found at all.
  44362. */
  44363. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44364. /**
  44365. * Gets a transform node with its auto-generated unique id
  44366. * @param uniqueId efines the unique id to search for
  44367. * @return the found transform node or null if not found at all.
  44368. */
  44369. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44370. /**
  44371. * Gets a list of transform nodes using their id
  44372. * @param id defines the id to search for
  44373. * @returns a list of transform nodes
  44374. */
  44375. getTransformNodesByID(id: string): Array<TransformNode>;
  44376. /**
  44377. * Gets a mesh with its auto-generated unique id
  44378. * @param uniqueId defines the unique id to search for
  44379. * @return the found mesh or null if not found at all.
  44380. */
  44381. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44382. /**
  44383. * Gets a the last added mesh using a given id
  44384. * @param id defines the id to search for
  44385. * @return the found mesh or null if not found at all.
  44386. */
  44387. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44388. /**
  44389. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44390. * @param id defines the id to search for
  44391. * @return the found node or null if not found at all
  44392. */
  44393. getLastEntryByID(id: string): Nullable<Node>;
  44394. /**
  44395. * Gets a node (Mesh, Camera, Light) using a given id
  44396. * @param id defines the id to search for
  44397. * @return the found node or null if not found at all
  44398. */
  44399. getNodeByID(id: string): Nullable<Node>;
  44400. /**
  44401. * Gets a node (Mesh, Camera, Light) using a given name
  44402. * @param name defines the name to search for
  44403. * @return the found node or null if not found at all.
  44404. */
  44405. getNodeByName(name: string): Nullable<Node>;
  44406. /**
  44407. * Gets a mesh using a given name
  44408. * @param name defines the name to search for
  44409. * @return the found mesh or null if not found at all.
  44410. */
  44411. getMeshByName(name: string): Nullable<AbstractMesh>;
  44412. /**
  44413. * Gets a transform node using a given name
  44414. * @param name defines the name to search for
  44415. * @return the found transform node or null if not found at all.
  44416. */
  44417. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44418. /**
  44419. * Gets a skeleton 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 skeleton or null if not found at all.
  44422. */
  44423. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44424. /**
  44425. * Gets a skeleton using a given auto generated unique id
  44426. * @param uniqueId defines the unique id to search for
  44427. * @return the found skeleton or null if not found at all.
  44428. */
  44429. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44430. /**
  44431. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44432. * @param id defines the id to search for
  44433. * @return the found skeleton or null if not found at all.
  44434. */
  44435. getSkeletonById(id: string): Nullable<Skeleton>;
  44436. /**
  44437. * Gets a skeleton using a given name
  44438. * @param name defines the name to search for
  44439. * @return the found skeleton or null if not found at all.
  44440. */
  44441. getSkeletonByName(name: string): Nullable<Skeleton>;
  44442. /**
  44443. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44444. * @param id defines the id to search for
  44445. * @return the found morph target manager or null if not found at all.
  44446. */
  44447. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44448. /**
  44449. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44450. * @param id defines the id to search for
  44451. * @return the found morph target or null if not found at all.
  44452. */
  44453. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44454. /**
  44455. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44456. * @param name defines the name to search for
  44457. * @return the found morph target or null if not found at all.
  44458. */
  44459. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44460. /**
  44461. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44462. * @param name defines the name to search for
  44463. * @return the found post process or null if not found at all.
  44464. */
  44465. getPostProcessByName(name: string): Nullable<PostProcess>;
  44466. /**
  44467. * Gets a boolean indicating if the given mesh is active
  44468. * @param mesh defines the mesh to look for
  44469. * @returns true if the mesh is in the active list
  44470. */
  44471. isActiveMesh(mesh: AbstractMesh): boolean;
  44472. /**
  44473. * Return a unique id as a string which can serve as an identifier for the scene
  44474. */
  44475. get uid(): string;
  44476. /**
  44477. * Add an externaly attached data from its key.
  44478. * This method call will fail and return false, if such key already exists.
  44479. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44480. * @param key the unique key that identifies the data
  44481. * @param data the data object to associate to the key for this Engine instance
  44482. * @return true if no such key were already present and the data was added successfully, false otherwise
  44483. */
  44484. addExternalData<T>(key: string, data: T): boolean;
  44485. /**
  44486. * Get an externaly attached data from its key
  44487. * @param key the unique key that identifies the data
  44488. * @return the associated data, if present (can be null), or undefined if not present
  44489. */
  44490. getExternalData<T>(key: string): Nullable<T>;
  44491. /**
  44492. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44493. * @param key the unique key that identifies the data
  44494. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44495. * @return the associated data, can be null if the factory returned null.
  44496. */
  44497. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44498. /**
  44499. * Remove an externaly attached data from the Engine instance
  44500. * @param key the unique key that identifies the data
  44501. * @return true if the data was successfully removed, false if it doesn't exist
  44502. */
  44503. removeExternalData(key: string): boolean;
  44504. private _evaluateSubMesh;
  44505. /**
  44506. * Clear the processed materials smart array preventing retention point in material dispose.
  44507. */
  44508. freeProcessedMaterials(): void;
  44509. private _preventFreeActiveMeshesAndRenderingGroups;
  44510. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44511. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44512. * when disposing several meshes in a row or a hierarchy of meshes.
  44513. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44514. */
  44515. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44516. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44517. /**
  44518. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44519. */
  44520. freeActiveMeshes(): void;
  44521. /**
  44522. * Clear the info related to rendering groups preventing retention points during dispose.
  44523. */
  44524. freeRenderingGroups(): void;
  44525. /** @hidden */
  44526. _isInIntermediateRendering(): boolean;
  44527. /**
  44528. * Lambda returning the list of potentially active meshes.
  44529. */
  44530. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44531. /**
  44532. * Lambda returning the list of potentially active sub meshes.
  44533. */
  44534. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44535. /**
  44536. * Lambda returning the list of potentially intersecting sub meshes.
  44537. */
  44538. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44539. /**
  44540. * Lambda returning the list of potentially colliding sub meshes.
  44541. */
  44542. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44543. /** @hidden */
  44544. _activeMeshesFrozen: boolean;
  44545. private _skipEvaluateActiveMeshesCompletely;
  44546. /**
  44547. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44548. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44549. * @param onSuccess optional success callback
  44550. * @param onError optional error callback
  44551. * @returns the current scene
  44552. */
  44553. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44554. /**
  44555. * Use this function to restart evaluating active meshes on every frame
  44556. * @returns the current scene
  44557. */
  44558. unfreezeActiveMeshes(): Scene;
  44559. private _evaluateActiveMeshes;
  44560. private _activeMesh;
  44561. /**
  44562. * Update the transform matrix to update from the current active camera
  44563. * @param force defines a boolean used to force the update even if cache is up to date
  44564. */
  44565. updateTransformMatrix(force?: boolean): void;
  44566. private _bindFrameBuffer;
  44567. /** @hidden */
  44568. _allowPostProcessClearColor: boolean;
  44569. /** @hidden */
  44570. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44571. private _processSubCameras;
  44572. private _checkIntersections;
  44573. /** @hidden */
  44574. _advancePhysicsEngineStep(step: number): void;
  44575. /**
  44576. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44577. */
  44578. getDeterministicFrameTime: () => number;
  44579. /** @hidden */
  44580. _animate(): void;
  44581. /** Execute all animations (for a frame) */
  44582. animate(): void;
  44583. /**
  44584. * Render the scene
  44585. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44586. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44587. */
  44588. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44589. /**
  44590. * Freeze all materials
  44591. * A frozen material will not be updatable but should be faster to render
  44592. */
  44593. freezeMaterials(): void;
  44594. /**
  44595. * Unfreeze all materials
  44596. * A frozen material will not be updatable but should be faster to render
  44597. */
  44598. unfreezeMaterials(): void;
  44599. /**
  44600. * Releases all held ressources
  44601. */
  44602. dispose(): void;
  44603. /**
  44604. * Gets if the scene is already disposed
  44605. */
  44606. get isDisposed(): boolean;
  44607. /**
  44608. * Call this function to reduce memory footprint of the scene.
  44609. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44610. */
  44611. clearCachedVertexData(): void;
  44612. /**
  44613. * This function will remove the local cached buffer data from texture.
  44614. * It will save memory but will prevent the texture from being rebuilt
  44615. */
  44616. cleanCachedTextureBuffer(): void;
  44617. /**
  44618. * Get the world extend vectors with an optional filter
  44619. *
  44620. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44621. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44622. */
  44623. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44624. min: Vector3;
  44625. max: Vector3;
  44626. };
  44627. /**
  44628. * Creates a ray that can be used to pick in the scene
  44629. * @param x defines the x coordinate of the origin (on-screen)
  44630. * @param y defines the y coordinate of the origin (on-screen)
  44631. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44632. * @param camera defines the camera to use for the picking
  44633. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44634. * @returns a Ray
  44635. */
  44636. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44637. /**
  44638. * Creates a ray that can be used to pick in the scene
  44639. * @param x defines the x coordinate of the origin (on-screen)
  44640. * @param y defines the y coordinate of the origin (on-screen)
  44641. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44642. * @param result defines the ray where to store the picking ray
  44643. * @param camera defines the camera to use for the picking
  44644. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44645. * @returns the current scene
  44646. */
  44647. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44648. /**
  44649. * Creates a ray that can be used to pick in the scene
  44650. * @param x defines the x coordinate of the origin (on-screen)
  44651. * @param y defines the y coordinate of the origin (on-screen)
  44652. * @param camera defines the camera to use for the picking
  44653. * @returns a Ray
  44654. */
  44655. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44656. /**
  44657. * Creates a ray that can be used to pick in the scene
  44658. * @param x defines the x coordinate of the origin (on-screen)
  44659. * @param y defines the y coordinate of the origin (on-screen)
  44660. * @param result defines the ray where to store the picking ray
  44661. * @param camera defines the camera to use for the picking
  44662. * @returns the current scene
  44663. */
  44664. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44665. /** Launch a ray to try to pick a mesh in the scene
  44666. * @param x position on screen
  44667. * @param y position on screen
  44668. * @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
  44669. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44670. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44672. * @returns a PickingInfo
  44673. */
  44674. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44675. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44676. * @param x position on screen
  44677. * @param y position on screen
  44678. * @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
  44679. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44680. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44681. * @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)
  44682. */
  44683. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44684. /** Use the given ray to pick a mesh in the scene
  44685. * @param ray The ray to use to pick meshes
  44686. * @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
  44687. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44688. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44689. * @returns a PickingInfo
  44690. */
  44691. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44692. /**
  44693. * Launch a ray to try to pick a mesh in the scene
  44694. * @param x X position on screen
  44695. * @param y Y position on screen
  44696. * @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
  44697. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44698. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44699. * @returns an array of PickingInfo
  44700. */
  44701. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44702. /**
  44703. * Launch a ray to try to pick a mesh in the scene
  44704. * @param ray Ray to use
  44705. * @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
  44706. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44707. * @returns an array of PickingInfo
  44708. */
  44709. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44710. /**
  44711. * Force the value of meshUnderPointer
  44712. * @param mesh defines the mesh to use
  44713. * @param pointerId optional pointer id when using more than one pointer
  44714. */
  44715. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44716. /**
  44717. * Gets the mesh under the pointer
  44718. * @returns a Mesh or null if no mesh is under the pointer
  44719. */
  44720. getPointerOverMesh(): Nullable<AbstractMesh>;
  44721. /** @hidden */
  44722. _rebuildGeometries(): void;
  44723. /** @hidden */
  44724. _rebuildTextures(): void;
  44725. private _getByTags;
  44726. /**
  44727. * Get a list of meshes by tags
  44728. * @param tagsQuery defines the tags query to use
  44729. * @param forEach defines a predicate used to filter results
  44730. * @returns an array of Mesh
  44731. */
  44732. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44733. /**
  44734. * Get a list of cameras by tags
  44735. * @param tagsQuery defines the tags query to use
  44736. * @param forEach defines a predicate used to filter results
  44737. * @returns an array of Camera
  44738. */
  44739. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44740. /**
  44741. * Get a list of lights by tags
  44742. * @param tagsQuery defines the tags query to use
  44743. * @param forEach defines a predicate used to filter results
  44744. * @returns an array of Light
  44745. */
  44746. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44747. /**
  44748. * Get a list of materials by tags
  44749. * @param tagsQuery defines the tags query to use
  44750. * @param forEach defines a predicate used to filter results
  44751. * @returns an array of Material
  44752. */
  44753. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44754. /**
  44755. * Get a list of transform nodes by tags
  44756. * @param tagsQuery defines the tags query to use
  44757. * @param forEach defines a predicate used to filter results
  44758. * @returns an array of TransformNode
  44759. */
  44760. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44761. /**
  44762. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44763. * This allowed control for front to back rendering or reversly depending of the special needs.
  44764. *
  44765. * @param renderingGroupId The rendering group id corresponding to its index
  44766. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44767. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44768. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44769. */
  44770. 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;
  44771. /**
  44772. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44773. *
  44774. * @param renderingGroupId The rendering group id corresponding to its index
  44775. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44776. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44777. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44778. */
  44779. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44780. /**
  44781. * Gets the current auto clear configuration for one rendering group of the rendering
  44782. * manager.
  44783. * @param index the rendering group index to get the information for
  44784. * @returns The auto clear setup for the requested rendering group
  44785. */
  44786. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44787. private _blockMaterialDirtyMechanism;
  44788. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44789. get blockMaterialDirtyMechanism(): boolean;
  44790. set blockMaterialDirtyMechanism(value: boolean);
  44791. /**
  44792. * Will flag all materials as dirty to trigger new shader compilation
  44793. * @param flag defines the flag used to specify which material part must be marked as dirty
  44794. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44795. */
  44796. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44797. /** @hidden */
  44798. _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;
  44799. /** @hidden */
  44800. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44801. /** @hidden */
  44802. _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;
  44803. /** @hidden */
  44804. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44805. /** @hidden */
  44806. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44807. /** @hidden */
  44808. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44809. }
  44810. }
  44811. declare module BABYLON {
  44812. /**
  44813. * Set of assets to keep when moving a scene into an asset container.
  44814. */
  44815. export class KeepAssets extends AbstractScene {
  44816. }
  44817. /**
  44818. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44819. */
  44820. export class InstantiatedEntries {
  44821. /**
  44822. * List of new root nodes (eg. nodes with no parent)
  44823. */
  44824. rootNodes: TransformNode[];
  44825. /**
  44826. * List of new skeletons
  44827. */
  44828. skeletons: Skeleton[];
  44829. /**
  44830. * List of new animation groups
  44831. */
  44832. animationGroups: AnimationGroup[];
  44833. }
  44834. /**
  44835. * Container with a set of assets that can be added or removed from a scene.
  44836. */
  44837. export class AssetContainer extends AbstractScene {
  44838. private _wasAddedToScene;
  44839. /**
  44840. * The scene the AssetContainer belongs to.
  44841. */
  44842. scene: Scene;
  44843. /**
  44844. * Instantiates an AssetContainer.
  44845. * @param scene The scene the AssetContainer belongs to.
  44846. */
  44847. constructor(scene: Scene);
  44848. /**
  44849. * Instantiate or clone all meshes and add the new ones to the scene.
  44850. * Skeletons and animation groups will all be cloned
  44851. * @param nameFunction defines an optional function used to get new names for clones
  44852. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44853. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44854. */
  44855. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44856. /**
  44857. * Adds all the assets from the container to the scene.
  44858. */
  44859. addAllToScene(): void;
  44860. /**
  44861. * Removes all the assets in the container from the scene
  44862. */
  44863. removeAllFromScene(): void;
  44864. /**
  44865. * Disposes all the assets in the container
  44866. */
  44867. dispose(): void;
  44868. private _moveAssets;
  44869. /**
  44870. * Removes all the assets contained in the scene and adds them to the container.
  44871. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44872. */
  44873. moveAllFromScene(keepAssets?: KeepAssets): void;
  44874. /**
  44875. * 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.
  44876. * @returns the root mesh
  44877. */
  44878. createRootMesh(): Mesh;
  44879. /**
  44880. * Merge animations (direct and animation groups) from this asset container into a scene
  44881. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44882. * @param animatables set of animatables to retarget to a node from the scene
  44883. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44884. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44885. */
  44886. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44887. }
  44888. }
  44889. declare module BABYLON {
  44890. /**
  44891. * Defines how the parser contract is defined.
  44892. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44893. */
  44894. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44895. /**
  44896. * Defines how the individual parser contract is defined.
  44897. * These parser can parse an individual asset
  44898. */
  44899. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44900. /**
  44901. * Base class of the scene acting as a container for the different elements composing a scene.
  44902. * This class is dynamically extended by the different components of the scene increasing
  44903. * flexibility and reducing coupling
  44904. */
  44905. export abstract class AbstractScene {
  44906. /**
  44907. * Stores the list of available parsers in the application.
  44908. */
  44909. private static _BabylonFileParsers;
  44910. /**
  44911. * Stores the list of available individual parsers in the application.
  44912. */
  44913. private static _IndividualBabylonFileParsers;
  44914. /**
  44915. * Adds a parser in the list of available ones
  44916. * @param name Defines the name of the parser
  44917. * @param parser Defines the parser to add
  44918. */
  44919. static AddParser(name: string, parser: BabylonFileParser): void;
  44920. /**
  44921. * Gets a general parser from the list of avaialble ones
  44922. * @param name Defines the name of the parser
  44923. * @returns the requested parser or null
  44924. */
  44925. static GetParser(name: string): Nullable<BabylonFileParser>;
  44926. /**
  44927. * Adds n individual parser in the list of available ones
  44928. * @param name Defines the name of the parser
  44929. * @param parser Defines the parser to add
  44930. */
  44931. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44932. /**
  44933. * Gets an individual parser from the list of avaialble ones
  44934. * @param name Defines the name of the parser
  44935. * @returns the requested parser or null
  44936. */
  44937. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44938. /**
  44939. * Parser json data and populate both a scene and its associated container object
  44940. * @param jsonData Defines the data to parse
  44941. * @param scene Defines the scene to parse the data for
  44942. * @param container Defines the container attached to the parsing sequence
  44943. * @param rootUrl Defines the root url of the data
  44944. */
  44945. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44946. /**
  44947. * Gets the list of root nodes (ie. nodes with no parent)
  44948. */
  44949. rootNodes: Node[];
  44950. /** All of the cameras added to this scene
  44951. * @see https://doc.babylonjs.com/babylon101/cameras
  44952. */
  44953. cameras: Camera[];
  44954. /**
  44955. * All of the lights added to this scene
  44956. * @see https://doc.babylonjs.com/babylon101/lights
  44957. */
  44958. lights: Light[];
  44959. /**
  44960. * All of the (abstract) meshes added to this scene
  44961. */
  44962. meshes: AbstractMesh[];
  44963. /**
  44964. * The list of skeletons added to the scene
  44965. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44966. */
  44967. skeletons: Skeleton[];
  44968. /**
  44969. * All of the particle systems added to this scene
  44970. * @see https://doc.babylonjs.com/babylon101/particles
  44971. */
  44972. particleSystems: IParticleSystem[];
  44973. /**
  44974. * Gets a list of Animations associated with the scene
  44975. */
  44976. animations: Animation[];
  44977. /**
  44978. * All of the animation groups added to this scene
  44979. * @see https://doc.babylonjs.com/how_to/group
  44980. */
  44981. animationGroups: AnimationGroup[];
  44982. /**
  44983. * All of the multi-materials added to this scene
  44984. * @see https://doc.babylonjs.com/how_to/multi_materials
  44985. */
  44986. multiMaterials: MultiMaterial[];
  44987. /**
  44988. * All of the materials added to this scene
  44989. * In the context of a Scene, it is not supposed to be modified manually.
  44990. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44991. * Note also that the order of the Material within the array is not significant and might change.
  44992. * @see https://doc.babylonjs.com/babylon101/materials
  44993. */
  44994. materials: Material[];
  44995. /**
  44996. * The list of morph target managers added to the scene
  44997. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44998. */
  44999. morphTargetManagers: MorphTargetManager[];
  45000. /**
  45001. * The list of geometries used in the scene.
  45002. */
  45003. geometries: Geometry[];
  45004. /**
  45005. * All of the tranform nodes added to this scene
  45006. * In the context of a Scene, it is not supposed to be modified manually.
  45007. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45008. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45009. * @see https://doc.babylonjs.com/how_to/transformnode
  45010. */
  45011. transformNodes: TransformNode[];
  45012. /**
  45013. * ActionManagers available on the scene.
  45014. */
  45015. actionManagers: AbstractActionManager[];
  45016. /**
  45017. * Textures to keep.
  45018. */
  45019. textures: BaseTexture[];
  45020. /** @hidden */
  45021. protected _environmentTexture: Nullable<BaseTexture>;
  45022. /**
  45023. * Texture used in all pbr material as the reflection texture.
  45024. * As in the majority of the scene they are the same (exception for multi room and so on),
  45025. * this is easier to reference from here than from all the materials.
  45026. */
  45027. get environmentTexture(): Nullable<BaseTexture>;
  45028. set environmentTexture(value: Nullable<BaseTexture>);
  45029. /**
  45030. * The list of postprocesses added to the scene
  45031. */
  45032. postProcesses: PostProcess[];
  45033. /**
  45034. * @returns all meshes, lights, cameras, transformNodes and bones
  45035. */
  45036. getNodes(): Array<Node>;
  45037. }
  45038. }
  45039. declare module BABYLON {
  45040. /**
  45041. * Interface used to define options for Sound class
  45042. */
  45043. export interface ISoundOptions {
  45044. /**
  45045. * Does the sound autoplay once loaded.
  45046. */
  45047. autoplay?: boolean;
  45048. /**
  45049. * Does the sound loop after it finishes playing once.
  45050. */
  45051. loop?: boolean;
  45052. /**
  45053. * Sound's volume
  45054. */
  45055. volume?: number;
  45056. /**
  45057. * Is it a spatial sound?
  45058. */
  45059. spatialSound?: boolean;
  45060. /**
  45061. * Maximum distance to hear that sound
  45062. */
  45063. maxDistance?: number;
  45064. /**
  45065. * Uses user defined attenuation function
  45066. */
  45067. useCustomAttenuation?: boolean;
  45068. /**
  45069. * Define the roll off factor of spatial sounds.
  45070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45071. */
  45072. rolloffFactor?: number;
  45073. /**
  45074. * Define the reference distance the sound should be heard perfectly.
  45075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45076. */
  45077. refDistance?: number;
  45078. /**
  45079. * Define the distance attenuation model the sound will follow.
  45080. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45081. */
  45082. distanceModel?: string;
  45083. /**
  45084. * Defines the playback speed (1 by default)
  45085. */
  45086. playbackRate?: number;
  45087. /**
  45088. * Defines if the sound is from a streaming source
  45089. */
  45090. streaming?: boolean;
  45091. /**
  45092. * Defines an optional length (in seconds) inside the sound file
  45093. */
  45094. length?: number;
  45095. /**
  45096. * Defines an optional offset (in seconds) inside the sound file
  45097. */
  45098. offset?: number;
  45099. /**
  45100. * If true, URLs will not be required to state the audio file codec to use.
  45101. */
  45102. skipCodecCheck?: boolean;
  45103. }
  45104. }
  45105. declare module BABYLON {
  45106. /**
  45107. * Defines a sound that can be played in the application.
  45108. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45110. */
  45111. export class Sound {
  45112. /**
  45113. * The name of the sound in the scene.
  45114. */
  45115. name: string;
  45116. /**
  45117. * Does the sound autoplay once loaded.
  45118. */
  45119. autoplay: boolean;
  45120. /**
  45121. * Does the sound loop after it finishes playing once.
  45122. */
  45123. loop: boolean;
  45124. /**
  45125. * Does the sound use a custom attenuation curve to simulate the falloff
  45126. * happening when the source gets further away from the camera.
  45127. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45128. */
  45129. useCustomAttenuation: boolean;
  45130. /**
  45131. * The sound track id this sound belongs to.
  45132. */
  45133. soundTrackId: number;
  45134. /**
  45135. * Is this sound currently played.
  45136. */
  45137. isPlaying: boolean;
  45138. /**
  45139. * Is this sound currently paused.
  45140. */
  45141. isPaused: boolean;
  45142. /**
  45143. * Does this sound enables spatial sound.
  45144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45145. */
  45146. spatialSound: boolean;
  45147. /**
  45148. * Define the reference distance the sound should be heard perfectly.
  45149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45150. */
  45151. refDistance: number;
  45152. /**
  45153. * Define the roll off factor of spatial sounds.
  45154. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45155. */
  45156. rolloffFactor: number;
  45157. /**
  45158. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45160. */
  45161. maxDistance: number;
  45162. /**
  45163. * Define the distance attenuation model the sound will follow.
  45164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45165. */
  45166. distanceModel: string;
  45167. /**
  45168. * @hidden
  45169. * Back Compat
  45170. **/
  45171. onended: () => any;
  45172. /**
  45173. * Gets or sets an object used to store user defined information for the sound.
  45174. */
  45175. metadata: any;
  45176. /**
  45177. * Observable event when the current playing sound finishes.
  45178. */
  45179. onEndedObservable: Observable<Sound>;
  45180. /**
  45181. * Gets the current time for the sound.
  45182. */
  45183. get currentTime(): number;
  45184. private _panningModel;
  45185. private _playbackRate;
  45186. private _streaming;
  45187. private _startTime;
  45188. private _startOffset;
  45189. private _position;
  45190. /** @hidden */
  45191. _positionInEmitterSpace: boolean;
  45192. private _localDirection;
  45193. private _volume;
  45194. private _isReadyToPlay;
  45195. private _isDirectional;
  45196. private _readyToPlayCallback;
  45197. private _audioBuffer;
  45198. private _soundSource;
  45199. private _streamingSource;
  45200. private _soundPanner;
  45201. private _soundGain;
  45202. private _inputAudioNode;
  45203. private _outputAudioNode;
  45204. private _coneInnerAngle;
  45205. private _coneOuterAngle;
  45206. private _coneOuterGain;
  45207. private _scene;
  45208. private _connectedTransformNode;
  45209. private _customAttenuationFunction;
  45210. private _registerFunc;
  45211. private _isOutputConnected;
  45212. private _htmlAudioElement;
  45213. private _urlType;
  45214. private _length?;
  45215. private _offset?;
  45216. /** @hidden */
  45217. static _SceneComponentInitialization: (scene: Scene) => void;
  45218. /**
  45219. * Create a sound and attach it to a scene
  45220. * @param name Name of your sound
  45221. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45222. * @param scene defines the scene the sound belongs to
  45223. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45224. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45225. */
  45226. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45227. /**
  45228. * Release the sound and its associated resources
  45229. */
  45230. dispose(): void;
  45231. /**
  45232. * Gets if the sounds is ready to be played or not.
  45233. * @returns true if ready, otherwise false
  45234. */
  45235. isReady(): boolean;
  45236. private _soundLoaded;
  45237. /**
  45238. * Sets the data of the sound from an audiobuffer
  45239. * @param audioBuffer The audioBuffer containing the data
  45240. */
  45241. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45242. /**
  45243. * Updates the current sounds options such as maxdistance, loop...
  45244. * @param options A JSON object containing values named as the object properties
  45245. */
  45246. updateOptions(options: ISoundOptions): void;
  45247. private _createSpatialParameters;
  45248. private _updateSpatialParameters;
  45249. /**
  45250. * Switch the panning model to HRTF:
  45251. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45253. */
  45254. switchPanningModelToHRTF(): void;
  45255. /**
  45256. * Switch the panning model to Equal Power:
  45257. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45259. */
  45260. switchPanningModelToEqualPower(): void;
  45261. private _switchPanningModel;
  45262. /**
  45263. * Connect this sound to a sound track audio node like gain...
  45264. * @param soundTrackAudioNode the sound track audio node to connect to
  45265. */
  45266. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45267. /**
  45268. * Transform this sound into a directional source
  45269. * @param coneInnerAngle Size of the inner cone in degree
  45270. * @param coneOuterAngle Size of the outer cone in degree
  45271. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45272. */
  45273. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45274. /**
  45275. * Gets or sets the inner angle for the directional cone.
  45276. */
  45277. get directionalConeInnerAngle(): number;
  45278. /**
  45279. * Gets or sets the inner angle for the directional cone.
  45280. */
  45281. set directionalConeInnerAngle(value: number);
  45282. /**
  45283. * Gets or sets the outer angle for the directional cone.
  45284. */
  45285. get directionalConeOuterAngle(): number;
  45286. /**
  45287. * Gets or sets the outer angle for the directional cone.
  45288. */
  45289. set directionalConeOuterAngle(value: number);
  45290. /**
  45291. * Sets the position of the emitter if spatial sound is enabled
  45292. * @param newPosition Defines the new posisiton
  45293. */
  45294. setPosition(newPosition: Vector3): void;
  45295. /**
  45296. * Sets the local direction of the emitter if spatial sound is enabled
  45297. * @param newLocalDirection Defines the new local direction
  45298. */
  45299. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45300. private _updateDirection;
  45301. /** @hidden */
  45302. updateDistanceFromListener(): void;
  45303. /**
  45304. * Sets a new custom attenuation function for the sound.
  45305. * @param callback Defines the function used for the attenuation
  45306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45307. */
  45308. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45309. /**
  45310. * Play the sound
  45311. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45312. * @param offset (optional) Start the sound at a specific time in seconds
  45313. * @param length (optional) Sound duration (in seconds)
  45314. */
  45315. play(time?: number, offset?: number, length?: number): void;
  45316. private _onended;
  45317. /**
  45318. * Stop the sound
  45319. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45320. */
  45321. stop(time?: number): void;
  45322. /**
  45323. * Put the sound in pause
  45324. */
  45325. pause(): void;
  45326. /**
  45327. * Sets a dedicated volume for this sounds
  45328. * @param newVolume Define the new volume of the sound
  45329. * @param time Define time for gradual change to new volume
  45330. */
  45331. setVolume(newVolume: number, time?: number): void;
  45332. /**
  45333. * Set the sound play back rate
  45334. * @param newPlaybackRate Define the playback rate the sound should be played at
  45335. */
  45336. setPlaybackRate(newPlaybackRate: number): void;
  45337. /**
  45338. * Gets the volume of the sound.
  45339. * @returns the volume of the sound
  45340. */
  45341. getVolume(): number;
  45342. /**
  45343. * Attach the sound to a dedicated mesh
  45344. * @param transformNode The transform node to connect the sound with
  45345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45346. */
  45347. attachToMesh(transformNode: TransformNode): void;
  45348. /**
  45349. * Detach the sound from the previously attached mesh
  45350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45351. */
  45352. detachFromMesh(): void;
  45353. private _onRegisterAfterWorldMatrixUpdate;
  45354. /**
  45355. * Clone the current sound in the scene.
  45356. * @returns the new sound clone
  45357. */
  45358. clone(): Nullable<Sound>;
  45359. /**
  45360. * Gets the current underlying audio buffer containing the data
  45361. * @returns the audio buffer
  45362. */
  45363. getAudioBuffer(): Nullable<AudioBuffer>;
  45364. /**
  45365. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45366. * @returns the source node
  45367. */
  45368. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45369. /**
  45370. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45371. * @returns the gain node
  45372. */
  45373. getSoundGain(): Nullable<GainNode>;
  45374. /**
  45375. * Serializes the Sound in a JSON representation
  45376. * @returns the JSON representation of the sound
  45377. */
  45378. serialize(): any;
  45379. /**
  45380. * Parse a JSON representation of a sound to innstantiate in a given scene
  45381. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45382. * @param scene Define the scene the new parsed sound should be created in
  45383. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45384. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45385. * @returns the newly parsed sound
  45386. */
  45387. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45388. }
  45389. }
  45390. declare module BABYLON {
  45391. /**
  45392. * This defines an action helpful to play a defined sound on a triggered action.
  45393. */
  45394. export class PlaySoundAction extends Action {
  45395. private _sound;
  45396. /**
  45397. * Instantiate the action
  45398. * @param triggerOptions defines the trigger options
  45399. * @param sound defines the sound to play
  45400. * @param condition defines the trigger related conditions
  45401. */
  45402. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45403. /** @hidden */
  45404. _prepare(): void;
  45405. /**
  45406. * Execute the action and play the sound.
  45407. */
  45408. execute(): void;
  45409. /**
  45410. * Serializes the actions and its related information.
  45411. * @param parent defines the object to serialize in
  45412. * @returns the serialized object
  45413. */
  45414. serialize(parent: any): any;
  45415. }
  45416. /**
  45417. * This defines an action helpful to stop a defined sound on a triggered action.
  45418. */
  45419. export class StopSoundAction extends Action {
  45420. private _sound;
  45421. /**
  45422. * Instantiate the action
  45423. * @param triggerOptions defines the trigger options
  45424. * @param sound defines the sound to stop
  45425. * @param condition defines the trigger related conditions
  45426. */
  45427. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45428. /** @hidden */
  45429. _prepare(): void;
  45430. /**
  45431. * Execute the action and stop the sound.
  45432. */
  45433. execute(): void;
  45434. /**
  45435. * Serializes the actions and its related information.
  45436. * @param parent defines the object to serialize in
  45437. * @returns the serialized object
  45438. */
  45439. serialize(parent: any): any;
  45440. }
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * This defines an action responsible to change the value of a property
  45445. * by interpolating between its current value and the newly set one once triggered.
  45446. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45447. */
  45448. export class InterpolateValueAction extends Action {
  45449. /**
  45450. * Defines the path of the property where the value should be interpolated
  45451. */
  45452. propertyPath: string;
  45453. /**
  45454. * Defines the target value at the end of the interpolation.
  45455. */
  45456. value: any;
  45457. /**
  45458. * Defines the time it will take for the property to interpolate to the value.
  45459. */
  45460. duration: number;
  45461. /**
  45462. * Defines if the other scene animations should be stopped when the action has been triggered
  45463. */
  45464. stopOtherAnimations?: boolean;
  45465. /**
  45466. * Defines a callback raised once the interpolation animation has been done.
  45467. */
  45468. onInterpolationDone?: () => void;
  45469. /**
  45470. * Observable triggered once the interpolation animation has been done.
  45471. */
  45472. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45473. private _target;
  45474. private _effectiveTarget;
  45475. private _property;
  45476. /**
  45477. * Instantiate the action
  45478. * @param triggerOptions defines the trigger options
  45479. * @param target defines the object containing the value to interpolate
  45480. * @param propertyPath defines the path to the property in the target object
  45481. * @param value defines the target value at the end of the interpolation
  45482. * @param duration deines the time it will take for the property to interpolate to the value.
  45483. * @param condition defines the trigger related conditions
  45484. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45485. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45486. */
  45487. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45488. /** @hidden */
  45489. _prepare(): void;
  45490. /**
  45491. * Execute the action starts the value interpolation.
  45492. */
  45493. execute(): void;
  45494. /**
  45495. * Serializes the actions and its related information.
  45496. * @param parent defines the object to serialize in
  45497. * @returns the serialized object
  45498. */
  45499. serialize(parent: any): any;
  45500. }
  45501. }
  45502. declare module BABYLON {
  45503. /**
  45504. * This represents the default audio engine used in babylon.
  45505. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45506. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45507. */
  45508. export class AudioEngine implements IAudioEngine {
  45509. private _audioContext;
  45510. private _audioContextInitialized;
  45511. private _muteButton;
  45512. private _hostElement;
  45513. /**
  45514. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45515. */
  45516. canUseWebAudio: boolean;
  45517. /**
  45518. * The master gain node defines the global audio volume of your audio engine.
  45519. */
  45520. masterGain: GainNode;
  45521. /**
  45522. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45523. * @ignoreNaming
  45524. */
  45525. WarnedWebAudioUnsupported: boolean;
  45526. /**
  45527. * Gets whether or not mp3 are supported by your browser.
  45528. */
  45529. isMP3supported: boolean;
  45530. /**
  45531. * Gets whether or not ogg are supported by your browser.
  45532. */
  45533. isOGGsupported: boolean;
  45534. /**
  45535. * Gets whether audio has been unlocked on the device.
  45536. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45537. * a user interaction has happened.
  45538. */
  45539. unlocked: boolean;
  45540. /**
  45541. * Defines if the audio engine relies on a custom unlocked button.
  45542. * In this case, the embedded button will not be displayed.
  45543. */
  45544. useCustomUnlockedButton: boolean;
  45545. /**
  45546. * Event raised when audio has been unlocked on the browser.
  45547. */
  45548. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45549. /**
  45550. * Event raised when audio has been locked on the browser.
  45551. */
  45552. onAudioLockedObservable: Observable<IAudioEngine>;
  45553. /**
  45554. * Gets the current AudioContext if available.
  45555. */
  45556. get audioContext(): Nullable<AudioContext>;
  45557. private _connectedAnalyser;
  45558. /**
  45559. * Instantiates a new audio engine.
  45560. *
  45561. * There should be only one per page as some browsers restrict the number
  45562. * of audio contexts you can create.
  45563. * @param hostElement defines the host element where to display the mute icon if necessary
  45564. */
  45565. constructor(hostElement?: Nullable<HTMLElement>);
  45566. /**
  45567. * Flags the audio engine in Locked state.
  45568. * This happens due to new browser policies preventing audio to autoplay.
  45569. */
  45570. lock(): void;
  45571. /**
  45572. * Unlocks the audio engine once a user action has been done on the dom.
  45573. * This is helpful to resume play once browser policies have been satisfied.
  45574. */
  45575. unlock(): void;
  45576. private _resumeAudioContext;
  45577. private _initializeAudioContext;
  45578. private _tryToRun;
  45579. private _triggerRunningState;
  45580. private _triggerSuspendedState;
  45581. private _displayMuteButton;
  45582. private _moveButtonToTopLeft;
  45583. private _onResize;
  45584. private _hideMuteButton;
  45585. /**
  45586. * Destroy and release the resources associated with the audio ccontext.
  45587. */
  45588. dispose(): void;
  45589. /**
  45590. * Gets the global volume sets on the master gain.
  45591. * @returns the global volume if set or -1 otherwise
  45592. */
  45593. getGlobalVolume(): number;
  45594. /**
  45595. * Sets the global volume of your experience (sets on the master gain).
  45596. * @param newVolume Defines the new global volume of the application
  45597. */
  45598. setGlobalVolume(newVolume: number): void;
  45599. /**
  45600. * Connect the audio engine to an audio analyser allowing some amazing
  45601. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45603. * @param analyser The analyser to connect to the engine
  45604. */
  45605. connectToAnalyser(analyser: Analyser): void;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * Options allowed during the creation of a sound track.
  45611. */
  45612. export interface ISoundTrackOptions {
  45613. /**
  45614. * The volume the sound track should take during creation
  45615. */
  45616. volume?: number;
  45617. /**
  45618. * Define if the sound track is the main sound track of the scene
  45619. */
  45620. mainTrack?: boolean;
  45621. }
  45622. /**
  45623. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45624. * It will be also used in a future release to apply effects on a specific track.
  45625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45626. */
  45627. export class SoundTrack {
  45628. /**
  45629. * The unique identifier of the sound track in the scene.
  45630. */
  45631. id: number;
  45632. /**
  45633. * The list of sounds included in the sound track.
  45634. */
  45635. soundCollection: Array<Sound>;
  45636. private _outputAudioNode;
  45637. private _scene;
  45638. private _connectedAnalyser;
  45639. private _options;
  45640. private _isInitialized;
  45641. /**
  45642. * Creates a new sound track.
  45643. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45644. * @param scene Define the scene the sound track belongs to
  45645. * @param options
  45646. */
  45647. constructor(scene: Scene, options?: ISoundTrackOptions);
  45648. private _initializeSoundTrackAudioGraph;
  45649. /**
  45650. * Release the sound track and its associated resources
  45651. */
  45652. dispose(): void;
  45653. /**
  45654. * Adds a sound to this sound track
  45655. * @param sound define the cound to add
  45656. * @ignoreNaming
  45657. */
  45658. addSound(sound: Sound): void;
  45659. /**
  45660. * Removes a sound to this sound track
  45661. * @param sound define the cound to remove
  45662. * @ignoreNaming
  45663. */
  45664. removeSound(sound: Sound): void;
  45665. /**
  45666. * Set a global volume for the full sound track.
  45667. * @param newVolume Define the new volume of the sound track
  45668. */
  45669. setVolume(newVolume: number): void;
  45670. /**
  45671. * Switch the panning model to HRTF:
  45672. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45674. */
  45675. switchPanningModelToHRTF(): void;
  45676. /**
  45677. * Switch the panning model to Equal Power:
  45678. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45679. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45680. */
  45681. switchPanningModelToEqualPower(): void;
  45682. /**
  45683. * Connect the sound track to an audio analyser allowing some amazing
  45684. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45686. * @param analyser The analyser to connect to the engine
  45687. */
  45688. connectToAnalyser(analyser: Analyser): void;
  45689. }
  45690. }
  45691. declare module BABYLON {
  45692. interface AbstractScene {
  45693. /**
  45694. * The list of sounds used in the scene.
  45695. */
  45696. sounds: Nullable<Array<Sound>>;
  45697. }
  45698. interface Scene {
  45699. /**
  45700. * @hidden
  45701. * Backing field
  45702. */
  45703. _mainSoundTrack: SoundTrack;
  45704. /**
  45705. * The main sound track played by the scene.
  45706. * It cotains your primary collection of sounds.
  45707. */
  45708. mainSoundTrack: SoundTrack;
  45709. /**
  45710. * The list of sound tracks added to the scene
  45711. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45712. */
  45713. soundTracks: Nullable<Array<SoundTrack>>;
  45714. /**
  45715. * Gets a sound using a given name
  45716. * @param name defines the name to search for
  45717. * @return the found sound or null if not found at all.
  45718. */
  45719. getSoundByName(name: string): Nullable<Sound>;
  45720. /**
  45721. * Gets or sets if audio support is enabled
  45722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45723. */
  45724. audioEnabled: boolean;
  45725. /**
  45726. * Gets or sets if audio will be output to headphones
  45727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45728. */
  45729. headphone: boolean;
  45730. /**
  45731. * Gets or sets custom audio listener position provider
  45732. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45733. */
  45734. audioListenerPositionProvider: Nullable<() => Vector3>;
  45735. /**
  45736. * Gets or sets a refresh rate when using 3D audio positioning
  45737. */
  45738. audioPositioningRefreshRate: number;
  45739. }
  45740. /**
  45741. * Defines the sound scene component responsible to manage any sounds
  45742. * in a given scene.
  45743. */
  45744. export class AudioSceneComponent implements ISceneSerializableComponent {
  45745. private static _CameraDirectionLH;
  45746. private static _CameraDirectionRH;
  45747. /**
  45748. * The component name helpfull to identify the component in the list of scene components.
  45749. */
  45750. readonly name: string;
  45751. /**
  45752. * The scene the component belongs to.
  45753. */
  45754. scene: Scene;
  45755. private _audioEnabled;
  45756. /**
  45757. * Gets whether audio is enabled or not.
  45758. * Please use related enable/disable method to switch state.
  45759. */
  45760. get audioEnabled(): boolean;
  45761. private _headphone;
  45762. /**
  45763. * Gets whether audio is outputing to headphone or not.
  45764. * Please use the according Switch methods to change output.
  45765. */
  45766. get headphone(): boolean;
  45767. /**
  45768. * Gets or sets a refresh rate when using 3D audio positioning
  45769. */
  45770. audioPositioningRefreshRate: number;
  45771. private _audioListenerPositionProvider;
  45772. /**
  45773. * Gets the current audio listener position provider
  45774. */
  45775. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45776. /**
  45777. * Sets a custom listener position for all sounds in the scene
  45778. * By default, this is the position of the first active camera
  45779. */
  45780. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45781. /**
  45782. * Creates a new instance of the component for the given scene
  45783. * @param scene Defines the scene to register the component in
  45784. */
  45785. constructor(scene: Scene);
  45786. /**
  45787. * Registers the component in a given scene
  45788. */
  45789. register(): void;
  45790. /**
  45791. * Rebuilds the elements related to this component in case of
  45792. * context lost for instance.
  45793. */
  45794. rebuild(): void;
  45795. /**
  45796. * Serializes the component data to the specified json object
  45797. * @param serializationObject The object to serialize to
  45798. */
  45799. serialize(serializationObject: any): void;
  45800. /**
  45801. * Adds all the elements from the container to the scene
  45802. * @param container the container holding the elements
  45803. */
  45804. addFromContainer(container: AbstractScene): void;
  45805. /**
  45806. * Removes all the elements in the container from the scene
  45807. * @param container contains the elements to remove
  45808. * @param dispose if the removed element should be disposed (default: false)
  45809. */
  45810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45811. /**
  45812. * Disposes the component and the associated ressources.
  45813. */
  45814. dispose(): void;
  45815. /**
  45816. * Disables audio in the associated scene.
  45817. */
  45818. disableAudio(): void;
  45819. /**
  45820. * Enables audio in the associated scene.
  45821. */
  45822. enableAudio(): void;
  45823. /**
  45824. * Switch audio to headphone output.
  45825. */
  45826. switchAudioModeForHeadphones(): void;
  45827. /**
  45828. * Switch audio to normal speakers.
  45829. */
  45830. switchAudioModeForNormalSpeakers(): void;
  45831. private _cachedCameraDirection;
  45832. private _cachedCameraPosition;
  45833. private _lastCheck;
  45834. private _afterRender;
  45835. }
  45836. }
  45837. declare module BABYLON {
  45838. /**
  45839. * Wraps one or more Sound objects and selects one with random weight for playback.
  45840. */
  45841. export class WeightedSound {
  45842. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45843. loop: boolean;
  45844. private _coneInnerAngle;
  45845. private _coneOuterAngle;
  45846. private _volume;
  45847. /** A Sound is currently playing. */
  45848. isPlaying: boolean;
  45849. /** A Sound is currently paused. */
  45850. isPaused: boolean;
  45851. private _sounds;
  45852. private _weights;
  45853. private _currentIndex?;
  45854. /**
  45855. * Creates a new WeightedSound from the list of sounds given.
  45856. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45857. * @param sounds Array of Sounds that will be selected from.
  45858. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45859. */
  45860. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45861. /**
  45862. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45863. */
  45864. get directionalConeInnerAngle(): number;
  45865. /**
  45866. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45867. */
  45868. set directionalConeInnerAngle(value: number);
  45869. /**
  45870. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45871. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45872. */
  45873. get directionalConeOuterAngle(): number;
  45874. /**
  45875. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45876. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45877. */
  45878. set directionalConeOuterAngle(value: number);
  45879. /**
  45880. * Playback volume.
  45881. */
  45882. get volume(): number;
  45883. /**
  45884. * Playback volume.
  45885. */
  45886. set volume(value: number);
  45887. private _onended;
  45888. /**
  45889. * Suspend playback
  45890. */
  45891. pause(): void;
  45892. /**
  45893. * Stop playback
  45894. */
  45895. stop(): void;
  45896. /**
  45897. * Start playback.
  45898. * @param startOffset Position the clip head at a specific time in seconds.
  45899. */
  45900. play(startOffset?: number): void;
  45901. }
  45902. }
  45903. declare module BABYLON {
  45904. /**
  45905. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45906. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45907. */
  45908. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45909. /**
  45910. * Gets the name of the behavior.
  45911. */
  45912. get name(): string;
  45913. /**
  45914. * The easing function used by animations
  45915. */
  45916. static EasingFunction: BackEase;
  45917. /**
  45918. * The easing mode used by animations
  45919. */
  45920. static EasingMode: number;
  45921. /**
  45922. * The duration of the animation, in milliseconds
  45923. */
  45924. transitionDuration: number;
  45925. /**
  45926. * Length of the distance animated by the transition when lower radius is reached
  45927. */
  45928. lowerRadiusTransitionRange: number;
  45929. /**
  45930. * Length of the distance animated by the transition when upper radius is reached
  45931. */
  45932. upperRadiusTransitionRange: number;
  45933. private _autoTransitionRange;
  45934. /**
  45935. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45936. */
  45937. get autoTransitionRange(): boolean;
  45938. /**
  45939. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45940. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45941. */
  45942. set autoTransitionRange(value: boolean);
  45943. private _attachedCamera;
  45944. private _onAfterCheckInputsObserver;
  45945. private _onMeshTargetChangedObserver;
  45946. /**
  45947. * Initializes the behavior.
  45948. */
  45949. init(): void;
  45950. /**
  45951. * Attaches the behavior to its arc rotate camera.
  45952. * @param camera Defines the camera to attach the behavior to
  45953. */
  45954. attach(camera: ArcRotateCamera): void;
  45955. /**
  45956. * Detaches the behavior from its current arc rotate camera.
  45957. */
  45958. detach(): void;
  45959. private _radiusIsAnimating;
  45960. private _radiusBounceTransition;
  45961. private _animatables;
  45962. private _cachedWheelPrecision;
  45963. /**
  45964. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45965. * @param radiusLimit The limit to check against.
  45966. * @return Bool to indicate if at limit.
  45967. */
  45968. private _isRadiusAtLimit;
  45969. /**
  45970. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45971. * @param radiusDelta The delta by which to animate to. Can be negative.
  45972. */
  45973. private _applyBoundRadiusAnimation;
  45974. /**
  45975. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45976. */
  45977. protected _clearAnimationLocks(): void;
  45978. /**
  45979. * Stops and removes all animations that have been applied to the camera
  45980. */
  45981. stopAllAnimations(): void;
  45982. }
  45983. }
  45984. declare module BABYLON {
  45985. /**
  45986. * 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.
  45987. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45988. */
  45989. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45990. /**
  45991. * Gets the name of the behavior.
  45992. */
  45993. get name(): string;
  45994. private _mode;
  45995. private _radiusScale;
  45996. private _positionScale;
  45997. private _defaultElevation;
  45998. private _elevationReturnTime;
  45999. private _elevationReturnWaitTime;
  46000. private _zoomStopsAnimation;
  46001. private _framingTime;
  46002. /**
  46003. * The easing function used by animations
  46004. */
  46005. static EasingFunction: ExponentialEase;
  46006. /**
  46007. * The easing mode used by animations
  46008. */
  46009. static EasingMode: number;
  46010. /**
  46011. * Sets the current mode used by the behavior
  46012. */
  46013. set mode(mode: number);
  46014. /**
  46015. * Gets current mode used by the behavior.
  46016. */
  46017. get mode(): number;
  46018. /**
  46019. * Sets the scale applied to the radius (1 by default)
  46020. */
  46021. set radiusScale(radius: number);
  46022. /**
  46023. * Gets the scale applied to the radius
  46024. */
  46025. get radiusScale(): number;
  46026. /**
  46027. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46028. */
  46029. set positionScale(scale: number);
  46030. /**
  46031. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46032. */
  46033. get positionScale(): number;
  46034. /**
  46035. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46036. * behaviour is triggered, in radians.
  46037. */
  46038. set defaultElevation(elevation: number);
  46039. /**
  46040. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46041. * behaviour is triggered, in radians.
  46042. */
  46043. get defaultElevation(): number;
  46044. /**
  46045. * Sets the time (in milliseconds) taken to return to the default beta position.
  46046. * Negative value indicates camera should not return to default.
  46047. */
  46048. set elevationReturnTime(speed: number);
  46049. /**
  46050. * Gets the time (in milliseconds) taken to return to the default beta position.
  46051. * Negative value indicates camera should not return to default.
  46052. */
  46053. get elevationReturnTime(): number;
  46054. /**
  46055. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46056. */
  46057. set elevationReturnWaitTime(time: number);
  46058. /**
  46059. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46060. */
  46061. get elevationReturnWaitTime(): number;
  46062. /**
  46063. * Sets the flag that indicates if user zooming should stop animation.
  46064. */
  46065. set zoomStopsAnimation(flag: boolean);
  46066. /**
  46067. * Gets the flag that indicates if user zooming should stop animation.
  46068. */
  46069. get zoomStopsAnimation(): boolean;
  46070. /**
  46071. * Sets the transition time when framing the mesh, in milliseconds
  46072. */
  46073. set framingTime(time: number);
  46074. /**
  46075. * Gets the transition time when framing the mesh, in milliseconds
  46076. */
  46077. get framingTime(): number;
  46078. /**
  46079. * Define if the behavior should automatically change the configured
  46080. * camera limits and sensibilities.
  46081. */
  46082. autoCorrectCameraLimitsAndSensibility: boolean;
  46083. private _onPrePointerObservableObserver;
  46084. private _onAfterCheckInputsObserver;
  46085. private _onMeshTargetChangedObserver;
  46086. private _attachedCamera;
  46087. private _isPointerDown;
  46088. private _lastInteractionTime;
  46089. /**
  46090. * Initializes the behavior.
  46091. */
  46092. init(): void;
  46093. /**
  46094. * Attaches the behavior to its arc rotate camera.
  46095. * @param camera Defines the camera to attach the behavior to
  46096. */
  46097. attach(camera: ArcRotateCamera): void;
  46098. /**
  46099. * Detaches the behavior from its current arc rotate camera.
  46100. */
  46101. detach(): void;
  46102. private _animatables;
  46103. private _betaIsAnimating;
  46104. private _betaTransition;
  46105. private _radiusTransition;
  46106. private _vectorTransition;
  46107. /**
  46108. * Targets the given mesh and updates zoom level accordingly.
  46109. * @param mesh The mesh to target.
  46110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46112. */
  46113. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46114. /**
  46115. * Targets the given mesh with its children and updates zoom level accordingly.
  46116. * @param mesh The mesh to target.
  46117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46119. */
  46120. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46121. /**
  46122. * Targets the given meshes with their children and updates zoom level accordingly.
  46123. * @param meshes The mesh to target.
  46124. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46125. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46126. */
  46127. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46128. /**
  46129. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46130. * @param minimumWorld Determines the smaller position of the bounding box extend
  46131. * @param maximumWorld Determines the bigger position of the bounding box extend
  46132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46134. */
  46135. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46136. /**
  46137. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46138. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46139. * frustum width.
  46140. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46141. * to fully enclose the mesh in the viewing frustum.
  46142. */
  46143. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46144. /**
  46145. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46146. * is automatically returned to its default position (expected to be above ground plane).
  46147. */
  46148. private _maintainCameraAboveGround;
  46149. /**
  46150. * Returns the frustum slope based on the canvas ratio and camera FOV
  46151. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46152. */
  46153. private _getFrustumSlope;
  46154. /**
  46155. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46156. */
  46157. private _clearAnimationLocks;
  46158. /**
  46159. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46160. */
  46161. private _applyUserInteraction;
  46162. /**
  46163. * Stops and removes all animations that have been applied to the camera
  46164. */
  46165. stopAllAnimations(): void;
  46166. /**
  46167. * Gets a value indicating if the user is moving the camera
  46168. */
  46169. get isUserIsMoving(): boolean;
  46170. /**
  46171. * The camera can move all the way towards the mesh.
  46172. */
  46173. static IgnoreBoundsSizeMode: number;
  46174. /**
  46175. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46176. */
  46177. static FitFrustumSidesMode: number;
  46178. }
  46179. }
  46180. declare module BABYLON {
  46181. /**
  46182. * Base class for Camera Pointer Inputs.
  46183. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46184. * for example usage.
  46185. */
  46186. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46187. /**
  46188. * Defines the camera the input is attached to.
  46189. */
  46190. abstract camera: Camera;
  46191. /**
  46192. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46193. */
  46194. protected _altKey: boolean;
  46195. protected _ctrlKey: boolean;
  46196. protected _metaKey: boolean;
  46197. protected _shiftKey: boolean;
  46198. /**
  46199. * Which mouse buttons were pressed at time of last mouse event.
  46200. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46201. */
  46202. protected _buttonsPressed: number;
  46203. /**
  46204. * Defines the buttons associated with the input to handle camera move.
  46205. */
  46206. buttons: number[];
  46207. /**
  46208. * Attach the input controls to a specific dom element to get the input from.
  46209. * @param element Defines the element the controls should be listened from
  46210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46211. */
  46212. attachControl(noPreventDefault?: boolean): void;
  46213. /**
  46214. * Detach the current controls from the specified dom element.
  46215. */
  46216. detachControl(): void;
  46217. /**
  46218. * Gets the class name of the current input.
  46219. * @returns the class name
  46220. */
  46221. getClassName(): string;
  46222. /**
  46223. * Get the friendly name associated with the input class.
  46224. * @returns the input friendly name
  46225. */
  46226. getSimpleName(): string;
  46227. /**
  46228. * Called on pointer POINTERDOUBLETAP event.
  46229. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46230. */
  46231. protected onDoubleTap(type: string): void;
  46232. /**
  46233. * Called on pointer POINTERMOVE event if only a single touch is active.
  46234. * Override this method to provide functionality.
  46235. */
  46236. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46237. /**
  46238. * Called on pointer POINTERMOVE event if multiple touches are active.
  46239. * Override this method to provide functionality.
  46240. */
  46241. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46242. /**
  46243. * Called on JS contextmenu event.
  46244. * Override this method to provide functionality.
  46245. */
  46246. protected onContextMenu(evt: PointerEvent): void;
  46247. /**
  46248. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46249. * press.
  46250. * Override this method to provide functionality.
  46251. */
  46252. protected onButtonDown(evt: PointerEvent): void;
  46253. /**
  46254. * Called each time a new POINTERUP event occurs. Ie, for each button
  46255. * release.
  46256. * Override this method to provide functionality.
  46257. */
  46258. protected onButtonUp(evt: PointerEvent): void;
  46259. /**
  46260. * Called when window becomes inactive.
  46261. * Override this method to provide functionality.
  46262. */
  46263. protected onLostFocus(): void;
  46264. private _pointerInput;
  46265. private _observer;
  46266. private _onLostFocus;
  46267. private pointA;
  46268. private pointB;
  46269. }
  46270. }
  46271. declare module BABYLON {
  46272. /**
  46273. * Manage the pointers inputs to control an arc rotate camera.
  46274. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46275. */
  46276. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46277. /**
  46278. * Defines the camera the input is attached to.
  46279. */
  46280. camera: ArcRotateCamera;
  46281. /**
  46282. * Gets the class name of the current input.
  46283. * @returns the class name
  46284. */
  46285. getClassName(): string;
  46286. /**
  46287. * Defines the buttons associated with the input to handle camera move.
  46288. */
  46289. buttons: number[];
  46290. /**
  46291. * Defines the pointer angular sensibility along the X axis or how fast is
  46292. * the camera rotating.
  46293. */
  46294. angularSensibilityX: number;
  46295. /**
  46296. * Defines the pointer angular sensibility along the Y axis or how fast is
  46297. * the camera rotating.
  46298. */
  46299. angularSensibilityY: number;
  46300. /**
  46301. * Defines the pointer pinch precision or how fast is the camera zooming.
  46302. */
  46303. pinchPrecision: number;
  46304. /**
  46305. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46306. * from 0.
  46307. * It defines the percentage of current camera.radius to use as delta when
  46308. * pinch zoom is used.
  46309. */
  46310. pinchDeltaPercentage: number;
  46311. /**
  46312. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46313. * that any object in the plane at the camera's target point will scale
  46314. * perfectly with finger motion.
  46315. * Overrides pinchDeltaPercentage and pinchPrecision.
  46316. */
  46317. useNaturalPinchZoom: boolean;
  46318. /**
  46319. * Defines the pointer panning sensibility or how fast is the camera moving.
  46320. */
  46321. panningSensibility: number;
  46322. /**
  46323. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46324. */
  46325. multiTouchPanning: boolean;
  46326. /**
  46327. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46328. * zoom (pinch) through multitouch.
  46329. */
  46330. multiTouchPanAndZoom: boolean;
  46331. /**
  46332. * Revers pinch action direction.
  46333. */
  46334. pinchInwards: boolean;
  46335. private _isPanClick;
  46336. private _twoFingerActivityCount;
  46337. private _isPinching;
  46338. /**
  46339. * Called on pointer POINTERMOVE event if only a single touch is active.
  46340. */
  46341. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46342. /**
  46343. * Called on pointer POINTERDOUBLETAP event.
  46344. */
  46345. protected onDoubleTap(type: string): void;
  46346. /**
  46347. * Called on pointer POINTERMOVE event if multiple touches are active.
  46348. */
  46349. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46350. /**
  46351. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46352. * press.
  46353. */
  46354. protected onButtonDown(evt: PointerEvent): void;
  46355. /**
  46356. * Called each time a new POINTERUP event occurs. Ie, for each button
  46357. * release.
  46358. */
  46359. protected onButtonUp(evt: PointerEvent): void;
  46360. /**
  46361. * Called when window becomes inactive.
  46362. */
  46363. protected onLostFocus(): void;
  46364. }
  46365. }
  46366. declare module BABYLON {
  46367. /**
  46368. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46369. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46370. */
  46371. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46372. /**
  46373. * Defines the camera the input is attached to.
  46374. */
  46375. camera: ArcRotateCamera;
  46376. /**
  46377. * Defines the list of key codes associated with the up action (increase alpha)
  46378. */
  46379. keysUp: number[];
  46380. /**
  46381. * Defines the list of key codes associated with the down action (decrease alpha)
  46382. */
  46383. keysDown: number[];
  46384. /**
  46385. * Defines the list of key codes associated with the left action (increase beta)
  46386. */
  46387. keysLeft: number[];
  46388. /**
  46389. * Defines the list of key codes associated with the right action (decrease beta)
  46390. */
  46391. keysRight: number[];
  46392. /**
  46393. * Defines the list of key codes associated with the reset action.
  46394. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46395. */
  46396. keysReset: number[];
  46397. /**
  46398. * Defines the panning sensibility of the inputs.
  46399. * (How fast is the camera panning)
  46400. */
  46401. panningSensibility: number;
  46402. /**
  46403. * Defines the zooming sensibility of the inputs.
  46404. * (How fast is the camera zooming)
  46405. */
  46406. zoomingSensibility: number;
  46407. /**
  46408. * Defines whether maintaining the alt key down switch the movement mode from
  46409. * orientation to zoom.
  46410. */
  46411. useAltToZoom: boolean;
  46412. /**
  46413. * Rotation speed of the camera
  46414. */
  46415. angularSpeed: number;
  46416. private _keys;
  46417. private _ctrlPressed;
  46418. private _altPressed;
  46419. private _onCanvasBlurObserver;
  46420. private _onKeyboardObserver;
  46421. private _engine;
  46422. private _scene;
  46423. /**
  46424. * Attach the input controls to a specific dom element to get the input from.
  46425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46426. */
  46427. attachControl(noPreventDefault?: boolean): void;
  46428. /**
  46429. * Detach the current controls from the specified dom element.
  46430. */
  46431. detachControl(): void;
  46432. /**
  46433. * Update the current camera state depending on the inputs that have been used this frame.
  46434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46435. */
  46436. checkInputs(): void;
  46437. /**
  46438. * Gets the class name of the current intput.
  46439. * @returns the class name
  46440. */
  46441. getClassName(): string;
  46442. /**
  46443. * Get the friendly name associated with the input class.
  46444. * @returns the input friendly name
  46445. */
  46446. getSimpleName(): string;
  46447. }
  46448. }
  46449. declare module BABYLON {
  46450. /**
  46451. * Manage the mouse wheel inputs to control an arc rotate camera.
  46452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46453. */
  46454. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46455. /**
  46456. * Defines the camera the input is attached to.
  46457. */
  46458. camera: ArcRotateCamera;
  46459. /**
  46460. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46461. */
  46462. wheelPrecision: number;
  46463. /**
  46464. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46465. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46466. */
  46467. wheelDeltaPercentage: number;
  46468. private _wheel;
  46469. private _observer;
  46470. private computeDeltaFromMouseWheelLegacyEvent;
  46471. /**
  46472. * Attach the input controls to a specific dom element to get the input from.
  46473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46474. */
  46475. attachControl(noPreventDefault?: boolean): void;
  46476. /**
  46477. * Detach the current controls from the specified dom element.
  46478. */
  46479. detachControl(): void;
  46480. /**
  46481. * Gets the class name of the current intput.
  46482. * @returns the class name
  46483. */
  46484. getClassName(): string;
  46485. /**
  46486. * Get the friendly name associated with the input class.
  46487. * @returns the input friendly name
  46488. */
  46489. getSimpleName(): string;
  46490. }
  46491. }
  46492. declare module BABYLON {
  46493. /**
  46494. * Default Inputs manager for the ArcRotateCamera.
  46495. * It groups all the default supported inputs for ease of use.
  46496. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46497. */
  46498. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46499. /**
  46500. * Instantiates a new ArcRotateCameraInputsManager.
  46501. * @param camera Defines the camera the inputs belong to
  46502. */
  46503. constructor(camera: ArcRotateCamera);
  46504. /**
  46505. * Add mouse wheel input support to the input manager.
  46506. * @returns the current input manager
  46507. */
  46508. addMouseWheel(): ArcRotateCameraInputsManager;
  46509. /**
  46510. * Add pointers input support to the input manager.
  46511. * @returns the current input manager
  46512. */
  46513. addPointers(): ArcRotateCameraInputsManager;
  46514. /**
  46515. * Add keyboard input support to the input manager.
  46516. * @returns the current input manager
  46517. */
  46518. addKeyboard(): ArcRotateCameraInputsManager;
  46519. }
  46520. }
  46521. declare module BABYLON {
  46522. /**
  46523. * This represents an orbital type of camera.
  46524. *
  46525. * 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.
  46526. * 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.
  46527. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46528. */
  46529. export class ArcRotateCamera extends TargetCamera {
  46530. /**
  46531. * Defines the rotation angle of the camera along the longitudinal axis.
  46532. */
  46533. alpha: number;
  46534. /**
  46535. * Defines the rotation angle of the camera along the latitudinal axis.
  46536. */
  46537. beta: number;
  46538. /**
  46539. * Defines the radius of the camera from it s target point.
  46540. */
  46541. radius: number;
  46542. protected _target: Vector3;
  46543. protected _targetHost: Nullable<AbstractMesh>;
  46544. /**
  46545. * Defines the target point of the camera.
  46546. * The camera looks towards it form the radius distance.
  46547. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46548. */
  46549. get target(): Vector3;
  46550. set target(value: Vector3);
  46551. /**
  46552. * Define the current local position of the camera in the scene
  46553. */
  46554. get position(): Vector3;
  46555. set position(newPosition: Vector3);
  46556. protected _upToYMatrix: Matrix;
  46557. protected _YToUpMatrix: Matrix;
  46558. /**
  46559. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46560. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46561. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46562. */
  46563. set upVector(vec: Vector3);
  46564. get upVector(): Vector3;
  46565. /**
  46566. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46567. */
  46568. setMatUp(): void;
  46569. /**
  46570. * Current inertia value on the longitudinal axis.
  46571. * The bigger this number the longer it will take for the camera to stop.
  46572. */
  46573. inertialAlphaOffset: number;
  46574. /**
  46575. * Current inertia value on the latitudinal axis.
  46576. * The bigger this number the longer it will take for the camera to stop.
  46577. */
  46578. inertialBetaOffset: number;
  46579. /**
  46580. * Current inertia value on the radius axis.
  46581. * The bigger this number the longer it will take for the camera to stop.
  46582. */
  46583. inertialRadiusOffset: number;
  46584. /**
  46585. * Minimum allowed angle on the longitudinal axis.
  46586. * This can help limiting how the Camera is able to move in the scene.
  46587. */
  46588. lowerAlphaLimit: Nullable<number>;
  46589. /**
  46590. * Maximum allowed angle on the longitudinal axis.
  46591. * This can help limiting how the Camera is able to move in the scene.
  46592. */
  46593. upperAlphaLimit: Nullable<number>;
  46594. /**
  46595. * Minimum allowed angle on the latitudinal axis.
  46596. * This can help limiting how the Camera is able to move in the scene.
  46597. */
  46598. lowerBetaLimit: number;
  46599. /**
  46600. * Maximum allowed angle on the latitudinal axis.
  46601. * This can help limiting how the Camera is able to move in the scene.
  46602. */
  46603. upperBetaLimit: number;
  46604. /**
  46605. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46606. * This can help limiting how the Camera is able to move in the scene.
  46607. */
  46608. lowerRadiusLimit: Nullable<number>;
  46609. /**
  46610. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46611. * This can help limiting how the Camera is able to move in the scene.
  46612. */
  46613. upperRadiusLimit: Nullable<number>;
  46614. /**
  46615. * Defines the current inertia value used during panning of the camera along the X axis.
  46616. */
  46617. inertialPanningX: number;
  46618. /**
  46619. * Defines the current inertia value used during panning of the camera along the Y axis.
  46620. */
  46621. inertialPanningY: number;
  46622. /**
  46623. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46624. * Basically if your fingers moves away from more than this distance you will be considered
  46625. * in pinch mode.
  46626. */
  46627. pinchToPanMaxDistance: number;
  46628. /**
  46629. * Defines the maximum distance the camera can pan.
  46630. * This could help keeping the cammera always in your scene.
  46631. */
  46632. panningDistanceLimit: Nullable<number>;
  46633. /**
  46634. * Defines the target of the camera before paning.
  46635. */
  46636. panningOriginTarget: Vector3;
  46637. /**
  46638. * Defines the value of the inertia used during panning.
  46639. * 0 would mean stop inertia and one would mean no decelleration at all.
  46640. */
  46641. panningInertia: number;
  46642. /**
  46643. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46644. */
  46645. get angularSensibilityX(): number;
  46646. set angularSensibilityX(value: number);
  46647. /**
  46648. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46649. */
  46650. get angularSensibilityY(): number;
  46651. set angularSensibilityY(value: number);
  46652. /**
  46653. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46654. */
  46655. get pinchPrecision(): number;
  46656. set pinchPrecision(value: number);
  46657. /**
  46658. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46659. * It will be used instead of pinchDeltaPrecision if different from 0.
  46660. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46661. */
  46662. get pinchDeltaPercentage(): number;
  46663. set pinchDeltaPercentage(value: number);
  46664. /**
  46665. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46666. * and pinch delta percentage.
  46667. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46668. * that any object in the plane at the camera's target point will scale
  46669. * perfectly with finger motion.
  46670. */
  46671. get useNaturalPinchZoom(): boolean;
  46672. set useNaturalPinchZoom(value: boolean);
  46673. /**
  46674. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46675. */
  46676. get panningSensibility(): number;
  46677. set panningSensibility(value: number);
  46678. /**
  46679. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46680. */
  46681. get keysUp(): number[];
  46682. set keysUp(value: number[]);
  46683. /**
  46684. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46685. */
  46686. get keysDown(): number[];
  46687. set keysDown(value: number[]);
  46688. /**
  46689. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46690. */
  46691. get keysLeft(): number[];
  46692. set keysLeft(value: number[]);
  46693. /**
  46694. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46695. */
  46696. get keysRight(): number[];
  46697. set keysRight(value: number[]);
  46698. /**
  46699. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46700. */
  46701. get wheelPrecision(): number;
  46702. set wheelPrecision(value: number);
  46703. /**
  46704. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46705. * It will be used instead of pinchDeltaPrecision if different from 0.
  46706. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46707. */
  46708. get wheelDeltaPercentage(): number;
  46709. set wheelDeltaPercentage(value: number);
  46710. /**
  46711. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46712. */
  46713. zoomOnFactor: number;
  46714. /**
  46715. * Defines a screen offset for the camera position.
  46716. */
  46717. targetScreenOffset: Vector2;
  46718. /**
  46719. * Allows the camera to be completely reversed.
  46720. * If false the camera can not arrive upside down.
  46721. */
  46722. allowUpsideDown: boolean;
  46723. /**
  46724. * Define if double tap/click is used to restore the previously saved state of the camera.
  46725. */
  46726. useInputToRestoreState: boolean;
  46727. /** @hidden */
  46728. _viewMatrix: Matrix;
  46729. /** @hidden */
  46730. _useCtrlForPanning: boolean;
  46731. /** @hidden */
  46732. _panningMouseButton: number;
  46733. /**
  46734. * Defines the input associated to the camera.
  46735. */
  46736. inputs: ArcRotateCameraInputsManager;
  46737. /** @hidden */
  46738. _reset: () => void;
  46739. /**
  46740. * Defines the allowed panning axis.
  46741. */
  46742. panningAxis: Vector3;
  46743. protected _localDirection: Vector3;
  46744. protected _transformedDirection: Vector3;
  46745. private _bouncingBehavior;
  46746. /**
  46747. * Gets the bouncing behavior of the camera if it has been enabled.
  46748. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46749. */
  46750. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46751. /**
  46752. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46753. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46754. */
  46755. get useBouncingBehavior(): boolean;
  46756. set useBouncingBehavior(value: boolean);
  46757. private _framingBehavior;
  46758. /**
  46759. * Gets the framing behavior of the camera if it has been enabled.
  46760. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46761. */
  46762. get framingBehavior(): Nullable<FramingBehavior>;
  46763. /**
  46764. * Defines if the framing behavior of the camera is enabled on the camera.
  46765. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46766. */
  46767. get useFramingBehavior(): boolean;
  46768. set useFramingBehavior(value: boolean);
  46769. private _autoRotationBehavior;
  46770. /**
  46771. * Gets the auto rotation behavior of the camera if it has been enabled.
  46772. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46773. */
  46774. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46775. /**
  46776. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46777. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46778. */
  46779. get useAutoRotationBehavior(): boolean;
  46780. set useAutoRotationBehavior(value: boolean);
  46781. /**
  46782. * Observable triggered when the mesh target has been changed on the camera.
  46783. */
  46784. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46785. /**
  46786. * Event raised when the camera is colliding with a mesh.
  46787. */
  46788. onCollide: (collidedMesh: AbstractMesh) => void;
  46789. /**
  46790. * Defines whether the camera should check collision with the objects oh the scene.
  46791. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46792. */
  46793. checkCollisions: boolean;
  46794. /**
  46795. * Defines the collision radius of the camera.
  46796. * This simulates a sphere around the camera.
  46797. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46798. */
  46799. collisionRadius: Vector3;
  46800. protected _collider: Collider;
  46801. protected _previousPosition: Vector3;
  46802. protected _collisionVelocity: Vector3;
  46803. protected _newPosition: Vector3;
  46804. protected _previousAlpha: number;
  46805. protected _previousBeta: number;
  46806. protected _previousRadius: number;
  46807. protected _collisionTriggered: boolean;
  46808. protected _targetBoundingCenter: Nullable<Vector3>;
  46809. private _computationVector;
  46810. /**
  46811. * Instantiates a new ArcRotateCamera in a given scene
  46812. * @param name Defines the name of the camera
  46813. * @param alpha Defines the camera rotation along the logitudinal axis
  46814. * @param beta Defines the camera rotation along the latitudinal axis
  46815. * @param radius Defines the camera distance from its target
  46816. * @param target Defines the camera target
  46817. * @param scene Defines the scene the camera belongs to
  46818. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46819. */
  46820. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46821. /** @hidden */
  46822. _initCache(): void;
  46823. /** @hidden */
  46824. _updateCache(ignoreParentClass?: boolean): void;
  46825. protected _getTargetPosition(): Vector3;
  46826. private _storedAlpha;
  46827. private _storedBeta;
  46828. private _storedRadius;
  46829. private _storedTarget;
  46830. private _storedTargetScreenOffset;
  46831. /**
  46832. * Stores the current state of the camera (alpha, beta, radius and target)
  46833. * @returns the camera itself
  46834. */
  46835. storeState(): Camera;
  46836. /**
  46837. * @hidden
  46838. * Restored camera state. You must call storeState() first
  46839. */
  46840. _restoreStateValues(): boolean;
  46841. /** @hidden */
  46842. _isSynchronizedViewMatrix(): boolean;
  46843. /**
  46844. * Attach the input controls to a specific dom element to get the input from.
  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. */
  46847. attachControl(noPreventDefault?: boolean): void;
  46848. /**
  46849. * Attach the input controls to a specific dom element to get the input from.
  46850. * @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
  46851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46852. */
  46853. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46854. /**
  46855. * Attached controls to the current camera.
  46856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46857. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46858. */
  46859. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46860. /**
  46861. * Attached controls to the current camera.
  46862. * @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
  46863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46864. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46865. */
  46866. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46867. /**
  46868. * Attached controls to the current camera.
  46869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46870. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46871. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46872. */
  46873. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46874. /**
  46875. * Detach the current controls from the specified dom element.
  46876. */
  46877. detachControl(): void;
  46878. /**
  46879. * Detach the current controls from the specified dom element.
  46880. * @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
  46881. */
  46882. detachControl(ignored: any): void;
  46883. /** @hidden */
  46884. _checkInputs(): void;
  46885. protected _checkLimits(): void;
  46886. /**
  46887. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46888. */
  46889. rebuildAnglesAndRadius(): void;
  46890. /**
  46891. * Use a position to define the current camera related information like alpha, beta and radius
  46892. * @param position Defines the position to set the camera at
  46893. */
  46894. setPosition(position: Vector3): void;
  46895. /**
  46896. * Defines the target the camera should look at.
  46897. * This will automatically adapt alpha beta and radius to fit within the new target.
  46898. * @param target Defines the new target as a Vector or a mesh
  46899. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46900. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46901. */
  46902. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46903. /** @hidden */
  46904. _getViewMatrix(): Matrix;
  46905. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46906. /**
  46907. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46908. * @param meshes Defines the mesh to zoom on
  46909. * @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)
  46910. */
  46911. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46912. /**
  46913. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46914. * The target will be changed but the radius
  46915. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46916. * @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)
  46917. */
  46918. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46919. min: Vector3;
  46920. max: Vector3;
  46921. distance: number;
  46922. }, doNotUpdateMaxZ?: boolean): void;
  46923. /**
  46924. * @override
  46925. * Override Camera.createRigCamera
  46926. */
  46927. createRigCamera(name: string, cameraIndex: number): Camera;
  46928. /**
  46929. * @hidden
  46930. * @override
  46931. * Override Camera._updateRigCameras
  46932. */
  46933. _updateRigCameras(): void;
  46934. /**
  46935. * Destroy the camera and release the current resources hold by it.
  46936. */
  46937. dispose(): void;
  46938. /**
  46939. * Gets the current object class name.
  46940. * @return the class name
  46941. */
  46942. getClassName(): string;
  46943. }
  46944. }
  46945. declare module BABYLON {
  46946. /**
  46947. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46949. */
  46950. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46951. /**
  46952. * Gets the name of the behavior.
  46953. */
  46954. get name(): string;
  46955. private _zoomStopsAnimation;
  46956. private _idleRotationSpeed;
  46957. private _idleRotationWaitTime;
  46958. private _idleRotationSpinupTime;
  46959. /**
  46960. * Sets the flag that indicates if user zooming should stop animation.
  46961. */
  46962. set zoomStopsAnimation(flag: boolean);
  46963. /**
  46964. * Gets the flag that indicates if user zooming should stop animation.
  46965. */
  46966. get zoomStopsAnimation(): boolean;
  46967. /**
  46968. * Sets the default speed at which the camera rotates around the model.
  46969. */
  46970. set idleRotationSpeed(speed: number);
  46971. /**
  46972. * Gets the default speed at which the camera rotates around the model.
  46973. */
  46974. get idleRotationSpeed(): number;
  46975. /**
  46976. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46977. */
  46978. set idleRotationWaitTime(time: number);
  46979. /**
  46980. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46981. */
  46982. get idleRotationWaitTime(): number;
  46983. /**
  46984. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46985. */
  46986. set idleRotationSpinupTime(time: number);
  46987. /**
  46988. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46989. */
  46990. get idleRotationSpinupTime(): number;
  46991. /**
  46992. * Gets a value indicating if the camera is currently rotating because of this behavior
  46993. */
  46994. get rotationInProgress(): boolean;
  46995. private _onPrePointerObservableObserver;
  46996. private _onAfterCheckInputsObserver;
  46997. private _attachedCamera;
  46998. private _isPointerDown;
  46999. private _lastFrameTime;
  47000. private _lastInteractionTime;
  47001. private _cameraRotationSpeed;
  47002. /**
  47003. * Initializes the behavior.
  47004. */
  47005. init(): void;
  47006. /**
  47007. * Attaches the behavior to its arc rotate camera.
  47008. * @param camera Defines the camera to attach the behavior to
  47009. */
  47010. attach(camera: ArcRotateCamera): void;
  47011. /**
  47012. * Detaches the behavior from its current arc rotate camera.
  47013. */
  47014. detach(): void;
  47015. /**
  47016. * Returns true if user is scrolling.
  47017. * @return true if user is scrolling.
  47018. */
  47019. private _userIsZooming;
  47020. private _lastFrameRadius;
  47021. private _shouldAnimationStopForInteraction;
  47022. /**
  47023. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47024. */
  47025. private _applyUserInteraction;
  47026. private _userIsMoving;
  47027. }
  47028. }
  47029. declare module BABYLON {
  47030. /**
  47031. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47032. */
  47033. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47034. private ui;
  47035. /**
  47036. * The name of the behavior
  47037. */
  47038. name: string;
  47039. /**
  47040. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47041. */
  47042. distanceAwayFromFace: number;
  47043. /**
  47044. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47045. */
  47046. distanceAwayFromBottomOfFace: number;
  47047. private _faceVectors;
  47048. private _target;
  47049. private _scene;
  47050. private _onRenderObserver;
  47051. private _tmpMatrix;
  47052. private _tmpVector;
  47053. /**
  47054. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47055. * @param ui The transform node that should be attched to the mesh
  47056. */
  47057. constructor(ui: TransformNode);
  47058. /**
  47059. * Initializes the behavior
  47060. */
  47061. init(): void;
  47062. private _closestFace;
  47063. private _zeroVector;
  47064. private _lookAtTmpMatrix;
  47065. private _lookAtToRef;
  47066. /**
  47067. * Attaches the AttachToBoxBehavior to the passed in mesh
  47068. * @param target The mesh that the specified node will be attached to
  47069. */
  47070. attach(target: Mesh): void;
  47071. /**
  47072. * Detaches the behavior from the mesh
  47073. */
  47074. detach(): void;
  47075. }
  47076. }
  47077. declare module BABYLON {
  47078. /**
  47079. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47080. */
  47081. export class FadeInOutBehavior implements Behavior<Mesh> {
  47082. /**
  47083. * Time in milliseconds to delay before fading in (Default: 0)
  47084. */
  47085. delay: number;
  47086. /**
  47087. * Time in milliseconds for the mesh to fade in (Default: 300)
  47088. */
  47089. fadeInTime: number;
  47090. private _millisecondsPerFrame;
  47091. private _hovered;
  47092. private _hoverValue;
  47093. private _ownerNode;
  47094. /**
  47095. * Instatiates the FadeInOutBehavior
  47096. */
  47097. constructor();
  47098. /**
  47099. * The name of the behavior
  47100. */
  47101. get name(): string;
  47102. /**
  47103. * Initializes the behavior
  47104. */
  47105. init(): void;
  47106. /**
  47107. * Attaches the fade behavior on the passed in mesh
  47108. * @param ownerNode The mesh that will be faded in/out once attached
  47109. */
  47110. attach(ownerNode: Mesh): void;
  47111. /**
  47112. * Detaches the behavior from the mesh
  47113. */
  47114. detach(): void;
  47115. /**
  47116. * Triggers the mesh to begin fading in or out
  47117. * @param value if the object should fade in or out (true to fade in)
  47118. */
  47119. fadeIn(value: boolean): void;
  47120. private _update;
  47121. private _setAllVisibility;
  47122. }
  47123. }
  47124. declare module BABYLON {
  47125. /**
  47126. * Class containing a set of static utilities functions for managing Pivots
  47127. * @hidden
  47128. */
  47129. export class PivotTools {
  47130. private static _PivotCached;
  47131. private static _OldPivotPoint;
  47132. private static _PivotTranslation;
  47133. private static _PivotTmpVector;
  47134. private static _PivotPostMultiplyPivotMatrix;
  47135. /** @hidden */
  47136. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47137. /** @hidden */
  47138. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47139. }
  47140. }
  47141. declare module BABYLON {
  47142. /**
  47143. * Class containing static functions to help procedurally build meshes
  47144. */
  47145. export class PlaneBuilder {
  47146. /**
  47147. * Creates a plane mesh
  47148. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47149. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47150. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47152. * * 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
  47153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47154. * @param name defines the name of the mesh
  47155. * @param options defines the options used to create the mesh
  47156. * @param scene defines the hosting scene
  47157. * @returns the plane mesh
  47158. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47159. */
  47160. static CreatePlane(name: string, options: {
  47161. size?: number;
  47162. width?: number;
  47163. height?: number;
  47164. sideOrientation?: number;
  47165. frontUVs?: Vector4;
  47166. backUVs?: Vector4;
  47167. updatable?: boolean;
  47168. sourcePlane?: Plane;
  47169. }, scene?: Nullable<Scene>): Mesh;
  47170. }
  47171. }
  47172. declare module BABYLON {
  47173. /**
  47174. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47175. */
  47176. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47177. private static _AnyMouseID;
  47178. /**
  47179. * Abstract mesh the behavior is set on
  47180. */
  47181. attachedNode: AbstractMesh;
  47182. private _dragPlane;
  47183. private _scene;
  47184. private _pointerObserver;
  47185. private _beforeRenderObserver;
  47186. private static _planeScene;
  47187. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47188. /**
  47189. * 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)
  47190. */
  47191. maxDragAngle: number;
  47192. /**
  47193. * @hidden
  47194. */
  47195. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47196. /**
  47197. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47198. */
  47199. currentDraggingPointerID: number;
  47200. /**
  47201. * The last position where the pointer hit the drag plane in world space
  47202. */
  47203. lastDragPosition: Vector3;
  47204. /**
  47205. * If the behavior is currently in a dragging state
  47206. */
  47207. dragging: boolean;
  47208. /**
  47209. * 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)
  47210. */
  47211. dragDeltaRatio: number;
  47212. /**
  47213. * If the drag plane orientation should be updated during the dragging (Default: true)
  47214. */
  47215. updateDragPlane: boolean;
  47216. private _debugMode;
  47217. private _moving;
  47218. /**
  47219. * Fires each time the attached mesh is dragged with the pointer
  47220. * * delta between last drag position and current drag position in world space
  47221. * * dragDistance along the drag axis
  47222. * * dragPlaneNormal normal of the current drag plane used during the drag
  47223. * * dragPlanePoint in world space where the drag intersects the drag plane
  47224. */
  47225. onDragObservable: Observable<{
  47226. delta: Vector3;
  47227. dragPlanePoint: Vector3;
  47228. dragPlaneNormal: Vector3;
  47229. dragDistance: number;
  47230. pointerId: number;
  47231. }>;
  47232. /**
  47233. * Fires each time a drag begins (eg. mouse down on mesh)
  47234. */
  47235. onDragStartObservable: Observable<{
  47236. dragPlanePoint: Vector3;
  47237. pointerId: number;
  47238. }>;
  47239. /**
  47240. * Fires each time a drag ends (eg. mouse release after drag)
  47241. */
  47242. onDragEndObservable: Observable<{
  47243. dragPlanePoint: Vector3;
  47244. pointerId: number;
  47245. }>;
  47246. /**
  47247. * If the attached mesh should be moved when dragged
  47248. */
  47249. moveAttached: boolean;
  47250. /**
  47251. * If the drag behavior will react to drag events (Default: true)
  47252. */
  47253. enabled: boolean;
  47254. /**
  47255. * If pointer events should start and release the drag (Default: true)
  47256. */
  47257. startAndReleaseDragOnPointerEvents: boolean;
  47258. /**
  47259. * If camera controls should be detached during the drag
  47260. */
  47261. detachCameraControls: boolean;
  47262. /**
  47263. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47264. */
  47265. useObjectOrientationForDragging: boolean;
  47266. private _options;
  47267. /**
  47268. * Gets the options used by the behavior
  47269. */
  47270. get options(): {
  47271. dragAxis?: Vector3;
  47272. dragPlaneNormal?: Vector3;
  47273. };
  47274. /**
  47275. * Sets the options used by the behavior
  47276. */
  47277. set options(options: {
  47278. dragAxis?: Vector3;
  47279. dragPlaneNormal?: Vector3;
  47280. });
  47281. /**
  47282. * Creates a pointer drag behavior that can be attached to a mesh
  47283. * @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)
  47284. */
  47285. constructor(options?: {
  47286. dragAxis?: Vector3;
  47287. dragPlaneNormal?: Vector3;
  47288. });
  47289. /**
  47290. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47291. */
  47292. validateDrag: (targetPosition: Vector3) => boolean;
  47293. /**
  47294. * The name of the behavior
  47295. */
  47296. get name(): string;
  47297. /**
  47298. * Initializes the behavior
  47299. */
  47300. init(): void;
  47301. private _tmpVector;
  47302. private _alternatePickedPoint;
  47303. private _worldDragAxis;
  47304. private _targetPosition;
  47305. private _attachedToElement;
  47306. /**
  47307. * Attaches the drag behavior the passed in mesh
  47308. * @param ownerNode The mesh that will be dragged around once attached
  47309. * @param predicate Predicate to use for pick filtering
  47310. */
  47311. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47312. /**
  47313. * Force relase the drag action by code.
  47314. */
  47315. releaseDrag(): void;
  47316. private _startDragRay;
  47317. private _lastPointerRay;
  47318. /**
  47319. * Simulates the start of a pointer drag event on the behavior
  47320. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47321. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47322. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47323. */
  47324. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47325. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47326. private _dragDelta;
  47327. protected _moveDrag(ray: Ray): void;
  47328. private _pickWithRayOnDragPlane;
  47329. private _pointA;
  47330. private _pointC;
  47331. private _localAxis;
  47332. private _lookAt;
  47333. private _updateDragPlanePosition;
  47334. /**
  47335. * Detaches the behavior from the mesh
  47336. */
  47337. detach(): void;
  47338. }
  47339. }
  47340. declare module BABYLON {
  47341. /**
  47342. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47343. */
  47344. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47345. private _dragBehaviorA;
  47346. private _dragBehaviorB;
  47347. private _startDistance;
  47348. private _initialScale;
  47349. private _targetScale;
  47350. private _ownerNode;
  47351. private _sceneRenderObserver;
  47352. /**
  47353. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47354. */
  47355. constructor();
  47356. /**
  47357. * The name of the behavior
  47358. */
  47359. get name(): string;
  47360. /**
  47361. * Initializes the behavior
  47362. */
  47363. init(): void;
  47364. private _getCurrentDistance;
  47365. /**
  47366. * Attaches the scale behavior the passed in mesh
  47367. * @param ownerNode The mesh that will be scaled around once attached
  47368. */
  47369. attach(ownerNode: Mesh): void;
  47370. /**
  47371. * Detaches the behavior from the mesh
  47372. */
  47373. detach(): void;
  47374. }
  47375. }
  47376. declare module BABYLON {
  47377. /**
  47378. * 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
  47379. */
  47380. export class SixDofDragBehavior implements Behavior<Mesh> {
  47381. private static _virtualScene;
  47382. private _ownerNode;
  47383. private _sceneRenderObserver;
  47384. private _scene;
  47385. private _targetPosition;
  47386. private _virtualOriginMesh;
  47387. private _virtualDragMesh;
  47388. private _pointerObserver;
  47389. private _moving;
  47390. private _startingOrientation;
  47391. private _attachedToElement;
  47392. /**
  47393. * 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)
  47394. */
  47395. private zDragFactor;
  47396. /**
  47397. * If the object should rotate to face the drag origin
  47398. */
  47399. rotateDraggedObject: boolean;
  47400. /**
  47401. * If the behavior is currently in a dragging state
  47402. */
  47403. dragging: boolean;
  47404. /**
  47405. * 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)
  47406. */
  47407. dragDeltaRatio: number;
  47408. /**
  47409. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47410. */
  47411. currentDraggingPointerID: number;
  47412. /**
  47413. * If camera controls should be detached during the drag
  47414. */
  47415. detachCameraControls: boolean;
  47416. /**
  47417. * Fires each time a drag starts
  47418. */
  47419. onDragStartObservable: Observable<{}>;
  47420. /**
  47421. * Fires each time a drag happens
  47422. */
  47423. onDragObservable: Observable<void>;
  47424. /**
  47425. * Fires each time a drag ends (eg. mouse release after drag)
  47426. */
  47427. onDragEndObservable: Observable<{}>;
  47428. /**
  47429. * 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
  47430. */
  47431. constructor();
  47432. /**
  47433. * The name of the behavior
  47434. */
  47435. get name(): string;
  47436. /**
  47437. * Initializes the behavior
  47438. */
  47439. init(): void;
  47440. /**
  47441. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47442. */
  47443. private get _pointerCamera();
  47444. /**
  47445. * Attaches the scale behavior the passed in mesh
  47446. * @param ownerNode The mesh that will be scaled around once attached
  47447. */
  47448. attach(ownerNode: Mesh): void;
  47449. /**
  47450. * Detaches the behavior from the mesh
  47451. */
  47452. detach(): void;
  47453. }
  47454. }
  47455. declare module BABYLON {
  47456. /**
  47457. * Class used to apply inverse kinematics to bones
  47458. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47459. */
  47460. export class BoneIKController {
  47461. private static _tmpVecs;
  47462. private static _tmpQuat;
  47463. private static _tmpMats;
  47464. /**
  47465. * Gets or sets the target mesh
  47466. */
  47467. targetMesh: AbstractMesh;
  47468. /** Gets or sets the mesh used as pole */
  47469. poleTargetMesh: AbstractMesh;
  47470. /**
  47471. * Gets or sets the bone used as pole
  47472. */
  47473. poleTargetBone: Nullable<Bone>;
  47474. /**
  47475. * Gets or sets the target position
  47476. */
  47477. targetPosition: Vector3;
  47478. /**
  47479. * Gets or sets the pole target position
  47480. */
  47481. poleTargetPosition: Vector3;
  47482. /**
  47483. * Gets or sets the pole target local offset
  47484. */
  47485. poleTargetLocalOffset: Vector3;
  47486. /**
  47487. * Gets or sets the pole angle
  47488. */
  47489. poleAngle: number;
  47490. /**
  47491. * Gets or sets the mesh associated with the controller
  47492. */
  47493. mesh: AbstractMesh;
  47494. /**
  47495. * 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)
  47496. */
  47497. slerpAmount: number;
  47498. private _bone1Quat;
  47499. private _bone1Mat;
  47500. private _bone2Ang;
  47501. private _bone1;
  47502. private _bone2;
  47503. private _bone1Length;
  47504. private _bone2Length;
  47505. private _maxAngle;
  47506. private _maxReach;
  47507. private _rightHandedSystem;
  47508. private _bendAxis;
  47509. private _slerping;
  47510. private _adjustRoll;
  47511. /**
  47512. * Gets or sets maximum allowed angle
  47513. */
  47514. get maxAngle(): number;
  47515. set maxAngle(value: number);
  47516. /**
  47517. * Creates a new BoneIKController
  47518. * @param mesh defines the mesh to control
  47519. * @param bone defines the bone to control
  47520. * @param options defines options to set up the controller
  47521. */
  47522. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47523. targetMesh?: AbstractMesh;
  47524. poleTargetMesh?: AbstractMesh;
  47525. poleTargetBone?: Bone;
  47526. poleTargetLocalOffset?: Vector3;
  47527. poleAngle?: number;
  47528. bendAxis?: Vector3;
  47529. maxAngle?: number;
  47530. slerpAmount?: number;
  47531. });
  47532. private _setMaxAngle;
  47533. /**
  47534. * Force the controller to update the bones
  47535. */
  47536. update(): void;
  47537. }
  47538. }
  47539. declare module BABYLON {
  47540. /**
  47541. * Class used to make a bone look toward a point in space
  47542. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47543. */
  47544. export class BoneLookController {
  47545. private static _tmpVecs;
  47546. private static _tmpQuat;
  47547. private static _tmpMats;
  47548. /**
  47549. * The target Vector3 that the bone will look at
  47550. */
  47551. target: Vector3;
  47552. /**
  47553. * The mesh that the bone is attached to
  47554. */
  47555. mesh: AbstractMesh;
  47556. /**
  47557. * The bone that will be looking to the target
  47558. */
  47559. bone: Bone;
  47560. /**
  47561. * The up axis of the coordinate system that is used when the bone is rotated
  47562. */
  47563. upAxis: Vector3;
  47564. /**
  47565. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47566. */
  47567. upAxisSpace: Space;
  47568. /**
  47569. * Used to make an adjustment to the yaw of the bone
  47570. */
  47571. adjustYaw: number;
  47572. /**
  47573. * Used to make an adjustment to the pitch of the bone
  47574. */
  47575. adjustPitch: number;
  47576. /**
  47577. * Used to make an adjustment to the roll of the bone
  47578. */
  47579. adjustRoll: number;
  47580. /**
  47581. * 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)
  47582. */
  47583. slerpAmount: number;
  47584. private _minYaw;
  47585. private _maxYaw;
  47586. private _minPitch;
  47587. private _maxPitch;
  47588. private _minYawSin;
  47589. private _minYawCos;
  47590. private _maxYawSin;
  47591. private _maxYawCos;
  47592. private _midYawConstraint;
  47593. private _minPitchTan;
  47594. private _maxPitchTan;
  47595. private _boneQuat;
  47596. private _slerping;
  47597. private _transformYawPitch;
  47598. private _transformYawPitchInv;
  47599. private _firstFrameSkipped;
  47600. private _yawRange;
  47601. private _fowardAxis;
  47602. /**
  47603. * Gets or sets the minimum yaw angle that the bone can look to
  47604. */
  47605. get minYaw(): number;
  47606. set minYaw(value: number);
  47607. /**
  47608. * Gets or sets the maximum yaw angle that the bone can look to
  47609. */
  47610. get maxYaw(): number;
  47611. set maxYaw(value: number);
  47612. /**
  47613. * Gets or sets the minimum pitch angle that the bone can look to
  47614. */
  47615. get minPitch(): number;
  47616. set minPitch(value: number);
  47617. /**
  47618. * Gets or sets the maximum pitch angle that the bone can look to
  47619. */
  47620. get maxPitch(): number;
  47621. set maxPitch(value: number);
  47622. /**
  47623. * Create a BoneLookController
  47624. * @param mesh the mesh that the bone belongs to
  47625. * @param bone the bone that will be looking to the target
  47626. * @param target the target Vector3 to look at
  47627. * @param options optional settings:
  47628. * * maxYaw: the maximum angle the bone will yaw to
  47629. * * minYaw: the minimum angle the bone will yaw to
  47630. * * maxPitch: the maximum angle the bone will pitch to
  47631. * * minPitch: the minimum angle the bone will yaw to
  47632. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47633. * * upAxis: the up axis of the coordinate system
  47634. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47635. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47636. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47637. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47638. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47639. * * adjustRoll: used to make an adjustment to the roll of the bone
  47640. **/
  47641. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47642. maxYaw?: number;
  47643. minYaw?: number;
  47644. maxPitch?: number;
  47645. minPitch?: number;
  47646. slerpAmount?: number;
  47647. upAxis?: Vector3;
  47648. upAxisSpace?: Space;
  47649. yawAxis?: Vector3;
  47650. pitchAxis?: Vector3;
  47651. adjustYaw?: number;
  47652. adjustPitch?: number;
  47653. adjustRoll?: number;
  47654. });
  47655. /**
  47656. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47657. */
  47658. update(): void;
  47659. private _getAngleDiff;
  47660. private _getAngleBetween;
  47661. private _isAngleBetween;
  47662. }
  47663. }
  47664. declare module BABYLON {
  47665. /**
  47666. * Manage the gamepad inputs to control an arc rotate camera.
  47667. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47668. */
  47669. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47670. /**
  47671. * Defines the camera the input is attached to.
  47672. */
  47673. camera: ArcRotateCamera;
  47674. /**
  47675. * Defines the gamepad the input is gathering event from.
  47676. */
  47677. gamepad: Nullable<Gamepad>;
  47678. /**
  47679. * Defines the gamepad rotation sensiblity.
  47680. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47681. */
  47682. gamepadRotationSensibility: number;
  47683. /**
  47684. * Defines the gamepad move sensiblity.
  47685. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47686. */
  47687. gamepadMoveSensibility: number;
  47688. private _yAxisScale;
  47689. /**
  47690. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47691. */
  47692. get invertYAxis(): boolean;
  47693. set invertYAxis(value: boolean);
  47694. private _onGamepadConnectedObserver;
  47695. private _onGamepadDisconnectedObserver;
  47696. /**
  47697. * Attach the input controls to a specific dom element to get the input from.
  47698. */
  47699. attachControl(): void;
  47700. /**
  47701. * Detach the current controls from the specified dom element.
  47702. */
  47703. detachControl(): void;
  47704. /**
  47705. * Update the current camera state depending on the inputs that have been used this frame.
  47706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47707. */
  47708. checkInputs(): void;
  47709. /**
  47710. * Gets the class name of the current intput.
  47711. * @returns the class name
  47712. */
  47713. getClassName(): string;
  47714. /**
  47715. * Get the friendly name associated with the input class.
  47716. * @returns the input friendly name
  47717. */
  47718. getSimpleName(): string;
  47719. }
  47720. }
  47721. declare module BABYLON {
  47722. interface ArcRotateCameraInputsManager {
  47723. /**
  47724. * Add orientation input support to the input manager.
  47725. * @returns the current input manager
  47726. */
  47727. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47728. }
  47729. /**
  47730. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47731. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47732. */
  47733. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47734. /**
  47735. * Defines the camera the input is attached to.
  47736. */
  47737. camera: ArcRotateCamera;
  47738. /**
  47739. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47740. */
  47741. alphaCorrection: number;
  47742. /**
  47743. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47744. */
  47745. gammaCorrection: number;
  47746. private _alpha;
  47747. private _gamma;
  47748. private _dirty;
  47749. private _deviceOrientationHandler;
  47750. /**
  47751. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47752. */
  47753. constructor();
  47754. /**
  47755. * Attach the input controls to a specific dom element to get the input from.
  47756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47757. */
  47758. attachControl(noPreventDefault?: boolean): void;
  47759. /** @hidden */
  47760. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47761. /**
  47762. * Update the current camera state depending on the inputs that have been used this frame.
  47763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47764. */
  47765. checkInputs(): void;
  47766. /**
  47767. * Detach the current controls from the specified dom element.
  47768. */
  47769. detachControl(): void;
  47770. /**
  47771. * Gets the class name of the current intput.
  47772. * @returns the class name
  47773. */
  47774. getClassName(): string;
  47775. /**
  47776. * Get the friendly name associated with the input class.
  47777. * @returns the input friendly name
  47778. */
  47779. getSimpleName(): string;
  47780. }
  47781. }
  47782. declare module BABYLON {
  47783. /**
  47784. * Listen to mouse events to control the camera.
  47785. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47786. */
  47787. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47788. /**
  47789. * Defines the camera the input is attached to.
  47790. */
  47791. camera: FlyCamera;
  47792. /**
  47793. * Defines if touch is enabled. (Default is true.)
  47794. */
  47795. touchEnabled: boolean;
  47796. /**
  47797. * Defines the buttons associated with the input to handle camera rotation.
  47798. */
  47799. buttons: number[];
  47800. /**
  47801. * Assign buttons for Yaw control.
  47802. */
  47803. buttonsYaw: number[];
  47804. /**
  47805. * Assign buttons for Pitch control.
  47806. */
  47807. buttonsPitch: number[];
  47808. /**
  47809. * Assign buttons for Roll control.
  47810. */
  47811. buttonsRoll: number[];
  47812. /**
  47813. * Detect if any button is being pressed while mouse is moved.
  47814. * -1 = Mouse locked.
  47815. * 0 = Left button.
  47816. * 1 = Middle Button.
  47817. * 2 = Right Button.
  47818. */
  47819. activeButton: number;
  47820. /**
  47821. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47822. * Higher values reduce its sensitivity.
  47823. */
  47824. angularSensibility: number;
  47825. private _observer;
  47826. private _rollObserver;
  47827. private previousPosition;
  47828. private noPreventDefault;
  47829. private element;
  47830. /**
  47831. * Listen to mouse events to control the camera.
  47832. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47833. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47834. */
  47835. constructor(touchEnabled?: boolean);
  47836. /**
  47837. * Attach the mouse control to the HTML DOM element.
  47838. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47839. */
  47840. attachControl(noPreventDefault?: boolean): void;
  47841. /**
  47842. * Detach the current controls from the specified dom element.
  47843. */
  47844. detachControl(): void;
  47845. /**
  47846. * Gets the class name of the current input.
  47847. * @returns the class name.
  47848. */
  47849. getClassName(): string;
  47850. /**
  47851. * Get the friendly name associated with the input class.
  47852. * @returns the input's friendly name.
  47853. */
  47854. getSimpleName(): string;
  47855. private _pointerInput;
  47856. private _onMouseMove;
  47857. /**
  47858. * Rotate camera by mouse offset.
  47859. */
  47860. private rotateCamera;
  47861. }
  47862. }
  47863. declare module BABYLON {
  47864. /**
  47865. * Default Inputs manager for the FlyCamera.
  47866. * It groups all the default supported inputs for ease of use.
  47867. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47868. */
  47869. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47870. /**
  47871. * Instantiates a new FlyCameraInputsManager.
  47872. * @param camera Defines the camera the inputs belong to.
  47873. */
  47874. constructor(camera: FlyCamera);
  47875. /**
  47876. * Add keyboard input support to the input manager.
  47877. * @returns the new FlyCameraKeyboardMoveInput().
  47878. */
  47879. addKeyboard(): FlyCameraInputsManager;
  47880. /**
  47881. * Add mouse input support to the input manager.
  47882. * @param touchEnabled Enable touch screen support.
  47883. * @returns the new FlyCameraMouseInput().
  47884. */
  47885. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47886. }
  47887. }
  47888. declare module BABYLON {
  47889. /**
  47890. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47891. * such as in a 3D Space Shooter or a Flight Simulator.
  47892. */
  47893. export class FlyCamera extends TargetCamera {
  47894. /**
  47895. * Define the collision ellipsoid of the camera.
  47896. * This is helpful for simulating a camera body, like a player's body.
  47897. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47898. */
  47899. ellipsoid: Vector3;
  47900. /**
  47901. * Define an offset for the position of the ellipsoid around the camera.
  47902. * This can be helpful if the camera is attached away from the player's body center,
  47903. * such as at its head.
  47904. */
  47905. ellipsoidOffset: Vector3;
  47906. /**
  47907. * Enable or disable collisions of the camera with the rest of the scene objects.
  47908. */
  47909. checkCollisions: boolean;
  47910. /**
  47911. * Enable or disable gravity on the camera.
  47912. */
  47913. applyGravity: boolean;
  47914. /**
  47915. * Define the current direction the camera is moving to.
  47916. */
  47917. cameraDirection: Vector3;
  47918. /**
  47919. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47920. * This overrides and empties cameraRotation.
  47921. */
  47922. rotationQuaternion: Quaternion;
  47923. /**
  47924. * Track Roll to maintain the wanted Rolling when looking around.
  47925. */
  47926. _trackRoll: number;
  47927. /**
  47928. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47929. */
  47930. rollCorrect: number;
  47931. /**
  47932. * Mimic a banked turn, Rolling the camera when Yawing.
  47933. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47934. */
  47935. bankedTurn: boolean;
  47936. /**
  47937. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47938. */
  47939. bankedTurnLimit: number;
  47940. /**
  47941. * Value of 0 disables the banked Roll.
  47942. * Value of 1 is equal to the Yaw angle in radians.
  47943. */
  47944. bankedTurnMultiplier: number;
  47945. /**
  47946. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47947. */
  47948. inputs: FlyCameraInputsManager;
  47949. /**
  47950. * Gets the input sensibility for mouse input.
  47951. * Higher values reduce sensitivity.
  47952. */
  47953. get angularSensibility(): number;
  47954. /**
  47955. * Sets the input sensibility for a mouse input.
  47956. * Higher values reduce sensitivity.
  47957. */
  47958. set angularSensibility(value: number);
  47959. /**
  47960. * Get the keys for camera movement forward.
  47961. */
  47962. get keysForward(): number[];
  47963. /**
  47964. * Set the keys for camera movement forward.
  47965. */
  47966. set keysForward(value: number[]);
  47967. /**
  47968. * Get the keys for camera movement backward.
  47969. */
  47970. get keysBackward(): number[];
  47971. set keysBackward(value: number[]);
  47972. /**
  47973. * Get the keys for camera movement up.
  47974. */
  47975. get keysUp(): number[];
  47976. /**
  47977. * Set the keys for camera movement up.
  47978. */
  47979. set keysUp(value: number[]);
  47980. /**
  47981. * Get the keys for camera movement down.
  47982. */
  47983. get keysDown(): number[];
  47984. /**
  47985. * Set the keys for camera movement down.
  47986. */
  47987. set keysDown(value: number[]);
  47988. /**
  47989. * Get the keys for camera movement left.
  47990. */
  47991. get keysLeft(): number[];
  47992. /**
  47993. * Set the keys for camera movement left.
  47994. */
  47995. set keysLeft(value: number[]);
  47996. /**
  47997. * Set the keys for camera movement right.
  47998. */
  47999. get keysRight(): number[];
  48000. /**
  48001. * Set the keys for camera movement right.
  48002. */
  48003. set keysRight(value: number[]);
  48004. /**
  48005. * Event raised when the camera collides with a mesh in the scene.
  48006. */
  48007. onCollide: (collidedMesh: AbstractMesh) => void;
  48008. private _collider;
  48009. private _needMoveForGravity;
  48010. private _oldPosition;
  48011. private _diffPosition;
  48012. private _newPosition;
  48013. /** @hidden */
  48014. _localDirection: Vector3;
  48015. /** @hidden */
  48016. _transformedDirection: Vector3;
  48017. /**
  48018. * Instantiates a FlyCamera.
  48019. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48020. * such as in a 3D Space Shooter or a Flight Simulator.
  48021. * @param name Define the name of the camera in the scene.
  48022. * @param position Define the starting position of the camera in the scene.
  48023. * @param scene Define the scene the camera belongs to.
  48024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  48025. */
  48026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48027. /**
  48028. * Attach the input controls to a specific dom element to get the input from.
  48029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48030. */
  48031. attachControl(noPreventDefault?: boolean): void;
  48032. /**
  48033. * Detach a control from the HTML DOM element.
  48034. * The camera will stop reacting to that input.
  48035. */
  48036. detachControl(): void;
  48037. private _collisionMask;
  48038. /**
  48039. * Get the mask that the camera ignores in collision events.
  48040. */
  48041. get collisionMask(): number;
  48042. /**
  48043. * Set the mask that the camera ignores in collision events.
  48044. */
  48045. set collisionMask(mask: number);
  48046. /** @hidden */
  48047. _collideWithWorld(displacement: Vector3): void;
  48048. /** @hidden */
  48049. private _onCollisionPositionChange;
  48050. /** @hidden */
  48051. _checkInputs(): void;
  48052. /** @hidden */
  48053. _decideIfNeedsToMove(): boolean;
  48054. /** @hidden */
  48055. _updatePosition(): void;
  48056. /**
  48057. * Restore the Roll to its target value at the rate specified.
  48058. * @param rate - Higher means slower restoring.
  48059. * @hidden
  48060. */
  48061. restoreRoll(rate: number): void;
  48062. /**
  48063. * Destroy the camera and release the current resources held by it.
  48064. */
  48065. dispose(): void;
  48066. /**
  48067. * Get the current object class name.
  48068. * @returns the class name.
  48069. */
  48070. getClassName(): string;
  48071. }
  48072. }
  48073. declare module BABYLON {
  48074. /**
  48075. * Listen to keyboard events to control the camera.
  48076. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48077. */
  48078. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48079. /**
  48080. * Defines the camera the input is attached to.
  48081. */
  48082. camera: FlyCamera;
  48083. /**
  48084. * The list of keyboard keys used to control the forward move of the camera.
  48085. */
  48086. keysForward: number[];
  48087. /**
  48088. * The list of keyboard keys used to control the backward move of the camera.
  48089. */
  48090. keysBackward: number[];
  48091. /**
  48092. * The list of keyboard keys used to control the forward move of the camera.
  48093. */
  48094. keysUp: number[];
  48095. /**
  48096. * The list of keyboard keys used to control the backward move of the camera.
  48097. */
  48098. keysDown: number[];
  48099. /**
  48100. * The list of keyboard keys used to control the right strafe move of the camera.
  48101. */
  48102. keysRight: number[];
  48103. /**
  48104. * The list of keyboard keys used to control the left strafe move of the camera.
  48105. */
  48106. keysLeft: number[];
  48107. private _keys;
  48108. private _onCanvasBlurObserver;
  48109. private _onKeyboardObserver;
  48110. private _engine;
  48111. private _scene;
  48112. /**
  48113. * Attach the input controls to a specific dom element to get the input from.
  48114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48115. */
  48116. attachControl(noPreventDefault?: boolean): void;
  48117. /**
  48118. * Detach the current controls from the specified dom element.
  48119. */
  48120. detachControl(): void;
  48121. /**
  48122. * Gets the class name of the current intput.
  48123. * @returns the class name
  48124. */
  48125. getClassName(): string;
  48126. /** @hidden */
  48127. _onLostFocus(e: FocusEvent): void;
  48128. /**
  48129. * Get the friendly name associated with the input class.
  48130. * @returns the input friendly name
  48131. */
  48132. getSimpleName(): string;
  48133. /**
  48134. * Update the current camera state depending on the inputs that have been used this frame.
  48135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48136. */
  48137. checkInputs(): void;
  48138. }
  48139. }
  48140. declare module BABYLON {
  48141. /**
  48142. * Manage the mouse wheel inputs to control a follow camera.
  48143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48144. */
  48145. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48146. /**
  48147. * Defines the camera the input is attached to.
  48148. */
  48149. camera: FollowCamera;
  48150. /**
  48151. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48152. */
  48153. axisControlRadius: boolean;
  48154. /**
  48155. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48156. */
  48157. axisControlHeight: boolean;
  48158. /**
  48159. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48160. */
  48161. axisControlRotation: boolean;
  48162. /**
  48163. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48164. * relation to mouseWheel events.
  48165. */
  48166. wheelPrecision: number;
  48167. /**
  48168. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48169. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48170. */
  48171. wheelDeltaPercentage: number;
  48172. private _wheel;
  48173. private _observer;
  48174. /**
  48175. * Attach the input controls to a specific dom element to get the input from.
  48176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48177. */
  48178. attachControl(noPreventDefault?: boolean): void;
  48179. /**
  48180. * Detach the current controls from the specified dom element.
  48181. */
  48182. detachControl(): void;
  48183. /**
  48184. * Gets the class name of the current intput.
  48185. * @returns the class name
  48186. */
  48187. getClassName(): string;
  48188. /**
  48189. * Get the friendly name associated with the input class.
  48190. * @returns the input friendly name
  48191. */
  48192. getSimpleName(): string;
  48193. }
  48194. }
  48195. declare module BABYLON {
  48196. /**
  48197. * Manage the pointers inputs to control an follow camera.
  48198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48199. */
  48200. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48201. /**
  48202. * Defines the camera the input is attached to.
  48203. */
  48204. camera: FollowCamera;
  48205. /**
  48206. * Gets the class name of the current input.
  48207. * @returns the class name
  48208. */
  48209. getClassName(): string;
  48210. /**
  48211. * Defines the pointer angular sensibility along the X axis or how fast is
  48212. * the camera rotating.
  48213. * A negative number will reverse the axis direction.
  48214. */
  48215. angularSensibilityX: number;
  48216. /**
  48217. * Defines the pointer angular sensibility along the Y axis or how fast is
  48218. * the camera rotating.
  48219. * A negative number will reverse the axis direction.
  48220. */
  48221. angularSensibilityY: number;
  48222. /**
  48223. * Defines the pointer pinch precision or how fast is the camera zooming.
  48224. * A negative number will reverse the axis direction.
  48225. */
  48226. pinchPrecision: number;
  48227. /**
  48228. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48229. * from 0.
  48230. * It defines the percentage of current camera.radius to use as delta when
  48231. * pinch zoom is used.
  48232. */
  48233. pinchDeltaPercentage: number;
  48234. /**
  48235. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48236. */
  48237. axisXControlRadius: boolean;
  48238. /**
  48239. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48240. */
  48241. axisXControlHeight: boolean;
  48242. /**
  48243. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48244. */
  48245. axisXControlRotation: boolean;
  48246. /**
  48247. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48248. */
  48249. axisYControlRadius: boolean;
  48250. /**
  48251. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48252. */
  48253. axisYControlHeight: boolean;
  48254. /**
  48255. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48256. */
  48257. axisYControlRotation: boolean;
  48258. /**
  48259. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48260. */
  48261. axisPinchControlRadius: boolean;
  48262. /**
  48263. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48264. */
  48265. axisPinchControlHeight: boolean;
  48266. /**
  48267. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48268. */
  48269. axisPinchControlRotation: boolean;
  48270. /**
  48271. * Log error messages if basic misconfiguration has occurred.
  48272. */
  48273. warningEnable: boolean;
  48274. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48275. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48276. private _warningCounter;
  48277. private _warning;
  48278. }
  48279. }
  48280. declare module BABYLON {
  48281. /**
  48282. * Default Inputs manager for the FollowCamera.
  48283. * It groups all the default supported inputs for ease of use.
  48284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48285. */
  48286. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48287. /**
  48288. * Instantiates a new FollowCameraInputsManager.
  48289. * @param camera Defines the camera the inputs belong to
  48290. */
  48291. constructor(camera: FollowCamera);
  48292. /**
  48293. * Add keyboard input support to the input manager.
  48294. * @returns the current input manager
  48295. */
  48296. addKeyboard(): FollowCameraInputsManager;
  48297. /**
  48298. * Add mouse wheel input support to the input manager.
  48299. * @returns the current input manager
  48300. */
  48301. addMouseWheel(): FollowCameraInputsManager;
  48302. /**
  48303. * Add pointers input support to the input manager.
  48304. * @returns the current input manager
  48305. */
  48306. addPointers(): FollowCameraInputsManager;
  48307. /**
  48308. * Add orientation input support to the input manager.
  48309. * @returns the current input manager
  48310. */
  48311. addVRDeviceOrientation(): FollowCameraInputsManager;
  48312. }
  48313. }
  48314. declare module BABYLON {
  48315. /**
  48316. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48317. * an arc rotate version arcFollowCamera are available.
  48318. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48319. */
  48320. export class FollowCamera extends TargetCamera {
  48321. /**
  48322. * Distance the follow camera should follow an object at
  48323. */
  48324. radius: number;
  48325. /**
  48326. * Minimum allowed distance of the camera to the axis of rotation
  48327. * (The camera can not get closer).
  48328. * This can help limiting how the Camera is able to move in the scene.
  48329. */
  48330. lowerRadiusLimit: Nullable<number>;
  48331. /**
  48332. * Maximum allowed distance of the camera to the axis of rotation
  48333. * (The camera can not get further).
  48334. * This can help limiting how the Camera is able to move in the scene.
  48335. */
  48336. upperRadiusLimit: Nullable<number>;
  48337. /**
  48338. * Define a rotation offset between the camera and the object it follows
  48339. */
  48340. rotationOffset: number;
  48341. /**
  48342. * Minimum allowed angle to camera position relative to target object.
  48343. * This can help limiting how the Camera is able to move in the scene.
  48344. */
  48345. lowerRotationOffsetLimit: Nullable<number>;
  48346. /**
  48347. * Maximum allowed angle to camera position relative to target object.
  48348. * This can help limiting how the Camera is able to move in the scene.
  48349. */
  48350. upperRotationOffsetLimit: Nullable<number>;
  48351. /**
  48352. * Define a height offset between the camera and the object it follows.
  48353. * It can help following an object from the top (like a car chaing a plane)
  48354. */
  48355. heightOffset: number;
  48356. /**
  48357. * Minimum allowed height of camera position relative to target object.
  48358. * This can help limiting how the Camera is able to move in the scene.
  48359. */
  48360. lowerHeightOffsetLimit: Nullable<number>;
  48361. /**
  48362. * Maximum allowed height of camera position relative to target object.
  48363. * This can help limiting how the Camera is able to move in the scene.
  48364. */
  48365. upperHeightOffsetLimit: Nullable<number>;
  48366. /**
  48367. * Define how fast the camera can accelerate to follow it s target.
  48368. */
  48369. cameraAcceleration: number;
  48370. /**
  48371. * Define the speed limit of the camera following an object.
  48372. */
  48373. maxCameraSpeed: number;
  48374. /**
  48375. * Define the target of the camera.
  48376. */
  48377. lockedTarget: Nullable<AbstractMesh>;
  48378. /**
  48379. * Defines the input associated with the camera.
  48380. */
  48381. inputs: FollowCameraInputsManager;
  48382. /**
  48383. * Instantiates the follow camera.
  48384. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48385. * @param name Define the name of the camera in the scene
  48386. * @param position Define the position of the camera
  48387. * @param scene Define the scene the camera belong to
  48388. * @param lockedTarget Define the target of the camera
  48389. */
  48390. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48391. private _follow;
  48392. /**
  48393. * Attach the input controls to a specific dom element to get the input from.
  48394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48395. */
  48396. attachControl(noPreventDefault?: boolean): void;
  48397. /**
  48398. * Detach the current controls from the specified dom element.
  48399. */
  48400. detachControl(): void;
  48401. /** @hidden */
  48402. _checkInputs(): void;
  48403. private _checkLimits;
  48404. /**
  48405. * Gets the camera class name.
  48406. * @returns the class name
  48407. */
  48408. getClassName(): string;
  48409. }
  48410. /**
  48411. * Arc Rotate version of the follow camera.
  48412. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48413. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48414. */
  48415. export class ArcFollowCamera extends TargetCamera {
  48416. /** The longitudinal angle of the camera */
  48417. alpha: number;
  48418. /** The latitudinal angle of the camera */
  48419. beta: number;
  48420. /** The radius of the camera from its target */
  48421. radius: number;
  48422. private _cartesianCoordinates;
  48423. /** Define the camera target (the mesh it should follow) */
  48424. private _meshTarget;
  48425. /**
  48426. * Instantiates a new ArcFollowCamera
  48427. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48428. * @param name Define the name of the camera
  48429. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48430. * @param beta Define the rotation angle of the camera around the elevation axis
  48431. * @param radius Define the radius of the camera from its target point
  48432. * @param target Define the target of the camera
  48433. * @param scene Define the scene the camera belongs to
  48434. */
  48435. constructor(name: string,
  48436. /** The longitudinal angle of the camera */
  48437. alpha: number,
  48438. /** The latitudinal angle of the camera */
  48439. beta: number,
  48440. /** The radius of the camera from its target */
  48441. radius: number,
  48442. /** Define the camera target (the mesh it should follow) */
  48443. target: Nullable<AbstractMesh>, scene: Scene);
  48444. private _follow;
  48445. /** @hidden */
  48446. _checkInputs(): void;
  48447. /**
  48448. * Returns the class name of the object.
  48449. * It is mostly used internally for serialization purposes.
  48450. */
  48451. getClassName(): string;
  48452. }
  48453. }
  48454. declare module BABYLON {
  48455. /**
  48456. * Manage the keyboard inputs to control the movement of a follow camera.
  48457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48458. */
  48459. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48460. /**
  48461. * Defines the camera the input is attached to.
  48462. */
  48463. camera: FollowCamera;
  48464. /**
  48465. * Defines the list of key codes associated with the up action (increase heightOffset)
  48466. */
  48467. keysHeightOffsetIncr: number[];
  48468. /**
  48469. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48470. */
  48471. keysHeightOffsetDecr: number[];
  48472. /**
  48473. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48474. */
  48475. keysHeightOffsetModifierAlt: boolean;
  48476. /**
  48477. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48478. */
  48479. keysHeightOffsetModifierCtrl: boolean;
  48480. /**
  48481. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48482. */
  48483. keysHeightOffsetModifierShift: boolean;
  48484. /**
  48485. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48486. */
  48487. keysRotationOffsetIncr: number[];
  48488. /**
  48489. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48490. */
  48491. keysRotationOffsetDecr: number[];
  48492. /**
  48493. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48494. */
  48495. keysRotationOffsetModifierAlt: boolean;
  48496. /**
  48497. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48498. */
  48499. keysRotationOffsetModifierCtrl: boolean;
  48500. /**
  48501. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48502. */
  48503. keysRotationOffsetModifierShift: boolean;
  48504. /**
  48505. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48506. */
  48507. keysRadiusIncr: number[];
  48508. /**
  48509. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48510. */
  48511. keysRadiusDecr: number[];
  48512. /**
  48513. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48514. */
  48515. keysRadiusModifierAlt: boolean;
  48516. /**
  48517. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48518. */
  48519. keysRadiusModifierCtrl: boolean;
  48520. /**
  48521. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48522. */
  48523. keysRadiusModifierShift: boolean;
  48524. /**
  48525. * Defines the rate of change of heightOffset.
  48526. */
  48527. heightSensibility: number;
  48528. /**
  48529. * Defines the rate of change of rotationOffset.
  48530. */
  48531. rotationSensibility: number;
  48532. /**
  48533. * Defines the rate of change of radius.
  48534. */
  48535. radiusSensibility: number;
  48536. private _keys;
  48537. private _ctrlPressed;
  48538. private _altPressed;
  48539. private _shiftPressed;
  48540. private _onCanvasBlurObserver;
  48541. private _onKeyboardObserver;
  48542. private _engine;
  48543. private _scene;
  48544. /**
  48545. * Attach the input controls to a specific dom element to get the input from.
  48546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48547. */
  48548. attachControl(noPreventDefault?: boolean): void;
  48549. /**
  48550. * Detach the current controls from the specified dom element.
  48551. */
  48552. detachControl(): void;
  48553. /**
  48554. * Update the current camera state depending on the inputs that have been used this frame.
  48555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48556. */
  48557. checkInputs(): void;
  48558. /**
  48559. * Gets the class name of the current input.
  48560. * @returns the class name
  48561. */
  48562. getClassName(): string;
  48563. /**
  48564. * Get the friendly name associated with the input class.
  48565. * @returns the input friendly name
  48566. */
  48567. getSimpleName(): string;
  48568. /**
  48569. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48570. * allow modification of the heightOffset value.
  48571. */
  48572. private _modifierHeightOffset;
  48573. /**
  48574. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48575. * allow modification of the rotationOffset value.
  48576. */
  48577. private _modifierRotationOffset;
  48578. /**
  48579. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48580. * allow modification of the radius value.
  48581. */
  48582. private _modifierRadius;
  48583. }
  48584. }
  48585. declare module BABYLON {
  48586. interface FreeCameraInputsManager {
  48587. /**
  48588. * @hidden
  48589. */
  48590. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48591. /**
  48592. * Add orientation input support to the input manager.
  48593. * @returns the current input manager
  48594. */
  48595. addDeviceOrientation(): FreeCameraInputsManager;
  48596. }
  48597. /**
  48598. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48599. * Screen rotation is taken into account.
  48600. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48601. */
  48602. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48603. private _camera;
  48604. private _screenOrientationAngle;
  48605. private _constantTranform;
  48606. private _screenQuaternion;
  48607. private _alpha;
  48608. private _beta;
  48609. private _gamma;
  48610. /**
  48611. * Can be used to detect if a device orientation sensor is available on a device
  48612. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48613. * @returns a promise that will resolve on orientation change
  48614. */
  48615. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48616. /**
  48617. * @hidden
  48618. */
  48619. _onDeviceOrientationChangedObservable: Observable<void>;
  48620. /**
  48621. * Instantiates a new input
  48622. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48623. */
  48624. constructor();
  48625. /**
  48626. * Define the camera controlled by the input.
  48627. */
  48628. get camera(): FreeCamera;
  48629. set camera(camera: FreeCamera);
  48630. /**
  48631. * Attach the input controls to a specific dom element to get the input from.
  48632. */
  48633. attachControl(): void;
  48634. private _orientationChanged;
  48635. private _deviceOrientation;
  48636. /**
  48637. * Detach the current controls from the specified dom element.
  48638. */
  48639. detachControl(): void;
  48640. /**
  48641. * Update the current camera state depending on the inputs that have been used this frame.
  48642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48643. */
  48644. checkInputs(): void;
  48645. /**
  48646. * Gets the class name of the current intput.
  48647. * @returns the class name
  48648. */
  48649. getClassName(): string;
  48650. /**
  48651. * Get the friendly name associated with the input class.
  48652. * @returns the input friendly name
  48653. */
  48654. getSimpleName(): string;
  48655. }
  48656. }
  48657. declare module BABYLON {
  48658. /**
  48659. * Manage the gamepad inputs to control a free camera.
  48660. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48661. */
  48662. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48663. /**
  48664. * Define the camera the input is attached to.
  48665. */
  48666. camera: FreeCamera;
  48667. /**
  48668. * Define the Gamepad controlling the input
  48669. */
  48670. gamepad: Nullable<Gamepad>;
  48671. /**
  48672. * Defines the gamepad rotation sensiblity.
  48673. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48674. */
  48675. gamepadAngularSensibility: number;
  48676. /**
  48677. * Defines the gamepad move sensiblity.
  48678. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48679. */
  48680. gamepadMoveSensibility: number;
  48681. private _yAxisScale;
  48682. /**
  48683. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48684. */
  48685. get invertYAxis(): boolean;
  48686. set invertYAxis(value: boolean);
  48687. private _onGamepadConnectedObserver;
  48688. private _onGamepadDisconnectedObserver;
  48689. private _cameraTransform;
  48690. private _deltaTransform;
  48691. private _vector3;
  48692. private _vector2;
  48693. /**
  48694. * Attach the input controls to a specific dom element to get the input from.
  48695. */
  48696. attachControl(): void;
  48697. /**
  48698. * Detach the current controls from the specified dom element.
  48699. */
  48700. detachControl(): void;
  48701. /**
  48702. * Update the current camera state depending on the inputs that have been used this frame.
  48703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48704. */
  48705. checkInputs(): void;
  48706. /**
  48707. * Gets the class name of the current intput.
  48708. * @returns the class name
  48709. */
  48710. getClassName(): string;
  48711. /**
  48712. * Get the friendly name associated with the input class.
  48713. * @returns the input friendly name
  48714. */
  48715. getSimpleName(): string;
  48716. }
  48717. }
  48718. declare module BABYLON {
  48719. /**
  48720. * Defines the potential axis of a Joystick
  48721. */
  48722. export enum JoystickAxis {
  48723. /** X axis */
  48724. X = 0,
  48725. /** Y axis */
  48726. Y = 1,
  48727. /** Z axis */
  48728. Z = 2
  48729. }
  48730. /**
  48731. * Represents the different customization options available
  48732. * for VirtualJoystick
  48733. */
  48734. interface VirtualJoystickCustomizations {
  48735. /**
  48736. * Size of the joystick's puck
  48737. */
  48738. puckSize: number;
  48739. /**
  48740. * Size of the joystick's container
  48741. */
  48742. containerSize: number;
  48743. /**
  48744. * Color of the joystick && puck
  48745. */
  48746. color: string;
  48747. /**
  48748. * Image URL for the joystick's puck
  48749. */
  48750. puckImage?: string;
  48751. /**
  48752. * Image URL for the joystick's container
  48753. */
  48754. containerImage?: string;
  48755. /**
  48756. * Defines the unmoving position of the joystick container
  48757. */
  48758. position?: {
  48759. x: number;
  48760. y: number;
  48761. };
  48762. /**
  48763. * Defines whether or not the joystick container is always visible
  48764. */
  48765. alwaysVisible: boolean;
  48766. /**
  48767. * Defines whether or not to limit the movement of the puck to the joystick's container
  48768. */
  48769. limitToContainer: boolean;
  48770. }
  48771. /**
  48772. * Class used to define virtual joystick (used in touch mode)
  48773. */
  48774. export class VirtualJoystick {
  48775. /**
  48776. * Gets or sets a boolean indicating that left and right values must be inverted
  48777. */
  48778. reverseLeftRight: boolean;
  48779. /**
  48780. * Gets or sets a boolean indicating that up and down values must be inverted
  48781. */
  48782. reverseUpDown: boolean;
  48783. /**
  48784. * Gets the offset value for the position (ie. the change of the position value)
  48785. */
  48786. deltaPosition: Vector3;
  48787. /**
  48788. * Gets a boolean indicating if the virtual joystick was pressed
  48789. */
  48790. pressed: boolean;
  48791. /**
  48792. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48793. */
  48794. static Canvas: Nullable<HTMLCanvasElement>;
  48795. /**
  48796. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48797. */
  48798. limitToContainer: boolean;
  48799. private static _globalJoystickIndex;
  48800. private static _alwaysVisibleSticks;
  48801. private static vjCanvasContext;
  48802. private static vjCanvasWidth;
  48803. private static vjCanvasHeight;
  48804. private static halfWidth;
  48805. private static _GetDefaultOptions;
  48806. private _action;
  48807. private _axisTargetedByLeftAndRight;
  48808. private _axisTargetedByUpAndDown;
  48809. private _joystickSensibility;
  48810. private _inversedSensibility;
  48811. private _joystickPointerID;
  48812. private _joystickColor;
  48813. private _joystickPointerPos;
  48814. private _joystickPreviousPointerPos;
  48815. private _joystickPointerStartPos;
  48816. private _deltaJoystickVector;
  48817. private _leftJoystick;
  48818. private _touches;
  48819. private _joystickPosition;
  48820. private _alwaysVisible;
  48821. private _puckImage;
  48822. private _containerImage;
  48823. private _joystickPuckSize;
  48824. private _joystickContainerSize;
  48825. private _clearPuckSize;
  48826. private _clearContainerSize;
  48827. private _clearPuckSizeOffset;
  48828. private _clearContainerSizeOffset;
  48829. private _onPointerDownHandlerRef;
  48830. private _onPointerMoveHandlerRef;
  48831. private _onPointerUpHandlerRef;
  48832. private _onResize;
  48833. /**
  48834. * Creates a new virtual joystick
  48835. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48836. * @param customizations Defines the options we want to customize the VirtualJoystick
  48837. */
  48838. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48839. /**
  48840. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48841. * @param newJoystickSensibility defines the new sensibility
  48842. */
  48843. setJoystickSensibility(newJoystickSensibility: number): void;
  48844. private _onPointerDown;
  48845. private _onPointerMove;
  48846. private _onPointerUp;
  48847. /**
  48848. * Change the color of the virtual joystick
  48849. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48850. */
  48851. setJoystickColor(newColor: string): void;
  48852. /**
  48853. * Size of the joystick's container
  48854. */
  48855. set containerSize(newSize: number);
  48856. get containerSize(): number;
  48857. /**
  48858. * Size of the joystick's puck
  48859. */
  48860. set puckSize(newSize: number);
  48861. get puckSize(): number;
  48862. /**
  48863. * Clears the set position of the joystick
  48864. */
  48865. clearPosition(): void;
  48866. /**
  48867. * Defines whether or not the joystick container is always visible
  48868. */
  48869. set alwaysVisible(value: boolean);
  48870. get alwaysVisible(): boolean;
  48871. /**
  48872. * Sets the constant position of the Joystick container
  48873. * @param x X axis coordinate
  48874. * @param y Y axis coordinate
  48875. */
  48876. setPosition(x: number, y: number): void;
  48877. /**
  48878. * Defines a callback to call when the joystick is touched
  48879. * @param action defines the callback
  48880. */
  48881. setActionOnTouch(action: () => any): void;
  48882. /**
  48883. * Defines which axis you'd like to control for left & right
  48884. * @param axis defines the axis to use
  48885. */
  48886. setAxisForLeftRight(axis: JoystickAxis): void;
  48887. /**
  48888. * Defines which axis you'd like to control for up & down
  48889. * @param axis defines the axis to use
  48890. */
  48891. setAxisForUpDown(axis: JoystickAxis): void;
  48892. /**
  48893. * Clears the canvas from the previous puck / container draw
  48894. */
  48895. private _clearPreviousDraw;
  48896. /**
  48897. * Loads `urlPath` to be used for the container's image
  48898. * @param urlPath defines the urlPath of an image to use
  48899. */
  48900. setContainerImage(urlPath: string): void;
  48901. /**
  48902. * Loads `urlPath` to be used for the puck's image
  48903. * @param urlPath defines the urlPath of an image to use
  48904. */
  48905. setPuckImage(urlPath: string): void;
  48906. /**
  48907. * Draws the Virtual Joystick's container
  48908. */
  48909. private _drawContainer;
  48910. /**
  48911. * Draws the Virtual Joystick's puck
  48912. */
  48913. private _drawPuck;
  48914. private _drawVirtualJoystick;
  48915. /**
  48916. * Release internal HTML canvas
  48917. */
  48918. releaseCanvas(): void;
  48919. }
  48920. }
  48921. declare module BABYLON {
  48922. interface FreeCameraInputsManager {
  48923. /**
  48924. * Add virtual joystick input support to the input manager.
  48925. * @returns the current input manager
  48926. */
  48927. addVirtualJoystick(): FreeCameraInputsManager;
  48928. }
  48929. /**
  48930. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48932. */
  48933. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48934. /**
  48935. * Defines the camera the input is attached to.
  48936. */
  48937. camera: FreeCamera;
  48938. private _leftjoystick;
  48939. private _rightjoystick;
  48940. /**
  48941. * Gets the left stick of the virtual joystick.
  48942. * @returns The virtual Joystick
  48943. */
  48944. getLeftJoystick(): VirtualJoystick;
  48945. /**
  48946. * Gets the right stick of the virtual joystick.
  48947. * @returns The virtual Joystick
  48948. */
  48949. getRightJoystick(): VirtualJoystick;
  48950. /**
  48951. * Update the current camera state depending on the inputs that have been used this frame.
  48952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48953. */
  48954. checkInputs(): void;
  48955. /**
  48956. * Attach the input controls to a specific dom element to get the input from.
  48957. */
  48958. attachControl(): void;
  48959. /**
  48960. * Detach the current controls from the specified dom element.
  48961. */
  48962. detachControl(): void;
  48963. /**
  48964. * Gets the class name of the current intput.
  48965. * @returns the class name
  48966. */
  48967. getClassName(): string;
  48968. /**
  48969. * Get the friendly name associated with the input class.
  48970. * @returns the input friendly name
  48971. */
  48972. getSimpleName(): string;
  48973. }
  48974. }
  48975. declare module BABYLON {
  48976. /**
  48977. * This represents a FPS type of camera controlled by touch.
  48978. * This is like a universal camera minus the Gamepad controls.
  48979. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48980. */
  48981. export class TouchCamera extends FreeCamera {
  48982. /**
  48983. * Defines the touch sensibility for rotation.
  48984. * The higher the faster.
  48985. */
  48986. get touchAngularSensibility(): number;
  48987. set touchAngularSensibility(value: number);
  48988. /**
  48989. * Defines the touch sensibility for move.
  48990. * The higher the faster.
  48991. */
  48992. get touchMoveSensibility(): number;
  48993. set touchMoveSensibility(value: number);
  48994. /**
  48995. * Instantiates a new touch camera.
  48996. * This represents a FPS type of camera controlled by touch.
  48997. * This is like a universal camera minus the Gamepad controls.
  48998. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48999. * @param name Define the name of the camera in the scene
  49000. * @param position Define the start position of the camera in the scene
  49001. * @param scene Define the scene the camera belongs to
  49002. */
  49003. constructor(name: string, position: Vector3, scene: Scene);
  49004. /**
  49005. * Gets the current object class name.
  49006. * @return the class name
  49007. */
  49008. getClassName(): string;
  49009. /** @hidden */
  49010. _setupInputs(): void;
  49011. }
  49012. }
  49013. declare module BABYLON {
  49014. /**
  49015. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  49016. * being tilted forward or back and left or right.
  49017. */
  49018. export class DeviceOrientationCamera extends FreeCamera {
  49019. private _initialQuaternion;
  49020. private _quaternionCache;
  49021. private _tmpDragQuaternion;
  49022. private _disablePointerInputWhenUsingDeviceOrientation;
  49023. /**
  49024. * Creates a new device orientation camera
  49025. * @param name The name of the camera
  49026. * @param position The start position camera
  49027. * @param scene The scene the camera belongs to
  49028. */
  49029. constructor(name: string, position: Vector3, scene: Scene);
  49030. /**
  49031. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  49032. */
  49033. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  49034. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  49035. private _dragFactor;
  49036. /**
  49037. * Enabled turning on the y axis when the orientation sensor is active
  49038. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49039. */
  49040. enableHorizontalDragging(dragFactor?: number): void;
  49041. /**
  49042. * Gets the current instance class name ("DeviceOrientationCamera").
  49043. * This helps avoiding instanceof at run time.
  49044. * @returns the class name
  49045. */
  49046. getClassName(): string;
  49047. /**
  49048. * @hidden
  49049. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49050. */
  49051. _checkInputs(): void;
  49052. /**
  49053. * Reset the camera to its default orientation on the specified axis only.
  49054. * @param axis The axis to reset
  49055. */
  49056. resetToCurrentRotation(axis?: Axis): void;
  49057. }
  49058. }
  49059. declare module BABYLON {
  49060. /**
  49061. * Defines supported buttons for XBox360 compatible gamepads
  49062. */
  49063. export enum Xbox360Button {
  49064. /** A */
  49065. A = 0,
  49066. /** B */
  49067. B = 1,
  49068. /** X */
  49069. X = 2,
  49070. /** Y */
  49071. Y = 3,
  49072. /** Left button */
  49073. LB = 4,
  49074. /** Right button */
  49075. RB = 5,
  49076. /** Back */
  49077. Back = 8,
  49078. /** Start */
  49079. Start = 9,
  49080. /** Left stick */
  49081. LeftStick = 10,
  49082. /** Right stick */
  49083. RightStick = 11
  49084. }
  49085. /** Defines values for XBox360 DPad */
  49086. export enum Xbox360Dpad {
  49087. /** Up */
  49088. Up = 12,
  49089. /** Down */
  49090. Down = 13,
  49091. /** Left */
  49092. Left = 14,
  49093. /** Right */
  49094. Right = 15
  49095. }
  49096. /**
  49097. * Defines a XBox360 gamepad
  49098. */
  49099. export class Xbox360Pad extends Gamepad {
  49100. private _leftTrigger;
  49101. private _rightTrigger;
  49102. private _onlefttriggerchanged;
  49103. private _onrighttriggerchanged;
  49104. private _onbuttondown;
  49105. private _onbuttonup;
  49106. private _ondpaddown;
  49107. private _ondpadup;
  49108. /** Observable raised when a button is pressed */
  49109. onButtonDownObservable: Observable<Xbox360Button>;
  49110. /** Observable raised when a button is released */
  49111. onButtonUpObservable: Observable<Xbox360Button>;
  49112. /** Observable raised when a pad is pressed */
  49113. onPadDownObservable: Observable<Xbox360Dpad>;
  49114. /** Observable raised when a pad is released */
  49115. onPadUpObservable: Observable<Xbox360Dpad>;
  49116. private _buttonA;
  49117. private _buttonB;
  49118. private _buttonX;
  49119. private _buttonY;
  49120. private _buttonBack;
  49121. private _buttonStart;
  49122. private _buttonLB;
  49123. private _buttonRB;
  49124. private _buttonLeftStick;
  49125. private _buttonRightStick;
  49126. private _dPadUp;
  49127. private _dPadDown;
  49128. private _dPadLeft;
  49129. private _dPadRight;
  49130. private _isXboxOnePad;
  49131. /**
  49132. * Creates a new XBox360 gamepad object
  49133. * @param id defines the id of this gamepad
  49134. * @param index defines its index
  49135. * @param gamepad defines the internal HTML gamepad object
  49136. * @param xboxOne defines if it is a XBox One gamepad
  49137. */
  49138. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49139. /**
  49140. * Defines the callback to call when left trigger is pressed
  49141. * @param callback defines the callback to use
  49142. */
  49143. onlefttriggerchanged(callback: (value: number) => void): void;
  49144. /**
  49145. * Defines the callback to call when right trigger is pressed
  49146. * @param callback defines the callback to use
  49147. */
  49148. onrighttriggerchanged(callback: (value: number) => void): void;
  49149. /**
  49150. * Gets the left trigger value
  49151. */
  49152. get leftTrigger(): number;
  49153. /**
  49154. * Sets the left trigger value
  49155. */
  49156. set leftTrigger(newValue: number);
  49157. /**
  49158. * Gets the right trigger value
  49159. */
  49160. get rightTrigger(): number;
  49161. /**
  49162. * Sets the right trigger value
  49163. */
  49164. set rightTrigger(newValue: number);
  49165. /**
  49166. * Defines the callback to call when a button is pressed
  49167. * @param callback defines the callback to use
  49168. */
  49169. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49170. /**
  49171. * Defines the callback to call when a button is released
  49172. * @param callback defines the callback to use
  49173. */
  49174. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49175. /**
  49176. * Defines the callback to call when a pad is pressed
  49177. * @param callback defines the callback to use
  49178. */
  49179. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49180. /**
  49181. * Defines the callback to call when a pad is released
  49182. * @param callback defines the callback to use
  49183. */
  49184. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49185. private _setButtonValue;
  49186. private _setDPadValue;
  49187. /**
  49188. * Gets the value of the `A` button
  49189. */
  49190. get buttonA(): number;
  49191. /**
  49192. * Sets the value of the `A` button
  49193. */
  49194. set buttonA(value: number);
  49195. /**
  49196. * Gets the value of the `B` button
  49197. */
  49198. get buttonB(): number;
  49199. /**
  49200. * Sets the value of the `B` button
  49201. */
  49202. set buttonB(value: number);
  49203. /**
  49204. * Gets the value of the `X` button
  49205. */
  49206. get buttonX(): number;
  49207. /**
  49208. * Sets the value of the `X` button
  49209. */
  49210. set buttonX(value: number);
  49211. /**
  49212. * Gets the value of the `Y` button
  49213. */
  49214. get buttonY(): number;
  49215. /**
  49216. * Sets the value of the `Y` button
  49217. */
  49218. set buttonY(value: number);
  49219. /**
  49220. * Gets the value of the `Start` button
  49221. */
  49222. get buttonStart(): number;
  49223. /**
  49224. * Sets the value of the `Start` button
  49225. */
  49226. set buttonStart(value: number);
  49227. /**
  49228. * Gets the value of the `Back` button
  49229. */
  49230. get buttonBack(): number;
  49231. /**
  49232. * Sets the value of the `Back` button
  49233. */
  49234. set buttonBack(value: number);
  49235. /**
  49236. * Gets the value of the `Left` button
  49237. */
  49238. get buttonLB(): number;
  49239. /**
  49240. * Sets the value of the `Left` button
  49241. */
  49242. set buttonLB(value: number);
  49243. /**
  49244. * Gets the value of the `Right` button
  49245. */
  49246. get buttonRB(): number;
  49247. /**
  49248. * Sets the value of the `Right` button
  49249. */
  49250. set buttonRB(value: number);
  49251. /**
  49252. * Gets the value of the Left joystick
  49253. */
  49254. get buttonLeftStick(): number;
  49255. /**
  49256. * Sets the value of the Left joystick
  49257. */
  49258. set buttonLeftStick(value: number);
  49259. /**
  49260. * Gets the value of the Right joystick
  49261. */
  49262. get buttonRightStick(): number;
  49263. /**
  49264. * Sets the value of the Right joystick
  49265. */
  49266. set buttonRightStick(value: number);
  49267. /**
  49268. * Gets the value of D-pad up
  49269. */
  49270. get dPadUp(): number;
  49271. /**
  49272. * Sets the value of D-pad up
  49273. */
  49274. set dPadUp(value: number);
  49275. /**
  49276. * Gets the value of D-pad down
  49277. */
  49278. get dPadDown(): number;
  49279. /**
  49280. * Sets the value of D-pad down
  49281. */
  49282. set dPadDown(value: number);
  49283. /**
  49284. * Gets the value of D-pad left
  49285. */
  49286. get dPadLeft(): number;
  49287. /**
  49288. * Sets the value of D-pad left
  49289. */
  49290. set dPadLeft(value: number);
  49291. /**
  49292. * Gets the value of D-pad right
  49293. */
  49294. get dPadRight(): number;
  49295. /**
  49296. * Sets the value of D-pad right
  49297. */
  49298. set dPadRight(value: number);
  49299. /**
  49300. * Force the gamepad to synchronize with device values
  49301. */
  49302. update(): void;
  49303. /**
  49304. * Disposes the gamepad
  49305. */
  49306. dispose(): void;
  49307. }
  49308. }
  49309. declare module BABYLON {
  49310. /**
  49311. * Defines supported buttons for DualShock compatible gamepads
  49312. */
  49313. export enum DualShockButton {
  49314. /** Cross */
  49315. Cross = 0,
  49316. /** Circle */
  49317. Circle = 1,
  49318. /** Square */
  49319. Square = 2,
  49320. /** Triangle */
  49321. Triangle = 3,
  49322. /** L1 */
  49323. L1 = 4,
  49324. /** R1 */
  49325. R1 = 5,
  49326. /** Share */
  49327. Share = 8,
  49328. /** Options */
  49329. Options = 9,
  49330. /** Left stick */
  49331. LeftStick = 10,
  49332. /** Right stick */
  49333. RightStick = 11
  49334. }
  49335. /** Defines values for DualShock DPad */
  49336. export enum DualShockDpad {
  49337. /** Up */
  49338. Up = 12,
  49339. /** Down */
  49340. Down = 13,
  49341. /** Left */
  49342. Left = 14,
  49343. /** Right */
  49344. Right = 15
  49345. }
  49346. /**
  49347. * Defines a DualShock gamepad
  49348. */
  49349. export class DualShockPad extends Gamepad {
  49350. private _leftTrigger;
  49351. private _rightTrigger;
  49352. private _onlefttriggerchanged;
  49353. private _onrighttriggerchanged;
  49354. private _onbuttondown;
  49355. private _onbuttonup;
  49356. private _ondpaddown;
  49357. private _ondpadup;
  49358. /** Observable raised when a button is pressed */
  49359. onButtonDownObservable: Observable<DualShockButton>;
  49360. /** Observable raised when a button is released */
  49361. onButtonUpObservable: Observable<DualShockButton>;
  49362. /** Observable raised when a pad is pressed */
  49363. onPadDownObservable: Observable<DualShockDpad>;
  49364. /** Observable raised when a pad is released */
  49365. onPadUpObservable: Observable<DualShockDpad>;
  49366. private _buttonCross;
  49367. private _buttonCircle;
  49368. private _buttonSquare;
  49369. private _buttonTriangle;
  49370. private _buttonShare;
  49371. private _buttonOptions;
  49372. private _buttonL1;
  49373. private _buttonR1;
  49374. private _buttonLeftStick;
  49375. private _buttonRightStick;
  49376. private _dPadUp;
  49377. private _dPadDown;
  49378. private _dPadLeft;
  49379. private _dPadRight;
  49380. /**
  49381. * Creates a new DualShock gamepad object
  49382. * @param id defines the id of this gamepad
  49383. * @param index defines its index
  49384. * @param gamepad defines the internal HTML gamepad object
  49385. */
  49386. constructor(id: string, index: number, gamepad: any);
  49387. /**
  49388. * Defines the callback to call when left trigger is pressed
  49389. * @param callback defines the callback to use
  49390. */
  49391. onlefttriggerchanged(callback: (value: number) => void): void;
  49392. /**
  49393. * Defines the callback to call when right trigger is pressed
  49394. * @param callback defines the callback to use
  49395. */
  49396. onrighttriggerchanged(callback: (value: number) => void): void;
  49397. /**
  49398. * Gets the left trigger value
  49399. */
  49400. get leftTrigger(): number;
  49401. /**
  49402. * Sets the left trigger value
  49403. */
  49404. set leftTrigger(newValue: number);
  49405. /**
  49406. * Gets the right trigger value
  49407. */
  49408. get rightTrigger(): number;
  49409. /**
  49410. * Sets the right trigger value
  49411. */
  49412. set rightTrigger(newValue: number);
  49413. /**
  49414. * Defines the callback to call when a button is pressed
  49415. * @param callback defines the callback to use
  49416. */
  49417. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49418. /**
  49419. * Defines the callback to call when a button is released
  49420. * @param callback defines the callback to use
  49421. */
  49422. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49423. /**
  49424. * Defines the callback to call when a pad is pressed
  49425. * @param callback defines the callback to use
  49426. */
  49427. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49428. /**
  49429. * Defines the callback to call when a pad is released
  49430. * @param callback defines the callback to use
  49431. */
  49432. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49433. private _setButtonValue;
  49434. private _setDPadValue;
  49435. /**
  49436. * Gets the value of the `Cross` button
  49437. */
  49438. get buttonCross(): number;
  49439. /**
  49440. * Sets the value of the `Cross` button
  49441. */
  49442. set buttonCross(value: number);
  49443. /**
  49444. * Gets the value of the `Circle` button
  49445. */
  49446. get buttonCircle(): number;
  49447. /**
  49448. * Sets the value of the `Circle` button
  49449. */
  49450. set buttonCircle(value: number);
  49451. /**
  49452. * Gets the value of the `Square` button
  49453. */
  49454. get buttonSquare(): number;
  49455. /**
  49456. * Sets the value of the `Square` button
  49457. */
  49458. set buttonSquare(value: number);
  49459. /**
  49460. * Gets the value of the `Triangle` button
  49461. */
  49462. get buttonTriangle(): number;
  49463. /**
  49464. * Sets the value of the `Triangle` button
  49465. */
  49466. set buttonTriangle(value: number);
  49467. /**
  49468. * Gets the value of the `Options` button
  49469. */
  49470. get buttonOptions(): number;
  49471. /**
  49472. * Sets the value of the `Options` button
  49473. */
  49474. set buttonOptions(value: number);
  49475. /**
  49476. * Gets the value of the `Share` button
  49477. */
  49478. get buttonShare(): number;
  49479. /**
  49480. * Sets the value of the `Share` button
  49481. */
  49482. set buttonShare(value: number);
  49483. /**
  49484. * Gets the value of the `L1` button
  49485. */
  49486. get buttonL1(): number;
  49487. /**
  49488. * Sets the value of the `L1` button
  49489. */
  49490. set buttonL1(value: number);
  49491. /**
  49492. * Gets the value of the `R1` button
  49493. */
  49494. get buttonR1(): number;
  49495. /**
  49496. * Sets the value of the `R1` button
  49497. */
  49498. set buttonR1(value: number);
  49499. /**
  49500. * Gets the value of the Left joystick
  49501. */
  49502. get buttonLeftStick(): number;
  49503. /**
  49504. * Sets the value of the Left joystick
  49505. */
  49506. set buttonLeftStick(value: number);
  49507. /**
  49508. * Gets the value of the Right joystick
  49509. */
  49510. get buttonRightStick(): number;
  49511. /**
  49512. * Sets the value of the Right joystick
  49513. */
  49514. set buttonRightStick(value: number);
  49515. /**
  49516. * Gets the value of D-pad up
  49517. */
  49518. get dPadUp(): number;
  49519. /**
  49520. * Sets the value of D-pad up
  49521. */
  49522. set dPadUp(value: number);
  49523. /**
  49524. * Gets the value of D-pad down
  49525. */
  49526. get dPadDown(): number;
  49527. /**
  49528. * Sets the value of D-pad down
  49529. */
  49530. set dPadDown(value: number);
  49531. /**
  49532. * Gets the value of D-pad left
  49533. */
  49534. get dPadLeft(): number;
  49535. /**
  49536. * Sets the value of D-pad left
  49537. */
  49538. set dPadLeft(value: number);
  49539. /**
  49540. * Gets the value of D-pad right
  49541. */
  49542. get dPadRight(): number;
  49543. /**
  49544. * Sets the value of D-pad right
  49545. */
  49546. set dPadRight(value: number);
  49547. /**
  49548. * Force the gamepad to synchronize with device values
  49549. */
  49550. update(): void;
  49551. /**
  49552. * Disposes the gamepad
  49553. */
  49554. dispose(): void;
  49555. }
  49556. }
  49557. declare module BABYLON {
  49558. /**
  49559. * Manager for handling gamepads
  49560. */
  49561. export class GamepadManager {
  49562. private _scene?;
  49563. private _babylonGamepads;
  49564. private _oneGamepadConnected;
  49565. /** @hidden */
  49566. _isMonitoring: boolean;
  49567. private _gamepadEventSupported;
  49568. private _gamepadSupport?;
  49569. /**
  49570. * observable to be triggered when the gamepad controller has been connected
  49571. */
  49572. onGamepadConnectedObservable: Observable<Gamepad>;
  49573. /**
  49574. * observable to be triggered when the gamepad controller has been disconnected
  49575. */
  49576. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49577. private _onGamepadConnectedEvent;
  49578. private _onGamepadDisconnectedEvent;
  49579. /**
  49580. * Initializes the gamepad manager
  49581. * @param _scene BabylonJS scene
  49582. */
  49583. constructor(_scene?: Scene | undefined);
  49584. /**
  49585. * The gamepads in the game pad manager
  49586. */
  49587. get gamepads(): Gamepad[];
  49588. /**
  49589. * Get the gamepad controllers based on type
  49590. * @param type The type of gamepad controller
  49591. * @returns Nullable gamepad
  49592. */
  49593. getGamepadByType(type?: number): Nullable<Gamepad>;
  49594. /**
  49595. * Disposes the gamepad manager
  49596. */
  49597. dispose(): void;
  49598. private _addNewGamepad;
  49599. private _startMonitoringGamepads;
  49600. private _stopMonitoringGamepads;
  49601. /** @hidden */
  49602. _checkGamepadsStatus(): void;
  49603. private _updateGamepadObjects;
  49604. }
  49605. }
  49606. declare module BABYLON {
  49607. interface Scene {
  49608. /** @hidden */
  49609. _gamepadManager: Nullable<GamepadManager>;
  49610. /**
  49611. * Gets the gamepad manager associated with the scene
  49612. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49613. */
  49614. gamepadManager: GamepadManager;
  49615. }
  49616. /**
  49617. * Interface representing a free camera inputs manager
  49618. */
  49619. interface FreeCameraInputsManager {
  49620. /**
  49621. * Adds gamepad input support to the FreeCameraInputsManager.
  49622. * @returns the FreeCameraInputsManager
  49623. */
  49624. addGamepad(): FreeCameraInputsManager;
  49625. }
  49626. /**
  49627. * Interface representing an arc rotate camera inputs manager
  49628. */
  49629. interface ArcRotateCameraInputsManager {
  49630. /**
  49631. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49632. * @returns the camera inputs manager
  49633. */
  49634. addGamepad(): ArcRotateCameraInputsManager;
  49635. }
  49636. /**
  49637. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49638. */
  49639. export class GamepadSystemSceneComponent implements ISceneComponent {
  49640. /**
  49641. * The component name helpfull to identify the component in the list of scene components.
  49642. */
  49643. readonly name: string;
  49644. /**
  49645. * The scene the component belongs to.
  49646. */
  49647. scene: Scene;
  49648. /**
  49649. * Creates a new instance of the component for the given scene
  49650. * @param scene Defines the scene to register the component in
  49651. */
  49652. constructor(scene: Scene);
  49653. /**
  49654. * Registers the component in a given scene
  49655. */
  49656. register(): void;
  49657. /**
  49658. * Rebuilds the elements related to this component in case of
  49659. * context lost for instance.
  49660. */
  49661. rebuild(): void;
  49662. /**
  49663. * Disposes the component and the associated ressources
  49664. */
  49665. dispose(): void;
  49666. private _beforeCameraUpdate;
  49667. }
  49668. }
  49669. declare module BABYLON {
  49670. /**
  49671. * 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,
  49672. * which still works and will still be found in many Playgrounds.
  49673. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49674. */
  49675. export class UniversalCamera extends TouchCamera {
  49676. /**
  49677. * Defines the gamepad rotation sensiblity.
  49678. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49679. */
  49680. get gamepadAngularSensibility(): number;
  49681. set gamepadAngularSensibility(value: number);
  49682. /**
  49683. * Defines the gamepad move sensiblity.
  49684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49685. */
  49686. get gamepadMoveSensibility(): number;
  49687. set gamepadMoveSensibility(value: number);
  49688. /**
  49689. * 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,
  49690. * which still works and will still be found in many Playgrounds.
  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. /**
  49706. * This represents a FPS type of camera. This is only here for back compat purpose.
  49707. * Please use the UniversalCamera instead as both are identical.
  49708. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49709. */
  49710. export class GamepadCamera extends UniversalCamera {
  49711. /**
  49712. * Instantiates a new Gamepad Camera
  49713. * This represents a FPS type of camera. This is only here for back compat purpose.
  49714. * Please use the UniversalCamera instead as both are identical.
  49715. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49716. * @param name Define the name of the camera in the scene
  49717. * @param position Define the start position of the camera in the scene
  49718. * @param scene Define the scene the camera belongs to
  49719. */
  49720. constructor(name: string, position: Vector3, scene: Scene);
  49721. /**
  49722. * Gets the current object class name.
  49723. * @return the class name
  49724. */
  49725. getClassName(): string;
  49726. }
  49727. }
  49728. declare module BABYLON {
  49729. /** @hidden */
  49730. export var passPixelShader: {
  49731. name: string;
  49732. shader: string;
  49733. };
  49734. }
  49735. declare module BABYLON {
  49736. /** @hidden */
  49737. export var passCubePixelShader: {
  49738. name: string;
  49739. shader: string;
  49740. };
  49741. }
  49742. declare module BABYLON {
  49743. /**
  49744. * PassPostProcess which produces an output the same as it's input
  49745. */
  49746. export class PassPostProcess extends PostProcess {
  49747. /**
  49748. * Gets a string identifying the name of the class
  49749. * @returns "PassPostProcess" string
  49750. */
  49751. getClassName(): string;
  49752. /**
  49753. * Creates the PassPostProcess
  49754. * @param name The name of the effect.
  49755. * @param options The required width/height ratio to downsize to before computing the render pass.
  49756. * @param camera The camera to apply the render pass to.
  49757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49758. * @param engine The engine which the post process will be applied. (default: current engine)
  49759. * @param reusable If the post process can be reused on the same frame. (default: false)
  49760. * @param textureType The type of texture to be used when performing the post processing.
  49761. * @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)
  49762. */
  49763. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49764. /** @hidden */
  49765. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49766. }
  49767. /**
  49768. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49769. */
  49770. export class PassCubePostProcess extends PostProcess {
  49771. private _face;
  49772. /**
  49773. * Gets or sets the cube face to display.
  49774. * * 0 is +X
  49775. * * 1 is -X
  49776. * * 2 is +Y
  49777. * * 3 is -Y
  49778. * * 4 is +Z
  49779. * * 5 is -Z
  49780. */
  49781. get face(): number;
  49782. set face(value: number);
  49783. /**
  49784. * Gets a string identifying the name of the class
  49785. * @returns "PassCubePostProcess" string
  49786. */
  49787. getClassName(): string;
  49788. /**
  49789. * Creates the PassCubePostProcess
  49790. * @param name The name of the effect.
  49791. * @param options The required width/height ratio to downsize to before computing the render pass.
  49792. * @param camera The camera to apply the render pass to.
  49793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49794. * @param engine The engine which the post process will be applied. (default: current engine)
  49795. * @param reusable If the post process can be reused on the same frame. (default: false)
  49796. * @param textureType The type of texture to be used when performing the post processing.
  49797. * @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)
  49798. */
  49799. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49800. /** @hidden */
  49801. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49802. }
  49803. }
  49804. declare module BABYLON {
  49805. /** @hidden */
  49806. export var anaglyphPixelShader: {
  49807. name: string;
  49808. shader: string;
  49809. };
  49810. }
  49811. declare module BABYLON {
  49812. /**
  49813. * Postprocess used to generate anaglyphic rendering
  49814. */
  49815. export class AnaglyphPostProcess extends PostProcess {
  49816. private _passedProcess;
  49817. /**
  49818. * Gets a string identifying the name of the class
  49819. * @returns "AnaglyphPostProcess" string
  49820. */
  49821. getClassName(): string;
  49822. /**
  49823. * Creates a new AnaglyphPostProcess
  49824. * @param name defines postprocess name
  49825. * @param options defines creation options or target ratio scale
  49826. * @param rigCameras defines cameras using this postprocess
  49827. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49828. * @param engine defines hosting engine
  49829. * @param reusable defines if the postprocess will be reused multiple times per frame
  49830. */
  49831. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49832. }
  49833. }
  49834. declare module BABYLON {
  49835. /**
  49836. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49837. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49838. */
  49839. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49840. /**
  49841. * Creates a new AnaglyphArcRotateCamera
  49842. * @param name defines camera name
  49843. * @param alpha defines alpha angle (in radians)
  49844. * @param beta defines beta angle (in radians)
  49845. * @param radius defines radius
  49846. * @param target defines camera target
  49847. * @param interaxialDistance defines distance between each color axis
  49848. * @param scene defines the hosting scene
  49849. */
  49850. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49851. /**
  49852. * Gets camera class name
  49853. * @returns AnaglyphArcRotateCamera
  49854. */
  49855. getClassName(): string;
  49856. }
  49857. }
  49858. declare module BABYLON {
  49859. /**
  49860. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49861. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49862. */
  49863. export class AnaglyphFreeCamera extends FreeCamera {
  49864. /**
  49865. * Creates a new AnaglyphFreeCamera
  49866. * @param name defines camera name
  49867. * @param position defines initial position
  49868. * @param interaxialDistance defines distance between each color axis
  49869. * @param scene defines the hosting scene
  49870. */
  49871. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49872. /**
  49873. * Gets camera class name
  49874. * @returns AnaglyphFreeCamera
  49875. */
  49876. getClassName(): string;
  49877. }
  49878. }
  49879. declare module BABYLON {
  49880. /**
  49881. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49882. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49883. */
  49884. export class AnaglyphGamepadCamera extends GamepadCamera {
  49885. /**
  49886. * Creates a new AnaglyphGamepadCamera
  49887. * @param name defines camera name
  49888. * @param position defines initial position
  49889. * @param interaxialDistance defines distance between each color axis
  49890. * @param scene defines the hosting scene
  49891. */
  49892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49893. /**
  49894. * Gets camera class name
  49895. * @returns AnaglyphGamepadCamera
  49896. */
  49897. getClassName(): string;
  49898. }
  49899. }
  49900. declare module BABYLON {
  49901. /**
  49902. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49903. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49904. */
  49905. export class AnaglyphUniversalCamera extends UniversalCamera {
  49906. /**
  49907. * Creates a new AnaglyphUniversalCamera
  49908. * @param name defines camera name
  49909. * @param position defines initial position
  49910. * @param interaxialDistance defines distance between each color axis
  49911. * @param scene defines the hosting scene
  49912. */
  49913. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49914. /**
  49915. * Gets camera class name
  49916. * @returns AnaglyphUniversalCamera
  49917. */
  49918. getClassName(): string;
  49919. }
  49920. }
  49921. declare module BABYLON {
  49922. /**
  49923. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49924. * @see https://doc.babylonjs.com/features/cameras
  49925. */
  49926. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49927. /**
  49928. * Creates a new StereoscopicArcRotateCamera
  49929. * @param name defines camera name
  49930. * @param alpha defines alpha angle (in radians)
  49931. * @param beta defines beta angle (in radians)
  49932. * @param radius defines radius
  49933. * @param target defines camera target
  49934. * @param interaxialDistance defines distance between each color axis
  49935. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49936. * @param scene defines the hosting scene
  49937. */
  49938. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49939. /**
  49940. * Gets camera class name
  49941. * @returns StereoscopicArcRotateCamera
  49942. */
  49943. getClassName(): string;
  49944. }
  49945. }
  49946. declare module BABYLON {
  49947. /**
  49948. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49949. * @see https://doc.babylonjs.com/features/cameras
  49950. */
  49951. export class StereoscopicFreeCamera extends FreeCamera {
  49952. /**
  49953. * Creates a new StereoscopicFreeCamera
  49954. * @param name defines camera name
  49955. * @param position defines initial position
  49956. * @param interaxialDistance defines distance between each color axis
  49957. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49958. * @param scene defines the hosting scene
  49959. */
  49960. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49961. /**
  49962. * Gets camera class name
  49963. * @returns StereoscopicFreeCamera
  49964. */
  49965. getClassName(): string;
  49966. }
  49967. }
  49968. declare module BABYLON {
  49969. /**
  49970. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49971. * @see https://doc.babylonjs.com/features/cameras
  49972. */
  49973. export class StereoscopicGamepadCamera extends GamepadCamera {
  49974. /**
  49975. * Creates a new StereoscopicGamepadCamera
  49976. * @param name defines camera name
  49977. * @param position defines initial position
  49978. * @param interaxialDistance defines distance between each color axis
  49979. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49980. * @param scene defines the hosting scene
  49981. */
  49982. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49983. /**
  49984. * Gets camera class name
  49985. * @returns StereoscopicGamepadCamera
  49986. */
  49987. getClassName(): string;
  49988. }
  49989. }
  49990. declare module BABYLON {
  49991. /**
  49992. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49993. * @see https://doc.babylonjs.com/features/cameras
  49994. */
  49995. export class StereoscopicUniversalCamera extends UniversalCamera {
  49996. /**
  49997. * Creates a new StereoscopicUniversalCamera
  49998. * @param name defines camera name
  49999. * @param position defines initial position
  50000. * @param interaxialDistance defines distance between each color axis
  50001. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  50002. * @param scene defines the hosting scene
  50003. */
  50004. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  50005. /**
  50006. * Gets camera class name
  50007. * @returns StereoscopicUniversalCamera
  50008. */
  50009. getClassName(): string;
  50010. }
  50011. }
  50012. declare module BABYLON {
  50013. /**
  50014. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  50015. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50016. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50017. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50018. */
  50019. export class VirtualJoysticksCamera extends FreeCamera {
  50020. /**
  50021. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  50022. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50023. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50024. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50025. * @param name Define the name of the camera in the scene
  50026. * @param position Define the start position of the camera in the scene
  50027. * @param scene Define the scene the camera belongs to
  50028. */
  50029. constructor(name: string, position: Vector3, scene: Scene);
  50030. /**
  50031. * Gets the current object class name.
  50032. * @return the class name
  50033. */
  50034. getClassName(): string;
  50035. }
  50036. }
  50037. declare module BABYLON {
  50038. /**
  50039. * This represents all the required metrics to create a VR camera.
  50040. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50041. */
  50042. export class VRCameraMetrics {
  50043. /**
  50044. * Define the horizontal resolution off the screen.
  50045. */
  50046. hResolution: number;
  50047. /**
  50048. * Define the vertical resolution off the screen.
  50049. */
  50050. vResolution: number;
  50051. /**
  50052. * Define the horizontal screen size.
  50053. */
  50054. hScreenSize: number;
  50055. /**
  50056. * Define the vertical screen size.
  50057. */
  50058. vScreenSize: number;
  50059. /**
  50060. * Define the vertical screen center position.
  50061. */
  50062. vScreenCenter: number;
  50063. /**
  50064. * Define the distance of the eyes to the screen.
  50065. */
  50066. eyeToScreenDistance: number;
  50067. /**
  50068. * Define the distance between both lenses
  50069. */
  50070. lensSeparationDistance: number;
  50071. /**
  50072. * Define the distance between both viewer's eyes.
  50073. */
  50074. interpupillaryDistance: number;
  50075. /**
  50076. * Define the distortion factor of the VR postprocess.
  50077. * Please, touch with care.
  50078. */
  50079. distortionK: number[];
  50080. /**
  50081. * Define the chromatic aberration correction factors for the VR post process.
  50082. */
  50083. chromaAbCorrection: number[];
  50084. /**
  50085. * Define the scale factor of the post process.
  50086. * The smaller the better but the slower.
  50087. */
  50088. postProcessScaleFactor: number;
  50089. /**
  50090. * Define an offset for the lens center.
  50091. */
  50092. lensCenterOffset: number;
  50093. /**
  50094. * Define if the current vr camera should compensate the distortion of the lense or not.
  50095. */
  50096. compensateDistortion: boolean;
  50097. /**
  50098. * Defines if multiview should be enabled when rendering (Default: false)
  50099. */
  50100. multiviewEnabled: boolean;
  50101. /**
  50102. * Gets the rendering aspect ratio based on the provided resolutions.
  50103. */
  50104. get aspectRatio(): number;
  50105. /**
  50106. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50107. */
  50108. get aspectRatioFov(): number;
  50109. /**
  50110. * @hidden
  50111. */
  50112. get leftHMatrix(): Matrix;
  50113. /**
  50114. * @hidden
  50115. */
  50116. get rightHMatrix(): Matrix;
  50117. /**
  50118. * @hidden
  50119. */
  50120. get leftPreViewMatrix(): Matrix;
  50121. /**
  50122. * @hidden
  50123. */
  50124. get rightPreViewMatrix(): Matrix;
  50125. /**
  50126. * Get the default VRMetrics based on the most generic setup.
  50127. * @returns the default vr metrics
  50128. */
  50129. static GetDefault(): VRCameraMetrics;
  50130. }
  50131. }
  50132. declare module BABYLON {
  50133. /** @hidden */
  50134. export var vrDistortionCorrectionPixelShader: {
  50135. name: string;
  50136. shader: string;
  50137. };
  50138. }
  50139. declare module BABYLON {
  50140. /**
  50141. * VRDistortionCorrectionPostProcess used for mobile VR
  50142. */
  50143. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50144. private _isRightEye;
  50145. private _distortionFactors;
  50146. private _postProcessScaleFactor;
  50147. private _lensCenterOffset;
  50148. private _scaleIn;
  50149. private _scaleFactor;
  50150. private _lensCenter;
  50151. /**
  50152. * Gets a string identifying the name of the class
  50153. * @returns "VRDistortionCorrectionPostProcess" string
  50154. */
  50155. getClassName(): string;
  50156. /**
  50157. * Initializes the VRDistortionCorrectionPostProcess
  50158. * @param name The name of the effect.
  50159. * @param camera The camera to apply the render pass to.
  50160. * @param isRightEye If this is for the right eye distortion
  50161. * @param vrMetrics All the required metrics for the VR camera
  50162. */
  50163. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50164. }
  50165. }
  50166. declare module BABYLON {
  50167. /**
  50168. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50169. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50170. */
  50171. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50172. /**
  50173. * Creates a new VRDeviceOrientationArcRotateCamera
  50174. * @param name defines camera name
  50175. * @param alpha defines the camera rotation along the logitudinal axis
  50176. * @param beta defines the camera rotation along the latitudinal axis
  50177. * @param radius defines the camera distance from its target
  50178. * @param target defines the camera target
  50179. * @param scene defines the scene the camera belongs to
  50180. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50181. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50182. */
  50183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50184. /**
  50185. * Gets camera class name
  50186. * @returns VRDeviceOrientationArcRotateCamera
  50187. */
  50188. getClassName(): string;
  50189. }
  50190. }
  50191. declare module BABYLON {
  50192. /**
  50193. * Camera used to simulate VR rendering (based on FreeCamera)
  50194. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50195. */
  50196. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50197. /**
  50198. * Creates a new VRDeviceOrientationFreeCamera
  50199. * @param name defines camera name
  50200. * @param position defines the start position of the camera
  50201. * @param scene defines the scene the camera belongs to
  50202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50204. */
  50205. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50206. /**
  50207. * Gets camera class name
  50208. * @returns VRDeviceOrientationFreeCamera
  50209. */
  50210. getClassName(): string;
  50211. }
  50212. }
  50213. declare module BABYLON {
  50214. /**
  50215. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50216. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50217. */
  50218. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50219. /**
  50220. * Creates a new VRDeviceOrientationGamepadCamera
  50221. * @param name defines camera name
  50222. * @param position defines the start position of the camera
  50223. * @param scene defines the scene the camera belongs to
  50224. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50225. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50226. */
  50227. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50228. /**
  50229. * Gets camera class name
  50230. * @returns VRDeviceOrientationGamepadCamera
  50231. */
  50232. getClassName(): string;
  50233. }
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * A class extending Texture allowing drawing on a texture
  50238. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50239. */
  50240. export class DynamicTexture extends Texture {
  50241. private _generateMipMaps;
  50242. private _canvas;
  50243. private _context;
  50244. /**
  50245. * Creates a DynamicTexture
  50246. * @param name defines the name of the texture
  50247. * @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
  50248. * @param scene defines the scene where you want the texture
  50249. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50250. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50251. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50252. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50253. */
  50254. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50255. /**
  50256. * Get the current class name of the texture useful for serialization or dynamic coding.
  50257. * @returns "DynamicTexture"
  50258. */
  50259. getClassName(): string;
  50260. /**
  50261. * Gets the current state of canRescale
  50262. */
  50263. get canRescale(): boolean;
  50264. private _recreate;
  50265. /**
  50266. * Scales the texture
  50267. * @param ratio the scale factor to apply to both width and height
  50268. */
  50269. scale(ratio: number): void;
  50270. /**
  50271. * Resizes the texture
  50272. * @param width the new width
  50273. * @param height the new height
  50274. */
  50275. scaleTo(width: number, height: number): void;
  50276. /**
  50277. * Gets the context of the canvas used by the texture
  50278. * @returns the canvas context of the dynamic texture
  50279. */
  50280. getContext(): CanvasRenderingContext2D;
  50281. /**
  50282. * Clears the texture
  50283. */
  50284. clear(): void;
  50285. /**
  50286. * Updates the texture
  50287. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50288. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50289. */
  50290. update(invertY?: boolean, premulAlpha?: boolean): void;
  50291. /**
  50292. * Draws text onto the texture
  50293. * @param text defines the text to be drawn
  50294. * @param x defines the placement of the text from the left
  50295. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50296. * @param font defines the font to be used with font-style, font-size, font-name
  50297. * @param color defines the color used for the text
  50298. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50299. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50300. * @param update defines whether texture is immediately update (default is true)
  50301. */
  50302. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50303. /**
  50304. * Clones the texture
  50305. * @returns the clone of the texture.
  50306. */
  50307. clone(): DynamicTexture;
  50308. /**
  50309. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50310. * @returns a serialized dynamic texture object
  50311. */
  50312. serialize(): any;
  50313. private _IsCanvasElement;
  50314. /** @hidden */
  50315. _rebuild(): void;
  50316. }
  50317. }
  50318. declare module BABYLON {
  50319. /**
  50320. * Class containing static functions to help procedurally build meshes
  50321. */
  50322. export class GroundBuilder {
  50323. /**
  50324. * Creates a ground mesh
  50325. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50326. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50328. * @param name defines the name of the mesh
  50329. * @param options defines the options used to create the mesh
  50330. * @param scene defines the hosting scene
  50331. * @returns the ground mesh
  50332. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50333. */
  50334. static CreateGround(name: string, options: {
  50335. width?: number;
  50336. height?: number;
  50337. subdivisions?: number;
  50338. subdivisionsX?: number;
  50339. subdivisionsY?: number;
  50340. updatable?: boolean;
  50341. }, scene: any): Mesh;
  50342. /**
  50343. * Creates a tiled ground mesh
  50344. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50345. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50346. * * 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
  50347. * * 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
  50348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50349. * @param name defines the name of the mesh
  50350. * @param options defines the options used to create the mesh
  50351. * @param scene defines the hosting scene
  50352. * @returns the tiled ground mesh
  50353. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50354. */
  50355. static CreateTiledGround(name: string, options: {
  50356. xmin: number;
  50357. zmin: number;
  50358. xmax: number;
  50359. zmax: number;
  50360. subdivisions?: {
  50361. w: number;
  50362. h: number;
  50363. };
  50364. precision?: {
  50365. w: number;
  50366. h: number;
  50367. };
  50368. updatable?: boolean;
  50369. }, scene?: Nullable<Scene>): Mesh;
  50370. /**
  50371. * Creates a ground mesh from a height map
  50372. * * The parameter `url` sets the URL of the height map image resource.
  50373. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50374. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50375. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50376. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50377. * * 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.
  50378. * * 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).
  50379. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50381. * @param name defines the name of the mesh
  50382. * @param url defines the url to the height map
  50383. * @param options defines the options used to create the mesh
  50384. * @param scene defines the hosting scene
  50385. * @returns the ground mesh
  50386. * @see https://doc.babylonjs.com/babylon101/height_map
  50387. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50388. */
  50389. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50390. width?: number;
  50391. height?: number;
  50392. subdivisions?: number;
  50393. minHeight?: number;
  50394. maxHeight?: number;
  50395. colorFilter?: Color3;
  50396. alphaFilter?: number;
  50397. updatable?: boolean;
  50398. onReady?: (mesh: GroundMesh) => void;
  50399. }, scene?: Nullable<Scene>): GroundMesh;
  50400. }
  50401. }
  50402. declare module BABYLON {
  50403. /**
  50404. * Class containing static functions to help procedurally build meshes
  50405. */
  50406. export class TorusBuilder {
  50407. /**
  50408. * Creates a torus mesh
  50409. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50410. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50411. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50413. * * 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
  50414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50415. * @param name defines the name of the mesh
  50416. * @param options defines the options used to create the mesh
  50417. * @param scene defines the hosting scene
  50418. * @returns the torus mesh
  50419. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50420. */
  50421. static CreateTorus(name: string, options: {
  50422. diameter?: number;
  50423. thickness?: number;
  50424. tessellation?: number;
  50425. updatable?: boolean;
  50426. sideOrientation?: number;
  50427. frontUVs?: Vector4;
  50428. backUVs?: Vector4;
  50429. }, scene: any): Mesh;
  50430. }
  50431. }
  50432. declare module BABYLON {
  50433. /**
  50434. * Class containing static functions to help procedurally build meshes
  50435. */
  50436. export class CylinderBuilder {
  50437. /**
  50438. * Creates a cylinder or a cone mesh
  50439. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50440. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50441. * * 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.
  50442. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50443. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50444. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50445. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50446. * * 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).
  50447. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50448. * * 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).
  50449. * * 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
  50450. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50451. * * 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
  50452. * * 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.
  50453. * * If `enclose` is false, a ring surface is one element.
  50454. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50455. * * 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
  50456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50457. * * 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
  50458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50459. * @param name defines the name of the mesh
  50460. * @param options defines the options used to create the mesh
  50461. * @param scene defines the hosting scene
  50462. * @returns the cylinder mesh
  50463. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50464. */
  50465. static CreateCylinder(name: string, options: {
  50466. height?: number;
  50467. diameterTop?: number;
  50468. diameterBottom?: number;
  50469. diameter?: number;
  50470. tessellation?: number;
  50471. subdivisions?: number;
  50472. arc?: number;
  50473. faceColors?: Color4[];
  50474. faceUV?: Vector4[];
  50475. updatable?: boolean;
  50476. hasRings?: boolean;
  50477. enclose?: boolean;
  50478. cap?: number;
  50479. sideOrientation?: number;
  50480. frontUVs?: Vector4;
  50481. backUVs?: Vector4;
  50482. }, scene: any): Mesh;
  50483. }
  50484. }
  50485. declare module BABYLON {
  50486. /**
  50487. * States of the webXR experience
  50488. */
  50489. export enum WebXRState {
  50490. /**
  50491. * Transitioning to being in XR mode
  50492. */
  50493. ENTERING_XR = 0,
  50494. /**
  50495. * Transitioning to non XR mode
  50496. */
  50497. EXITING_XR = 1,
  50498. /**
  50499. * In XR mode and presenting
  50500. */
  50501. IN_XR = 2,
  50502. /**
  50503. * Not entered XR mode
  50504. */
  50505. NOT_IN_XR = 3
  50506. }
  50507. /**
  50508. * The state of the XR camera's tracking
  50509. */
  50510. export enum WebXRTrackingState {
  50511. /**
  50512. * No transformation received, device is not being tracked
  50513. */
  50514. NOT_TRACKING = 0,
  50515. /**
  50516. * Tracking lost - using emulated position
  50517. */
  50518. TRACKING_LOST = 1,
  50519. /**
  50520. * Transformation tracking works normally
  50521. */
  50522. TRACKING = 2
  50523. }
  50524. /**
  50525. * Abstraction of the XR render target
  50526. */
  50527. export interface WebXRRenderTarget extends IDisposable {
  50528. /**
  50529. * xrpresent context of the canvas which can be used to display/mirror xr content
  50530. */
  50531. canvasContext: WebGLRenderingContext;
  50532. /**
  50533. * xr layer for the canvas
  50534. */
  50535. xrLayer: Nullable<XRWebGLLayer>;
  50536. /**
  50537. * Initializes the xr layer for the session
  50538. * @param xrSession xr session
  50539. * @returns a promise that will resolve once the XR Layer has been created
  50540. */
  50541. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50542. }
  50543. }
  50544. declare module BABYLON {
  50545. /**
  50546. * COnfiguration object for WebXR output canvas
  50547. */
  50548. export class WebXRManagedOutputCanvasOptions {
  50549. /**
  50550. * An optional canvas in case you wish to create it yourself and provide it here.
  50551. * If not provided, a new canvas will be created
  50552. */
  50553. canvasElement?: HTMLCanvasElement;
  50554. /**
  50555. * Options for this XR Layer output
  50556. */
  50557. canvasOptions?: XRWebGLLayerInit;
  50558. /**
  50559. * CSS styling for a newly created canvas (if not provided)
  50560. */
  50561. newCanvasCssStyle?: string;
  50562. /**
  50563. * Get the default values of the configuration object
  50564. * @param engine defines the engine to use (can be null)
  50565. * @returns default values of this configuration object
  50566. */
  50567. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50568. }
  50569. /**
  50570. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50571. */
  50572. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50573. private _options;
  50574. private _canvas;
  50575. private _engine;
  50576. private _originalCanvasSize;
  50577. /**
  50578. * Rendering context of the canvas which can be used to display/mirror xr content
  50579. */
  50580. canvasContext: WebGLRenderingContext;
  50581. /**
  50582. * xr layer for the canvas
  50583. */
  50584. xrLayer: Nullable<XRWebGLLayer>;
  50585. /**
  50586. * Obseervers registered here will be triggered when the xr layer was initialized
  50587. */
  50588. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50589. /**
  50590. * Initializes the canvas to be added/removed upon entering/exiting xr
  50591. * @param _xrSessionManager The XR Session manager
  50592. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50593. */
  50594. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50595. /**
  50596. * Disposes of the object
  50597. */
  50598. dispose(): void;
  50599. /**
  50600. * Initializes the xr layer for the session
  50601. * @param xrSession xr session
  50602. * @returns a promise that will resolve once the XR Layer has been created
  50603. */
  50604. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50605. private _addCanvas;
  50606. private _removeCanvas;
  50607. private _setCanvasSize;
  50608. private _setManagedOutputCanvas;
  50609. }
  50610. }
  50611. declare module BABYLON {
  50612. /**
  50613. * Manages an XRSession to work with Babylon's engine
  50614. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50615. */
  50616. export class WebXRSessionManager implements IDisposable {
  50617. /** The scene which the session should be created for */
  50618. scene: Scene;
  50619. private _referenceSpace;
  50620. private _rttProvider;
  50621. private _sessionEnded;
  50622. private _xrNavigator;
  50623. private baseLayer;
  50624. /**
  50625. * The base reference space from which the session started. good if you want to reset your
  50626. * reference space
  50627. */
  50628. baseReferenceSpace: XRReferenceSpace;
  50629. /**
  50630. * Current XR frame
  50631. */
  50632. currentFrame: Nullable<XRFrame>;
  50633. /** WebXR timestamp updated every frame */
  50634. currentTimestamp: number;
  50635. /**
  50636. * Used just in case of a failure to initialize an immersive session.
  50637. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50638. */
  50639. defaultHeightCompensation: number;
  50640. /**
  50641. * Fires every time a new xrFrame arrives which can be used to update the camera
  50642. */
  50643. onXRFrameObservable: Observable<XRFrame>;
  50644. /**
  50645. * Fires when the reference space changed
  50646. */
  50647. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50648. /**
  50649. * Fires when the xr session is ended either by the device or manually done
  50650. */
  50651. onXRSessionEnded: Observable<any>;
  50652. /**
  50653. * Fires when the xr session is ended either by the device or manually done
  50654. */
  50655. onXRSessionInit: Observable<XRSession>;
  50656. /**
  50657. * Underlying xr session
  50658. */
  50659. session: XRSession;
  50660. /**
  50661. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50662. * or get the offset the player is currently at.
  50663. */
  50664. viewerReferenceSpace: XRReferenceSpace;
  50665. /**
  50666. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50667. * @param scene The scene which the session should be created for
  50668. */
  50669. constructor(
  50670. /** The scene which the session should be created for */
  50671. scene: Scene);
  50672. /**
  50673. * The current reference space used in this session. This reference space can constantly change!
  50674. * It is mainly used to offset the camera's position.
  50675. */
  50676. get referenceSpace(): XRReferenceSpace;
  50677. /**
  50678. * Set a new reference space and triggers the observable
  50679. */
  50680. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50681. /**
  50682. * Disposes of the session manager
  50683. */
  50684. dispose(): void;
  50685. /**
  50686. * Stops the xrSession and restores the render loop
  50687. * @returns Promise which resolves after it exits XR
  50688. */
  50689. exitXRAsync(): Promise<void>;
  50690. /**
  50691. * Gets the correct render target texture to be rendered this frame for this eye
  50692. * @param eye the eye for which to get the render target
  50693. * @returns the render target for the specified eye
  50694. */
  50695. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50696. /**
  50697. * Creates a WebXRRenderTarget object for the XR session
  50698. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50699. * @param options optional options to provide when creating a new render target
  50700. * @returns a WebXR render target to which the session can render
  50701. */
  50702. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50703. /**
  50704. * Initializes the manager
  50705. * After initialization enterXR can be called to start an XR session
  50706. * @returns Promise which resolves after it is initialized
  50707. */
  50708. initializeAsync(): Promise<void>;
  50709. /**
  50710. * Initializes an xr session
  50711. * @param xrSessionMode mode to initialize
  50712. * @param xrSessionInit defines optional and required values to pass to the session builder
  50713. * @returns a promise which will resolve once the session has been initialized
  50714. */
  50715. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50716. /**
  50717. * Checks if a session would be supported for the creation options specified
  50718. * @param sessionMode session mode to check if supported eg. immersive-vr
  50719. * @returns A Promise that resolves to true if supported and false if not
  50720. */
  50721. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50722. /**
  50723. * Resets the reference space to the one started the session
  50724. */
  50725. resetReferenceSpace(): void;
  50726. /**
  50727. * Starts rendering to the xr layer
  50728. */
  50729. runXRRenderLoop(): void;
  50730. /**
  50731. * Sets the reference space on the xr session
  50732. * @param referenceSpaceType space to set
  50733. * @returns a promise that will resolve once the reference space has been set
  50734. */
  50735. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50736. /**
  50737. * Updates the render state of the session
  50738. * @param state state to set
  50739. * @returns a promise that resolves once the render state has been updated
  50740. */
  50741. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50742. /**
  50743. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50744. * @param sessionMode defines the session to test
  50745. * @returns a promise with boolean as final value
  50746. */
  50747. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50748. private _createRenderTargetTexture;
  50749. }
  50750. }
  50751. declare module BABYLON {
  50752. /**
  50753. * WebXR Camera which holds the views for the xrSession
  50754. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50755. */
  50756. export class WebXRCamera extends FreeCamera {
  50757. private _xrSessionManager;
  50758. private _firstFrame;
  50759. private _referenceQuaternion;
  50760. private _referencedPosition;
  50761. private _xrInvPositionCache;
  50762. private _xrInvQuaternionCache;
  50763. private _trackingState;
  50764. /**
  50765. * Observable raised before camera teleportation
  50766. */
  50767. onBeforeCameraTeleport: Observable<Vector3>;
  50768. /**
  50769. * Observable raised after camera teleportation
  50770. */
  50771. onAfterCameraTeleport: Observable<Vector3>;
  50772. /**
  50773. * Notifies when the camera's tracking state has changed.
  50774. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50775. */
  50776. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50777. /**
  50778. * Should position compensation execute on first frame.
  50779. * This is used when copying the position from a native (non XR) camera
  50780. */
  50781. compensateOnFirstFrame: boolean;
  50782. /**
  50783. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50784. * @param name the name of the camera
  50785. * @param scene the scene to add the camera to
  50786. * @param _xrSessionManager a constructed xr session manager
  50787. */
  50788. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50789. /**
  50790. * Get the current XR tracking state of the camera
  50791. */
  50792. get trackingState(): WebXRTrackingState;
  50793. private _setTrackingState;
  50794. /**
  50795. * Return the user's height, unrelated to the current ground.
  50796. * This will be the y position of this camera, when ground level is 0.
  50797. */
  50798. get realWorldHeight(): number;
  50799. /** @hidden */
  50800. _updateForDualEyeDebugging(): void;
  50801. /**
  50802. * Sets this camera's transformation based on a non-vr camera
  50803. * @param otherCamera the non-vr camera to copy the transformation from
  50804. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50805. */
  50806. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50807. /**
  50808. * Gets the current instance class name ("WebXRCamera").
  50809. * @returns the class name
  50810. */
  50811. getClassName(): string;
  50812. private _rotate180;
  50813. private _updateFromXRSession;
  50814. private _updateNumberOfRigCameras;
  50815. private _updateReferenceSpace;
  50816. private _updateReferenceSpaceOffset;
  50817. }
  50818. }
  50819. declare module BABYLON {
  50820. /**
  50821. * Defining the interface required for a (webxr) feature
  50822. */
  50823. export interface IWebXRFeature extends IDisposable {
  50824. /**
  50825. * Is this feature attached
  50826. */
  50827. attached: boolean;
  50828. /**
  50829. * Should auto-attach be disabled?
  50830. */
  50831. disableAutoAttach: boolean;
  50832. /**
  50833. * Attach the feature to the session
  50834. * Will usually be called by the features manager
  50835. *
  50836. * @param force should attachment be forced (even when already attached)
  50837. * @returns true if successful.
  50838. */
  50839. attach(force?: boolean): boolean;
  50840. /**
  50841. * Detach the feature from the session
  50842. * Will usually be called by the features manager
  50843. *
  50844. * @returns true if successful.
  50845. */
  50846. detach(): boolean;
  50847. /**
  50848. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50849. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50850. *
  50851. * @returns whether or not the feature is compatible in this environment
  50852. */
  50853. isCompatible(): boolean;
  50854. /**
  50855. * Was this feature disposed;
  50856. */
  50857. isDisposed: boolean;
  50858. /**
  50859. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50860. */
  50861. xrNativeFeatureName?: string;
  50862. /**
  50863. * A list of (Babylon WebXR) features this feature depends on
  50864. */
  50865. dependsOn?: string[];
  50866. }
  50867. /**
  50868. * A list of the currently available features without referencing them
  50869. */
  50870. export class WebXRFeatureName {
  50871. /**
  50872. * The name of the anchor system feature
  50873. */
  50874. static readonly ANCHOR_SYSTEM: string;
  50875. /**
  50876. * The name of the background remover feature
  50877. */
  50878. static readonly BACKGROUND_REMOVER: string;
  50879. /**
  50880. * The name of the hit test feature
  50881. */
  50882. static readonly HIT_TEST: string;
  50883. /**
  50884. * physics impostors for xr controllers feature
  50885. */
  50886. static readonly PHYSICS_CONTROLLERS: string;
  50887. /**
  50888. * The name of the plane detection feature
  50889. */
  50890. static readonly PLANE_DETECTION: string;
  50891. /**
  50892. * The name of the pointer selection feature
  50893. */
  50894. static readonly POINTER_SELECTION: string;
  50895. /**
  50896. * The name of the teleportation feature
  50897. */
  50898. static readonly TELEPORTATION: string;
  50899. /**
  50900. * The name of the feature points feature.
  50901. */
  50902. static readonly FEATURE_POINTS: string;
  50903. /**
  50904. * The name of the hand tracking feature.
  50905. */
  50906. static readonly HAND_TRACKING: string;
  50907. }
  50908. /**
  50909. * Defining the constructor of a feature. Used to register the modules.
  50910. */
  50911. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50912. /**
  50913. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50914. * It is mainly used in AR sessions.
  50915. *
  50916. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50917. */
  50918. export class WebXRFeaturesManager implements IDisposable {
  50919. private _xrSessionManager;
  50920. private static readonly _AvailableFeatures;
  50921. private _features;
  50922. /**
  50923. * constructs a new features manages.
  50924. *
  50925. * @param _xrSessionManager an instance of WebXRSessionManager
  50926. */
  50927. constructor(_xrSessionManager: WebXRSessionManager);
  50928. /**
  50929. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50930. * Mainly used internally.
  50931. *
  50932. * @param featureName the name of the feature to register
  50933. * @param constructorFunction the function used to construct the module
  50934. * @param version the (babylon) version of the module
  50935. * @param stable is that a stable version of this module
  50936. */
  50937. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50938. /**
  50939. * Returns a constructor of a specific feature.
  50940. *
  50941. * @param featureName the name of the feature to construct
  50942. * @param version the version of the feature to load
  50943. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50944. * @param options optional options provided to the module.
  50945. * @returns a function that, when called, will return a new instance of this feature
  50946. */
  50947. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50948. /**
  50949. * Can be used to return the list of features currently registered
  50950. *
  50951. * @returns an Array of available features
  50952. */
  50953. static GetAvailableFeatures(): string[];
  50954. /**
  50955. * Gets the versions available for a specific feature
  50956. * @param featureName the name of the feature
  50957. * @returns an array with the available versions
  50958. */
  50959. static GetAvailableVersions(featureName: string): string[];
  50960. /**
  50961. * Return the latest unstable version of this feature
  50962. * @param featureName the name of the feature to search
  50963. * @returns the version number. if not found will return -1
  50964. */
  50965. static GetLatestVersionOfFeature(featureName: string): number;
  50966. /**
  50967. * Return the latest stable version of this feature
  50968. * @param featureName the name of the feature to search
  50969. * @returns the version number. if not found will return -1
  50970. */
  50971. static GetStableVersionOfFeature(featureName: string): number;
  50972. /**
  50973. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50974. * Can be used during a session to start a feature
  50975. * @param featureName the name of feature to attach
  50976. */
  50977. attachFeature(featureName: string): void;
  50978. /**
  50979. * Can be used inside a session or when the session ends to detach a specific feature
  50980. * @param featureName the name of the feature to detach
  50981. */
  50982. detachFeature(featureName: string): void;
  50983. /**
  50984. * Used to disable an already-enabled feature
  50985. * The feature will be disposed and will be recreated once enabled.
  50986. * @param featureName the feature to disable
  50987. * @returns true if disable was successful
  50988. */
  50989. disableFeature(featureName: string | {
  50990. Name: string;
  50991. }): boolean;
  50992. /**
  50993. * dispose this features manager
  50994. */
  50995. dispose(): void;
  50996. /**
  50997. * 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.
  50998. * 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.
  50999. *
  51000. * @param featureName the name of the feature to load or the class of the feature
  51001. * @param version optional version to load. if not provided the latest version will be enabled
  51002. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  51003. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  51004. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  51005. * @returns a new constructed feature or throws an error if feature not found.
  51006. */
  51007. enableFeature(featureName: string | {
  51008. Name: string;
  51009. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  51010. /**
  51011. * get the implementation of an enabled feature.
  51012. * @param featureName the name of the feature to load
  51013. * @returns the feature class, if found
  51014. */
  51015. getEnabledFeature(featureName: string): IWebXRFeature;
  51016. /**
  51017. * Get the list of enabled features
  51018. * @returns an array of enabled features
  51019. */
  51020. getEnabledFeatures(): string[];
  51021. /**
  51022. * This function will exten the session creation configuration object with enabled features.
  51023. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  51024. * according to the defined "required" variable, provided during enableFeature call
  51025. * @param xrSessionInit the xr Session init object to extend
  51026. *
  51027. * @returns an extended XRSessionInit object
  51028. */
  51029. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  51030. }
  51031. }
  51032. declare module BABYLON {
  51033. /**
  51034. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  51035. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  51036. */
  51037. export class WebXRExperienceHelper implements IDisposable {
  51038. private scene;
  51039. private _nonVRCamera;
  51040. private _originalSceneAutoClear;
  51041. private _supported;
  51042. /**
  51043. * Camera used to render xr content
  51044. */
  51045. camera: WebXRCamera;
  51046. /** A features manager for this xr session */
  51047. featuresManager: WebXRFeaturesManager;
  51048. /**
  51049. * Observers registered here will be triggered after the camera's initial transformation is set
  51050. * This can be used to set a different ground level or an extra rotation.
  51051. *
  51052. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51053. * to the position set after this observable is done executing.
  51054. */
  51055. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51056. /**
  51057. * Fires when the state of the experience helper has changed
  51058. */
  51059. onStateChangedObservable: Observable<WebXRState>;
  51060. /** Session manager used to keep track of xr session */
  51061. sessionManager: WebXRSessionManager;
  51062. /**
  51063. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51064. */
  51065. state: WebXRState;
  51066. /**
  51067. * Creates a WebXRExperienceHelper
  51068. * @param scene The scene the helper should be created in
  51069. */
  51070. private constructor();
  51071. /**
  51072. * Creates the experience helper
  51073. * @param scene the scene to attach the experience helper to
  51074. * @returns a promise for the experience helper
  51075. */
  51076. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51077. /**
  51078. * Disposes of the experience helper
  51079. */
  51080. dispose(): void;
  51081. /**
  51082. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51083. * @param sessionMode options for the XR session
  51084. * @param referenceSpaceType frame of reference of the XR session
  51085. * @param renderTarget the output canvas that will be used to enter XR mode
  51086. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51087. * @returns promise that resolves after xr mode has entered
  51088. */
  51089. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51090. /**
  51091. * Exits XR mode and returns the scene to its original state
  51092. * @returns promise that resolves after xr mode has exited
  51093. */
  51094. exitXRAsync(): Promise<void>;
  51095. private _nonXRToXRCamera;
  51096. private _setState;
  51097. }
  51098. }
  51099. declare module BABYLON {
  51100. /**
  51101. * X-Y values for axes in WebXR
  51102. */
  51103. export interface IWebXRMotionControllerAxesValue {
  51104. /**
  51105. * The value of the x axis
  51106. */
  51107. x: number;
  51108. /**
  51109. * The value of the y-axis
  51110. */
  51111. y: number;
  51112. }
  51113. /**
  51114. * changed / previous values for the values of this component
  51115. */
  51116. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51117. /**
  51118. * current (this frame) value
  51119. */
  51120. current: T;
  51121. /**
  51122. * previous (last change) value
  51123. */
  51124. previous: T;
  51125. }
  51126. /**
  51127. * Represents changes in the component between current frame and last values recorded
  51128. */
  51129. export interface IWebXRMotionControllerComponentChanges {
  51130. /**
  51131. * will be populated with previous and current values if axes changed
  51132. */
  51133. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51134. /**
  51135. * will be populated with previous and current values if pressed changed
  51136. */
  51137. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51138. /**
  51139. * will be populated with previous and current values if touched changed
  51140. */
  51141. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51142. /**
  51143. * will be populated with previous and current values if value changed
  51144. */
  51145. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51146. }
  51147. /**
  51148. * This class represents a single component (for example button or thumbstick) of a motion controller
  51149. */
  51150. export class WebXRControllerComponent implements IDisposable {
  51151. /**
  51152. * the id of this component
  51153. */
  51154. id: string;
  51155. /**
  51156. * the type of the component
  51157. */
  51158. type: MotionControllerComponentType;
  51159. private _buttonIndex;
  51160. private _axesIndices;
  51161. private _axes;
  51162. private _changes;
  51163. private _currentValue;
  51164. private _hasChanges;
  51165. private _pressed;
  51166. private _touched;
  51167. /**
  51168. * button component type
  51169. */
  51170. static BUTTON_TYPE: MotionControllerComponentType;
  51171. /**
  51172. * squeeze component type
  51173. */
  51174. static SQUEEZE_TYPE: MotionControllerComponentType;
  51175. /**
  51176. * Thumbstick component type
  51177. */
  51178. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51179. /**
  51180. * Touchpad component type
  51181. */
  51182. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51183. /**
  51184. * trigger component type
  51185. */
  51186. static TRIGGER_TYPE: MotionControllerComponentType;
  51187. /**
  51188. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51189. * the axes data changes
  51190. */
  51191. onAxisValueChangedObservable: Observable<{
  51192. x: number;
  51193. y: number;
  51194. }>;
  51195. /**
  51196. * Observers registered here will be triggered when the state of a button changes
  51197. * State change is either pressed / touched / value
  51198. */
  51199. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51200. /**
  51201. * Creates a new component for a motion controller.
  51202. * It is created by the motion controller itself
  51203. *
  51204. * @param id the id of this component
  51205. * @param type the type of the component
  51206. * @param _buttonIndex index in the buttons array of the gamepad
  51207. * @param _axesIndices indices of the values in the axes array of the gamepad
  51208. */
  51209. constructor(
  51210. /**
  51211. * the id of this component
  51212. */
  51213. id: string,
  51214. /**
  51215. * the type of the component
  51216. */
  51217. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51218. /**
  51219. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51220. */
  51221. get axes(): IWebXRMotionControllerAxesValue;
  51222. /**
  51223. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51224. */
  51225. get changes(): IWebXRMotionControllerComponentChanges;
  51226. /**
  51227. * Return whether or not the component changed the last frame
  51228. */
  51229. get hasChanges(): boolean;
  51230. /**
  51231. * is the button currently pressed
  51232. */
  51233. get pressed(): boolean;
  51234. /**
  51235. * is the button currently touched
  51236. */
  51237. get touched(): boolean;
  51238. /**
  51239. * Get the current value of this component
  51240. */
  51241. get value(): number;
  51242. /**
  51243. * Dispose this component
  51244. */
  51245. dispose(): void;
  51246. /**
  51247. * Are there axes correlating to this component
  51248. * @return true is axes data is available
  51249. */
  51250. isAxes(): boolean;
  51251. /**
  51252. * Is this component a button (hence - pressable)
  51253. * @returns true if can be pressed
  51254. */
  51255. isButton(): boolean;
  51256. /**
  51257. * update this component using the gamepad object it is in. Called on every frame
  51258. * @param nativeController the native gamepad controller object
  51259. */
  51260. update(nativeController: IMinimalMotionControllerObject): void;
  51261. }
  51262. }
  51263. declare module BABYLON {
  51264. /**
  51265. * Type used for the success callback of ImportMesh
  51266. */
  51267. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51268. /**
  51269. * Interface used for the result of ImportMeshAsync
  51270. */
  51271. export interface ISceneLoaderAsyncResult {
  51272. /**
  51273. * The array of loaded meshes
  51274. */
  51275. readonly meshes: AbstractMesh[];
  51276. /**
  51277. * The array of loaded particle systems
  51278. */
  51279. readonly particleSystems: IParticleSystem[];
  51280. /**
  51281. * The array of loaded skeletons
  51282. */
  51283. readonly skeletons: Skeleton[];
  51284. /**
  51285. * The array of loaded animation groups
  51286. */
  51287. readonly animationGroups: AnimationGroup[];
  51288. /**
  51289. * The array of loaded transform nodes
  51290. */
  51291. readonly transformNodes: TransformNode[];
  51292. /**
  51293. * The array of loaded geometries
  51294. */
  51295. readonly geometries: Geometry[];
  51296. /**
  51297. * The array of loaded lights
  51298. */
  51299. readonly lights: Light[];
  51300. }
  51301. /**
  51302. * Interface used to represent data loading progression
  51303. */
  51304. export interface ISceneLoaderProgressEvent {
  51305. /**
  51306. * Defines if data length to load can be evaluated
  51307. */
  51308. readonly lengthComputable: boolean;
  51309. /**
  51310. * Defines the loaded data length
  51311. */
  51312. readonly loaded: number;
  51313. /**
  51314. * Defines the data length to load
  51315. */
  51316. readonly total: number;
  51317. }
  51318. /**
  51319. * Interface used by SceneLoader plugins to define supported file extensions
  51320. */
  51321. export interface ISceneLoaderPluginExtensions {
  51322. /**
  51323. * Defines the list of supported extensions
  51324. */
  51325. [extension: string]: {
  51326. isBinary: boolean;
  51327. };
  51328. }
  51329. /**
  51330. * Interface used by SceneLoader plugin factory
  51331. */
  51332. export interface ISceneLoaderPluginFactory {
  51333. /**
  51334. * Defines the name of the factory
  51335. */
  51336. name: string;
  51337. /**
  51338. * Function called to create a new plugin
  51339. * @return the new plugin
  51340. */
  51341. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51342. /**
  51343. * The callback that returns true if the data can be directly loaded.
  51344. * @param data string containing the file data
  51345. * @returns if the data can be loaded directly
  51346. */
  51347. canDirectLoad?(data: string): boolean;
  51348. }
  51349. /**
  51350. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51351. */
  51352. export interface ISceneLoaderPluginBase {
  51353. /**
  51354. * The friendly name of this plugin.
  51355. */
  51356. name: string;
  51357. /**
  51358. * The file extensions supported by this plugin.
  51359. */
  51360. extensions: string | ISceneLoaderPluginExtensions;
  51361. /**
  51362. * The callback called when loading from a url.
  51363. * @param scene scene loading this url
  51364. * @param url url to load
  51365. * @param onSuccess callback called when the file successfully loads
  51366. * @param onProgress callback called while file is loading (if the server supports this mode)
  51367. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51368. * @param onError callback called when the file fails to load
  51369. * @returns a file request object
  51370. */
  51371. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51372. /**
  51373. * The callback called when loading from a file object.
  51374. * @param scene scene loading this file
  51375. * @param file defines the file to load
  51376. * @param onSuccess defines the callback to call when data is loaded
  51377. * @param onProgress defines the callback to call during loading process
  51378. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51379. * @param onError defines the callback to call when an error occurs
  51380. * @returns a file request object
  51381. */
  51382. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51383. /**
  51384. * The callback that returns true if the data can be directly loaded.
  51385. * @param data string containing the file data
  51386. * @returns if the data can be loaded directly
  51387. */
  51388. canDirectLoad?(data: string): boolean;
  51389. /**
  51390. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51391. * @param scene scene loading this data
  51392. * @param data string containing the data
  51393. * @returns data to pass to the plugin
  51394. */
  51395. directLoad?(scene: Scene, data: string): any;
  51396. /**
  51397. * The callback that allows custom handling of the root url based on the response url.
  51398. * @param rootUrl the original root url
  51399. * @param responseURL the response url if available
  51400. * @returns the new root url
  51401. */
  51402. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51403. }
  51404. /**
  51405. * Interface used to define a SceneLoader plugin
  51406. */
  51407. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51408. /**
  51409. * Import meshes into a scene.
  51410. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51411. * @param scene The scene to import into
  51412. * @param data The data to import
  51413. * @param rootUrl The root url for scene and resources
  51414. * @param meshes The meshes array to import into
  51415. * @param particleSystems The particle systems array to import into
  51416. * @param skeletons The skeletons array to import into
  51417. * @param onError The callback when import fails
  51418. * @returns True if successful or false otherwise
  51419. */
  51420. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51421. /**
  51422. * Load into a scene.
  51423. * @param scene The scene to load into
  51424. * @param data The data to import
  51425. * @param rootUrl The root url for scene and resources
  51426. * @param onError The callback when import fails
  51427. * @returns True if successful or false otherwise
  51428. */
  51429. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51430. /**
  51431. * Load into an asset container.
  51432. * @param scene The scene to load into
  51433. * @param data The data to import
  51434. * @param rootUrl The root url for scene and resources
  51435. * @param onError The callback when import fails
  51436. * @returns The loaded asset container
  51437. */
  51438. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51439. }
  51440. /**
  51441. * Interface used to define an async SceneLoader plugin
  51442. */
  51443. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51444. /**
  51445. * Import meshes into a scene.
  51446. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51447. * @param scene The scene to import into
  51448. * @param data The data to import
  51449. * @param rootUrl The root url for scene and resources
  51450. * @param onProgress The callback when the load progresses
  51451. * @param fileName Defines the name of the file to load
  51452. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51453. */
  51454. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51455. /**
  51456. * Load into a scene.
  51457. * @param scene The scene to load into
  51458. * @param data The data to import
  51459. * @param rootUrl The root url for scene and resources
  51460. * @param onProgress The callback when the load progresses
  51461. * @param fileName Defines the name of the file to load
  51462. * @returns Nothing
  51463. */
  51464. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51465. /**
  51466. * Load into an asset container.
  51467. * @param scene The scene to load into
  51468. * @param data The data to import
  51469. * @param rootUrl The root url for scene and resources
  51470. * @param onProgress The callback when the load progresses
  51471. * @param fileName Defines the name of the file to load
  51472. * @returns The loaded asset container
  51473. */
  51474. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51475. }
  51476. /**
  51477. * Mode that determines how to handle old animation groups before loading new ones.
  51478. */
  51479. export enum SceneLoaderAnimationGroupLoadingMode {
  51480. /**
  51481. * Reset all old animations to initial state then dispose them.
  51482. */
  51483. Clean = 0,
  51484. /**
  51485. * Stop all old animations.
  51486. */
  51487. Stop = 1,
  51488. /**
  51489. * Restart old animations from first frame.
  51490. */
  51491. Sync = 2,
  51492. /**
  51493. * Old animations remains untouched.
  51494. */
  51495. NoSync = 3
  51496. }
  51497. /**
  51498. * Defines a plugin registered by the SceneLoader
  51499. */
  51500. interface IRegisteredPlugin {
  51501. /**
  51502. * Defines the plugin to use
  51503. */
  51504. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51505. /**
  51506. * Defines if the plugin supports binary data
  51507. */
  51508. isBinary: boolean;
  51509. }
  51510. /**
  51511. * Class used to load scene from various file formats using registered plugins
  51512. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51513. */
  51514. export class SceneLoader {
  51515. /**
  51516. * No logging while loading
  51517. */
  51518. static readonly NO_LOGGING: number;
  51519. /**
  51520. * Minimal logging while loading
  51521. */
  51522. static readonly MINIMAL_LOGGING: number;
  51523. /**
  51524. * Summary logging while loading
  51525. */
  51526. static readonly SUMMARY_LOGGING: number;
  51527. /**
  51528. * Detailled logging while loading
  51529. */
  51530. static readonly DETAILED_LOGGING: number;
  51531. /**
  51532. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51533. */
  51534. static get ForceFullSceneLoadingForIncremental(): boolean;
  51535. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51536. /**
  51537. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51538. */
  51539. static get ShowLoadingScreen(): boolean;
  51540. static set ShowLoadingScreen(value: boolean);
  51541. /**
  51542. * Defines the current logging level (while loading the scene)
  51543. * @ignorenaming
  51544. */
  51545. static get loggingLevel(): number;
  51546. static set loggingLevel(value: number);
  51547. /**
  51548. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51549. */
  51550. static get CleanBoneMatrixWeights(): boolean;
  51551. static set CleanBoneMatrixWeights(value: boolean);
  51552. /**
  51553. * Event raised when a plugin is used to load a scene
  51554. */
  51555. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51556. private static _registeredPlugins;
  51557. private static _showingLoadingScreen;
  51558. /**
  51559. * Gets the default plugin (used to load Babylon files)
  51560. * @returns the .babylon plugin
  51561. */
  51562. static GetDefaultPlugin(): IRegisteredPlugin;
  51563. private static _GetPluginForExtension;
  51564. private static _GetPluginForDirectLoad;
  51565. private static _GetPluginForFilename;
  51566. private static _GetDirectLoad;
  51567. private static _LoadData;
  51568. private static _GetFileInfo;
  51569. /**
  51570. * Gets a plugin that can load the given extension
  51571. * @param extension defines the extension to load
  51572. * @returns a plugin or null if none works
  51573. */
  51574. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51575. /**
  51576. * Gets a boolean indicating that the given extension can be loaded
  51577. * @param extension defines the extension to load
  51578. * @returns true if the extension is supported
  51579. */
  51580. static IsPluginForExtensionAvailable(extension: string): boolean;
  51581. /**
  51582. * Adds a new plugin to the list of registered plugins
  51583. * @param plugin defines the plugin to add
  51584. */
  51585. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51586. /**
  51587. * Import meshes into a scene
  51588. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51589. * @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)
  51590. * @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)
  51591. * @param scene the instance of BABYLON.Scene to append to
  51592. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51593. * @param onProgress a callback with a progress event for each file being loaded
  51594. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51595. * @param pluginExtension the extension used to determine the plugin
  51596. * @returns The loaded plugin
  51597. */
  51598. 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>;
  51599. /**
  51600. * Import meshes into a scene
  51601. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51602. * @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)
  51603. * @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)
  51604. * @param scene the instance of BABYLON.Scene to append to
  51605. * @param onProgress a callback with a progress event for each file being loaded
  51606. * @param pluginExtension the extension used to determine the plugin
  51607. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51608. */
  51609. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51610. /**
  51611. * Load a scene
  51612. * @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)
  51613. * @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)
  51614. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51615. * @param onSuccess a callback with the scene when import succeeds
  51616. * @param onProgress a callback with a progress event for each file being loaded
  51617. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51618. * @param pluginExtension the extension used to determine the plugin
  51619. * @returns The loaded plugin
  51620. */
  51621. 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>;
  51622. /**
  51623. * Load a scene
  51624. * @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)
  51625. * @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)
  51626. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51627. * @param onProgress a callback with a progress event for each file being loaded
  51628. * @param pluginExtension the extension used to determine the plugin
  51629. * @returns The loaded scene
  51630. */
  51631. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51632. /**
  51633. * Append a scene
  51634. * @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)
  51635. * @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)
  51636. * @param scene is the instance of BABYLON.Scene to append to
  51637. * @param onSuccess a callback with the scene when import succeeds
  51638. * @param onProgress a callback with a progress event for each file being loaded
  51639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51640. * @param pluginExtension the extension used to determine the plugin
  51641. * @returns The loaded plugin
  51642. */
  51643. 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>;
  51644. /**
  51645. * Append a scene
  51646. * @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)
  51647. * @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)
  51648. * @param scene is the instance of BABYLON.Scene to append to
  51649. * @param onProgress a callback with a progress event for each file being loaded
  51650. * @param pluginExtension the extension used to determine the plugin
  51651. * @returns The given scene
  51652. */
  51653. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51654. /**
  51655. * Load a scene into an asset container
  51656. * @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)
  51657. * @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)
  51658. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51659. * @param onSuccess a callback with the scene when import succeeds
  51660. * @param onProgress a callback with a progress event for each file being loaded
  51661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51662. * @param pluginExtension the extension used to determine the plugin
  51663. * @returns The loaded plugin
  51664. */
  51665. 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>;
  51666. /**
  51667. * Load a scene into an asset container
  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 (default: empty string)
  51670. * @param scene is the instance of Scene to append to
  51671. * @param onProgress a callback with a progress event for each file being loaded
  51672. * @param pluginExtension the extension used to determine the plugin
  51673. * @returns The loaded asset container
  51674. */
  51675. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51676. /**
  51677. * Import animations from a file into a scene
  51678. * @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)
  51679. * @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)
  51680. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51681. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51682. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51683. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51684. * @param onSuccess a callback with the scene when import succeeds
  51685. * @param onProgress a callback with a progress event for each file being loaded
  51686. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51687. * @param pluginExtension the extension used to determine the plugin
  51688. */
  51689. 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;
  51690. /**
  51691. * Import animations from a file into a scene
  51692. * @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)
  51693. * @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)
  51694. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51695. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51696. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51697. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51698. * @param onSuccess a callback with the scene when import succeeds
  51699. * @param onProgress a callback with a progress event for each file being loaded
  51700. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51701. * @param pluginExtension the extension used to determine the plugin
  51702. * @returns the updated scene with imported animations
  51703. */
  51704. 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>;
  51705. }
  51706. }
  51707. declare module BABYLON {
  51708. /**
  51709. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51710. */
  51711. export type MotionControllerHandedness = "none" | "left" | "right";
  51712. /**
  51713. * The type of components available in motion controllers.
  51714. * This is not the name of the component.
  51715. */
  51716. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51717. /**
  51718. * The state of a controller component
  51719. */
  51720. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51721. /**
  51722. * The schema of motion controller layout.
  51723. * No object will be initialized using this interface
  51724. * This is used just to define the profile.
  51725. */
  51726. export interface IMotionControllerLayout {
  51727. /**
  51728. * Path to load the assets. Usually relative to the base path
  51729. */
  51730. assetPath: string;
  51731. /**
  51732. * Available components (unsorted)
  51733. */
  51734. components: {
  51735. /**
  51736. * A map of component Ids
  51737. */
  51738. [componentId: string]: {
  51739. /**
  51740. * The type of input the component outputs
  51741. */
  51742. type: MotionControllerComponentType;
  51743. /**
  51744. * The indices of this component in the gamepad object
  51745. */
  51746. gamepadIndices: {
  51747. /**
  51748. * Index of button
  51749. */
  51750. button?: number;
  51751. /**
  51752. * If available, index of x-axis
  51753. */
  51754. xAxis?: number;
  51755. /**
  51756. * If available, index of y-axis
  51757. */
  51758. yAxis?: number;
  51759. };
  51760. /**
  51761. * The mesh's root node name
  51762. */
  51763. rootNodeName: string;
  51764. /**
  51765. * Animation definitions for this model
  51766. */
  51767. visualResponses: {
  51768. [stateKey: string]: {
  51769. /**
  51770. * What property will be animated
  51771. */
  51772. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51773. /**
  51774. * What states influence this visual response
  51775. */
  51776. states: MotionControllerComponentStateType[];
  51777. /**
  51778. * Type of animation - movement or visibility
  51779. */
  51780. valueNodeProperty: "transform" | "visibility";
  51781. /**
  51782. * Base node name to move. Its position will be calculated according to the min and max nodes
  51783. */
  51784. valueNodeName?: string;
  51785. /**
  51786. * Minimum movement node
  51787. */
  51788. minNodeName?: string;
  51789. /**
  51790. * Max movement node
  51791. */
  51792. maxNodeName?: string;
  51793. };
  51794. };
  51795. /**
  51796. * If touch enabled, what is the name of node to display user feedback
  51797. */
  51798. touchPointNodeName?: string;
  51799. };
  51800. };
  51801. /**
  51802. * Is it xr standard mapping or not
  51803. */
  51804. gamepadMapping: "" | "xr-standard";
  51805. /**
  51806. * Base root node of this entire model
  51807. */
  51808. rootNodeName: string;
  51809. /**
  51810. * Defines the main button component id
  51811. */
  51812. selectComponentId: string;
  51813. }
  51814. /**
  51815. * A definition for the layout map in the input profile
  51816. */
  51817. export interface IMotionControllerLayoutMap {
  51818. /**
  51819. * Layouts with handedness type as a key
  51820. */
  51821. [handedness: string]: IMotionControllerLayout;
  51822. }
  51823. /**
  51824. * The XR Input profile schema
  51825. * Profiles can be found here:
  51826. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51827. */
  51828. export interface IMotionControllerProfile {
  51829. /**
  51830. * fallback profiles for this profileId
  51831. */
  51832. fallbackProfileIds: string[];
  51833. /**
  51834. * The layout map, with handedness as key
  51835. */
  51836. layouts: IMotionControllerLayoutMap;
  51837. /**
  51838. * The id of this profile
  51839. * correlates to the profile(s) in the xrInput.profiles array
  51840. */
  51841. profileId: string;
  51842. }
  51843. /**
  51844. * A helper-interface for the 3 meshes needed for controller button animation
  51845. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51846. */
  51847. export interface IMotionControllerButtonMeshMap {
  51848. /**
  51849. * the mesh that defines the pressed value mesh position.
  51850. * This is used to find the max-position of this button
  51851. */
  51852. pressedMesh: AbstractMesh;
  51853. /**
  51854. * the mesh that defines the unpressed value mesh position.
  51855. * This is used to find the min (or initial) position of this button
  51856. */
  51857. unpressedMesh: AbstractMesh;
  51858. /**
  51859. * The mesh that will be changed when value changes
  51860. */
  51861. valueMesh: AbstractMesh;
  51862. }
  51863. /**
  51864. * A helper-interface for the 3 meshes needed for controller axis animation.
  51865. * This will be expanded when touchpad animations are fully supported
  51866. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51867. */
  51868. export interface IMotionControllerMeshMap {
  51869. /**
  51870. * the mesh that defines the maximum value mesh position.
  51871. */
  51872. maxMesh?: AbstractMesh;
  51873. /**
  51874. * the mesh that defines the minimum value mesh position.
  51875. */
  51876. minMesh?: AbstractMesh;
  51877. /**
  51878. * The mesh that will be changed when axis value changes
  51879. */
  51880. valueMesh?: AbstractMesh;
  51881. }
  51882. /**
  51883. * The elements needed for change-detection of the gamepad objects in motion controllers
  51884. */
  51885. export interface IMinimalMotionControllerObject {
  51886. /**
  51887. * Available axes of this controller
  51888. */
  51889. axes: number[];
  51890. /**
  51891. * An array of available buttons
  51892. */
  51893. buttons: Array<{
  51894. /**
  51895. * Value of the button/trigger
  51896. */
  51897. value: number;
  51898. /**
  51899. * If the button/trigger is currently touched
  51900. */
  51901. touched: boolean;
  51902. /**
  51903. * If the button/trigger is currently pressed
  51904. */
  51905. pressed: boolean;
  51906. }>;
  51907. /**
  51908. * EXPERIMENTAL haptic support.
  51909. */
  51910. hapticActuators?: Array<{
  51911. pulse: (value: number, duration: number) => Promise<boolean>;
  51912. }>;
  51913. }
  51914. /**
  51915. * An Abstract Motion controller
  51916. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51917. * Each component has an observable to check for changes in value and state
  51918. */
  51919. export abstract class WebXRAbstractMotionController implements IDisposable {
  51920. protected scene: Scene;
  51921. protected layout: IMotionControllerLayout;
  51922. /**
  51923. * The gamepad object correlating to this controller
  51924. */
  51925. gamepadObject: IMinimalMotionControllerObject;
  51926. /**
  51927. * handedness (left/right/none) of this controller
  51928. */
  51929. handedness: MotionControllerHandedness;
  51930. private _initComponent;
  51931. private _modelReady;
  51932. /**
  51933. * A map of components (WebXRControllerComponent) in this motion controller
  51934. * Components have a ComponentType and can also have both button and axis definitions
  51935. */
  51936. readonly components: {
  51937. [id: string]: WebXRControllerComponent;
  51938. };
  51939. /**
  51940. * Disable the model's animation. Can be set at any time.
  51941. */
  51942. disableAnimation: boolean;
  51943. /**
  51944. * Observers registered here will be triggered when the model of this controller is done loading
  51945. */
  51946. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51947. /**
  51948. * The profile id of this motion controller
  51949. */
  51950. abstract profileId: string;
  51951. /**
  51952. * The root mesh of the model. It is null if the model was not yet initialized
  51953. */
  51954. rootMesh: Nullable<AbstractMesh>;
  51955. /**
  51956. * constructs a new abstract motion controller
  51957. * @param scene the scene to which the model of the controller will be added
  51958. * @param layout The profile layout to load
  51959. * @param gamepadObject The gamepad object correlating to this controller
  51960. * @param handedness handedness (left/right/none) of this controller
  51961. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51962. */
  51963. constructor(scene: Scene, layout: IMotionControllerLayout,
  51964. /**
  51965. * The gamepad object correlating to this controller
  51966. */
  51967. gamepadObject: IMinimalMotionControllerObject,
  51968. /**
  51969. * handedness (left/right/none) of this controller
  51970. */
  51971. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51972. /**
  51973. * Dispose this controller, the model mesh and all its components
  51974. */
  51975. dispose(): void;
  51976. /**
  51977. * Returns all components of specific type
  51978. * @param type the type to search for
  51979. * @return an array of components with this type
  51980. */
  51981. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51982. /**
  51983. * get a component based an its component id as defined in layout.components
  51984. * @param id the id of the component
  51985. * @returns the component correlates to the id or undefined if not found
  51986. */
  51987. getComponent(id: string): WebXRControllerComponent;
  51988. /**
  51989. * Get the list of components available in this motion controller
  51990. * @returns an array of strings correlating to available components
  51991. */
  51992. getComponentIds(): string[];
  51993. /**
  51994. * Get the first component of specific type
  51995. * @param type type of component to find
  51996. * @return a controller component or null if not found
  51997. */
  51998. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51999. /**
  52000. * Get the main (Select) component of this controller as defined in the layout
  52001. * @returns the main component of this controller
  52002. */
  52003. getMainComponent(): WebXRControllerComponent;
  52004. /**
  52005. * Loads the model correlating to this controller
  52006. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  52007. * @returns A promise fulfilled with the result of the model loading
  52008. */
  52009. loadModel(): Promise<boolean>;
  52010. /**
  52011. * Update this model using the current XRFrame
  52012. * @param xrFrame the current xr frame to use and update the model
  52013. */
  52014. updateFromXRFrame(xrFrame: XRFrame): void;
  52015. /**
  52016. * Backwards compatibility due to a deeply-integrated typo
  52017. */
  52018. get handness(): XREye;
  52019. /**
  52020. * Pulse (vibrate) this controller
  52021. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  52022. * Consecutive calls to this function will cancel the last pulse call
  52023. *
  52024. * @param value the strength of the pulse in 0.0...1.0 range
  52025. * @param duration Duration of the pulse in milliseconds
  52026. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  52027. * @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
  52028. */
  52029. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  52030. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52031. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52032. /**
  52033. * Moves the axis on the controller mesh based on its current state
  52034. * @param axis the index of the axis
  52035. * @param axisValue the value of the axis which determines the meshes new position
  52036. * @hidden
  52037. */
  52038. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52039. /**
  52040. * Update the model itself with the current frame data
  52041. * @param xrFrame the frame to use for updating the model mesh
  52042. */
  52043. protected updateModel(xrFrame: XRFrame): void;
  52044. /**
  52045. * Get the filename and path for this controller's model
  52046. * @returns a map of filename and path
  52047. */
  52048. protected abstract _getFilenameAndPath(): {
  52049. filename: string;
  52050. path: string;
  52051. };
  52052. /**
  52053. * This function is called before the mesh is loaded. It checks for loading constraints.
  52054. * For example, this function can check if the GLB loader is available
  52055. * If this function returns false, the generic controller will be loaded instead
  52056. * @returns Is the client ready to load the mesh
  52057. */
  52058. protected abstract _getModelLoadingConstraints(): boolean;
  52059. /**
  52060. * This function will be called after the model was successfully loaded and can be used
  52061. * for mesh transformations before it is available for the user
  52062. * @param meshes the loaded meshes
  52063. */
  52064. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52065. /**
  52066. * Set the root mesh for this controller. Important for the WebXR controller class
  52067. * @param meshes the loaded meshes
  52068. */
  52069. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52070. /**
  52071. * A function executed each frame that updates the mesh (if needed)
  52072. * @param xrFrame the current xrFrame
  52073. */
  52074. protected abstract _updateModel(xrFrame: XRFrame): void;
  52075. private _getGenericFilenameAndPath;
  52076. private _getGenericParentMesh;
  52077. }
  52078. }
  52079. declare module BABYLON {
  52080. /**
  52081. * A generic trigger-only motion controller for WebXR
  52082. */
  52083. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52084. /**
  52085. * Static version of the profile id of this controller
  52086. */
  52087. static ProfileId: string;
  52088. profileId: string;
  52089. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52090. protected _getFilenameAndPath(): {
  52091. filename: string;
  52092. path: string;
  52093. };
  52094. protected _getModelLoadingConstraints(): boolean;
  52095. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52096. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52097. protected _updateModel(): void;
  52098. }
  52099. }
  52100. declare module BABYLON {
  52101. /**
  52102. * Class containing static functions to help procedurally build meshes
  52103. */
  52104. export class SphereBuilder {
  52105. /**
  52106. * Creates a sphere mesh
  52107. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52108. * * 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`)
  52109. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52110. * * 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
  52111. * * 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)
  52112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52113. * * 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
  52114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52115. * @param name defines the name of the mesh
  52116. * @param options defines the options used to create the mesh
  52117. * @param scene defines the hosting scene
  52118. * @returns the sphere mesh
  52119. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52120. */
  52121. static CreateSphere(name: string, options: {
  52122. segments?: number;
  52123. diameter?: number;
  52124. diameterX?: number;
  52125. diameterY?: number;
  52126. diameterZ?: number;
  52127. arc?: number;
  52128. slice?: number;
  52129. sideOrientation?: number;
  52130. frontUVs?: Vector4;
  52131. backUVs?: Vector4;
  52132. updatable?: boolean;
  52133. }, scene?: Nullable<Scene>): Mesh;
  52134. }
  52135. }
  52136. declare module BABYLON {
  52137. /**
  52138. * A profiled motion controller has its profile loaded from an online repository.
  52139. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52140. */
  52141. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52142. private _repositoryUrl;
  52143. private _buttonMeshMapping;
  52144. private _touchDots;
  52145. /**
  52146. * The profile ID of this controller. Will be populated when the controller initializes.
  52147. */
  52148. profileId: string;
  52149. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52150. dispose(): void;
  52151. protected _getFilenameAndPath(): {
  52152. filename: string;
  52153. path: string;
  52154. };
  52155. protected _getModelLoadingConstraints(): boolean;
  52156. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52157. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52158. protected _updateModel(_xrFrame: XRFrame): void;
  52159. }
  52160. }
  52161. declare module BABYLON {
  52162. /**
  52163. * A construction function type to create a new controller based on an xrInput object
  52164. */
  52165. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52166. /**
  52167. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52168. *
  52169. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52170. * it should be replaced with auto-loaded controllers.
  52171. *
  52172. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52173. */
  52174. export class WebXRMotionControllerManager {
  52175. private static _AvailableControllers;
  52176. private static _Fallbacks;
  52177. private static _ProfileLoadingPromises;
  52178. private static _ProfilesList;
  52179. /**
  52180. * The base URL of the online controller repository. Can be changed at any time.
  52181. */
  52182. static BaseRepositoryUrl: string;
  52183. /**
  52184. * Which repository gets priority - local or online
  52185. */
  52186. static PrioritizeOnlineRepository: boolean;
  52187. /**
  52188. * Use the online repository, or use only locally-defined controllers
  52189. */
  52190. static UseOnlineRepository: boolean;
  52191. /**
  52192. * Clear the cache used for profile loading and reload when requested again
  52193. */
  52194. static ClearProfilesCache(): void;
  52195. /**
  52196. * Register the default fallbacks.
  52197. * This function is called automatically when this file is imported.
  52198. */
  52199. static DefaultFallbacks(): void;
  52200. /**
  52201. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52202. * @param profileId the profile to which a fallback needs to be found
  52203. * @return an array with corresponding fallback profiles
  52204. */
  52205. static FindFallbackWithProfileId(profileId: string): string[];
  52206. /**
  52207. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52208. * The order of search:
  52209. *
  52210. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52211. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52212. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52213. * 4) return the generic trigger controller if none were found
  52214. *
  52215. * @param xrInput the xrInput to which a new controller is initialized
  52216. * @param scene the scene to which the model will be added
  52217. * @param forceProfile force a certain profile for this controller
  52218. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52219. */
  52220. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52221. /**
  52222. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52223. *
  52224. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52225. *
  52226. * @param type the profile type to register
  52227. * @param constructFunction the function to be called when loading this profile
  52228. */
  52229. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52230. /**
  52231. * Register a fallback to a specific profile.
  52232. * @param profileId the profileId that will receive the fallbacks
  52233. * @param fallbacks A list of fallback profiles
  52234. */
  52235. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52236. /**
  52237. * Will update the list of profiles available in the repository
  52238. * @return a promise that resolves to a map of profiles available online
  52239. */
  52240. static UpdateProfilesList(): Promise<{
  52241. [profile: string]: string;
  52242. }>;
  52243. private static _LoadProfileFromRepository;
  52244. private static _LoadProfilesFromAvailableControllers;
  52245. }
  52246. }
  52247. declare module BABYLON {
  52248. /**
  52249. * Configuration options for the WebXR controller creation
  52250. */
  52251. export interface IWebXRControllerOptions {
  52252. /**
  52253. * Should the controller mesh be animated when a user interacts with it
  52254. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52255. */
  52256. disableMotionControllerAnimation?: boolean;
  52257. /**
  52258. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52259. */
  52260. doNotLoadControllerMesh?: boolean;
  52261. /**
  52262. * Force a specific controller type for this controller.
  52263. * This can be used when creating your own profile or when testing different controllers
  52264. */
  52265. forceControllerProfile?: string;
  52266. /**
  52267. * Defines a rendering group ID for meshes that will be loaded.
  52268. * This is for the default controllers only.
  52269. */
  52270. renderingGroupId?: number;
  52271. }
  52272. /**
  52273. * Represents an XR controller
  52274. */
  52275. export class WebXRInputSource {
  52276. private _scene;
  52277. /** The underlying input source for the controller */
  52278. inputSource: XRInputSource;
  52279. private _options;
  52280. private _tmpVector;
  52281. private _uniqueId;
  52282. private _disposed;
  52283. /**
  52284. * 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
  52285. */
  52286. grip?: AbstractMesh;
  52287. /**
  52288. * If available, this is the gamepad object related to this controller.
  52289. * Using this object it is possible to get click events and trackpad changes of the
  52290. * webxr controller that is currently being used.
  52291. */
  52292. motionController?: WebXRAbstractMotionController;
  52293. /**
  52294. * Event that fires when the controller is removed/disposed.
  52295. * The object provided as event data is this controller, after associated assets were disposed.
  52296. * uniqueId is still available.
  52297. */
  52298. onDisposeObservable: Observable<WebXRInputSource>;
  52299. /**
  52300. * Will be triggered when the mesh associated with the motion controller is done loading.
  52301. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52302. * A shortened version of controller -> motion controller -> on mesh loaded.
  52303. */
  52304. onMeshLoadedObservable: Observable<AbstractMesh>;
  52305. /**
  52306. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52307. */
  52308. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52309. /**
  52310. * Pointer which can be used to select objects or attach a visible laser to
  52311. */
  52312. pointer: AbstractMesh;
  52313. /**
  52314. * Creates the input source object
  52315. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52316. * @param _scene the scene which the controller should be associated to
  52317. * @param inputSource the underlying input source for the controller
  52318. * @param _options options for this controller creation
  52319. */
  52320. constructor(_scene: Scene,
  52321. /** The underlying input source for the controller */
  52322. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52323. /**
  52324. * Get this controllers unique id
  52325. */
  52326. get uniqueId(): string;
  52327. /**
  52328. * Disposes of the object
  52329. */
  52330. dispose(): void;
  52331. /**
  52332. * Gets a world space ray coming from the pointer or grip
  52333. * @param result the resulting ray
  52334. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52335. */
  52336. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52337. /**
  52338. * Updates the controller pose based on the given XRFrame
  52339. * @param xrFrame xr frame to update the pose with
  52340. * @param referenceSpace reference space to use
  52341. */
  52342. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52343. }
  52344. }
  52345. declare module BABYLON {
  52346. /**
  52347. * The schema for initialization options of the XR Input class
  52348. */
  52349. export interface IWebXRInputOptions {
  52350. /**
  52351. * If set to true no model will be automatically loaded
  52352. */
  52353. doNotLoadControllerMeshes?: boolean;
  52354. /**
  52355. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52356. * If not found, the xr input profile data will be used.
  52357. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52358. */
  52359. forceInputProfile?: string;
  52360. /**
  52361. * Do not send a request to the controller repository to load the profile.
  52362. *
  52363. * Instead, use the controllers available in babylon itself.
  52364. */
  52365. disableOnlineControllerRepository?: boolean;
  52366. /**
  52367. * A custom URL for the controllers repository
  52368. */
  52369. customControllersRepositoryURL?: string;
  52370. /**
  52371. * Should the controller model's components not move according to the user input
  52372. */
  52373. disableControllerAnimation?: boolean;
  52374. /**
  52375. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52376. */
  52377. controllerOptions?: IWebXRControllerOptions;
  52378. }
  52379. /**
  52380. * XR input used to track XR inputs such as controllers/rays
  52381. */
  52382. export class WebXRInput implements IDisposable {
  52383. /**
  52384. * the xr session manager for this session
  52385. */
  52386. xrSessionManager: WebXRSessionManager;
  52387. /**
  52388. * the WebXR camera for this session. Mainly used for teleportation
  52389. */
  52390. xrCamera: WebXRCamera;
  52391. private readonly options;
  52392. /**
  52393. * XR controllers being tracked
  52394. */
  52395. controllers: Array<WebXRInputSource>;
  52396. private _frameObserver;
  52397. private _sessionEndedObserver;
  52398. private _sessionInitObserver;
  52399. /**
  52400. * Event when a controller has been connected/added
  52401. */
  52402. onControllerAddedObservable: Observable<WebXRInputSource>;
  52403. /**
  52404. * Event when a controller has been removed/disconnected
  52405. */
  52406. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52407. /**
  52408. * Initializes the WebXRInput
  52409. * @param xrSessionManager the xr session manager for this session
  52410. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52411. * @param options = initialization options for this xr input
  52412. */
  52413. constructor(
  52414. /**
  52415. * the xr session manager for this session
  52416. */
  52417. xrSessionManager: WebXRSessionManager,
  52418. /**
  52419. * the WebXR camera for this session. Mainly used for teleportation
  52420. */
  52421. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52422. private _onInputSourcesChange;
  52423. private _addAndRemoveControllers;
  52424. /**
  52425. * Disposes of the object
  52426. */
  52427. dispose(): void;
  52428. }
  52429. }
  52430. declare module BABYLON {
  52431. /**
  52432. * This is the base class for all WebXR features.
  52433. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52434. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52435. */
  52436. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52437. protected _xrSessionManager: WebXRSessionManager;
  52438. private _attached;
  52439. private _removeOnDetach;
  52440. /**
  52441. * Is this feature disposed?
  52442. */
  52443. isDisposed: boolean;
  52444. /**
  52445. * Should auto-attach be disabled?
  52446. */
  52447. disableAutoAttach: boolean;
  52448. /**
  52449. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52450. */
  52451. xrNativeFeatureName: string;
  52452. /**
  52453. * Construct a new (abstract) WebXR feature
  52454. * @param _xrSessionManager the xr session manager for this feature
  52455. */
  52456. constructor(_xrSessionManager: WebXRSessionManager);
  52457. /**
  52458. * Is this feature attached
  52459. */
  52460. get attached(): boolean;
  52461. /**
  52462. * attach this feature
  52463. *
  52464. * @param force should attachment be forced (even when already attached)
  52465. * @returns true if successful, false is failed or already attached
  52466. */
  52467. attach(force?: boolean): boolean;
  52468. /**
  52469. * detach this feature.
  52470. *
  52471. * @returns true if successful, false if failed or already detached
  52472. */
  52473. detach(): boolean;
  52474. /**
  52475. * Dispose this feature and all of the resources attached
  52476. */
  52477. dispose(): void;
  52478. /**
  52479. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52480. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52481. *
  52482. * @returns whether or not the feature is compatible in this environment
  52483. */
  52484. isCompatible(): boolean;
  52485. /**
  52486. * This is used to register callbacks that will automatically be removed when detach is called.
  52487. * @param observable the observable to which the observer will be attached
  52488. * @param callback the callback to register
  52489. */
  52490. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52491. /**
  52492. * Code in this function will be executed on each xrFrame received from the browser.
  52493. * This function will not execute after the feature is detached.
  52494. * @param _xrFrame the current frame
  52495. */
  52496. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52497. }
  52498. }
  52499. declare module BABYLON {
  52500. /**
  52501. * Renders a layer on top of an existing scene
  52502. */
  52503. export class UtilityLayerRenderer implements IDisposable {
  52504. /** the original scene that will be rendered on top of */
  52505. originalScene: Scene;
  52506. private _pointerCaptures;
  52507. private _lastPointerEvents;
  52508. private static _DefaultUtilityLayer;
  52509. private static _DefaultKeepDepthUtilityLayer;
  52510. private _sharedGizmoLight;
  52511. private _renderCamera;
  52512. /**
  52513. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52514. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52515. * @returns the camera that is used when rendering the utility layer
  52516. */
  52517. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52518. /**
  52519. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52520. * @param cam the camera that should be used when rendering the utility layer
  52521. */
  52522. setRenderCamera(cam: Nullable<Camera>): void;
  52523. /**
  52524. * @hidden
  52525. * Light which used by gizmos to get light shading
  52526. */
  52527. _getSharedGizmoLight(): HemisphericLight;
  52528. /**
  52529. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52530. */
  52531. pickUtilitySceneFirst: boolean;
  52532. /**
  52533. * 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)
  52534. */
  52535. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52536. /**
  52537. * 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)
  52538. */
  52539. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52540. /**
  52541. * The scene that is rendered on top of the original scene
  52542. */
  52543. utilityLayerScene: Scene;
  52544. /**
  52545. * If the utility layer should automatically be rendered on top of existing scene
  52546. */
  52547. shouldRender: boolean;
  52548. /**
  52549. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52550. */
  52551. onlyCheckPointerDownEvents: boolean;
  52552. /**
  52553. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52554. */
  52555. processAllEvents: boolean;
  52556. /**
  52557. * Observable raised when the pointer move from the utility layer scene to the main scene
  52558. */
  52559. onPointerOutObservable: Observable<number>;
  52560. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52561. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52562. private _afterRenderObserver;
  52563. private _sceneDisposeObserver;
  52564. private _originalPointerObserver;
  52565. /**
  52566. * Instantiates a UtilityLayerRenderer
  52567. * @param originalScene the original scene that will be rendered on top of
  52568. * @param handleEvents boolean indicating if the utility layer should handle events
  52569. */
  52570. constructor(
  52571. /** the original scene that will be rendered on top of */
  52572. originalScene: Scene, handleEvents?: boolean);
  52573. private _notifyObservers;
  52574. /**
  52575. * Renders the utility layers scene on top of the original scene
  52576. */
  52577. render(): void;
  52578. /**
  52579. * Disposes of the renderer
  52580. */
  52581. dispose(): void;
  52582. private _updateCamera;
  52583. }
  52584. }
  52585. declare module BABYLON {
  52586. /**
  52587. * Options interface for the pointer selection module
  52588. */
  52589. export interface IWebXRControllerPointerSelectionOptions {
  52590. /**
  52591. * if provided, this scene will be used to render meshes.
  52592. */
  52593. customUtilityLayerScene?: Scene;
  52594. /**
  52595. * 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)
  52596. * If not disabled, the last picked point will be used to execute a pointer up event
  52597. * If disabled, pointer up event will be triggered right after the pointer down event.
  52598. * Used in screen and gaze target ray mode only
  52599. */
  52600. disablePointerUpOnTouchOut: boolean;
  52601. /**
  52602. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52603. */
  52604. forceGazeMode: boolean;
  52605. /**
  52606. * 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
  52607. * to start a new countdown to the pointer down event.
  52608. * Defaults to 1.
  52609. */
  52610. gazeModePointerMovedFactor?: number;
  52611. /**
  52612. * Different button type to use instead of the main component
  52613. */
  52614. overrideButtonId?: string;
  52615. /**
  52616. * use this rendering group id for the meshes (optional)
  52617. */
  52618. renderingGroupId?: number;
  52619. /**
  52620. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52621. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52622. * 3000 means 3 seconds between pointing at something and selecting it
  52623. */
  52624. timeToSelect?: number;
  52625. /**
  52626. * Should meshes created here be added to a utility layer or the main scene
  52627. */
  52628. useUtilityLayer?: boolean;
  52629. /**
  52630. * Optional WebXR camera to be used for gaze selection
  52631. */
  52632. gazeCamera?: WebXRCamera;
  52633. /**
  52634. * the xr input to use with this pointer selection
  52635. */
  52636. xrInput: WebXRInput;
  52637. /**
  52638. * Should the scene pointerX and pointerY update be disabled
  52639. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52640. * Disable in VR, if not needed.
  52641. * The first rig camera (left eye) will be used to calculate the projection
  52642. */
  52643. disableScenePointerVectorUpdate: boolean;
  52644. /**
  52645. * Enable pointer selection on all controllers instead of switching between them
  52646. */
  52647. enablePointerSelectionOnAllControllers?: boolean;
  52648. /**
  52649. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52650. * If switch is enabled, it will still allow the user to switch between the different controllers
  52651. */
  52652. preferredHandedness?: XRHandedness;
  52653. /**
  52654. * Disable switching the pointer selection from one controller to the other.
  52655. * 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
  52656. */
  52657. disableSwitchOnClick?: boolean;
  52658. /**
  52659. * The maximum distance of the pointer selection feature. Defaults to 100.
  52660. */
  52661. maxPointerDistance?: number;
  52662. }
  52663. /**
  52664. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52665. */
  52666. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52667. private readonly _options;
  52668. private static _idCounter;
  52669. private _attachController;
  52670. private _controllers;
  52671. private _scene;
  52672. private _tmpVectorForPickCompare;
  52673. private _attachedController;
  52674. /**
  52675. * The module's name
  52676. */
  52677. static readonly Name: string;
  52678. /**
  52679. * The (Babylon) version of this module.
  52680. * This is an integer representing the implementation version.
  52681. * This number does not correspond to the WebXR specs version
  52682. */
  52683. static readonly Version: number;
  52684. /**
  52685. * Disable lighting on the laser pointer (so it will always be visible)
  52686. */
  52687. disablePointerLighting: boolean;
  52688. /**
  52689. * Disable lighting on the selection mesh (so it will always be visible)
  52690. */
  52691. disableSelectionMeshLighting: boolean;
  52692. /**
  52693. * Should the laser pointer be displayed
  52694. */
  52695. displayLaserPointer: boolean;
  52696. /**
  52697. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52698. */
  52699. displaySelectionMesh: boolean;
  52700. /**
  52701. * This color will be set to the laser pointer when selection is triggered
  52702. */
  52703. laserPointerPickedColor: Color3;
  52704. /**
  52705. * Default color of the laser pointer
  52706. */
  52707. laserPointerDefaultColor: Color3;
  52708. /**
  52709. * default color of the selection ring
  52710. */
  52711. selectionMeshDefaultColor: Color3;
  52712. /**
  52713. * This color will be applied to the selection ring when selection is triggered
  52714. */
  52715. selectionMeshPickedColor: Color3;
  52716. /**
  52717. * Optional filter to be used for ray selection. This predicate shares behavior with
  52718. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52719. */
  52720. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52721. /**
  52722. * constructs a new background remover module
  52723. * @param _xrSessionManager the session manager for this module
  52724. * @param _options read-only options to be used in this module
  52725. */
  52726. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52727. /**
  52728. * attach this feature
  52729. * Will usually be called by the features manager
  52730. *
  52731. * @returns true if successful.
  52732. */
  52733. attach(): boolean;
  52734. /**
  52735. * detach this feature.
  52736. * Will usually be called by the features manager
  52737. *
  52738. * @returns true if successful.
  52739. */
  52740. detach(): boolean;
  52741. /**
  52742. * Will get the mesh under a specific pointer.
  52743. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52744. * @param controllerId the controllerId to check
  52745. * @returns The mesh under pointer or null if no mesh is under the pointer
  52746. */
  52747. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52748. /**
  52749. * Get the xr controller that correlates to the pointer id in the pointer event
  52750. *
  52751. * @param id the pointer id to search for
  52752. * @returns the controller that correlates to this id or null if not found
  52753. */
  52754. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52755. private _identityMatrix;
  52756. private _screenCoordinatesRef;
  52757. private _viewportRef;
  52758. protected _onXRFrame(_xrFrame: XRFrame): void;
  52759. private _attachGazeMode;
  52760. private _attachScreenRayMode;
  52761. private _attachTrackedPointerRayMode;
  52762. private _convertNormalToDirectionOfRay;
  52763. private _detachController;
  52764. private _generateNewMeshPair;
  52765. private _pickingMoved;
  52766. private _updatePointerDistance;
  52767. /** @hidden */
  52768. get lasterPointerDefaultColor(): Color3;
  52769. }
  52770. }
  52771. declare module BABYLON {
  52772. /**
  52773. * Button which can be used to enter a different mode of XR
  52774. */
  52775. export class WebXREnterExitUIButton {
  52776. /** button element */
  52777. element: HTMLElement;
  52778. /** XR initialization options for the button */
  52779. sessionMode: XRSessionMode;
  52780. /** Reference space type */
  52781. referenceSpaceType: XRReferenceSpaceType;
  52782. /**
  52783. * Creates a WebXREnterExitUIButton
  52784. * @param element button element
  52785. * @param sessionMode XR initialization session mode
  52786. * @param referenceSpaceType the type of reference space to be used
  52787. */
  52788. constructor(
  52789. /** button element */
  52790. element: HTMLElement,
  52791. /** XR initialization options for the button */
  52792. sessionMode: XRSessionMode,
  52793. /** Reference space type */
  52794. referenceSpaceType: XRReferenceSpaceType);
  52795. /**
  52796. * Extendable function which can be used to update the button's visuals when the state changes
  52797. * @param activeButton the current active button in the UI
  52798. */
  52799. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52800. }
  52801. /**
  52802. * Options to create the webXR UI
  52803. */
  52804. export class WebXREnterExitUIOptions {
  52805. /**
  52806. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52807. */
  52808. customButtons?: Array<WebXREnterExitUIButton>;
  52809. /**
  52810. * A reference space type to use when creating the default button.
  52811. * Default is local-floor
  52812. */
  52813. referenceSpaceType?: XRReferenceSpaceType;
  52814. /**
  52815. * Context to enter xr with
  52816. */
  52817. renderTarget?: Nullable<WebXRRenderTarget>;
  52818. /**
  52819. * A session mode to use when creating the default button.
  52820. * Default is immersive-vr
  52821. */
  52822. sessionMode?: XRSessionMode;
  52823. /**
  52824. * A list of optional features to init the session with
  52825. */
  52826. optionalFeatures?: string[];
  52827. /**
  52828. * A list of optional features to init the session with
  52829. */
  52830. requiredFeatures?: string[];
  52831. /**
  52832. * If defined, this function will be executed if the UI encounters an error when entering XR
  52833. */
  52834. onError?: (error: any) => void;
  52835. }
  52836. /**
  52837. * UI to allow the user to enter/exit XR mode
  52838. */
  52839. export class WebXREnterExitUI implements IDisposable {
  52840. private scene;
  52841. /** version of the options passed to this UI */
  52842. options: WebXREnterExitUIOptions;
  52843. private _activeButton;
  52844. private _buttons;
  52845. /**
  52846. * The HTML Div Element to which buttons are added.
  52847. */
  52848. readonly overlay: HTMLDivElement;
  52849. /**
  52850. * Fired every time the active button is changed.
  52851. *
  52852. * When xr is entered via a button that launches xr that button will be the callback parameter
  52853. *
  52854. * When exiting xr the callback parameter will be null)
  52855. */
  52856. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52857. /**
  52858. *
  52859. * @param scene babylon scene object to use
  52860. * @param options (read-only) version of the options passed to this UI
  52861. */
  52862. private constructor();
  52863. /**
  52864. * Creates UI to allow the user to enter/exit XR mode
  52865. * @param scene the scene to add the ui to
  52866. * @param helper the xr experience helper to enter/exit xr with
  52867. * @param options options to configure the UI
  52868. * @returns the created ui
  52869. */
  52870. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52871. /**
  52872. * Disposes of the XR UI component
  52873. */
  52874. dispose(): void;
  52875. private _updateButtons;
  52876. }
  52877. }
  52878. declare module BABYLON {
  52879. /**
  52880. * Class containing static functions to help procedurally build meshes
  52881. */
  52882. export class LinesBuilder {
  52883. /**
  52884. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52885. * * 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
  52886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52887. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52888. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52889. * * The optional parameter `colors` is an array of line colors, each line colors being 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 the alpha blending (faster)
  52891. * * 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
  52892. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52895. * @param name defines the name of the new line system
  52896. * @param options defines the options used to create the line system
  52897. * @param scene defines the hosting scene
  52898. * @returns a new line system mesh
  52899. */
  52900. static CreateLineSystem(name: string, options: {
  52901. lines: Vector3[][];
  52902. updatable?: boolean;
  52903. instance?: Nullable<LinesMesh>;
  52904. colors?: Nullable<Color4[][]>;
  52905. useVertexAlpha?: boolean;
  52906. }, scene: Nullable<Scene>): LinesMesh;
  52907. /**
  52908. * Creates a line mesh
  52909. * 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
  52910. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52911. * * The parameter `points` is an array successive Vector3
  52912. * * 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
  52913. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52914. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52915. * * When updating an instance, remember that only point positions can change, not the number of points
  52916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52918. * @param name defines the name of the new line system
  52919. * @param options defines the options used to create the line system
  52920. * @param scene defines the hosting scene
  52921. * @returns a new line mesh
  52922. */
  52923. static CreateLines(name: string, options: {
  52924. points: Vector3[];
  52925. updatable?: boolean;
  52926. instance?: Nullable<LinesMesh>;
  52927. colors?: Color4[];
  52928. useVertexAlpha?: boolean;
  52929. }, scene?: Nullable<Scene>): LinesMesh;
  52930. /**
  52931. * Creates a dashed line mesh
  52932. * * 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
  52933. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52934. * * The parameter `points` is an array successive Vector3
  52935. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52936. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52937. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52938. * * 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
  52939. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52940. * * When updating an instance, remember that only point positions can change, not the number of points
  52941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52942. * @param name defines the name of the mesh
  52943. * @param options defines the options used to create the mesh
  52944. * @param scene defines the hosting scene
  52945. * @returns the dashed line mesh
  52946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52947. */
  52948. static CreateDashedLines(name: string, options: {
  52949. points: Vector3[];
  52950. dashSize?: number;
  52951. gapSize?: number;
  52952. dashNb?: number;
  52953. updatable?: boolean;
  52954. instance?: LinesMesh;
  52955. useVertexAlpha?: boolean;
  52956. }, scene?: Nullable<Scene>): LinesMesh;
  52957. }
  52958. }
  52959. declare module BABYLON {
  52960. /**
  52961. * Construction options for a timer
  52962. */
  52963. export interface ITimerOptions<T> {
  52964. /**
  52965. * Time-to-end
  52966. */
  52967. timeout: number;
  52968. /**
  52969. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52970. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52971. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52972. */
  52973. contextObservable: Observable<T>;
  52974. /**
  52975. * Optional parameters when adding an observer to the observable
  52976. */
  52977. observableParameters?: {
  52978. mask?: number;
  52979. insertFirst?: boolean;
  52980. scope?: any;
  52981. };
  52982. /**
  52983. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52984. */
  52985. breakCondition?: (data?: ITimerData<T>) => boolean;
  52986. /**
  52987. * Will be triggered when the time condition has met
  52988. */
  52989. onEnded?: (data: ITimerData<any>) => void;
  52990. /**
  52991. * Will be triggered when the break condition has met (prematurely ended)
  52992. */
  52993. onAborted?: (data: ITimerData<any>) => void;
  52994. /**
  52995. * Optional function to execute on each tick (or count)
  52996. */
  52997. onTick?: (data: ITimerData<any>) => void;
  52998. }
  52999. /**
  53000. * An interface defining the data sent by the timer
  53001. */
  53002. export interface ITimerData<T> {
  53003. /**
  53004. * When did it start
  53005. */
  53006. startTime: number;
  53007. /**
  53008. * Time now
  53009. */
  53010. currentTime: number;
  53011. /**
  53012. * Time passed since started
  53013. */
  53014. deltaTime: number;
  53015. /**
  53016. * How much is completed, in [0.0...1.0].
  53017. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  53018. */
  53019. completeRate: number;
  53020. /**
  53021. * What the registered observable sent in the last count
  53022. */
  53023. payload: T;
  53024. }
  53025. /**
  53026. * The current state of the timer
  53027. */
  53028. export enum TimerState {
  53029. /**
  53030. * Timer initialized, not yet started
  53031. */
  53032. INIT = 0,
  53033. /**
  53034. * Timer started and counting
  53035. */
  53036. STARTED = 1,
  53037. /**
  53038. * Timer ended (whether aborted or time reached)
  53039. */
  53040. ENDED = 2
  53041. }
  53042. /**
  53043. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53044. *
  53045. * @param options options with which to initialize this timer
  53046. */
  53047. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53048. /**
  53049. * An advanced implementation of a timer class
  53050. */
  53051. export class AdvancedTimer<T = any> implements IDisposable {
  53052. /**
  53053. * Will notify each time the timer calculates the remaining time
  53054. */
  53055. onEachCountObservable: Observable<ITimerData<T>>;
  53056. /**
  53057. * Will trigger when the timer was aborted due to the break condition
  53058. */
  53059. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53060. /**
  53061. * Will trigger when the timer ended successfully
  53062. */
  53063. onTimerEndedObservable: Observable<ITimerData<T>>;
  53064. /**
  53065. * Will trigger when the timer state has changed
  53066. */
  53067. onStateChangedObservable: Observable<TimerState>;
  53068. private _observer;
  53069. private _contextObservable;
  53070. private _observableParameters;
  53071. private _startTime;
  53072. private _timer;
  53073. private _state;
  53074. private _breakCondition;
  53075. private _timeToEnd;
  53076. private _breakOnNextTick;
  53077. /**
  53078. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53079. * @param options construction options for this advanced timer
  53080. */
  53081. constructor(options: ITimerOptions<T>);
  53082. /**
  53083. * set a breaking condition for this timer. Default is to never break during count
  53084. * @param predicate the new break condition. Returns true to break, false otherwise
  53085. */
  53086. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53087. /**
  53088. * Reset ALL associated observables in this advanced timer
  53089. */
  53090. clearObservables(): void;
  53091. /**
  53092. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53093. *
  53094. * @param timeToEnd how much time to measure until timer ended
  53095. */
  53096. start(timeToEnd?: number): void;
  53097. /**
  53098. * Will force a stop on the next tick.
  53099. */
  53100. stop(): void;
  53101. /**
  53102. * Dispose this timer, clearing all resources
  53103. */
  53104. dispose(): void;
  53105. private _setState;
  53106. private _tick;
  53107. private _stop;
  53108. }
  53109. }
  53110. declare module BABYLON {
  53111. /**
  53112. * The options container for the teleportation module
  53113. */
  53114. export interface IWebXRTeleportationOptions {
  53115. /**
  53116. * if provided, this scene will be used to render meshes.
  53117. */
  53118. customUtilityLayerScene?: Scene;
  53119. /**
  53120. * Values to configure the default target mesh
  53121. */
  53122. defaultTargetMeshOptions?: {
  53123. /**
  53124. * Fill color of the teleportation area
  53125. */
  53126. teleportationFillColor?: string;
  53127. /**
  53128. * Border color for the teleportation area
  53129. */
  53130. teleportationBorderColor?: string;
  53131. /**
  53132. * Disable the mesh's animation sequence
  53133. */
  53134. disableAnimation?: boolean;
  53135. /**
  53136. * Disable lighting on the material or the ring and arrow
  53137. */
  53138. disableLighting?: boolean;
  53139. /**
  53140. * Override the default material of the torus and arrow
  53141. */
  53142. torusArrowMaterial?: Material;
  53143. };
  53144. /**
  53145. * A list of meshes to use as floor meshes.
  53146. * Meshes can be added and removed after initializing the feature using the
  53147. * addFloorMesh and removeFloorMesh functions
  53148. * If empty, rotation will still work
  53149. */
  53150. floorMeshes?: AbstractMesh[];
  53151. /**
  53152. * use this rendering group id for the meshes (optional)
  53153. */
  53154. renderingGroupId?: number;
  53155. /**
  53156. * Should teleportation move only to snap points
  53157. */
  53158. snapPointsOnly?: boolean;
  53159. /**
  53160. * An array of points to which the teleportation will snap to.
  53161. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53162. */
  53163. snapPositions?: Vector3[];
  53164. /**
  53165. * How close should the teleportation ray be in order to snap to position.
  53166. * Default to 0.8 units (meters)
  53167. */
  53168. snapToPositionRadius?: number;
  53169. /**
  53170. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53171. * If you want to support rotation, make sure your mesh has a direction indicator.
  53172. *
  53173. * When left untouched, the default mesh will be initialized.
  53174. */
  53175. teleportationTargetMesh?: AbstractMesh;
  53176. /**
  53177. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53178. */
  53179. timeToTeleport?: number;
  53180. /**
  53181. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53182. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53183. */
  53184. useMainComponentOnly?: boolean;
  53185. /**
  53186. * Should meshes created here be added to a utility layer or the main scene
  53187. */
  53188. useUtilityLayer?: boolean;
  53189. /**
  53190. * Babylon XR Input class for controller
  53191. */
  53192. xrInput: WebXRInput;
  53193. /**
  53194. * Meshes that the teleportation ray cannot go through
  53195. */
  53196. pickBlockerMeshes?: AbstractMesh[];
  53197. /**
  53198. * Should teleport work only on a specific hand?
  53199. */
  53200. forceHandedness?: XRHandedness;
  53201. /**
  53202. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53203. */
  53204. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53205. }
  53206. /**
  53207. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53208. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53209. * the input of the attached controllers.
  53210. */
  53211. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53212. private _options;
  53213. private _controllers;
  53214. private _currentTeleportationControllerId;
  53215. private _floorMeshes;
  53216. private _quadraticBezierCurve;
  53217. private _selectionFeature;
  53218. private _snapToPositions;
  53219. private _snappedToPoint;
  53220. private _teleportationRingMaterial?;
  53221. private _tmpRay;
  53222. private _tmpVector;
  53223. private _tmpQuaternion;
  53224. /**
  53225. * The module's name
  53226. */
  53227. static readonly Name: string;
  53228. /**
  53229. * The (Babylon) version of this module.
  53230. * This is an integer representing the implementation version.
  53231. * This number does not correspond to the webxr specs version
  53232. */
  53233. static readonly Version: number;
  53234. /**
  53235. * Is movement backwards enabled
  53236. */
  53237. backwardsMovementEnabled: boolean;
  53238. /**
  53239. * Distance to travel when moving backwards
  53240. */
  53241. backwardsTeleportationDistance: number;
  53242. /**
  53243. * The distance from the user to the inspection point in the direction of the controller
  53244. * A higher number will allow the user to move further
  53245. * defaults to 5 (meters, in xr units)
  53246. */
  53247. parabolicCheckRadius: number;
  53248. /**
  53249. * Should the module support parabolic ray on top of direct ray
  53250. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53251. * Very helpful when moving between floors / different heights
  53252. */
  53253. parabolicRayEnabled: boolean;
  53254. /**
  53255. * The second type of ray - straight line.
  53256. * Should it be enabled or should the parabolic line be the only one.
  53257. */
  53258. straightRayEnabled: boolean;
  53259. /**
  53260. * How much rotation should be applied when rotating right and left
  53261. */
  53262. rotationAngle: number;
  53263. private _rotationEnabled;
  53264. /**
  53265. * Is rotation enabled when moving forward?
  53266. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53267. */
  53268. get rotationEnabled(): boolean;
  53269. /**
  53270. * Sets wether rotation is enabled or not
  53271. * @param enabled is rotation enabled when teleportation is shown
  53272. */
  53273. set rotationEnabled(enabled: boolean);
  53274. /**
  53275. * Exposes the currently set teleportation target mesh.
  53276. */
  53277. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53278. /**
  53279. * constructs a new anchor system
  53280. * @param _xrSessionManager an instance of WebXRSessionManager
  53281. * @param _options configuration object for this feature
  53282. */
  53283. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53284. /**
  53285. * Get the snapPointsOnly flag
  53286. */
  53287. get snapPointsOnly(): boolean;
  53288. /**
  53289. * Sets the snapPointsOnly flag
  53290. * @param snapToPoints should teleportation be exclusively to snap points
  53291. */
  53292. set snapPointsOnly(snapToPoints: boolean);
  53293. /**
  53294. * Add a new mesh to the floor meshes array
  53295. * @param mesh the mesh to use as floor mesh
  53296. */
  53297. addFloorMesh(mesh: AbstractMesh): void;
  53298. /**
  53299. * Add a new snap-to point to fix teleportation to this position
  53300. * @param newSnapPoint The new Snap-To point
  53301. */
  53302. addSnapPoint(newSnapPoint: Vector3): void;
  53303. attach(): boolean;
  53304. detach(): boolean;
  53305. dispose(): void;
  53306. /**
  53307. * Remove a mesh from the floor meshes array
  53308. * @param mesh the mesh to remove
  53309. */
  53310. removeFloorMesh(mesh: AbstractMesh): void;
  53311. /**
  53312. * Remove a mesh from the floor meshes array using its name
  53313. * @param name the mesh name to remove
  53314. */
  53315. removeFloorMeshByName(name: string): void;
  53316. /**
  53317. * 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
  53318. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53319. * @returns was the point found and removed or not
  53320. */
  53321. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53322. /**
  53323. * This function sets a selection feature that will be disabled when
  53324. * the forward ray is shown and will be reattached when hidden.
  53325. * This is used to remove the selection rays when moving.
  53326. * @param selectionFeature the feature to disable when forward movement is enabled
  53327. */
  53328. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53329. protected _onXRFrame(_xrFrame: XRFrame): void;
  53330. private _attachController;
  53331. private _createDefaultTargetMesh;
  53332. private _detachController;
  53333. private _findClosestSnapPointWithRadius;
  53334. private _setTargetMeshPosition;
  53335. private _setTargetMeshVisibility;
  53336. private _showParabolicPath;
  53337. private _teleportForward;
  53338. }
  53339. }
  53340. declare module BABYLON {
  53341. /**
  53342. * Options for the default xr helper
  53343. */
  53344. export class WebXRDefaultExperienceOptions {
  53345. /**
  53346. * Enable or disable default UI to enter XR
  53347. */
  53348. disableDefaultUI?: boolean;
  53349. /**
  53350. * Should teleportation not initialize. defaults to false.
  53351. */
  53352. disableTeleportation?: boolean;
  53353. /**
  53354. * Floor meshes that will be used for teleport
  53355. */
  53356. floorMeshes?: Array<AbstractMesh>;
  53357. /**
  53358. * If set to true, the first frame will not be used to reset position
  53359. * The first frame is mainly used when copying transformation from the old camera
  53360. * Mainly used in AR
  53361. */
  53362. ignoreNativeCameraTransformation?: boolean;
  53363. /**
  53364. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53365. */
  53366. inputOptions?: IWebXRInputOptions;
  53367. /**
  53368. * optional configuration for the output canvas
  53369. */
  53370. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53371. /**
  53372. * optional UI options. This can be used among other to change session mode and reference space type
  53373. */
  53374. uiOptions?: WebXREnterExitUIOptions;
  53375. /**
  53376. * When loading teleportation and pointer select, use stable versions instead of latest.
  53377. */
  53378. useStablePlugins?: boolean;
  53379. /**
  53380. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53381. */
  53382. renderingGroupId?: number;
  53383. /**
  53384. * A list of optional features to init the session with
  53385. * If set to true, all features we support will be added
  53386. */
  53387. optionalFeatures?: boolean | string[];
  53388. }
  53389. /**
  53390. * Default experience which provides a similar setup to the previous webVRExperience
  53391. */
  53392. export class WebXRDefaultExperience {
  53393. /**
  53394. * Base experience
  53395. */
  53396. baseExperience: WebXRExperienceHelper;
  53397. /**
  53398. * Enables ui for entering/exiting xr
  53399. */
  53400. enterExitUI: WebXREnterExitUI;
  53401. /**
  53402. * Input experience extension
  53403. */
  53404. input: WebXRInput;
  53405. /**
  53406. * Enables laser pointer and selection
  53407. */
  53408. pointerSelection: WebXRControllerPointerSelection;
  53409. /**
  53410. * Default target xr should render to
  53411. */
  53412. renderTarget: WebXRRenderTarget;
  53413. /**
  53414. * Enables teleportation
  53415. */
  53416. teleportation: WebXRMotionControllerTeleportation;
  53417. private constructor();
  53418. /**
  53419. * Creates the default xr experience
  53420. * @param scene scene
  53421. * @param options options for basic configuration
  53422. * @returns resulting WebXRDefaultExperience
  53423. */
  53424. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53425. /**
  53426. * DIsposes of the experience helper
  53427. */
  53428. dispose(): void;
  53429. }
  53430. }
  53431. declare module BABYLON {
  53432. /**
  53433. * Options to modify the vr teleportation behavior.
  53434. */
  53435. export interface VRTeleportationOptions {
  53436. /**
  53437. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53438. */
  53439. floorMeshName?: string;
  53440. /**
  53441. * A list of meshes to be used as the teleportation floor. (default: empty)
  53442. */
  53443. floorMeshes?: Mesh[];
  53444. /**
  53445. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53446. */
  53447. teleportationMode?: number;
  53448. /**
  53449. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53450. */
  53451. teleportationTime?: number;
  53452. /**
  53453. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53454. */
  53455. teleportationSpeed?: number;
  53456. /**
  53457. * The easing function used in the animation or null for Linear. (default CircleEase)
  53458. */
  53459. easingFunction?: EasingFunction;
  53460. }
  53461. /**
  53462. * Options to modify the vr experience helper's behavior.
  53463. */
  53464. export interface VRExperienceHelperOptions extends WebVROptions {
  53465. /**
  53466. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53467. */
  53468. createDeviceOrientationCamera?: boolean;
  53469. /**
  53470. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53471. */
  53472. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53473. /**
  53474. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53475. */
  53476. laserToggle?: boolean;
  53477. /**
  53478. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53479. */
  53480. floorMeshes?: Mesh[];
  53481. /**
  53482. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53483. */
  53484. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53485. /**
  53486. * Defines if WebXR should be used instead of WebVR (if available)
  53487. */
  53488. useXR?: boolean;
  53489. }
  53490. /**
  53491. * Event containing information after VR has been entered
  53492. */
  53493. export class OnAfterEnteringVRObservableEvent {
  53494. /**
  53495. * If entering vr was successful
  53496. */
  53497. success: boolean;
  53498. }
  53499. /**
  53500. * Helps to quickly add VR support to an existing scene.
  53501. * See https://doc.babylonjs.com/how_to/webvr_helper
  53502. */
  53503. export class VRExperienceHelper {
  53504. /** Options to modify the vr experience helper's behavior. */
  53505. webVROptions: VRExperienceHelperOptions;
  53506. private _scene;
  53507. private _position;
  53508. private _btnVR;
  53509. private _btnVRDisplayed;
  53510. private _webVRsupported;
  53511. private _webVRready;
  53512. private _webVRrequesting;
  53513. private _webVRpresenting;
  53514. private _hasEnteredVR;
  53515. private _fullscreenVRpresenting;
  53516. private _inputElement;
  53517. private _webVRCamera;
  53518. private _vrDeviceOrientationCamera;
  53519. private _deviceOrientationCamera;
  53520. private _existingCamera;
  53521. private _onKeyDown;
  53522. private _onVrDisplayPresentChange;
  53523. private _onVRDisplayChanged;
  53524. private _onVRRequestPresentStart;
  53525. private _onVRRequestPresentComplete;
  53526. /**
  53527. * 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)
  53528. */
  53529. enableGazeEvenWhenNoPointerLock: boolean;
  53530. /**
  53531. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53532. */
  53533. exitVROnDoubleTap: boolean;
  53534. /**
  53535. * Observable raised right before entering VR.
  53536. */
  53537. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53538. /**
  53539. * Observable raised when entering VR has completed.
  53540. */
  53541. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53542. /**
  53543. * Observable raised when exiting VR.
  53544. */
  53545. onExitingVRObservable: Observable<VRExperienceHelper>;
  53546. /**
  53547. * Observable raised when controller mesh is loaded.
  53548. */
  53549. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53550. /** Return this.onEnteringVRObservable
  53551. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53552. */
  53553. get onEnteringVR(): Observable<VRExperienceHelper>;
  53554. /** Return this.onExitingVRObservable
  53555. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53556. */
  53557. get onExitingVR(): Observable<VRExperienceHelper>;
  53558. /** Return this.onControllerMeshLoadedObservable
  53559. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53560. */
  53561. get onControllerMeshLoaded(): Observable<WebVRController>;
  53562. private _rayLength;
  53563. private _useCustomVRButton;
  53564. private _teleportationRequested;
  53565. private _teleportActive;
  53566. private _floorMeshName;
  53567. private _floorMeshesCollection;
  53568. private _teleportationMode;
  53569. private _teleportationTime;
  53570. private _teleportationSpeed;
  53571. private _teleportationEasing;
  53572. private _rotationAllowed;
  53573. private _teleportBackwardsVector;
  53574. private _teleportationTarget;
  53575. private _isDefaultTeleportationTarget;
  53576. private _postProcessMove;
  53577. private _teleportationFillColor;
  53578. private _teleportationBorderColor;
  53579. private _rotationAngle;
  53580. private _haloCenter;
  53581. private _cameraGazer;
  53582. private _padSensibilityUp;
  53583. private _padSensibilityDown;
  53584. private _leftController;
  53585. private _rightController;
  53586. private _gazeColor;
  53587. private _laserColor;
  53588. private _pickedLaserColor;
  53589. private _pickedGazeColor;
  53590. /**
  53591. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53592. */
  53593. onNewMeshSelected: Observable<AbstractMesh>;
  53594. /**
  53595. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53596. * This observable will provide the mesh and the controller used to select the mesh
  53597. */
  53598. onMeshSelectedWithController: Observable<{
  53599. mesh: AbstractMesh;
  53600. controller: WebVRController;
  53601. }>;
  53602. /**
  53603. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53604. */
  53605. onNewMeshPicked: Observable<PickingInfo>;
  53606. private _circleEase;
  53607. /**
  53608. * Observable raised before camera teleportation
  53609. */
  53610. onBeforeCameraTeleport: Observable<Vector3>;
  53611. /**
  53612. * Observable raised after camera teleportation
  53613. */
  53614. onAfterCameraTeleport: Observable<Vector3>;
  53615. /**
  53616. * Observable raised when current selected mesh gets unselected
  53617. */
  53618. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53619. private _raySelectionPredicate;
  53620. /**
  53621. * To be optionaly changed by user to define custom ray selection
  53622. */
  53623. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53624. /**
  53625. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53626. */
  53627. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53628. /**
  53629. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53630. */
  53631. teleportationEnabled: boolean;
  53632. private _defaultHeight;
  53633. private _teleportationInitialized;
  53634. private _interactionsEnabled;
  53635. private _interactionsRequested;
  53636. private _displayGaze;
  53637. private _displayLaserPointer;
  53638. /**
  53639. * The mesh used to display where the user is going to teleport.
  53640. */
  53641. get teleportationTarget(): Mesh;
  53642. /**
  53643. * Sets the mesh to be used to display where the user is going to teleport.
  53644. */
  53645. set teleportationTarget(value: Mesh);
  53646. /**
  53647. * 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
  53648. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53649. * See https://doc.babylonjs.com/resources/baking_transformations
  53650. */
  53651. get gazeTrackerMesh(): Mesh;
  53652. set gazeTrackerMesh(value: Mesh);
  53653. /**
  53654. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53655. */
  53656. updateGazeTrackerScale: boolean;
  53657. /**
  53658. * If the gaze trackers color should be updated when selecting meshes
  53659. */
  53660. updateGazeTrackerColor: boolean;
  53661. /**
  53662. * If the controller laser color should be updated when selecting meshes
  53663. */
  53664. updateControllerLaserColor: boolean;
  53665. /**
  53666. * The gaze tracking mesh corresponding to the left controller
  53667. */
  53668. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53669. /**
  53670. * The gaze tracking mesh corresponding to the right controller
  53671. */
  53672. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53673. /**
  53674. * If the ray of the gaze should be displayed.
  53675. */
  53676. get displayGaze(): boolean;
  53677. /**
  53678. * Sets if the ray of the gaze should be displayed.
  53679. */
  53680. set displayGaze(value: boolean);
  53681. /**
  53682. * If the ray of the LaserPointer should be displayed.
  53683. */
  53684. get displayLaserPointer(): boolean;
  53685. /**
  53686. * Sets if the ray of the LaserPointer should be displayed.
  53687. */
  53688. set displayLaserPointer(value: boolean);
  53689. /**
  53690. * The deviceOrientationCamera used as the camera when not in VR.
  53691. */
  53692. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53693. /**
  53694. * Based on the current WebVR support, returns the current VR camera used.
  53695. */
  53696. get currentVRCamera(): Nullable<Camera>;
  53697. /**
  53698. * The webVRCamera which is used when in VR.
  53699. */
  53700. get webVRCamera(): WebVRFreeCamera;
  53701. /**
  53702. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53703. */
  53704. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53705. /**
  53706. * The html button that is used to trigger entering into VR.
  53707. */
  53708. get vrButton(): Nullable<HTMLButtonElement>;
  53709. private get _teleportationRequestInitiated();
  53710. /**
  53711. * Defines whether or not Pointer lock should be requested when switching to
  53712. * full screen.
  53713. */
  53714. requestPointerLockOnFullScreen: boolean;
  53715. /**
  53716. * If asking to force XR, this will be populated with the default xr experience
  53717. */
  53718. xr: WebXRDefaultExperience;
  53719. /**
  53720. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53721. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53722. */
  53723. xrTestDone: boolean;
  53724. /**
  53725. * Instantiates a VRExperienceHelper.
  53726. * Helps to quickly add VR support to an existing scene.
  53727. * @param scene The scene the VRExperienceHelper belongs to.
  53728. * @param webVROptions Options to modify the vr experience helper's behavior.
  53729. */
  53730. constructor(scene: Scene,
  53731. /** Options to modify the vr experience helper's behavior. */
  53732. webVROptions?: VRExperienceHelperOptions);
  53733. private completeVRInit;
  53734. private _onDefaultMeshLoaded;
  53735. private _onResize;
  53736. private _onFullscreenChange;
  53737. /**
  53738. * Gets a value indicating if we are currently in VR mode.
  53739. */
  53740. get isInVRMode(): boolean;
  53741. private onVrDisplayPresentChange;
  53742. private onVRDisplayChanged;
  53743. private moveButtonToBottomRight;
  53744. private displayVRButton;
  53745. private updateButtonVisibility;
  53746. private _cachedAngularSensibility;
  53747. /**
  53748. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53749. * Otherwise, will use the fullscreen API.
  53750. */
  53751. enterVR(): void;
  53752. /**
  53753. * Attempt to exit VR, or fullscreen.
  53754. */
  53755. exitVR(): void;
  53756. /**
  53757. * The position of the vr experience helper.
  53758. */
  53759. get position(): Vector3;
  53760. /**
  53761. * Sets the position of the vr experience helper.
  53762. */
  53763. set position(value: Vector3);
  53764. /**
  53765. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53766. */
  53767. enableInteractions(): void;
  53768. private get _noControllerIsActive();
  53769. private beforeRender;
  53770. private _isTeleportationFloor;
  53771. /**
  53772. * Adds a floor mesh to be used for teleportation.
  53773. * @param floorMesh the mesh to be used for teleportation.
  53774. */
  53775. addFloorMesh(floorMesh: Mesh): void;
  53776. /**
  53777. * Removes a floor mesh from being used for teleportation.
  53778. * @param floorMesh the mesh to be removed.
  53779. */
  53780. removeFloorMesh(floorMesh: Mesh): void;
  53781. /**
  53782. * Enables interactions and teleportation using the VR controllers and gaze.
  53783. * @param vrTeleportationOptions options to modify teleportation behavior.
  53784. */
  53785. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53786. private _onNewGamepadConnected;
  53787. private _tryEnableInteractionOnController;
  53788. private _onNewGamepadDisconnected;
  53789. private _enableInteractionOnController;
  53790. private _checkTeleportWithRay;
  53791. private _checkRotate;
  53792. private _checkTeleportBackwards;
  53793. private _enableTeleportationOnController;
  53794. private _createTeleportationCircles;
  53795. private _displayTeleportationTarget;
  53796. private _hideTeleportationTarget;
  53797. private _rotateCamera;
  53798. private _moveTeleportationSelectorTo;
  53799. private _workingVector;
  53800. private _workingQuaternion;
  53801. private _workingMatrix;
  53802. /**
  53803. * Time Constant Teleportation Mode
  53804. */
  53805. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53806. /**
  53807. * Speed Constant Teleportation Mode
  53808. */
  53809. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53810. /**
  53811. * Teleports the users feet to the desired location
  53812. * @param location The location where the user's feet should be placed
  53813. */
  53814. teleportCamera(location: Vector3): void;
  53815. private _convertNormalToDirectionOfRay;
  53816. private _castRayAndSelectObject;
  53817. private _notifySelectedMeshUnselected;
  53818. /**
  53819. * Permanently set new colors for the laser pointer
  53820. * @param color the new laser color
  53821. * @param pickedColor the new laser color when picked mesh detected
  53822. */
  53823. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53824. /**
  53825. * Set lighting enabled / disabled on the laser pointer of both controllers
  53826. * @param enabled should the lighting be enabled on the laser pointer
  53827. */
  53828. setLaserLightingState(enabled?: boolean): void;
  53829. /**
  53830. * Permanently set new colors for the gaze pointer
  53831. * @param color the new gaze color
  53832. * @param pickedColor the new gaze color when picked mesh detected
  53833. */
  53834. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53835. /**
  53836. * Sets the color of the laser ray from the vr controllers.
  53837. * @param color new color for the ray.
  53838. */
  53839. changeLaserColor(color: Color3): void;
  53840. /**
  53841. * Sets the color of the ray from the vr headsets gaze.
  53842. * @param color new color for the ray.
  53843. */
  53844. changeGazeColor(color: Color3): void;
  53845. /**
  53846. * Exits VR and disposes of the vr experience helper
  53847. */
  53848. dispose(): void;
  53849. /**
  53850. * Gets the name of the VRExperienceHelper class
  53851. * @returns "VRExperienceHelper"
  53852. */
  53853. getClassName(): string;
  53854. }
  53855. }
  53856. declare module BABYLON {
  53857. /**
  53858. * Contains an array of blocks representing the octree
  53859. */
  53860. export interface IOctreeContainer<T> {
  53861. /**
  53862. * Blocks within the octree
  53863. */
  53864. blocks: Array<OctreeBlock<T>>;
  53865. }
  53866. /**
  53867. * Class used to store a cell in an octree
  53868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53869. */
  53870. export class OctreeBlock<T> {
  53871. /**
  53872. * Gets the content of the current block
  53873. */
  53874. entries: T[];
  53875. /**
  53876. * Gets the list of block children
  53877. */
  53878. blocks: Array<OctreeBlock<T>>;
  53879. private _depth;
  53880. private _maxDepth;
  53881. private _capacity;
  53882. private _minPoint;
  53883. private _maxPoint;
  53884. private _boundingVectors;
  53885. private _creationFunc;
  53886. /**
  53887. * Creates a new block
  53888. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53889. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53890. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53891. * @param depth defines the current depth of this block in the octree
  53892. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53893. * @param creationFunc defines a callback to call when an element is added to the block
  53894. */
  53895. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53896. /**
  53897. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53898. */
  53899. get capacity(): number;
  53900. /**
  53901. * Gets the minimum vector (in world space) of the block's bounding box
  53902. */
  53903. get minPoint(): Vector3;
  53904. /**
  53905. * Gets the maximum vector (in world space) of the block's bounding box
  53906. */
  53907. get maxPoint(): Vector3;
  53908. /**
  53909. * Add a new element to this block
  53910. * @param entry defines the element to add
  53911. */
  53912. addEntry(entry: T): void;
  53913. /**
  53914. * Remove an element from this block
  53915. * @param entry defines the element to remove
  53916. */
  53917. removeEntry(entry: T): void;
  53918. /**
  53919. * Add an array of elements to this block
  53920. * @param entries defines the array of elements to add
  53921. */
  53922. addEntries(entries: T[]): void;
  53923. /**
  53924. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53925. * @param frustumPlanes defines the frustum planes to test
  53926. * @param selection defines the array to store current content if selection is positive
  53927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53928. */
  53929. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53930. /**
  53931. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53932. * @param sphereCenter defines the bounding sphere center
  53933. * @param sphereRadius defines the bounding sphere radius
  53934. * @param selection defines the array to store current content if selection is positive
  53935. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53936. */
  53937. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53938. /**
  53939. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53940. * @param ray defines the ray to test with
  53941. * @param selection defines the array to store current content if selection is positive
  53942. */
  53943. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53944. /**
  53945. * Subdivide the content into child blocks (this block will then be empty)
  53946. */
  53947. createInnerBlocks(): void;
  53948. /**
  53949. * @hidden
  53950. */
  53951. 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;
  53952. }
  53953. }
  53954. declare module BABYLON {
  53955. /**
  53956. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53958. */
  53959. export class Octree<T> {
  53960. /** 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.) */
  53961. maxDepth: number;
  53962. /**
  53963. * Blocks within the octree containing objects
  53964. */
  53965. blocks: Array<OctreeBlock<T>>;
  53966. /**
  53967. * Content stored in the octree
  53968. */
  53969. dynamicContent: T[];
  53970. private _maxBlockCapacity;
  53971. private _selectionContent;
  53972. private _creationFunc;
  53973. /**
  53974. * Creates a octree
  53975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53976. * @param creationFunc function to be used to instatiate the octree
  53977. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53978. * @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.)
  53979. */
  53980. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53981. /** 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.) */
  53982. maxDepth?: number);
  53983. /**
  53984. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53985. * @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);
  53986. * @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);
  53987. * @param entries meshes to be added to the octree blocks
  53988. */
  53989. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53990. /**
  53991. * Adds a mesh to the octree
  53992. * @param entry Mesh to add to the octree
  53993. */
  53994. addMesh(entry: T): void;
  53995. /**
  53996. * Remove an element from the octree
  53997. * @param entry defines the element to remove
  53998. */
  53999. removeMesh(entry: T): void;
  54000. /**
  54001. * Selects an array of meshes within the frustum
  54002. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  54003. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  54004. * @returns array of meshes within the frustum
  54005. */
  54006. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  54007. /**
  54008. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  54009. * @param sphereCenter defines the bounding sphere center
  54010. * @param sphereRadius defines the bounding sphere radius
  54011. * @param allowDuplicate defines if the selection array can contains duplicated entries
  54012. * @returns an array of objects that intersect the sphere
  54013. */
  54014. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  54015. /**
  54016. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  54017. * @param ray defines the ray to test with
  54018. * @returns array of intersected objects
  54019. */
  54020. intersectsRay(ray: Ray): SmartArray<T>;
  54021. /**
  54022. * Adds a mesh into the octree block if it intersects the block
  54023. */
  54024. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  54025. /**
  54026. * Adds a submesh into the octree block if it intersects the block
  54027. */
  54028. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  54029. }
  54030. }
  54031. declare module BABYLON {
  54032. interface Scene {
  54033. /**
  54034. * @hidden
  54035. * Backing Filed
  54036. */
  54037. _selectionOctree: Octree<AbstractMesh>;
  54038. /**
  54039. * Gets the octree used to boost mesh selection (picking)
  54040. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54041. */
  54042. selectionOctree: Octree<AbstractMesh>;
  54043. /**
  54044. * Creates or updates the octree used to boost selection (picking)
  54045. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54046. * @param maxCapacity defines the maximum capacity per leaf
  54047. * @param maxDepth defines the maximum depth of the octree
  54048. * @returns an octree of AbstractMesh
  54049. */
  54050. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54051. }
  54052. interface AbstractMesh {
  54053. /**
  54054. * @hidden
  54055. * Backing Field
  54056. */
  54057. _submeshesOctree: Octree<SubMesh>;
  54058. /**
  54059. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54060. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54061. * @param maxCapacity defines the maximum size of each block (64 by default)
  54062. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54063. * @returns the new octree
  54064. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54065. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54066. */
  54067. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54068. }
  54069. /**
  54070. * Defines the octree scene component responsible to manage any octrees
  54071. * in a given scene.
  54072. */
  54073. export class OctreeSceneComponent {
  54074. /**
  54075. * The component name help to identify the component in the list of scene components.
  54076. */
  54077. readonly name: string;
  54078. /**
  54079. * The scene the component belongs to.
  54080. */
  54081. scene: Scene;
  54082. /**
  54083. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54084. */
  54085. readonly checksIsEnabled: boolean;
  54086. /**
  54087. * Creates a new instance of the component for the given scene
  54088. * @param scene Defines the scene to register the component in
  54089. */
  54090. constructor(scene: Scene);
  54091. /**
  54092. * Registers the component in a given scene
  54093. */
  54094. register(): void;
  54095. /**
  54096. * Return the list of active meshes
  54097. * @returns the list of active meshes
  54098. */
  54099. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54100. /**
  54101. * Return the list of active sub meshes
  54102. * @param mesh The mesh to get the candidates sub meshes from
  54103. * @returns the list of active sub meshes
  54104. */
  54105. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54106. private _tempRay;
  54107. /**
  54108. * Return the list of sub meshes intersecting with a given local ray
  54109. * @param mesh defines the mesh to find the submesh for
  54110. * @param localRay defines the ray in local space
  54111. * @returns the list of intersecting sub meshes
  54112. */
  54113. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54114. /**
  54115. * Return the list of sub meshes colliding with a collider
  54116. * @param mesh defines the mesh to find the submesh for
  54117. * @param collider defines the collider to evaluate the collision against
  54118. * @returns the list of colliding sub meshes
  54119. */
  54120. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54121. /**
  54122. * Rebuilds the elements related to this component in case of
  54123. * context lost for instance.
  54124. */
  54125. rebuild(): void;
  54126. /**
  54127. * Disposes the component and the associated ressources.
  54128. */
  54129. dispose(): void;
  54130. }
  54131. }
  54132. declare module BABYLON {
  54133. /**
  54134. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54135. */
  54136. export interface GizmoAxisCache {
  54137. /** Mesh used to runder the Gizmo */
  54138. gizmoMeshes: Mesh[];
  54139. /** Mesh used to detect user interaction with Gizmo */
  54140. colliderMeshes: Mesh[];
  54141. /** Material used to inicate color of gizmo mesh */
  54142. material: StandardMaterial;
  54143. /** Material used to inicate hover state of the Gizmo */
  54144. hoverMaterial: StandardMaterial;
  54145. /** Material used to inicate disabled state of the Gizmo */
  54146. disableMaterial: StandardMaterial;
  54147. /** Used to indicate Active state of the Gizmo */
  54148. active: boolean;
  54149. }
  54150. /**
  54151. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54152. */
  54153. export class Gizmo implements IDisposable {
  54154. /** The utility layer the gizmo will be added to */
  54155. gizmoLayer: UtilityLayerRenderer;
  54156. /**
  54157. * The root mesh of the gizmo
  54158. */
  54159. _rootMesh: Mesh;
  54160. private _attachedMesh;
  54161. private _attachedNode;
  54162. /**
  54163. * Ratio for the scale of the gizmo (Default: 1)
  54164. */
  54165. protected _scaleRatio: number;
  54166. /**
  54167. * boolean updated by pointermove when a gizmo mesh is hovered
  54168. */
  54169. protected _isHovered: boolean;
  54170. /**
  54171. * Ratio for the scale of the gizmo (Default: 1)
  54172. */
  54173. set scaleRatio(value: number);
  54174. get scaleRatio(): number;
  54175. /**
  54176. * True when the mouse pointer is hovered a gizmo mesh
  54177. */
  54178. get isHovered(): boolean;
  54179. /**
  54180. * If a custom mesh has been set (Default: false)
  54181. */
  54182. protected _customMeshSet: boolean;
  54183. /**
  54184. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54185. * * When set, interactions will be enabled
  54186. */
  54187. get attachedMesh(): Nullable<AbstractMesh>;
  54188. set attachedMesh(value: Nullable<AbstractMesh>);
  54189. /**
  54190. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54191. * * When set, interactions will be enabled
  54192. */
  54193. get attachedNode(): Nullable<Node>;
  54194. set attachedNode(value: Nullable<Node>);
  54195. /**
  54196. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54197. * @param mesh The mesh to replace the default mesh of the gizmo
  54198. */
  54199. setCustomMesh(mesh: Mesh): void;
  54200. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54201. /**
  54202. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54203. */
  54204. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54205. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54206. /**
  54207. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54208. */
  54209. updateGizmoPositionToMatchAttachedMesh: boolean;
  54210. /**
  54211. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54212. */
  54213. updateScale: boolean;
  54214. protected _interactionsEnabled: boolean;
  54215. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54216. private _beforeRenderObserver;
  54217. private _tempQuaternion;
  54218. private _tempVector;
  54219. private _tempVector2;
  54220. private _tempMatrix1;
  54221. private _tempMatrix2;
  54222. private _rightHandtoLeftHandMatrix;
  54223. /**
  54224. * Creates a gizmo
  54225. * @param gizmoLayer The utility layer the gizmo will be added to
  54226. */
  54227. constructor(
  54228. /** The utility layer the gizmo will be added to */
  54229. gizmoLayer?: UtilityLayerRenderer);
  54230. /**
  54231. * Updates the gizmo to match the attached mesh's position/rotation
  54232. */
  54233. protected _update(): void;
  54234. /**
  54235. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54236. * @param value Node, TransformNode or mesh
  54237. */
  54238. protected _matrixChanged(): void;
  54239. /**
  54240. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54241. * @param gizmoLayer The utility layer the gizmo will be added to
  54242. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54243. * @returns {Observer<PointerInfo>} pointerObserver
  54244. */
  54245. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54246. /**
  54247. * Disposes of the gizmo
  54248. */
  54249. dispose(): void;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * Single plane drag gizmo
  54255. */
  54256. export class PlaneDragGizmo extends Gizmo {
  54257. /**
  54258. * Drag behavior responsible for the gizmos dragging interactions
  54259. */
  54260. dragBehavior: PointerDragBehavior;
  54261. private _pointerObserver;
  54262. /**
  54263. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54264. */
  54265. snapDistance: number;
  54266. /**
  54267. * Event that fires each time the gizmo snaps to a new location.
  54268. * * snapDistance is the the change in distance
  54269. */
  54270. onSnapObservable: Observable<{
  54271. snapDistance: number;
  54272. }>;
  54273. private _gizmoMesh;
  54274. private _coloredMaterial;
  54275. private _hoverMaterial;
  54276. private _disableMaterial;
  54277. private _isEnabled;
  54278. private _parent;
  54279. private _dragging;
  54280. /** @hidden */
  54281. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54282. /**
  54283. * Creates a PlaneDragGizmo
  54284. * @param gizmoLayer The utility layer the gizmo will be added to
  54285. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54286. * @param color The color of the gizmo
  54287. */
  54288. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54289. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54290. /**
  54291. * If the gizmo is enabled
  54292. */
  54293. set isEnabled(value: boolean);
  54294. get isEnabled(): boolean;
  54295. /**
  54296. * Disposes of the gizmo
  54297. */
  54298. dispose(): void;
  54299. }
  54300. }
  54301. declare module BABYLON {
  54302. /**
  54303. * Single plane rotation gizmo
  54304. */
  54305. export class PlaneRotationGizmo extends Gizmo {
  54306. /**
  54307. * Drag behavior responsible for the gizmos dragging interactions
  54308. */
  54309. dragBehavior: PointerDragBehavior;
  54310. private _pointerObserver;
  54311. /**
  54312. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54313. */
  54314. snapDistance: number;
  54315. /**
  54316. * Event that fires each time the gizmo snaps to a new location.
  54317. * * snapDistance is the the change in distance
  54318. */
  54319. onSnapObservable: Observable<{
  54320. snapDistance: number;
  54321. }>;
  54322. private _isEnabled;
  54323. private _parent;
  54324. private _coloredMaterial;
  54325. private _hoverMaterial;
  54326. private _disableMaterial;
  54327. private _gizmoMesh;
  54328. private _rotationCircle;
  54329. private _dragging;
  54330. private static _CircleConstants;
  54331. /**
  54332. * Creates a PlaneRotationGizmo
  54333. * @param gizmoLayer The utility layer the gizmo will be added to
  54334. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54335. * @param color The color of the gizmo
  54336. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54337. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54338. * @param thickness display gizmo axis thickness
  54339. */
  54340. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54341. /** Create Geometry for Gizmo */
  54342. private _createGizmoMesh;
  54343. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54344. private setupRotationCircle;
  54345. private updateRotationPath;
  54346. private updateRotationCircle;
  54347. /**
  54348. * If the gizmo is enabled
  54349. */
  54350. set isEnabled(value: boolean);
  54351. get isEnabled(): boolean;
  54352. /**
  54353. * Disposes of the gizmo
  54354. */
  54355. dispose(): void;
  54356. }
  54357. }
  54358. declare module BABYLON {
  54359. /**
  54360. * Gizmo that enables rotating a mesh along 3 axis
  54361. */
  54362. export class RotationGizmo extends Gizmo {
  54363. /**
  54364. * Internal gizmo used for interactions on the x axis
  54365. */
  54366. xGizmo: PlaneRotationGizmo;
  54367. /**
  54368. * Internal gizmo used for interactions on the y axis
  54369. */
  54370. yGizmo: PlaneRotationGizmo;
  54371. /**
  54372. * Internal gizmo used for interactions on the z axis
  54373. */
  54374. zGizmo: PlaneRotationGizmo;
  54375. /** Fires an event when any of it's sub gizmos are dragged */
  54376. onDragStartObservable: Observable<unknown>;
  54377. /** Fires an event when any of it's sub gizmos are released from dragging */
  54378. onDragEndObservable: Observable<unknown>;
  54379. private _meshAttached;
  54380. private _nodeAttached;
  54381. private _observables;
  54382. /** Node Caching for quick lookup */
  54383. private _gizmoAxisCache;
  54384. get attachedMesh(): Nullable<AbstractMesh>;
  54385. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54386. get attachedNode(): Nullable<Node>;
  54387. set attachedNode(node: Nullable<Node>);
  54388. protected _checkBillboardTransform(): void;
  54389. /**
  54390. * True when the mouse pointer is hovering a gizmo mesh
  54391. */
  54392. get isHovered(): boolean;
  54393. /**
  54394. * Creates a RotationGizmo
  54395. * @param gizmoLayer The utility layer the gizmo will be added to
  54396. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54397. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54398. * @param thickness display gizmo axis thickness
  54399. */
  54400. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54401. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54402. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54403. /**
  54404. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54405. */
  54406. set snapDistance(value: number);
  54407. get snapDistance(): number;
  54408. /**
  54409. * Ratio for the scale of the gizmo (Default: 1)
  54410. */
  54411. set scaleRatio(value: number);
  54412. get scaleRatio(): number;
  54413. /**
  54414. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54415. * @param mesh Axis gizmo mesh
  54416. * @param cache Gizmo axis definition used for reactive gizmo UI
  54417. */
  54418. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54419. /**
  54420. * Disposes of the gizmo
  54421. */
  54422. dispose(): void;
  54423. /**
  54424. * CustomMeshes are not supported by this gizmo
  54425. * @param mesh The mesh to replace the default mesh of the gizmo
  54426. */
  54427. setCustomMesh(mesh: Mesh): void;
  54428. }
  54429. }
  54430. declare module BABYLON {
  54431. /**
  54432. * Class containing static functions to help procedurally build meshes
  54433. */
  54434. export class PolyhedronBuilder {
  54435. /**
  54436. * Creates a polyhedron mesh
  54437. * * 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
  54438. * * The parameter `size` (positive float, default 1) sets the polygon size
  54439. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54440. * * 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`
  54441. * * 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
  54442. * * 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)`)
  54443. * * 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
  54444. * * 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
  54445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54446. * * 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
  54447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54448. * @param name defines the name of the mesh
  54449. * @param options defines the options used to create the mesh
  54450. * @param scene defines the hosting scene
  54451. * @returns the polyhedron mesh
  54452. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54453. */
  54454. static CreatePolyhedron(name: string, options: {
  54455. type?: number;
  54456. size?: number;
  54457. sizeX?: number;
  54458. sizeY?: number;
  54459. sizeZ?: number;
  54460. custom?: any;
  54461. faceUV?: Vector4[];
  54462. faceColors?: Color4[];
  54463. flat?: boolean;
  54464. updatable?: boolean;
  54465. sideOrientation?: number;
  54466. frontUVs?: Vector4;
  54467. backUVs?: Vector4;
  54468. }, scene?: Nullable<Scene>): Mesh;
  54469. }
  54470. }
  54471. declare module BABYLON {
  54472. /**
  54473. * Class containing static functions to help procedurally build meshes
  54474. */
  54475. export class BoxBuilder {
  54476. /**
  54477. * Creates a box mesh
  54478. * * The parameter `size` sets the size (float) of each box side (default 1)
  54479. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54480. * * 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)
  54481. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54483. * * 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
  54484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54485. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54486. * @param name defines the name of the mesh
  54487. * @param options defines the options used to create the mesh
  54488. * @param scene defines the hosting scene
  54489. * @returns the box mesh
  54490. */
  54491. static CreateBox(name: string, options: {
  54492. size?: number;
  54493. width?: number;
  54494. height?: number;
  54495. depth?: number;
  54496. faceUV?: Vector4[];
  54497. faceColors?: Color4[];
  54498. sideOrientation?: number;
  54499. frontUVs?: Vector4;
  54500. backUVs?: Vector4;
  54501. wrap?: boolean;
  54502. topBaseAt?: number;
  54503. bottomBaseAt?: number;
  54504. updatable?: boolean;
  54505. }, scene?: Nullable<Scene>): Mesh;
  54506. }
  54507. }
  54508. declare module BABYLON {
  54509. /**
  54510. * Single axis scale gizmo
  54511. */
  54512. export class AxisScaleGizmo extends Gizmo {
  54513. /**
  54514. * Drag behavior responsible for the gizmos dragging interactions
  54515. */
  54516. dragBehavior: PointerDragBehavior;
  54517. private _pointerObserver;
  54518. /**
  54519. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54520. */
  54521. snapDistance: number;
  54522. /**
  54523. * Event that fires each time the gizmo snaps to a new location.
  54524. * * snapDistance is the the change in distance
  54525. */
  54526. onSnapObservable: Observable<{
  54527. snapDistance: number;
  54528. }>;
  54529. /**
  54530. * If the scaling operation should be done on all axis (default: false)
  54531. */
  54532. uniformScaling: boolean;
  54533. /**
  54534. * Custom sensitivity value for the drag strength
  54535. */
  54536. sensitivity: number;
  54537. private _isEnabled;
  54538. private _parent;
  54539. private _gizmoMesh;
  54540. private _coloredMaterial;
  54541. private _hoverMaterial;
  54542. private _disableMaterial;
  54543. private _dragging;
  54544. private _tmpVector;
  54545. private _tmpMatrix;
  54546. private _tmpMatrix2;
  54547. /**
  54548. * Creates an AxisScaleGizmo
  54549. * @param gizmoLayer The utility layer the gizmo will be added to
  54550. * @param dragAxis The axis which the gizmo will be able to scale on
  54551. * @param color The color of the gizmo
  54552. * @param thickness display gizmo axis thickness
  54553. */
  54554. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54555. /** Create Geometry for Gizmo */
  54556. private _createGizmoMesh;
  54557. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54558. /**
  54559. * If the gizmo is enabled
  54560. */
  54561. set isEnabled(value: boolean);
  54562. get isEnabled(): boolean;
  54563. /**
  54564. * Disposes of the gizmo
  54565. */
  54566. dispose(): void;
  54567. /**
  54568. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54569. * @param mesh The mesh to replace the default mesh of the gizmo
  54570. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54571. */
  54572. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54573. }
  54574. }
  54575. declare module BABYLON {
  54576. /**
  54577. * Gizmo that enables scaling a mesh along 3 axis
  54578. */
  54579. export class ScaleGizmo extends Gizmo {
  54580. /**
  54581. * Internal gizmo used for interactions on the x axis
  54582. */
  54583. xGizmo: AxisScaleGizmo;
  54584. /**
  54585. * Internal gizmo used for interactions on the y axis
  54586. */
  54587. yGizmo: AxisScaleGizmo;
  54588. /**
  54589. * Internal gizmo used for interactions on the z axis
  54590. */
  54591. zGizmo: AxisScaleGizmo;
  54592. /**
  54593. * Internal gizmo used to scale all axis equally
  54594. */
  54595. uniformScaleGizmo: AxisScaleGizmo;
  54596. private _meshAttached;
  54597. private _nodeAttached;
  54598. private _snapDistance;
  54599. private _uniformScalingMesh;
  54600. private _octahedron;
  54601. private _sensitivity;
  54602. private _coloredMaterial;
  54603. private _hoverMaterial;
  54604. private _disableMaterial;
  54605. private _observables;
  54606. /** Node Caching for quick lookup */
  54607. private _gizmoAxisCache;
  54608. /** Fires an event when any of it's sub gizmos are dragged */
  54609. onDragStartObservable: Observable<unknown>;
  54610. /** Fires an event when any of it's sub gizmos are released from dragging */
  54611. onDragEndObservable: Observable<unknown>;
  54612. get attachedMesh(): Nullable<AbstractMesh>;
  54613. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54614. get attachedNode(): Nullable<Node>;
  54615. set attachedNode(node: Nullable<Node>);
  54616. /**
  54617. * True when the mouse pointer is hovering a gizmo mesh
  54618. */
  54619. get isHovered(): boolean;
  54620. /**
  54621. * Creates a ScaleGizmo
  54622. * @param gizmoLayer The utility layer the gizmo will be added to
  54623. * @param thickness display gizmo axis thickness
  54624. */
  54625. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54626. /** Create Geometry for Gizmo */
  54627. private _createUniformScaleMesh;
  54628. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54629. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54630. /**
  54631. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54632. */
  54633. set snapDistance(value: number);
  54634. get snapDistance(): number;
  54635. /**
  54636. * Ratio for the scale of the gizmo (Default: 1)
  54637. */
  54638. set scaleRatio(value: number);
  54639. get scaleRatio(): number;
  54640. /**
  54641. * Sensitivity factor for dragging (Default: 1)
  54642. */
  54643. set sensitivity(value: number);
  54644. get sensitivity(): number;
  54645. /**
  54646. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54647. * @param mesh Axis gizmo mesh
  54648. * @param cache Gizmo axis definition used for reactive gizmo UI
  54649. */
  54650. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54651. /**
  54652. * Disposes of the gizmo
  54653. */
  54654. dispose(): void;
  54655. }
  54656. }
  54657. declare module BABYLON {
  54658. /**
  54659. * Bounding box gizmo
  54660. */
  54661. export class BoundingBoxGizmo extends Gizmo {
  54662. private _lineBoundingBox;
  54663. private _rotateSpheresParent;
  54664. private _scaleBoxesParent;
  54665. private _boundingDimensions;
  54666. private _renderObserver;
  54667. private _pointerObserver;
  54668. private _scaleDragSpeed;
  54669. private _tmpQuaternion;
  54670. private _tmpVector;
  54671. private _tmpRotationMatrix;
  54672. /**
  54673. * 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)
  54674. */
  54675. ignoreChildren: boolean;
  54676. /**
  54677. * 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)
  54678. */
  54679. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54680. /**
  54681. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54682. */
  54683. rotationSphereSize: number;
  54684. /**
  54685. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54686. */
  54687. scaleBoxSize: number;
  54688. /**
  54689. * 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)
  54690. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54691. */
  54692. fixedDragMeshScreenSize: boolean;
  54693. /**
  54694. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  54695. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54696. */
  54697. fixedDragMeshBoundsSize: boolean;
  54698. /**
  54699. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54700. */
  54701. fixedDragMeshScreenSizeDistanceFactor: number;
  54702. /**
  54703. * Fired when a rotation sphere or scale box is dragged
  54704. */
  54705. onDragStartObservable: Observable<{}>;
  54706. /**
  54707. * Fired when a scale box is dragged
  54708. */
  54709. onScaleBoxDragObservable: Observable<{}>;
  54710. /**
  54711. * Fired when a scale box drag is ended
  54712. */
  54713. onScaleBoxDragEndObservable: Observable<{}>;
  54714. /**
  54715. * Fired when a rotation sphere is dragged
  54716. */
  54717. onRotationSphereDragObservable: Observable<{}>;
  54718. /**
  54719. * Fired when a rotation sphere drag is ended
  54720. */
  54721. onRotationSphereDragEndObservable: Observable<{}>;
  54722. /**
  54723. * 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)
  54724. */
  54725. scalePivot: Nullable<Vector3>;
  54726. /**
  54727. * Mesh used as a pivot to rotate the attached node
  54728. */
  54729. private _anchorMesh;
  54730. private _existingMeshScale;
  54731. private _dragMesh;
  54732. private pointerDragBehavior;
  54733. private coloredMaterial;
  54734. private hoverColoredMaterial;
  54735. /**
  54736. * Sets the color of the bounding box gizmo
  54737. * @param color the color to set
  54738. */
  54739. setColor(color: Color3): void;
  54740. /**
  54741. * Creates an BoundingBoxGizmo
  54742. * @param gizmoLayer The utility layer the gizmo will be added to
  54743. * @param color The color of the gizmo
  54744. */
  54745. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54746. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54747. private _selectNode;
  54748. /**
  54749. * Updates the bounding box information for the Gizmo
  54750. */
  54751. updateBoundingBox(): void;
  54752. private _updateRotationSpheres;
  54753. private _updateScaleBoxes;
  54754. /**
  54755. * Enables rotation on the specified axis and disables rotation on the others
  54756. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54757. */
  54758. setEnabledRotationAxis(axis: string): void;
  54759. /**
  54760. * Enables/disables scaling
  54761. * @param enable if scaling should be enabled
  54762. * @param homogeneousScaling defines if scaling should only be homogeneous
  54763. */
  54764. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54765. private _updateDummy;
  54766. /**
  54767. * Enables a pointer drag behavior on the bounding box of the gizmo
  54768. */
  54769. enableDragBehavior(): void;
  54770. /**
  54771. * Disposes of the gizmo
  54772. */
  54773. dispose(): void;
  54774. /**
  54775. * 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)
  54776. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54777. * @returns the bounding box mesh with the passed in mesh as a child
  54778. */
  54779. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54780. /**
  54781. * CustomMeshes are not supported by this gizmo
  54782. * @param mesh The mesh to replace the default mesh of the gizmo
  54783. */
  54784. setCustomMesh(mesh: Mesh): void;
  54785. }
  54786. }
  54787. declare module BABYLON {
  54788. /**
  54789. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54790. */
  54791. export class GizmoManager implements IDisposable {
  54792. private scene;
  54793. /**
  54794. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54795. */
  54796. gizmos: {
  54797. positionGizmo: Nullable<PositionGizmo>;
  54798. rotationGizmo: Nullable<RotationGizmo>;
  54799. scaleGizmo: Nullable<ScaleGizmo>;
  54800. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54801. };
  54802. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54803. clearGizmoOnEmptyPointerEvent: boolean;
  54804. /** Fires an event when the manager is attached to a mesh */
  54805. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54806. /** Fires an event when the manager is attached to a node */
  54807. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54808. private _gizmosEnabled;
  54809. private _pointerObservers;
  54810. private _attachedMesh;
  54811. private _attachedNode;
  54812. private _boundingBoxColor;
  54813. private _defaultUtilityLayer;
  54814. private _defaultKeepDepthUtilityLayer;
  54815. private _thickness;
  54816. /** Node Caching for quick lookup */
  54817. private _gizmoAxisCache;
  54818. /**
  54819. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54820. */
  54821. boundingBoxDragBehavior: SixDofDragBehavior;
  54822. /**
  54823. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54824. */
  54825. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54826. /**
  54827. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54828. */
  54829. attachableNodes: Nullable<Array<Node>>;
  54830. /**
  54831. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54832. */
  54833. usePointerToAttachGizmos: boolean;
  54834. /**
  54835. * Utility layer that the bounding box gizmo belongs to
  54836. */
  54837. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54838. /**
  54839. * Utility layer that all gizmos besides bounding box belong to
  54840. */
  54841. get utilityLayer(): UtilityLayerRenderer;
  54842. /**
  54843. * True when the mouse pointer is hovering a gizmo mesh
  54844. */
  54845. get isHovered(): boolean;
  54846. /**
  54847. * Instatiates a gizmo manager
  54848. * @param scene the scene to overlay the gizmos on top of
  54849. * @param thickness display gizmo axis thickness
  54850. * @param utilityLayer the layer where gizmos are rendered
  54851. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54852. */
  54853. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54854. /**
  54855. * Subscribes to pointer down events, for attaching and detaching mesh
  54856. * @param scene The sceme layer the observer will be added to
  54857. */
  54858. private _attachToMeshPointerObserver;
  54859. /**
  54860. * Attaches a set of gizmos to the specified mesh
  54861. * @param mesh The mesh the gizmo's should be attached to
  54862. */
  54863. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54864. /**
  54865. * Attaches a set of gizmos to the specified node
  54866. * @param node The node the gizmo's should be attached to
  54867. */
  54868. attachToNode(node: Nullable<Node>): void;
  54869. /**
  54870. * If the position gizmo is enabled
  54871. */
  54872. set positionGizmoEnabled(value: boolean);
  54873. get positionGizmoEnabled(): boolean;
  54874. /**
  54875. * If the rotation gizmo is enabled
  54876. */
  54877. set rotationGizmoEnabled(value: boolean);
  54878. get rotationGizmoEnabled(): boolean;
  54879. /**
  54880. * If the scale gizmo is enabled
  54881. */
  54882. set scaleGizmoEnabled(value: boolean);
  54883. get scaleGizmoEnabled(): boolean;
  54884. /**
  54885. * If the boundingBox gizmo is enabled
  54886. */
  54887. set boundingBoxGizmoEnabled(value: boolean);
  54888. get boundingBoxGizmoEnabled(): boolean;
  54889. /**
  54890. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54891. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54892. */
  54893. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54894. /**
  54895. * Disposes of the gizmo manager
  54896. */
  54897. dispose(): void;
  54898. }
  54899. }
  54900. declare module BABYLON {
  54901. /**
  54902. * Gizmo that enables dragging a mesh along 3 axis
  54903. */
  54904. export class PositionGizmo extends Gizmo {
  54905. /**
  54906. * Internal gizmo used for interactions on the x axis
  54907. */
  54908. xGizmo: AxisDragGizmo;
  54909. /**
  54910. * Internal gizmo used for interactions on the y axis
  54911. */
  54912. yGizmo: AxisDragGizmo;
  54913. /**
  54914. * Internal gizmo used for interactions on the z axis
  54915. */
  54916. zGizmo: AxisDragGizmo;
  54917. /**
  54918. * Internal gizmo used for interactions on the yz plane
  54919. */
  54920. xPlaneGizmo: PlaneDragGizmo;
  54921. /**
  54922. * Internal gizmo used for interactions on the xz plane
  54923. */
  54924. yPlaneGizmo: PlaneDragGizmo;
  54925. /**
  54926. * Internal gizmo used for interactions on the xy plane
  54927. */
  54928. zPlaneGizmo: PlaneDragGizmo;
  54929. /**
  54930. * private variables
  54931. */
  54932. private _meshAttached;
  54933. private _nodeAttached;
  54934. private _snapDistance;
  54935. private _observables;
  54936. /** Node Caching for quick lookup */
  54937. private _gizmoAxisCache;
  54938. /** Fires an event when any of it's sub gizmos are dragged */
  54939. onDragStartObservable: Observable<unknown>;
  54940. /** Fires an event when any of it's sub gizmos are released from dragging */
  54941. onDragEndObservable: Observable<unknown>;
  54942. /**
  54943. * If set to true, planar drag is enabled
  54944. */
  54945. private _planarGizmoEnabled;
  54946. get attachedMesh(): Nullable<AbstractMesh>;
  54947. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54948. get attachedNode(): Nullable<Node>;
  54949. set attachedNode(node: Nullable<Node>);
  54950. /**
  54951. * True when the mouse pointer is hovering a gizmo mesh
  54952. */
  54953. get isHovered(): boolean;
  54954. /**
  54955. * Creates a PositionGizmo
  54956. * @param gizmoLayer The utility layer the gizmo will be added to
  54957. @param thickness display gizmo axis thickness
  54958. */
  54959. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54960. /**
  54961. * If the planar drag gizmo is enabled
  54962. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54963. */
  54964. set planarGizmoEnabled(value: boolean);
  54965. get planarGizmoEnabled(): boolean;
  54966. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54967. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54968. /**
  54969. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54970. */
  54971. set snapDistance(value: number);
  54972. get snapDistance(): number;
  54973. /**
  54974. * Ratio for the scale of the gizmo (Default: 1)
  54975. */
  54976. set scaleRatio(value: number);
  54977. get scaleRatio(): number;
  54978. /**
  54979. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54980. * @param mesh Axis gizmo mesh
  54981. * @param cache Gizmo axis definition used for reactive gizmo UI
  54982. */
  54983. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54984. /**
  54985. * Disposes of the gizmo
  54986. */
  54987. dispose(): void;
  54988. /**
  54989. * CustomMeshes are not supported by this gizmo
  54990. * @param mesh The mesh to replace the default mesh of the gizmo
  54991. */
  54992. setCustomMesh(mesh: Mesh): void;
  54993. }
  54994. }
  54995. declare module BABYLON {
  54996. /**
  54997. * Single axis drag gizmo
  54998. */
  54999. export class AxisDragGizmo extends Gizmo {
  55000. /**
  55001. * Drag behavior responsible for the gizmos dragging interactions
  55002. */
  55003. dragBehavior: PointerDragBehavior;
  55004. private _pointerObserver;
  55005. /**
  55006. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55007. */
  55008. snapDistance: number;
  55009. /**
  55010. * Event that fires each time the gizmo snaps to a new location.
  55011. * * snapDistance is the the change in distance
  55012. */
  55013. onSnapObservable: Observable<{
  55014. snapDistance: number;
  55015. }>;
  55016. private _isEnabled;
  55017. private _parent;
  55018. private _gizmoMesh;
  55019. private _coloredMaterial;
  55020. private _hoverMaterial;
  55021. private _disableMaterial;
  55022. private _dragging;
  55023. /** @hidden */
  55024. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  55025. /** @hidden */
  55026. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55027. /**
  55028. * Creates an AxisDragGizmo
  55029. * @param gizmoLayer The utility layer the gizmo will be added to
  55030. * @param dragAxis The axis which the gizmo will be able to drag on
  55031. * @param color The color of the gizmo
  55032. * @param thickness display gizmo axis thickness
  55033. */
  55034. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55035. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55036. /**
  55037. * If the gizmo is enabled
  55038. */
  55039. set isEnabled(value: boolean);
  55040. get isEnabled(): boolean;
  55041. /**
  55042. * Disposes of the gizmo
  55043. */
  55044. dispose(): void;
  55045. }
  55046. }
  55047. declare module BABYLON.Debug {
  55048. /**
  55049. * The Axes viewer will show 3 axes in a specific point in space
  55050. */
  55051. export class AxesViewer {
  55052. private _xAxis;
  55053. private _yAxis;
  55054. private _zAxis;
  55055. private _scaleLinesFactor;
  55056. private _instanced;
  55057. /**
  55058. * Gets the hosting scene
  55059. */
  55060. scene: Nullable<Scene>;
  55061. /**
  55062. * Gets or sets a number used to scale line length
  55063. */
  55064. scaleLines: number;
  55065. /** Gets the node hierarchy used to render x-axis */
  55066. get xAxis(): TransformNode;
  55067. /** Gets the node hierarchy used to render y-axis */
  55068. get yAxis(): TransformNode;
  55069. /** Gets the node hierarchy used to render z-axis */
  55070. get zAxis(): TransformNode;
  55071. /**
  55072. * Creates a new AxesViewer
  55073. * @param scene defines the hosting scene
  55074. * @param scaleLines defines a number used to scale line length (1 by default)
  55075. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55076. * @param xAxis defines the node hierarchy used to render the x-axis
  55077. * @param yAxis defines the node hierarchy used to render the y-axis
  55078. * @param zAxis defines the node hierarchy used to render the z-axis
  55079. */
  55080. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55081. /**
  55082. * Force the viewer to update
  55083. * @param position defines the position of the viewer
  55084. * @param xaxis defines the x axis of the viewer
  55085. * @param yaxis defines the y axis of the viewer
  55086. * @param zaxis defines the z axis of the viewer
  55087. */
  55088. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55089. /**
  55090. * Creates an instance of this axes viewer.
  55091. * @returns a new axes viewer with instanced meshes
  55092. */
  55093. createInstance(): AxesViewer;
  55094. /** Releases resources */
  55095. dispose(): void;
  55096. private static _SetRenderingGroupId;
  55097. }
  55098. }
  55099. declare module BABYLON.Debug {
  55100. /**
  55101. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55102. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55103. */
  55104. export class BoneAxesViewer extends AxesViewer {
  55105. /**
  55106. * Gets or sets the target mesh where to display the axes viewer
  55107. */
  55108. mesh: Nullable<Mesh>;
  55109. /**
  55110. * Gets or sets the target bone where to display the axes viewer
  55111. */
  55112. bone: Nullable<Bone>;
  55113. /** Gets current position */
  55114. pos: Vector3;
  55115. /** Gets direction of X axis */
  55116. xaxis: Vector3;
  55117. /** Gets direction of Y axis */
  55118. yaxis: Vector3;
  55119. /** Gets direction of Z axis */
  55120. zaxis: Vector3;
  55121. /**
  55122. * Creates a new BoneAxesViewer
  55123. * @param scene defines the hosting scene
  55124. * @param bone defines the target bone
  55125. * @param mesh defines the target mesh
  55126. * @param scaleLines defines a scaling factor for line length (1 by default)
  55127. */
  55128. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55129. /**
  55130. * Force the viewer to update
  55131. */
  55132. update(): void;
  55133. /** Releases resources */
  55134. dispose(): void;
  55135. }
  55136. }
  55137. declare module BABYLON {
  55138. /**
  55139. * Interface used to define scene explorer extensibility option
  55140. */
  55141. export interface IExplorerExtensibilityOption {
  55142. /**
  55143. * Define the option label
  55144. */
  55145. label: string;
  55146. /**
  55147. * Defines the action to execute on click
  55148. */
  55149. action: (entity: any) => void;
  55150. }
  55151. /**
  55152. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55153. */
  55154. export interface IExplorerExtensibilityGroup {
  55155. /**
  55156. * Defines a predicate to test if a given type mut be extended
  55157. */
  55158. predicate: (entity: any) => boolean;
  55159. /**
  55160. * Gets the list of options added to a type
  55161. */
  55162. entries: IExplorerExtensibilityOption[];
  55163. }
  55164. /**
  55165. * Interface used to define the options to use to create the Inspector
  55166. */
  55167. export interface IInspectorOptions {
  55168. /**
  55169. * Display in overlay mode (default: false)
  55170. */
  55171. overlay?: boolean;
  55172. /**
  55173. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55174. */
  55175. globalRoot?: HTMLElement;
  55176. /**
  55177. * Display the Scene explorer
  55178. */
  55179. showExplorer?: boolean;
  55180. /**
  55181. * Display the property inspector
  55182. */
  55183. showInspector?: boolean;
  55184. /**
  55185. * Display in embed mode (both panes on the right)
  55186. */
  55187. embedMode?: boolean;
  55188. /**
  55189. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55190. */
  55191. handleResize?: boolean;
  55192. /**
  55193. * Allow the panes to popup (default: true)
  55194. */
  55195. enablePopup?: boolean;
  55196. /**
  55197. * Allow the panes to be closed by users (default: true)
  55198. */
  55199. enableClose?: boolean;
  55200. /**
  55201. * Optional list of extensibility entries
  55202. */
  55203. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55204. /**
  55205. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55206. */
  55207. inspectorURL?: string;
  55208. /**
  55209. * Optional initial tab (default to DebugLayerTab.Properties)
  55210. */
  55211. initialTab?: DebugLayerTab;
  55212. }
  55213. interface Scene {
  55214. /**
  55215. * @hidden
  55216. * Backing field
  55217. */
  55218. _debugLayer: DebugLayer;
  55219. /**
  55220. * Gets the debug layer (aka Inspector) associated with the scene
  55221. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55222. */
  55223. debugLayer: DebugLayer;
  55224. }
  55225. /**
  55226. * Enum of inspector action tab
  55227. */
  55228. export enum DebugLayerTab {
  55229. /**
  55230. * Properties tag (default)
  55231. */
  55232. Properties = 0,
  55233. /**
  55234. * Debug tab
  55235. */
  55236. Debug = 1,
  55237. /**
  55238. * Statistics tab
  55239. */
  55240. Statistics = 2,
  55241. /**
  55242. * Tools tab
  55243. */
  55244. Tools = 3,
  55245. /**
  55246. * Settings tab
  55247. */
  55248. Settings = 4
  55249. }
  55250. /**
  55251. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55252. * what is happening in your scene
  55253. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55254. */
  55255. export class DebugLayer {
  55256. /**
  55257. * Define the url to get the inspector script from.
  55258. * By default it uses the babylonjs CDN.
  55259. * @ignoreNaming
  55260. */
  55261. static InspectorURL: string;
  55262. private _scene;
  55263. private BJSINSPECTOR;
  55264. private _onPropertyChangedObservable?;
  55265. /**
  55266. * Observable triggered when a property is changed through the inspector.
  55267. */
  55268. get onPropertyChangedObservable(): any;
  55269. /**
  55270. * Instantiates a new debug layer.
  55271. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55272. * what is happening in your scene
  55273. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55274. * @param scene Defines the scene to inspect
  55275. */
  55276. constructor(scene: Scene);
  55277. /** Creates the inspector window. */
  55278. private _createInspector;
  55279. /**
  55280. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55281. * @param entity defines the entity to select
  55282. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55283. */
  55284. select(entity: any, lineContainerTitles?: string | string[]): void;
  55285. /** Get the inspector from bundle or global */
  55286. private _getGlobalInspector;
  55287. /**
  55288. * Get if the inspector is visible or not.
  55289. * @returns true if visible otherwise, false
  55290. */
  55291. isVisible(): boolean;
  55292. /**
  55293. * Hide the inspector and close its window.
  55294. */
  55295. hide(): void;
  55296. /**
  55297. * Update the scene in the inspector
  55298. */
  55299. setAsActiveScene(): void;
  55300. /**
  55301. * Launch the debugLayer.
  55302. * @param config Define the configuration of the inspector
  55303. * @return a promise fulfilled when the debug layer is visible
  55304. */
  55305. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55306. }
  55307. }
  55308. declare module BABYLON.Debug {
  55309. /**
  55310. * Used to show the physics impostor around the specific mesh
  55311. */
  55312. export class PhysicsViewer {
  55313. /** @hidden */
  55314. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55315. /** @hidden */
  55316. protected _meshes: Array<Nullable<AbstractMesh>>;
  55317. /** @hidden */
  55318. protected _scene: Nullable<Scene>;
  55319. /** @hidden */
  55320. protected _numMeshes: number;
  55321. /** @hidden */
  55322. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55323. private _renderFunction;
  55324. private _utilityLayer;
  55325. private _debugBoxMesh;
  55326. private _debugSphereMesh;
  55327. private _debugCylinderMesh;
  55328. private _debugMaterial;
  55329. private _debugMeshMeshes;
  55330. /**
  55331. * Creates a new PhysicsViewer
  55332. * @param scene defines the hosting scene
  55333. */
  55334. constructor(scene: Scene);
  55335. /** @hidden */
  55336. protected _updateDebugMeshes(): void;
  55337. /**
  55338. * Renders a specified physic impostor
  55339. * @param impostor defines the impostor to render
  55340. * @param targetMesh defines the mesh represented by the impostor
  55341. * @returns the new debug mesh used to render the impostor
  55342. */
  55343. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55344. /**
  55345. * Hides a specified physic impostor
  55346. * @param impostor defines the impostor to hide
  55347. */
  55348. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55349. private _getDebugMaterial;
  55350. private _getDebugBoxMesh;
  55351. private _getDebugSphereMesh;
  55352. private _getDebugCylinderMesh;
  55353. private _getDebugMeshMesh;
  55354. private _getDebugMesh;
  55355. /** Releases all resources */
  55356. dispose(): void;
  55357. }
  55358. }
  55359. declare module BABYLON {
  55360. /**
  55361. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55362. * in order to better appreciate the issue one might have.
  55363. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55364. */
  55365. export class RayHelper {
  55366. /**
  55367. * Defines the ray we are currently tryin to visualize.
  55368. */
  55369. ray: Nullable<Ray>;
  55370. private _renderPoints;
  55371. private _renderLine;
  55372. private _renderFunction;
  55373. private _scene;
  55374. private _onAfterRenderObserver;
  55375. private _onAfterStepObserver;
  55376. private _attachedToMesh;
  55377. private _meshSpaceDirection;
  55378. private _meshSpaceOrigin;
  55379. /**
  55380. * Helper function to create a colored helper in a scene in one line.
  55381. * @param ray Defines the ray we are currently tryin to visualize
  55382. * @param scene Defines the scene the ray is used in
  55383. * @param color Defines the color we want to see the ray in
  55384. * @returns The newly created ray helper.
  55385. */
  55386. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55387. /**
  55388. * Instantiate a new ray helper.
  55389. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55390. * in order to better appreciate the issue one might have.
  55391. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55392. * @param ray Defines the ray we are currently tryin to visualize
  55393. */
  55394. constructor(ray: Ray);
  55395. /**
  55396. * Shows the ray we are willing to debug.
  55397. * @param scene Defines the scene the ray needs to be rendered in
  55398. * @param color Defines the color the ray needs to be rendered in
  55399. */
  55400. show(scene: Scene, color?: Color3): void;
  55401. /**
  55402. * Hides the ray we are debugging.
  55403. */
  55404. hide(): void;
  55405. private _render;
  55406. /**
  55407. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55408. * @param mesh Defines the mesh we want the helper attached to
  55409. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55410. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55411. * @param length Defines the length of the ray
  55412. */
  55413. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55414. /**
  55415. * Detach the ray helper from the mesh it has previously been attached to.
  55416. */
  55417. detachFromMesh(): void;
  55418. private _updateToMesh;
  55419. /**
  55420. * Dispose the helper and release its associated resources.
  55421. */
  55422. dispose(): void;
  55423. }
  55424. }
  55425. declare module BABYLON {
  55426. /**
  55427. * Defines the options associated with the creation of a SkeletonViewer.
  55428. */
  55429. export interface ISkeletonViewerOptions {
  55430. /** Should the system pause animations before building the Viewer? */
  55431. pauseAnimations: boolean;
  55432. /** Should the system return the skeleton to rest before building? */
  55433. returnToRest: boolean;
  55434. /** public Display Mode of the Viewer */
  55435. displayMode: number;
  55436. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55437. displayOptions: ISkeletonViewerDisplayOptions;
  55438. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55439. computeBonesUsingShaders: boolean;
  55440. /** Flag ignore non weighted bones */
  55441. useAllBones: boolean;
  55442. }
  55443. /**
  55444. * Defines how to display the various bone meshes for the viewer.
  55445. */
  55446. export interface ISkeletonViewerDisplayOptions {
  55447. /** How far down to start tapering the bone spurs */
  55448. midStep?: number;
  55449. /** How big is the midStep? */
  55450. midStepFactor?: number;
  55451. /** Base for the Sphere Size */
  55452. sphereBaseSize?: number;
  55453. /** The ratio of the sphere to the longest bone in units */
  55454. sphereScaleUnit?: number;
  55455. /** Ratio for the Sphere Size */
  55456. sphereFactor?: number;
  55457. /** Whether a spur should attach its far end to the child bone position */
  55458. spurFollowsChild?: boolean;
  55459. /** Whether to show local axes or not */
  55460. showLocalAxes?: boolean;
  55461. /** Length of each local axis */
  55462. localAxesSize?: number;
  55463. }
  55464. /**
  55465. * Defines the constructor options for the BoneWeight Shader.
  55466. */
  55467. export interface IBoneWeightShaderOptions {
  55468. /** Skeleton to Map */
  55469. skeleton: Skeleton;
  55470. /** Colors for Uninfluenced bones */
  55471. colorBase?: Color3;
  55472. /** Colors for 0.0-0.25 Weight bones */
  55473. colorZero?: Color3;
  55474. /** Color for 0.25-0.5 Weight Influence */
  55475. colorQuarter?: Color3;
  55476. /** Color for 0.5-0.75 Weight Influence */
  55477. colorHalf?: Color3;
  55478. /** Color for 0.75-1 Weight Influence */
  55479. colorFull?: Color3;
  55480. /** Color for Zero Weight Influence */
  55481. targetBoneIndex?: number;
  55482. }
  55483. /**
  55484. * Simple structure of the gradient steps for the Color Map.
  55485. */
  55486. export interface ISkeletonMapShaderColorMapKnot {
  55487. /** Color of the Knot */
  55488. color: Color3;
  55489. /** Location of the Knot */
  55490. location: number;
  55491. }
  55492. /**
  55493. * Defines the constructor options for the SkeletonMap Shader.
  55494. */
  55495. export interface ISkeletonMapShaderOptions {
  55496. /** Skeleton to Map */
  55497. skeleton: Skeleton;
  55498. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55499. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55500. }
  55501. }
  55502. declare module BABYLON {
  55503. /**
  55504. * Class containing static functions to help procedurally build meshes
  55505. */
  55506. export class RibbonBuilder {
  55507. /**
  55508. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55509. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55510. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55511. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55512. * * 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
  55513. * * 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
  55514. * * 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
  55515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55516. * * 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
  55517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55518. * * 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
  55519. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55520. * * 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
  55521. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55523. * @param name defines the name of the mesh
  55524. * @param options defines the options used to create the mesh
  55525. * @param scene defines the hosting scene
  55526. * @returns the ribbon mesh
  55527. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55528. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55529. */
  55530. static CreateRibbon(name: string, options: {
  55531. pathArray: Vector3[][];
  55532. closeArray?: boolean;
  55533. closePath?: boolean;
  55534. offset?: number;
  55535. updatable?: boolean;
  55536. sideOrientation?: number;
  55537. frontUVs?: Vector4;
  55538. backUVs?: Vector4;
  55539. instance?: Mesh;
  55540. invertUV?: boolean;
  55541. uvs?: Vector2[];
  55542. colors?: Color4[];
  55543. }, scene?: Nullable<Scene>): Mesh;
  55544. }
  55545. }
  55546. declare module BABYLON {
  55547. /**
  55548. * Class containing static functions to help procedurally build meshes
  55549. */
  55550. export class ShapeBuilder {
  55551. /**
  55552. * 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.
  55553. * * 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.
  55554. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55555. * * 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.
  55556. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55557. * * 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
  55558. * * 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
  55559. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55561. * * 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
  55562. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55564. * @param name defines the name of the mesh
  55565. * @param options defines the options used to create the mesh
  55566. * @param scene defines the hosting scene
  55567. * @returns the extruded shape mesh
  55568. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55570. */
  55571. static ExtrudeShape(name: string, options: {
  55572. shape: Vector3[];
  55573. path: Vector3[];
  55574. scale?: number;
  55575. rotation?: number;
  55576. cap?: number;
  55577. updatable?: boolean;
  55578. sideOrientation?: number;
  55579. frontUVs?: Vector4;
  55580. backUVs?: Vector4;
  55581. instance?: Mesh;
  55582. invertUV?: boolean;
  55583. }, scene?: Nullable<Scene>): Mesh;
  55584. /**
  55585. * Creates an custom extruded shape mesh.
  55586. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55587. * * 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.
  55588. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55589. * * 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
  55590. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55591. * * 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
  55592. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55593. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55594. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55595. * * 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
  55596. * * 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
  55597. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55599. * * 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
  55600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55602. * @param name defines the name of the mesh
  55603. * @param options defines the options used to create the mesh
  55604. * @param scene defines the hosting scene
  55605. * @returns the custom extruded shape mesh
  55606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55607. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55609. */
  55610. static ExtrudeShapeCustom(name: string, options: {
  55611. shape: Vector3[];
  55612. path: Vector3[];
  55613. scaleFunction?: any;
  55614. rotationFunction?: any;
  55615. ribbonCloseArray?: boolean;
  55616. ribbonClosePath?: boolean;
  55617. cap?: number;
  55618. updatable?: boolean;
  55619. sideOrientation?: number;
  55620. frontUVs?: Vector4;
  55621. backUVs?: Vector4;
  55622. instance?: Mesh;
  55623. invertUV?: boolean;
  55624. }, scene?: Nullable<Scene>): Mesh;
  55625. private static _ExtrudeShapeGeneric;
  55626. }
  55627. }
  55628. declare module BABYLON.Debug {
  55629. /**
  55630. * Class used to render a debug view of a given skeleton
  55631. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55632. */
  55633. export class SkeletonViewer {
  55634. /** defines the skeleton to render */
  55635. skeleton: Skeleton;
  55636. /** defines the mesh attached to the skeleton */
  55637. mesh: AbstractMesh;
  55638. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55639. autoUpdateBonesMatrices: boolean;
  55640. /** defines the rendering group id to use with the viewer */
  55641. renderingGroupId: number;
  55642. /** is the options for the viewer */
  55643. options: Partial<ISkeletonViewerOptions>;
  55644. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55645. static readonly DISPLAY_LINES: number;
  55646. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55647. static readonly DISPLAY_SPHERES: number;
  55648. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55649. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55650. /** public static method to create a BoneWeight Shader
  55651. * @param options The constructor options
  55652. * @param scene The scene that the shader is scoped to
  55653. * @returns The created ShaderMaterial
  55654. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55655. */
  55656. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55657. /** public static method to create a BoneWeight Shader
  55658. * @param options The constructor options
  55659. * @param scene The scene that the shader is scoped to
  55660. * @returns The created ShaderMaterial
  55661. */
  55662. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55663. /** private static method to create a BoneWeight Shader
  55664. * @param size The size of the buffer to create (usually the bone count)
  55665. * @param colorMap The gradient data to generate
  55666. * @param scene The scene that the shader is scoped to
  55667. * @returns an Array of floats from the color gradient values
  55668. */
  55669. private static _CreateBoneMapColorBuffer;
  55670. /** If SkeletonViewer scene scope. */
  55671. private _scene;
  55672. /** Gets or sets the color used to render the skeleton */
  55673. color: Color3;
  55674. /** Array of the points of the skeleton fo the line view. */
  55675. private _debugLines;
  55676. /** The SkeletonViewers Mesh. */
  55677. private _debugMesh;
  55678. /** The local axes Meshes. */
  55679. private _localAxes;
  55680. /** If SkeletonViewer is enabled. */
  55681. private _isEnabled;
  55682. /** If SkeletonViewer is ready. */
  55683. private _ready;
  55684. /** SkeletonViewer render observable. */
  55685. private _obs;
  55686. /** The Utility Layer to render the gizmos in. */
  55687. private _utilityLayer;
  55688. private _boneIndices;
  55689. /** Gets the Scene. */
  55690. get scene(): Scene;
  55691. /** Gets the utilityLayer. */
  55692. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55693. /** Checks Ready Status. */
  55694. get isReady(): Boolean;
  55695. /** Sets Ready Status. */
  55696. set ready(value: boolean);
  55697. /** Gets the debugMesh */
  55698. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55699. /** Sets the debugMesh */
  55700. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55701. /** Gets the displayMode */
  55702. get displayMode(): number;
  55703. /** Sets the displayMode */
  55704. set displayMode(value: number);
  55705. /**
  55706. * Creates a new SkeletonViewer
  55707. * @param skeleton defines the skeleton to render
  55708. * @param mesh defines the mesh attached to the skeleton
  55709. * @param scene defines the hosting scene
  55710. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55711. * @param renderingGroupId defines the rendering group id to use with the viewer
  55712. * @param options All of the extra constructor options for the SkeletonViewer
  55713. */
  55714. constructor(
  55715. /** defines the skeleton to render */
  55716. skeleton: Skeleton,
  55717. /** defines the mesh attached to the skeleton */
  55718. mesh: AbstractMesh,
  55719. /** The Scene scope*/
  55720. scene: Scene,
  55721. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55722. autoUpdateBonesMatrices?: boolean,
  55723. /** defines the rendering group id to use with the viewer */
  55724. renderingGroupId?: number,
  55725. /** is the options for the viewer */
  55726. options?: Partial<ISkeletonViewerOptions>);
  55727. /** The Dynamic bindings for the update functions */
  55728. private _bindObs;
  55729. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55730. update(): void;
  55731. /** Gets or sets a boolean indicating if the viewer is enabled */
  55732. set isEnabled(value: boolean);
  55733. get isEnabled(): boolean;
  55734. private _getBonePosition;
  55735. private _getLinesForBonesWithLength;
  55736. private _getLinesForBonesNoLength;
  55737. /** function to revert the mesh and scene back to the initial state. */
  55738. private _revert;
  55739. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55740. private _getAbsoluteBindPoseToRef;
  55741. /** function to build and bind sphere joint points and spur bone representations. */
  55742. private _buildSpheresAndSpurs;
  55743. private _buildLocalAxes;
  55744. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55745. private _displayLinesUpdate;
  55746. /** Changes the displayMode of the skeleton viewer
  55747. * @param mode The displayMode numerical value
  55748. */
  55749. changeDisplayMode(mode: number): void;
  55750. /** Sets a display option of the skeleton viewer
  55751. *
  55752. * | Option | Type | Default | Description |
  55753. * | ---------------- | ------- | ------- | ----------- |
  55754. * | 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`. |
  55755. * | 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`. |
  55756. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55757. * | 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`. |
  55758. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55759. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55760. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55761. *
  55762. * @param option String of the option name
  55763. * @param value The numerical option value
  55764. */
  55765. changeDisplayOptions(option: string, value: number): void;
  55766. /** Release associated resources */
  55767. dispose(): void;
  55768. }
  55769. }
  55770. declare module BABYLON {
  55771. /**
  55772. * Enum for Device Types
  55773. */
  55774. export enum DeviceType {
  55775. /** Generic */
  55776. Generic = 0,
  55777. /** Keyboard */
  55778. Keyboard = 1,
  55779. /** Mouse */
  55780. Mouse = 2,
  55781. /** Touch Pointers */
  55782. Touch = 3,
  55783. /** PS4 Dual Shock */
  55784. DualShock = 4,
  55785. /** Xbox */
  55786. Xbox = 5,
  55787. /** Switch Controller */
  55788. Switch = 6
  55789. }
  55790. /**
  55791. * Enum for All Pointers (Touch/Mouse)
  55792. */
  55793. export enum PointerInput {
  55794. /** Horizontal Axis */
  55795. Horizontal = 0,
  55796. /** Vertical Axis */
  55797. Vertical = 1,
  55798. /** Left Click or Touch */
  55799. LeftClick = 2,
  55800. /** Middle Click */
  55801. MiddleClick = 3,
  55802. /** Right Click */
  55803. RightClick = 4,
  55804. /** Browser Back */
  55805. BrowserBack = 5,
  55806. /** Browser Forward */
  55807. BrowserForward = 6
  55808. }
  55809. /**
  55810. * Enum for Dual Shock Gamepad
  55811. */
  55812. export enum DualShockInput {
  55813. /** Cross */
  55814. Cross = 0,
  55815. /** Circle */
  55816. Circle = 1,
  55817. /** Square */
  55818. Square = 2,
  55819. /** Triangle */
  55820. Triangle = 3,
  55821. /** L1 */
  55822. L1 = 4,
  55823. /** R1 */
  55824. R1 = 5,
  55825. /** L2 */
  55826. L2 = 6,
  55827. /** R2 */
  55828. R2 = 7,
  55829. /** Share */
  55830. Share = 8,
  55831. /** Options */
  55832. Options = 9,
  55833. /** L3 */
  55834. L3 = 10,
  55835. /** R3 */
  55836. R3 = 11,
  55837. /** DPadUp */
  55838. DPadUp = 12,
  55839. /** DPadDown */
  55840. DPadDown = 13,
  55841. /** DPadLeft */
  55842. DPadLeft = 14,
  55843. /** DRight */
  55844. DPadRight = 15,
  55845. /** Home */
  55846. Home = 16,
  55847. /** TouchPad */
  55848. TouchPad = 17,
  55849. /** LStickXAxis */
  55850. LStickXAxis = 18,
  55851. /** LStickYAxis */
  55852. LStickYAxis = 19,
  55853. /** RStickXAxis */
  55854. RStickXAxis = 20,
  55855. /** RStickYAxis */
  55856. RStickYAxis = 21
  55857. }
  55858. /**
  55859. * Enum for Xbox Gamepad
  55860. */
  55861. export enum XboxInput {
  55862. /** A */
  55863. A = 0,
  55864. /** B */
  55865. B = 1,
  55866. /** X */
  55867. X = 2,
  55868. /** Y */
  55869. Y = 3,
  55870. /** LB */
  55871. LB = 4,
  55872. /** RB */
  55873. RB = 5,
  55874. /** LT */
  55875. LT = 6,
  55876. /** RT */
  55877. RT = 7,
  55878. /** Back */
  55879. Back = 8,
  55880. /** Start */
  55881. Start = 9,
  55882. /** LS */
  55883. LS = 10,
  55884. /** RS */
  55885. RS = 11,
  55886. /** DPadUp */
  55887. DPadUp = 12,
  55888. /** DPadDown */
  55889. DPadDown = 13,
  55890. /** DPadLeft */
  55891. DPadLeft = 14,
  55892. /** DRight */
  55893. DPadRight = 15,
  55894. /** Home */
  55895. Home = 16,
  55896. /** LStickXAxis */
  55897. LStickXAxis = 17,
  55898. /** LStickYAxis */
  55899. LStickYAxis = 18,
  55900. /** RStickXAxis */
  55901. RStickXAxis = 19,
  55902. /** RStickYAxis */
  55903. RStickYAxis = 20
  55904. }
  55905. /**
  55906. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55907. */
  55908. export enum SwitchInput {
  55909. /** B */
  55910. B = 0,
  55911. /** A */
  55912. A = 1,
  55913. /** Y */
  55914. Y = 2,
  55915. /** X */
  55916. X = 3,
  55917. /** L */
  55918. L = 4,
  55919. /** R */
  55920. R = 5,
  55921. /** ZL */
  55922. ZL = 6,
  55923. /** ZR */
  55924. ZR = 7,
  55925. /** Minus */
  55926. Minus = 8,
  55927. /** Plus */
  55928. Plus = 9,
  55929. /** LS */
  55930. LS = 10,
  55931. /** RS */
  55932. RS = 11,
  55933. /** DPadUp */
  55934. DPadUp = 12,
  55935. /** DPadDown */
  55936. DPadDown = 13,
  55937. /** DPadLeft */
  55938. DPadLeft = 14,
  55939. /** DRight */
  55940. DPadRight = 15,
  55941. /** Home */
  55942. Home = 16,
  55943. /** Capture */
  55944. Capture = 17,
  55945. /** LStickXAxis */
  55946. LStickXAxis = 18,
  55947. /** LStickYAxis */
  55948. LStickYAxis = 19,
  55949. /** RStickXAxis */
  55950. RStickXAxis = 20,
  55951. /** RStickYAxis */
  55952. RStickYAxis = 21
  55953. }
  55954. }
  55955. declare module BABYLON {
  55956. /**
  55957. * This class will take all inputs from Keyboard, Pointer, and
  55958. * any Gamepads and provide a polling system that all devices
  55959. * will use. This class assumes that there will only be one
  55960. * pointer device and one keyboard.
  55961. */
  55962. export class DeviceInputSystem implements IDisposable {
  55963. /**
  55964. * Returns onDeviceConnected callback property
  55965. * @returns Callback with function to execute when a device is connected
  55966. */
  55967. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55968. /**
  55969. * Sets callback function when a device is connected and executes against all connected devices
  55970. * @param callback Function to execute when a device is connected
  55971. */
  55972. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55973. /**
  55974. * Callback to be triggered when a device is disconnected
  55975. */
  55976. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55977. /**
  55978. * Callback to be triggered when event driven input is updated
  55979. */
  55980. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55981. private _inputs;
  55982. private _gamepads;
  55983. private _keyboardActive;
  55984. private _pointerActive;
  55985. private _elementToAttachTo;
  55986. private _keyboardDownEvent;
  55987. private _keyboardUpEvent;
  55988. private _pointerMoveEvent;
  55989. private _pointerDownEvent;
  55990. private _pointerUpEvent;
  55991. private _gamepadConnectedEvent;
  55992. private _gamepadDisconnectedEvent;
  55993. private _onDeviceConnected;
  55994. private static _MAX_KEYCODES;
  55995. private static _MAX_POINTER_INPUTS;
  55996. private constructor();
  55997. /**
  55998. * Creates a new DeviceInputSystem instance
  55999. * @param engine Engine to pull input element from
  56000. * @returns The new instance
  56001. */
  56002. static Create(engine: Engine): DeviceInputSystem;
  56003. /**
  56004. * Checks for current device input value, given an id and input index
  56005. * @param deviceName Id of connected device
  56006. * @param inputIndex Index of device input
  56007. * @returns Current value of input
  56008. */
  56009. /**
  56010. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56011. * @param deviceType Enum specifiying device type
  56012. * @param deviceSlot "Slot" or index that device is referenced in
  56013. * @param inputIndex Id of input to be checked
  56014. * @returns Current value of input
  56015. */
  56016. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56017. /**
  56018. * Dispose of all the eventlisteners
  56019. */
  56020. dispose(): void;
  56021. /**
  56022. * Checks for existing connections to devices and register them, if necessary
  56023. * Currently handles gamepads and mouse
  56024. */
  56025. private _checkForConnectedDevices;
  56026. /**
  56027. * Add a gamepad to the DeviceInputSystem
  56028. * @param gamepad A single DOM Gamepad object
  56029. */
  56030. private _addGamePad;
  56031. /**
  56032. * Add pointer device to DeviceInputSystem
  56033. * @param deviceType Type of Pointer to add
  56034. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  56035. * @param currentX Current X at point of adding
  56036. * @param currentY Current Y at point of adding
  56037. */
  56038. private _addPointerDevice;
  56039. /**
  56040. * Add device and inputs to device array
  56041. * @param deviceType Enum specifiying device type
  56042. * @param deviceSlot "Slot" or index that device is referenced in
  56043. * @param numberOfInputs Number of input entries to create for given device
  56044. */
  56045. private _registerDevice;
  56046. /**
  56047. * Given a specific device name, remove that device from the device map
  56048. * @param deviceType Enum specifiying device type
  56049. * @param deviceSlot "Slot" or index that device is referenced in
  56050. */
  56051. private _unregisterDevice;
  56052. /**
  56053. * Handle all actions that come from keyboard interaction
  56054. */
  56055. private _handleKeyActions;
  56056. /**
  56057. * Handle all actions that come from pointer interaction
  56058. */
  56059. private _handlePointerActions;
  56060. /**
  56061. * Handle all actions that come from gamepad interaction
  56062. */
  56063. private _handleGamepadActions;
  56064. /**
  56065. * Update all non-event based devices with each frame
  56066. * @param deviceType Enum specifiying device type
  56067. * @param deviceSlot "Slot" or index that device is referenced in
  56068. * @param inputIndex Id of input to be checked
  56069. */
  56070. private _updateDevice;
  56071. /**
  56072. * Gets DeviceType from the device name
  56073. * @param deviceName Name of Device from DeviceInputSystem
  56074. * @returns DeviceType enum value
  56075. */
  56076. private _getGamepadDeviceType;
  56077. }
  56078. }
  56079. declare module BABYLON {
  56080. /**
  56081. * Type to handle enforcement of inputs
  56082. */
  56083. 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;
  56084. }
  56085. declare module BABYLON {
  56086. /**
  56087. * Class that handles all input for a specific device
  56088. */
  56089. export class DeviceSource<T extends DeviceType> {
  56090. /** Type of device */
  56091. readonly deviceType: DeviceType;
  56092. /** "Slot" or index that device is referenced in */
  56093. readonly deviceSlot: number;
  56094. /**
  56095. * Observable to handle device input changes per device
  56096. */
  56097. readonly onInputChangedObservable: Observable<{
  56098. inputIndex: DeviceInput<T>;
  56099. previousState: Nullable<number>;
  56100. currentState: Nullable<number>;
  56101. }>;
  56102. private readonly _deviceInputSystem;
  56103. /**
  56104. * Default Constructor
  56105. * @param deviceInputSystem Reference to DeviceInputSystem
  56106. * @param deviceType Type of device
  56107. * @param deviceSlot "Slot" or index that device is referenced in
  56108. */
  56109. constructor(deviceInputSystem: DeviceInputSystem,
  56110. /** Type of device */
  56111. deviceType: DeviceType,
  56112. /** "Slot" or index that device is referenced in */
  56113. deviceSlot?: number);
  56114. /**
  56115. * Get input for specific input
  56116. * @param inputIndex index of specific input on device
  56117. * @returns Input value from DeviceInputSystem
  56118. */
  56119. getInput(inputIndex: DeviceInput<T>): number;
  56120. }
  56121. /**
  56122. * Class to keep track of devices
  56123. */
  56124. export class DeviceSourceManager implements IDisposable {
  56125. /**
  56126. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56127. */
  56128. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56129. /**
  56130. * Observable to be triggered when after a device is disconnected
  56131. */
  56132. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56133. private readonly _devices;
  56134. private readonly _firstDevice;
  56135. private readonly _deviceInputSystem;
  56136. /**
  56137. * Default Constructor
  56138. * @param engine engine to pull input element from
  56139. */
  56140. constructor(engine: Engine);
  56141. /**
  56142. * Gets a DeviceSource, given a type and slot
  56143. * @param deviceType Enum specifying device type
  56144. * @param deviceSlot "Slot" or index that device is referenced in
  56145. * @returns DeviceSource object
  56146. */
  56147. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56148. /**
  56149. * Gets an array of DeviceSource objects for a given device type
  56150. * @param deviceType Enum specifying device type
  56151. * @returns Array of DeviceSource objects
  56152. */
  56153. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56154. /**
  56155. * Returns a read-only list of all available devices
  56156. * @returns Read-only array with active devices
  56157. */
  56158. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56159. /**
  56160. * Dispose of DeviceInputSystem and other parts
  56161. */
  56162. dispose(): void;
  56163. /**
  56164. * Function to add device name to device list
  56165. * @param deviceType Enum specifying device type
  56166. * @param deviceSlot "Slot" or index that device is referenced in
  56167. */
  56168. private _addDevice;
  56169. /**
  56170. * Function to remove device name to device list
  56171. * @param deviceType Enum specifying device type
  56172. * @param deviceSlot "Slot" or index that device is referenced in
  56173. */
  56174. private _removeDevice;
  56175. /**
  56176. * Updates array storing first connected device of each type
  56177. * @param type Type of Device
  56178. */
  56179. private _updateFirstDevices;
  56180. }
  56181. }
  56182. declare module BABYLON {
  56183. /**
  56184. * Options to create the null engine
  56185. */
  56186. export class NullEngineOptions {
  56187. /**
  56188. * Render width (Default: 512)
  56189. */
  56190. renderWidth: number;
  56191. /**
  56192. * Render height (Default: 256)
  56193. */
  56194. renderHeight: number;
  56195. /**
  56196. * Texture size (Default: 512)
  56197. */
  56198. textureSize: number;
  56199. /**
  56200. * If delta time between frames should be constant
  56201. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56202. */
  56203. deterministicLockstep: boolean;
  56204. /**
  56205. * Maximum about of steps between frames (Default: 4)
  56206. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56207. */
  56208. lockstepMaxSteps: number;
  56209. /**
  56210. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56211. */
  56212. useHighPrecisionMatrix?: boolean;
  56213. }
  56214. /**
  56215. * The null engine class provides support for headless version of babylon.js.
  56216. * This can be used in server side scenario or for testing purposes
  56217. */
  56218. export class NullEngine extends Engine {
  56219. private _options;
  56220. /**
  56221. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56222. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56223. * @returns true if engine is in deterministic lock step mode
  56224. */
  56225. isDeterministicLockStep(): boolean;
  56226. /**
  56227. * Gets the max steps when engine is running in deterministic lock step
  56228. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56229. * @returns the max steps
  56230. */
  56231. getLockstepMaxSteps(): number;
  56232. /**
  56233. * Gets the current hardware scaling level.
  56234. * By default the hardware scaling level is computed from the window device ratio.
  56235. * 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.
  56236. * @returns a number indicating the current hardware scaling level
  56237. */
  56238. getHardwareScalingLevel(): number;
  56239. constructor(options?: NullEngineOptions);
  56240. /**
  56241. * Creates a vertex buffer
  56242. * @param vertices the data for the vertex buffer
  56243. * @returns the new WebGL static buffer
  56244. */
  56245. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56246. /**
  56247. * Creates a new index buffer
  56248. * @param indices defines the content of the index buffer
  56249. * @param updatable defines if the index buffer must be updatable
  56250. * @returns a new webGL buffer
  56251. */
  56252. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56253. /**
  56254. * Clear the current render buffer or the current render target (if any is set up)
  56255. * @param color defines the color to use
  56256. * @param backBuffer defines if the back buffer must be cleared
  56257. * @param depth defines if the depth buffer must be cleared
  56258. * @param stencil defines if the stencil buffer must be cleared
  56259. */
  56260. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56261. /**
  56262. * Gets the current render width
  56263. * @param useScreen defines if screen size must be used (or the current render target if any)
  56264. * @returns a number defining the current render width
  56265. */
  56266. getRenderWidth(useScreen?: boolean): number;
  56267. /**
  56268. * Gets the current render height
  56269. * @param useScreen defines if screen size must be used (or the current render target if any)
  56270. * @returns a number defining the current render height
  56271. */
  56272. getRenderHeight(useScreen?: boolean): number;
  56273. /**
  56274. * Set the WebGL's viewport
  56275. * @param viewport defines the viewport element to be used
  56276. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56277. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56278. */
  56279. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56280. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56281. /**
  56282. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56283. * @param pipelineContext defines the pipeline context to use
  56284. * @param uniformsNames defines the list of uniform names
  56285. * @returns an array of webGL uniform locations
  56286. */
  56287. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56288. /**
  56289. * Gets the lsit of active attributes for a given webGL program
  56290. * @param pipelineContext defines the pipeline context to use
  56291. * @param attributesNames defines the list of attribute names to get
  56292. * @returns an array of indices indicating the offset of each attribute
  56293. */
  56294. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56295. /**
  56296. * Binds an effect to the webGL context
  56297. * @param effect defines the effect to bind
  56298. */
  56299. bindSamplers(effect: Effect): void;
  56300. /**
  56301. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56302. * @param effect defines the effect to activate
  56303. */
  56304. enableEffect(effect: Effect): void;
  56305. /**
  56306. * Set various states to the webGL context
  56307. * @param culling defines backface culling state
  56308. * @param zOffset defines the value to apply to zOffset (0 by default)
  56309. * @param force defines if states must be applied even if cache is up to date
  56310. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56311. */
  56312. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56313. /**
  56314. * Set the value of an uniform to an array of int32
  56315. * @param uniform defines the webGL uniform location where to store the value
  56316. * @param array defines the array of int32 to store
  56317. * @returns true if value was set
  56318. */
  56319. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56320. /**
  56321. * Set the value of an uniform to an array of int32 (stored as vec2)
  56322. * @param uniform defines the webGL uniform location where to store the value
  56323. * @param array defines the array of int32 to store
  56324. * @returns true if value was set
  56325. */
  56326. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56327. /**
  56328. * Set the value of an uniform to an array of int32 (stored as vec3)
  56329. * @param uniform defines the webGL uniform location where to store the value
  56330. * @param array defines the array of int32 to store
  56331. * @returns true if value was set
  56332. */
  56333. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56334. /**
  56335. * Set the value of an uniform to an array of int32 (stored as vec4)
  56336. * @param uniform defines the webGL uniform location where to store the value
  56337. * @param array defines the array of int32 to store
  56338. * @returns true if value was set
  56339. */
  56340. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56341. /**
  56342. * Set the value of an uniform to an array of float32
  56343. * @param uniform defines the webGL uniform location where to store the value
  56344. * @param array defines the array of float32 to store
  56345. * @returns true if value was set
  56346. */
  56347. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56348. /**
  56349. * Set the value of an uniform to an array of float32 (stored as vec2)
  56350. * @param uniform defines the webGL uniform location where to store the value
  56351. * @param array defines the array of float32 to store
  56352. * @returns true if value was set
  56353. */
  56354. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56355. /**
  56356. * Set the value of an uniform to an array of float32 (stored as vec3)
  56357. * @param uniform defines the webGL uniform location where to store the value
  56358. * @param array defines the array of float32 to store
  56359. * @returns true if value was set
  56360. */
  56361. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56362. /**
  56363. * Set the value of an uniform to an array of float32 (stored as vec4)
  56364. * @param uniform defines the webGL uniform location where to store the value
  56365. * @param array defines the array of float32 to store
  56366. * @returns true if value was set
  56367. */
  56368. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56369. /**
  56370. * Set the value of an uniform to an array of number
  56371. * @param uniform defines the webGL uniform location where to store the value
  56372. * @param array defines the array of number to store
  56373. * @returns true if value was set
  56374. */
  56375. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56376. /**
  56377. * Set the value of an uniform to an array of number (stored as vec2)
  56378. * @param uniform defines the webGL uniform location where to store the value
  56379. * @param array defines the array of number to store
  56380. * @returns true if value was set
  56381. */
  56382. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56383. /**
  56384. * Set the value of an uniform to an array of number (stored as vec3)
  56385. * @param uniform defines the webGL uniform location where to store the value
  56386. * @param array defines the array of number to store
  56387. * @returns true if value was set
  56388. */
  56389. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56390. /**
  56391. * Set the value of an uniform to an array of number (stored as vec4)
  56392. * @param uniform defines the webGL uniform location where to store the value
  56393. * @param array defines the array of number to store
  56394. * @returns true if value was set
  56395. */
  56396. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56397. /**
  56398. * Set the value of an uniform to an array of float32 (stored as matrices)
  56399. * @param uniform defines the webGL uniform location where to store the value
  56400. * @param matrices defines the array of float32 to store
  56401. * @returns true if value was set
  56402. */
  56403. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56404. /**
  56405. * Set the value of an uniform to a matrix (3x3)
  56406. * @param uniform defines the webGL uniform location where to store the value
  56407. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56408. * @returns true if value was set
  56409. */
  56410. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56411. /**
  56412. * Set the value of an uniform to a matrix (2x2)
  56413. * @param uniform defines the webGL uniform location where to store the value
  56414. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56415. * @returns true if value was set
  56416. */
  56417. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56418. /**
  56419. * Set the value of an uniform to a number (float)
  56420. * @param uniform defines the webGL uniform location where to store the value
  56421. * @param value defines the float number to store
  56422. * @returns true if value was set
  56423. */
  56424. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56425. /**
  56426. * Set the value of an uniform to a vec2
  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. * @returns true if value was set
  56431. */
  56432. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56433. /**
  56434. * Set the value of an uniform to a vec3
  56435. * @param uniform defines the webGL uniform location where to store the value
  56436. * @param x defines the 1st component of the value
  56437. * @param y defines the 2nd component of the value
  56438. * @param z defines the 3rd component of the value
  56439. * @returns true if value was set
  56440. */
  56441. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56442. /**
  56443. * Set the value of an uniform to a boolean
  56444. * @param uniform defines the webGL uniform location where to store the value
  56445. * @param bool defines the boolean to store
  56446. * @returns true if value was set
  56447. */
  56448. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56449. /**
  56450. * Set the value of an uniform to a vec4
  56451. * @param uniform defines the webGL uniform location where to store the value
  56452. * @param x defines the 1st component of the value
  56453. * @param y defines the 2nd component of the value
  56454. * @param z defines the 3rd component of the value
  56455. * @param w defines the 4th component of the value
  56456. * @returns true if value was set
  56457. */
  56458. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56459. /**
  56460. * Sets the current alpha mode
  56461. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56462. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56463. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56464. */
  56465. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56466. /**
  56467. * Bind webGl buffers directly to the webGL context
  56468. * @param vertexBuffers defines the vertex buffer to bind
  56469. * @param indexBuffer defines the index buffer to bind
  56470. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56471. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56472. * @param effect defines the effect associated with the vertex buffer
  56473. */
  56474. bindBuffers(vertexBuffers: {
  56475. [key: string]: VertexBuffer;
  56476. }, indexBuffer: DataBuffer, effect: Effect): void;
  56477. /**
  56478. * Force the entire cache to be cleared
  56479. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56480. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56481. */
  56482. wipeCaches(bruteForce?: boolean): void;
  56483. /**
  56484. * Send a draw order
  56485. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56486. * @param indexStart defines the starting index
  56487. * @param indexCount defines the number of index to draw
  56488. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56489. */
  56490. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56491. /**
  56492. * Draw a list of indexed primitives
  56493. * @param fillMode defines the primitive to use
  56494. * @param indexStart defines the starting index
  56495. * @param indexCount defines the number of index to draw
  56496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56497. */
  56498. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56499. /**
  56500. * Draw a list of unindexed primitives
  56501. * @param fillMode defines the primitive to use
  56502. * @param verticesStart defines the index of first vertex to draw
  56503. * @param verticesCount defines the count of vertices to draw
  56504. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56505. */
  56506. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56507. /** @hidden */
  56508. _createTexture(): WebGLTexture;
  56509. /** @hidden */
  56510. _releaseTexture(texture: InternalTexture): void;
  56511. /**
  56512. * Usually called from Texture.ts.
  56513. * Passed information to create a WebGLTexture
  56514. * @param urlArg defines a value which contains one of the following:
  56515. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56516. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56517. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56519. * @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)
  56520. * @param scene needed for loading to the correct scene
  56521. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56522. * @param onLoad optional callback to be called upon successful completion
  56523. * @param onError optional callback to be called upon failure
  56524. * @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
  56525. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56526. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56527. * @param forcedExtension defines the extension to use to pick the right loader
  56528. * @param mimeType defines an optional mime type
  56529. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56530. */
  56531. 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;
  56532. /**
  56533. * Creates a new render target texture
  56534. * @param size defines the size of the texture
  56535. * @param options defines the options used to create the texture
  56536. * @returns a new render target texture stored in an InternalTexture
  56537. */
  56538. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56539. /**
  56540. * Update the sampling mode of a given texture
  56541. * @param samplingMode defines the required sampling mode
  56542. * @param texture defines the texture to update
  56543. */
  56544. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56545. /**
  56546. * Binds the frame buffer to the specified texture.
  56547. * @param texture The texture to render to or null for the default canvas
  56548. * @param faceIndex The face of the texture to render to in case of cube texture
  56549. * @param requiredWidth The width of the target to render to
  56550. * @param requiredHeight The height of the target to render to
  56551. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56552. * @param lodLevel defines le lod level to bind to the frame buffer
  56553. */
  56554. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56555. /**
  56556. * Unbind the current render target texture from the webGL context
  56557. * @param texture defines the render target texture to unbind
  56558. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56559. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56560. */
  56561. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56562. /**
  56563. * Creates a dynamic vertex buffer
  56564. * @param vertices the data for the dynamic vertex buffer
  56565. * @returns the new WebGL dynamic buffer
  56566. */
  56567. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56568. /**
  56569. * Update the content of a dynamic texture
  56570. * @param texture defines the texture to update
  56571. * @param canvas defines the canvas containing the source
  56572. * @param invertY defines if data must be stored with Y axis inverted
  56573. * @param premulAlpha defines if alpha is stored as premultiplied
  56574. * @param format defines the format of the data
  56575. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56576. */
  56577. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56578. /**
  56579. * Gets a boolean indicating if all created effects are ready
  56580. * @returns true if all effects are ready
  56581. */
  56582. areAllEffectsReady(): boolean;
  56583. /**
  56584. * @hidden
  56585. * Get the current error code of the webGL context
  56586. * @returns the error code
  56587. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56588. */
  56589. getError(): number;
  56590. /** @hidden */
  56591. _getUnpackAlignement(): number;
  56592. /** @hidden */
  56593. _unpackFlipY(value: boolean): void;
  56594. /**
  56595. * Update a dynamic index buffer
  56596. * @param indexBuffer defines the target index buffer
  56597. * @param indices defines the data to update
  56598. * @param offset defines the offset in the target index buffer where update should start
  56599. */
  56600. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56601. /**
  56602. * Updates a dynamic vertex buffer.
  56603. * @param vertexBuffer the vertex buffer to update
  56604. * @param vertices the data used to update the vertex buffer
  56605. * @param byteOffset the byte offset of the data (optional)
  56606. * @param byteLength the byte length of the data (optional)
  56607. */
  56608. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56609. /** @hidden */
  56610. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56611. /** @hidden */
  56612. _bindTexture(channel: number, texture: InternalTexture): void;
  56613. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56614. /**
  56615. * 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
  56616. */
  56617. releaseEffects(): void;
  56618. displayLoadingUI(): void;
  56619. hideLoadingUI(): void;
  56620. /** @hidden */
  56621. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56622. /** @hidden */
  56623. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56624. /** @hidden */
  56625. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56626. /** @hidden */
  56627. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56628. }
  56629. }
  56630. declare module BABYLON {
  56631. /**
  56632. * @hidden
  56633. **/
  56634. export class _TimeToken {
  56635. _startTimeQuery: Nullable<WebGLQuery>;
  56636. _endTimeQuery: Nullable<WebGLQuery>;
  56637. _timeElapsedQuery: Nullable<WebGLQuery>;
  56638. _timeElapsedQueryEnded: boolean;
  56639. }
  56640. }
  56641. declare module BABYLON {
  56642. /** @hidden */
  56643. export class _OcclusionDataStorage {
  56644. /** @hidden */
  56645. occlusionInternalRetryCounter: number;
  56646. /** @hidden */
  56647. isOcclusionQueryInProgress: boolean;
  56648. /** @hidden */
  56649. isOccluded: boolean;
  56650. /** @hidden */
  56651. occlusionRetryCount: number;
  56652. /** @hidden */
  56653. occlusionType: number;
  56654. /** @hidden */
  56655. occlusionQueryAlgorithmType: number;
  56656. }
  56657. interface Engine {
  56658. /**
  56659. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56660. * @return the new query
  56661. */
  56662. createQuery(): WebGLQuery;
  56663. /**
  56664. * Delete and release a webGL query
  56665. * @param query defines the query to delete
  56666. * @return the current engine
  56667. */
  56668. deleteQuery(query: WebGLQuery): Engine;
  56669. /**
  56670. * Check if a given query has resolved and got its value
  56671. * @param query defines the query to check
  56672. * @returns true if the query got its value
  56673. */
  56674. isQueryResultAvailable(query: WebGLQuery): boolean;
  56675. /**
  56676. * Gets the value of a given query
  56677. * @param query defines the query to check
  56678. * @returns the value of the query
  56679. */
  56680. getQueryResult(query: WebGLQuery): number;
  56681. /**
  56682. * Initiates an occlusion query
  56683. * @param algorithmType defines the algorithm to use
  56684. * @param query defines the query to use
  56685. * @returns the current engine
  56686. * @see https://doc.babylonjs.com/features/occlusionquery
  56687. */
  56688. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56689. /**
  56690. * Ends an occlusion query
  56691. * @see https://doc.babylonjs.com/features/occlusionquery
  56692. * @param algorithmType defines the algorithm to use
  56693. * @returns the current engine
  56694. */
  56695. endOcclusionQuery(algorithmType: number): Engine;
  56696. /**
  56697. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56698. * Please note that only one query can be issued at a time
  56699. * @returns a time token used to track the time span
  56700. */
  56701. startTimeQuery(): Nullable<_TimeToken>;
  56702. /**
  56703. * Ends a time query
  56704. * @param token defines the token used to measure the time span
  56705. * @returns the time spent (in ns)
  56706. */
  56707. endTimeQuery(token: _TimeToken): int;
  56708. /** @hidden */
  56709. _currentNonTimestampToken: Nullable<_TimeToken>;
  56710. /** @hidden */
  56711. _createTimeQuery(): WebGLQuery;
  56712. /** @hidden */
  56713. _deleteTimeQuery(query: WebGLQuery): void;
  56714. /** @hidden */
  56715. _getGlAlgorithmType(algorithmType: number): number;
  56716. /** @hidden */
  56717. _getTimeQueryResult(query: WebGLQuery): any;
  56718. /** @hidden */
  56719. _getTimeQueryAvailability(query: WebGLQuery): any;
  56720. }
  56721. interface AbstractMesh {
  56722. /**
  56723. * Backing filed
  56724. * @hidden
  56725. */
  56726. __occlusionDataStorage: _OcclusionDataStorage;
  56727. /**
  56728. * Access property
  56729. * @hidden
  56730. */
  56731. _occlusionDataStorage: _OcclusionDataStorage;
  56732. /**
  56733. * 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.
  56734. * The default value is -1 which means don't break the query and wait till the result
  56735. * @see https://doc.babylonjs.com/features/occlusionquery
  56736. */
  56737. occlusionRetryCount: number;
  56738. /**
  56739. * 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:
  56740. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56741. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56742. * * 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.
  56743. * @see https://doc.babylonjs.com/features/occlusionquery
  56744. */
  56745. occlusionType: number;
  56746. /**
  56747. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56748. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56749. * * 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.
  56750. * @see https://doc.babylonjs.com/features/occlusionquery
  56751. */
  56752. occlusionQueryAlgorithmType: number;
  56753. /**
  56754. * 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
  56755. * @see https://doc.babylonjs.com/features/occlusionquery
  56756. */
  56757. isOccluded: boolean;
  56758. /**
  56759. * Flag to check the progress status of the query
  56760. * @see https://doc.babylonjs.com/features/occlusionquery
  56761. */
  56762. isOcclusionQueryInProgress: boolean;
  56763. }
  56764. }
  56765. declare module BABYLON {
  56766. /** @hidden */
  56767. export var _forceTransformFeedbackToBundle: boolean;
  56768. interface Engine {
  56769. /**
  56770. * Creates a webGL transform feedback object
  56771. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56772. * @returns the webGL transform feedback object
  56773. */
  56774. createTransformFeedback(): WebGLTransformFeedback;
  56775. /**
  56776. * Delete a webGL transform feedback object
  56777. * @param value defines the webGL transform feedback object to delete
  56778. */
  56779. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56780. /**
  56781. * Bind a webGL transform feedback object to the webgl context
  56782. * @param value defines the webGL transform feedback object to bind
  56783. */
  56784. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56785. /**
  56786. * Begins a transform feedback operation
  56787. * @param usePoints defines if points or triangles must be used
  56788. */
  56789. beginTransformFeedback(usePoints: boolean): void;
  56790. /**
  56791. * Ends a transform feedback operation
  56792. */
  56793. endTransformFeedback(): void;
  56794. /**
  56795. * Specify the varyings to use with transform feedback
  56796. * @param program defines the associated webGL program
  56797. * @param value defines the list of strings representing the varying names
  56798. */
  56799. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56800. /**
  56801. * Bind a webGL buffer for a transform feedback operation
  56802. * @param value defines the webGL buffer to bind
  56803. */
  56804. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56805. }
  56806. }
  56807. declare module BABYLON {
  56808. /**
  56809. * Class used to define an additional view for the engine
  56810. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56811. */
  56812. export class EngineView {
  56813. /** Defines the canvas where to render the view */
  56814. target: HTMLCanvasElement;
  56815. /** Defines an optional camera used to render the view (will use active camera else) */
  56816. camera?: Camera;
  56817. }
  56818. interface Engine {
  56819. /**
  56820. * Gets or sets the HTML element to use for attaching events
  56821. */
  56822. inputElement: Nullable<HTMLElement>;
  56823. /**
  56824. * Gets the current engine view
  56825. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56826. */
  56827. activeView: Nullable<EngineView>;
  56828. /** Gets or sets the list of views */
  56829. views: EngineView[];
  56830. /**
  56831. * Register a new child canvas
  56832. * @param canvas defines the canvas to register
  56833. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56834. * @returns the associated view
  56835. */
  56836. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56837. /**
  56838. * Remove a registered child canvas
  56839. * @param canvas defines the canvas to remove
  56840. * @returns the current engine
  56841. */
  56842. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56843. }
  56844. }
  56845. declare module BABYLON {
  56846. interface Engine {
  56847. /** @hidden */
  56848. _excludedCompressedTextures: string[];
  56849. /** @hidden */
  56850. _textureFormatInUse: string;
  56851. /**
  56852. * Gets the list of texture formats supported
  56853. */
  56854. readonly texturesSupported: Array<string>;
  56855. /**
  56856. * Gets the texture format in use
  56857. */
  56858. readonly textureFormatInUse: Nullable<string>;
  56859. /**
  56860. * Set the compressed texture extensions or file names to skip.
  56861. *
  56862. * @param skippedFiles defines the list of those texture files you want to skip
  56863. * Example: [".dds", ".env", "myfile.png"]
  56864. */
  56865. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56866. /**
  56867. * Set the compressed texture format to use, based on the formats you have, and the formats
  56868. * supported by the hardware / browser.
  56869. *
  56870. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56871. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56872. * to API arguments needed to compressed textures. This puts the burden on the container
  56873. * generator to house the arcane code for determining these for current & future formats.
  56874. *
  56875. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56876. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56877. *
  56878. * Note: The result of this call is not taken into account when a texture is base64.
  56879. *
  56880. * @param formatsAvailable defines the list of those format families you have created
  56881. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56882. *
  56883. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56884. * @returns The extension selected.
  56885. */
  56886. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56887. }
  56888. }
  56889. declare module BABYLON {
  56890. /** @hidden */
  56891. export var rgbdEncodePixelShader: {
  56892. name: string;
  56893. shader: string;
  56894. };
  56895. }
  56896. declare module BABYLON {
  56897. /**
  56898. * Raw texture data and descriptor sufficient for WebGL texture upload
  56899. */
  56900. export interface EnvironmentTextureInfo {
  56901. /**
  56902. * Version of the environment map
  56903. */
  56904. version: number;
  56905. /**
  56906. * Width of image
  56907. */
  56908. width: number;
  56909. /**
  56910. * Irradiance information stored in the file.
  56911. */
  56912. irradiance: any;
  56913. /**
  56914. * Specular information stored in the file.
  56915. */
  56916. specular: any;
  56917. }
  56918. /**
  56919. * Defines One Image in the file. It requires only the position in the file
  56920. * as well as the length.
  56921. */
  56922. interface BufferImageData {
  56923. /**
  56924. * Length of the image data.
  56925. */
  56926. length: number;
  56927. /**
  56928. * Position of the data from the null terminator delimiting the end of the JSON.
  56929. */
  56930. position: number;
  56931. }
  56932. /**
  56933. * Defines the specular data enclosed in the file.
  56934. * This corresponds to the version 1 of the data.
  56935. */
  56936. export interface EnvironmentTextureSpecularInfoV1 {
  56937. /**
  56938. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56939. */
  56940. specularDataPosition?: number;
  56941. /**
  56942. * This contains all the images data needed to reconstruct the cubemap.
  56943. */
  56944. mipmaps: Array<BufferImageData>;
  56945. /**
  56946. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56947. */
  56948. lodGenerationScale: number;
  56949. }
  56950. /**
  56951. * Sets of helpers addressing the serialization and deserialization of environment texture
  56952. * stored in a BabylonJS env file.
  56953. * Those files are usually stored as .env files.
  56954. */
  56955. export class EnvironmentTextureTools {
  56956. /**
  56957. * Magic number identifying the env file.
  56958. */
  56959. private static _MagicBytes;
  56960. /**
  56961. * Gets the environment info from an env file.
  56962. * @param data The array buffer containing the .env bytes.
  56963. * @returns the environment file info (the json header) if successfully parsed.
  56964. */
  56965. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56966. /**
  56967. * Creates an environment texture from a loaded cube texture.
  56968. * @param texture defines the cube texture to convert in env file
  56969. * @return a promise containing the environment data if succesfull.
  56970. */
  56971. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56972. /**
  56973. * Creates a JSON representation of the spherical data.
  56974. * @param texture defines the texture containing the polynomials
  56975. * @return the JSON representation of the spherical info
  56976. */
  56977. private static _CreateEnvTextureIrradiance;
  56978. /**
  56979. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56980. * @param data the image data
  56981. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56982. * @return the views described by info providing access to the underlying buffer
  56983. */
  56984. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56985. /**
  56986. * Uploads the texture info contained in the env file to the GPU.
  56987. * @param texture defines the internal texture to upload to
  56988. * @param data defines the data to load
  56989. * @param info defines the texture info retrieved through the GetEnvInfo method
  56990. * @returns a promise
  56991. */
  56992. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56993. private static _OnImageReadyAsync;
  56994. /**
  56995. * Uploads the levels of image data to the GPU.
  56996. * @param texture defines the internal texture to upload to
  56997. * @param imageData defines the array buffer views of image data [mipmap][face]
  56998. * @returns a promise
  56999. */
  57000. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57001. /**
  57002. * Uploads spherical polynomials information to the texture.
  57003. * @param texture defines the texture we are trying to upload the information to
  57004. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57005. */
  57006. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57007. /** @hidden */
  57008. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57009. }
  57010. }
  57011. declare module BABYLON {
  57012. /**
  57013. * Class used to inline functions in shader code
  57014. */
  57015. export class ShaderCodeInliner {
  57016. private static readonly _RegexpFindFunctionNameAndType;
  57017. private _sourceCode;
  57018. private _functionDescr;
  57019. private _numMaxIterations;
  57020. /** Gets or sets the token used to mark the functions to inline */
  57021. inlineToken: string;
  57022. /** Gets or sets the debug mode */
  57023. debug: boolean;
  57024. /** Gets the code after the inlining process */
  57025. get code(): string;
  57026. /**
  57027. * Initializes the inliner
  57028. * @param sourceCode shader code source to inline
  57029. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57030. */
  57031. constructor(sourceCode: string, numMaxIterations?: number);
  57032. /**
  57033. * Start the processing of the shader code
  57034. */
  57035. processCode(): void;
  57036. private _collectFunctions;
  57037. private _processInlining;
  57038. private _extractBetweenMarkers;
  57039. private _skipWhitespaces;
  57040. private _removeComments;
  57041. private _replaceFunctionCallsByCode;
  57042. private _findBackward;
  57043. private _escapeRegExp;
  57044. private _replaceNames;
  57045. }
  57046. }
  57047. declare module BABYLON {
  57048. /**
  57049. * Container for accessors for natively-stored mesh data buffers.
  57050. */
  57051. class NativeDataBuffer extends DataBuffer {
  57052. /**
  57053. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57054. */
  57055. nativeIndexBuffer?: any;
  57056. /**
  57057. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57058. */
  57059. nativeVertexBuffer?: any;
  57060. }
  57061. /** @hidden */
  57062. class NativeTexture extends InternalTexture {
  57063. getInternalTexture(): InternalTexture;
  57064. getViewCount(): number;
  57065. }
  57066. /** @hidden */
  57067. export class NativeEngine extends Engine {
  57068. private readonly _native;
  57069. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57070. private readonly INVALID_HANDLE;
  57071. private _boundBuffersVertexArray;
  57072. private _currentDepthTest;
  57073. getHardwareScalingLevel(): number;
  57074. constructor();
  57075. dispose(): void;
  57076. /**
  57077. * Can be used to override the current requestAnimationFrame requester.
  57078. * @hidden
  57079. */
  57080. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57081. /**
  57082. * Override default engine behavior.
  57083. * @param color
  57084. * @param backBuffer
  57085. * @param depth
  57086. * @param stencil
  57087. */
  57088. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57089. /**
  57090. * Gets host document
  57091. * @returns the host document object
  57092. */
  57093. getHostDocument(): Nullable<Document>;
  57094. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57095. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57096. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57097. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57098. [key: string]: VertexBuffer;
  57099. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57100. bindBuffers(vertexBuffers: {
  57101. [key: string]: VertexBuffer;
  57102. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57103. recordVertexArrayObject(vertexBuffers: {
  57104. [key: string]: VertexBuffer;
  57105. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57106. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57107. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57108. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57109. /**
  57110. * Draw a list of indexed primitives
  57111. * @param fillMode defines the primitive to use
  57112. * @param indexStart defines the starting index
  57113. * @param indexCount defines the number of index to draw
  57114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57115. */
  57116. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57117. /**
  57118. * Draw a list of unindexed primitives
  57119. * @param fillMode defines the primitive to use
  57120. * @param verticesStart defines the index of first vertex to draw
  57121. * @param verticesCount defines the count of vertices to draw
  57122. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57123. */
  57124. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57125. createPipelineContext(): IPipelineContext;
  57126. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57127. /** @hidden */
  57128. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57129. /** @hidden */
  57130. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57131. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57132. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57133. protected _setProgram(program: WebGLProgram): void;
  57134. _releaseEffect(effect: Effect): void;
  57135. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57136. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57137. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57138. bindSamplers(effect: Effect): void;
  57139. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57140. getRenderWidth(useScreen?: boolean): number;
  57141. getRenderHeight(useScreen?: boolean): number;
  57142. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57143. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57144. /**
  57145. * Set the z offset to apply to current rendering
  57146. * @param value defines the offset to apply
  57147. */
  57148. setZOffset(value: number): void;
  57149. /**
  57150. * Gets the current value of the zOffset
  57151. * @returns the current zOffset state
  57152. */
  57153. getZOffset(): number;
  57154. /**
  57155. * Enable or disable depth buffering
  57156. * @param enable defines the state to set
  57157. */
  57158. setDepthBuffer(enable: boolean): void;
  57159. /**
  57160. * Gets a boolean indicating if depth writing is enabled
  57161. * @returns the current depth writing state
  57162. */
  57163. getDepthWrite(): boolean;
  57164. setDepthFunctionToGreater(): void;
  57165. setDepthFunctionToGreaterOrEqual(): void;
  57166. setDepthFunctionToLess(): void;
  57167. setDepthFunctionToLessOrEqual(): void;
  57168. /**
  57169. * Enable or disable depth writing
  57170. * @param enable defines the state to set
  57171. */
  57172. setDepthWrite(enable: boolean): void;
  57173. /**
  57174. * Enable or disable color writing
  57175. * @param enable defines the state to set
  57176. */
  57177. setColorWrite(enable: boolean): void;
  57178. /**
  57179. * Gets a boolean indicating if color writing is enabled
  57180. * @returns the current color writing state
  57181. */
  57182. getColorWrite(): boolean;
  57183. /**
  57184. * Sets alpha constants used by some alpha blending modes
  57185. * @param r defines the red component
  57186. * @param g defines the green component
  57187. * @param b defines the blue component
  57188. * @param a defines the alpha component
  57189. */
  57190. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57191. /**
  57192. * Sets the current alpha mode
  57193. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57194. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57195. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57196. */
  57197. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57198. /**
  57199. * Gets the current alpha mode
  57200. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57201. * @returns the current alpha mode
  57202. */
  57203. getAlphaMode(): number;
  57204. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57205. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57206. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57207. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57208. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57209. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57210. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57211. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57212. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57213. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57214. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57215. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57216. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57217. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57218. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57219. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57220. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57221. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57222. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57223. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57224. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57225. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57226. wipeCaches(bruteForce?: boolean): void;
  57227. _createTexture(): WebGLTexture;
  57228. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57229. /**
  57230. * Update the content of a dynamic texture
  57231. * @param texture defines the texture to update
  57232. * @param canvas defines the canvas containing the source
  57233. * @param invertY defines if data must be stored with Y axis inverted
  57234. * @param premulAlpha defines if alpha is stored as premultiplied
  57235. * @param format defines the format of the data
  57236. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57237. */
  57238. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57239. /**
  57240. * Usually called from Texture.ts.
  57241. * Passed information to create a WebGLTexture
  57242. * @param url defines a value which contains one of the following:
  57243. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57244. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57245. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57246. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57247. * @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)
  57248. * @param scene needed for loading to the correct scene
  57249. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57250. * @param onLoad optional callback to be called upon successful completion
  57251. * @param onError optional callback to be called upon failure
  57252. * @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
  57253. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57254. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57255. * @param forcedExtension defines the extension to use to pick the right loader
  57256. * @param mimeType defines an optional mime type
  57257. * @param loaderOptions options to be passed to the loader
  57258. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57259. */
  57260. 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;
  57261. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57262. _releaseFramebufferObjects(texture: InternalTexture): void;
  57263. /**
  57264. * Creates a cube texture
  57265. * @param rootUrl defines the url where the files to load is located
  57266. * @param scene defines the current scene
  57267. * @param files defines the list of files to load (1 per face)
  57268. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57269. * @param onLoad defines an optional callback raised when the texture is loaded
  57270. * @param onError defines an optional callback raised if there is an issue to load the texture
  57271. * @param format defines the format of the data
  57272. * @param forcedExtension defines the extension to use to pick the right loader
  57273. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57274. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57275. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57276. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57277. * @returns the cube texture as an InternalTexture
  57278. */
  57279. 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;
  57280. createRenderTargetTexture(size: number | {
  57281. width: number;
  57282. height: number;
  57283. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57284. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57285. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57286. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57287. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57288. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57289. /**
  57290. * Updates a dynamic vertex buffer.
  57291. * @param vertexBuffer the vertex buffer to update
  57292. * @param data the data used to update the vertex buffer
  57293. * @param byteOffset the byte offset of the data (optional)
  57294. * @param byteLength the byte length of the data (optional)
  57295. */
  57296. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57297. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57298. private _updateAnisotropicLevel;
  57299. private _getAddressMode;
  57300. /** @hidden */
  57301. _bindTexture(channel: number, texture: InternalTexture): void;
  57302. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57303. releaseEffects(): void;
  57304. /** @hidden */
  57305. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57306. /** @hidden */
  57307. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57308. /** @hidden */
  57309. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57310. /** @hidden */
  57311. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57312. private _getNativeSamplingMode;
  57313. private _getNativeTextureFormat;
  57314. private _getNativeAlphaMode;
  57315. private _getNativeAttribType;
  57316. }
  57317. }
  57318. declare module BABYLON {
  57319. /**
  57320. * Gather the list of clipboard event types as constants.
  57321. */
  57322. export class ClipboardEventTypes {
  57323. /**
  57324. * The clipboard event is fired when a copy command is active (pressed).
  57325. */
  57326. static readonly COPY: number;
  57327. /**
  57328. * The clipboard event is fired when a cut command is active (pressed).
  57329. */
  57330. static readonly CUT: number;
  57331. /**
  57332. * The clipboard event is fired when a paste command is active (pressed).
  57333. */
  57334. static readonly PASTE: number;
  57335. }
  57336. /**
  57337. * This class is used to store clipboard related info for the onClipboardObservable event.
  57338. */
  57339. export class ClipboardInfo {
  57340. /**
  57341. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57342. */
  57343. type: number;
  57344. /**
  57345. * Defines the related dom event
  57346. */
  57347. event: ClipboardEvent;
  57348. /**
  57349. *Creates an instance of ClipboardInfo.
  57350. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57351. * @param event Defines the related dom event
  57352. */
  57353. constructor(
  57354. /**
  57355. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57356. */
  57357. type: number,
  57358. /**
  57359. * Defines the related dom event
  57360. */
  57361. event: ClipboardEvent);
  57362. /**
  57363. * Get the clipboard event's type from the keycode.
  57364. * @param keyCode Defines the keyCode for the current keyboard event.
  57365. * @return {number}
  57366. */
  57367. static GetTypeFromCharacter(keyCode: number): number;
  57368. }
  57369. }
  57370. declare module BABYLON {
  57371. /**
  57372. * Google Daydream controller
  57373. */
  57374. export class DaydreamController extends WebVRController {
  57375. /**
  57376. * Base Url for the controller model.
  57377. */
  57378. static MODEL_BASE_URL: string;
  57379. /**
  57380. * File name for the controller model.
  57381. */
  57382. static MODEL_FILENAME: string;
  57383. /**
  57384. * Gamepad Id prefix used to identify Daydream Controller.
  57385. */
  57386. static readonly GAMEPAD_ID_PREFIX: string;
  57387. /**
  57388. * Creates a new DaydreamController from a gamepad
  57389. * @param vrGamepad the gamepad that the controller should be created from
  57390. */
  57391. constructor(vrGamepad: any);
  57392. /**
  57393. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57394. * @param scene scene in which to add meshes
  57395. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57396. */
  57397. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57398. /**
  57399. * Called once for each button that changed state since the last frame
  57400. * @param buttonIdx Which button index changed
  57401. * @param state New state of the button
  57402. * @param changes Which properties on the state changed since last frame
  57403. */
  57404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57405. }
  57406. }
  57407. declare module BABYLON {
  57408. /**
  57409. * Gear VR Controller
  57410. */
  57411. export class GearVRController extends WebVRController {
  57412. /**
  57413. * Base Url for the controller model.
  57414. */
  57415. static MODEL_BASE_URL: string;
  57416. /**
  57417. * File name for the controller model.
  57418. */
  57419. static MODEL_FILENAME: string;
  57420. /**
  57421. * Gamepad Id prefix used to identify this controller.
  57422. */
  57423. static readonly GAMEPAD_ID_PREFIX: string;
  57424. private readonly _buttonIndexToObservableNameMap;
  57425. /**
  57426. * Creates a new GearVRController from a gamepad
  57427. * @param vrGamepad the gamepad that the controller should be created from
  57428. */
  57429. constructor(vrGamepad: any);
  57430. /**
  57431. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57432. * @param scene scene in which to add meshes
  57433. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57434. */
  57435. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57436. /**
  57437. * Called once for each button that changed state since the last frame
  57438. * @param buttonIdx Which button index changed
  57439. * @param state New state of the button
  57440. * @param changes Which properties on the state changed since last frame
  57441. */
  57442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57443. }
  57444. }
  57445. declare module BABYLON {
  57446. /**
  57447. * Generic Controller
  57448. */
  57449. export class GenericController extends WebVRController {
  57450. /**
  57451. * Base Url for the controller model.
  57452. */
  57453. static readonly MODEL_BASE_URL: string;
  57454. /**
  57455. * File name for the controller model.
  57456. */
  57457. static readonly MODEL_FILENAME: string;
  57458. /**
  57459. * Creates a new GenericController from a gamepad
  57460. * @param vrGamepad the gamepad that the controller should be created from
  57461. */
  57462. constructor(vrGamepad: any);
  57463. /**
  57464. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57465. * @param scene scene in which to add meshes
  57466. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57467. */
  57468. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57469. /**
  57470. * Called once for each button that changed state since the last frame
  57471. * @param buttonIdx Which button index changed
  57472. * @param state New state of the button
  57473. * @param changes Which properties on the state changed since last frame
  57474. */
  57475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57476. }
  57477. }
  57478. declare module BABYLON {
  57479. /**
  57480. * Oculus Touch Controller
  57481. */
  57482. export class OculusTouchController extends WebVRController {
  57483. /**
  57484. * Base Url for the controller model.
  57485. */
  57486. static MODEL_BASE_URL: string;
  57487. /**
  57488. * File name for the left controller model.
  57489. */
  57490. static MODEL_LEFT_FILENAME: string;
  57491. /**
  57492. * File name for the right controller model.
  57493. */
  57494. static MODEL_RIGHT_FILENAME: string;
  57495. /**
  57496. * Base Url for the Quest controller model.
  57497. */
  57498. static QUEST_MODEL_BASE_URL: string;
  57499. /**
  57500. * @hidden
  57501. * If the controllers are running on a device that needs the updated Quest controller models
  57502. */
  57503. static _IsQuest: boolean;
  57504. /**
  57505. * Fired when the secondary trigger on this controller is modified
  57506. */
  57507. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57508. /**
  57509. * Fired when the thumb rest on this controller is modified
  57510. */
  57511. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57512. /**
  57513. * Creates a new OculusTouchController from a gamepad
  57514. * @param vrGamepad the gamepad that the controller should be created from
  57515. */
  57516. constructor(vrGamepad: any);
  57517. /**
  57518. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57519. * @param scene scene in which to add meshes
  57520. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57521. */
  57522. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57523. /**
  57524. * Fired when the A button on this controller is modified
  57525. */
  57526. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57527. /**
  57528. * Fired when the B button on this controller is modified
  57529. */
  57530. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57531. /**
  57532. * Fired when the X button on this controller is modified
  57533. */
  57534. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57535. /**
  57536. * Fired when the Y button on this controller is modified
  57537. */
  57538. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57539. /**
  57540. * Called once for each button that changed state since the last frame
  57541. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57542. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57543. * 2) secondary trigger (same)
  57544. * 3) A (right) X (left), touch, pressed = value
  57545. * 4) B / Y
  57546. * 5) thumb rest
  57547. * @param buttonIdx Which button index changed
  57548. * @param state New state of the button
  57549. * @param changes Which properties on the state changed since last frame
  57550. */
  57551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /**
  57556. * Vive Controller
  57557. */
  57558. export class ViveController extends WebVRController {
  57559. /**
  57560. * Base Url for the controller model.
  57561. */
  57562. static MODEL_BASE_URL: string;
  57563. /**
  57564. * File name for the controller model.
  57565. */
  57566. static MODEL_FILENAME: string;
  57567. /**
  57568. * Creates a new ViveController from a gamepad
  57569. * @param vrGamepad the gamepad that the controller should be created from
  57570. */
  57571. constructor(vrGamepad: any);
  57572. /**
  57573. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57574. * @param scene scene in which to add meshes
  57575. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57576. */
  57577. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57578. /**
  57579. * Fired when the left button on this controller is modified
  57580. */
  57581. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57582. /**
  57583. * Fired when the right button on this controller is modified
  57584. */
  57585. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57586. /**
  57587. * Fired when the menu button on this controller is modified
  57588. */
  57589. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57590. /**
  57591. * Called once for each button that changed state since the last frame
  57592. * Vive mapping:
  57593. * 0: touchpad
  57594. * 1: trigger
  57595. * 2: left AND right buttons
  57596. * 3: menu button
  57597. * @param buttonIdx Which button index changed
  57598. * @param state New state of the button
  57599. * @param changes Which properties on the state changed since last frame
  57600. */
  57601. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57602. }
  57603. }
  57604. declare module BABYLON {
  57605. /**
  57606. * Defines the WindowsMotionController object that the state of the windows motion controller
  57607. */
  57608. export class WindowsMotionController extends WebVRController {
  57609. /**
  57610. * The base url used to load the left and right controller models
  57611. */
  57612. static MODEL_BASE_URL: string;
  57613. /**
  57614. * The name of the left controller model file
  57615. */
  57616. static MODEL_LEFT_FILENAME: string;
  57617. /**
  57618. * The name of the right controller model file
  57619. */
  57620. static MODEL_RIGHT_FILENAME: string;
  57621. /**
  57622. * The controller name prefix for this controller type
  57623. */
  57624. static readonly GAMEPAD_ID_PREFIX: string;
  57625. /**
  57626. * The controller id pattern for this controller type
  57627. */
  57628. private static readonly GAMEPAD_ID_PATTERN;
  57629. private _loadedMeshInfo;
  57630. protected readonly _mapping: {
  57631. buttons: string[];
  57632. buttonMeshNames: {
  57633. trigger: string;
  57634. menu: string;
  57635. grip: string;
  57636. thumbstick: string;
  57637. trackpad: string;
  57638. };
  57639. buttonObservableNames: {
  57640. trigger: string;
  57641. menu: string;
  57642. grip: string;
  57643. thumbstick: string;
  57644. trackpad: string;
  57645. };
  57646. axisMeshNames: string[];
  57647. pointingPoseMeshName: string;
  57648. };
  57649. /**
  57650. * Fired when the trackpad on this controller is clicked
  57651. */
  57652. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57653. /**
  57654. * Fired when the trackpad on this controller is modified
  57655. */
  57656. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57657. /**
  57658. * The current x and y values of this controller's trackpad
  57659. */
  57660. trackpad: StickValues;
  57661. /**
  57662. * Creates a new WindowsMotionController from a gamepad
  57663. * @param vrGamepad the gamepad that the controller should be created from
  57664. */
  57665. constructor(vrGamepad: any);
  57666. /**
  57667. * Fired when the trigger on this controller is modified
  57668. */
  57669. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57670. /**
  57671. * Fired when the menu button on this controller is modified
  57672. */
  57673. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57674. /**
  57675. * Fired when the grip button on this controller is modified
  57676. */
  57677. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57678. /**
  57679. * Fired when the thumbstick button on this controller is modified
  57680. */
  57681. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57682. /**
  57683. * Fired when the touchpad button on this controller is modified
  57684. */
  57685. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57686. /**
  57687. * Fired when the touchpad values on this controller are modified
  57688. */
  57689. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57690. protected _updateTrackpad(): void;
  57691. /**
  57692. * Called once per frame by the engine.
  57693. */
  57694. update(): void;
  57695. /**
  57696. * Called once for each button that changed state since the last frame
  57697. * @param buttonIdx Which button index changed
  57698. * @param state New state of the button
  57699. * @param changes Which properties on the state changed since last frame
  57700. */
  57701. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57702. /**
  57703. * Moves the buttons on the controller mesh based on their current state
  57704. * @param buttonName the name of the button to move
  57705. * @param buttonValue the value of the button which determines the buttons new position
  57706. */
  57707. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57708. /**
  57709. * Moves the axis on the controller mesh based on its current state
  57710. * @param axis the index of the axis
  57711. * @param axisValue the value of the axis which determines the meshes new position
  57712. * @hidden
  57713. */
  57714. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57715. /**
  57716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57717. * @param scene scene in which to add meshes
  57718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57719. */
  57720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57721. /**
  57722. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57723. * can be transformed by button presses and axes values, based on this._mapping.
  57724. *
  57725. * @param scene scene in which the meshes exist
  57726. * @param meshes list of meshes that make up the controller model to process
  57727. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57728. */
  57729. private processModel;
  57730. private createMeshInfo;
  57731. /**
  57732. * Gets the ray of the controller in the direction the controller is pointing
  57733. * @param length the length the resulting ray should be
  57734. * @returns a ray in the direction the controller is pointing
  57735. */
  57736. getForwardRay(length?: number): Ray;
  57737. /**
  57738. * Disposes of the controller
  57739. */
  57740. dispose(): void;
  57741. }
  57742. /**
  57743. * This class represents a new windows motion controller in XR.
  57744. */
  57745. export class XRWindowsMotionController extends WindowsMotionController {
  57746. /**
  57747. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57748. */
  57749. protected readonly _mapping: {
  57750. buttons: string[];
  57751. buttonMeshNames: {
  57752. trigger: string;
  57753. menu: string;
  57754. grip: string;
  57755. thumbstick: string;
  57756. trackpad: string;
  57757. };
  57758. buttonObservableNames: {
  57759. trigger: string;
  57760. menu: string;
  57761. grip: string;
  57762. thumbstick: string;
  57763. trackpad: string;
  57764. };
  57765. axisMeshNames: string[];
  57766. pointingPoseMeshName: string;
  57767. };
  57768. /**
  57769. * Construct a new XR-Based windows motion controller
  57770. *
  57771. * @param gamepadInfo the gamepad object from the browser
  57772. */
  57773. constructor(gamepadInfo: any);
  57774. /**
  57775. * holds the thumbstick values (X,Y)
  57776. */
  57777. thumbstickValues: StickValues;
  57778. /**
  57779. * Fired when the thumbstick on this controller is clicked
  57780. */
  57781. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57782. /**
  57783. * Fired when the thumbstick on this controller is modified
  57784. */
  57785. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57786. /**
  57787. * Fired when the touchpad button on this controller is modified
  57788. */
  57789. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57790. /**
  57791. * Fired when the touchpad values on this controller are modified
  57792. */
  57793. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57794. /**
  57795. * Fired when the thumbstick button on this controller is modified
  57796. * here to prevent breaking changes
  57797. */
  57798. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57799. /**
  57800. * updating the thumbstick(!) and not the trackpad.
  57801. * This is named this way due to the difference between WebVR and XR and to avoid
  57802. * changing the parent class.
  57803. */
  57804. protected _updateTrackpad(): void;
  57805. /**
  57806. * Disposes the class with joy
  57807. */
  57808. dispose(): void;
  57809. }
  57810. }
  57811. declare module BABYLON {
  57812. /**
  57813. * A directional light is defined by a direction (what a surprise!).
  57814. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57815. * 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.
  57816. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57817. */
  57818. export class DirectionalLight extends ShadowLight {
  57819. private _shadowFrustumSize;
  57820. /**
  57821. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57822. */
  57823. get shadowFrustumSize(): number;
  57824. /**
  57825. * Specifies a fix frustum size for the shadow generation.
  57826. */
  57827. set shadowFrustumSize(value: number);
  57828. private _shadowOrthoScale;
  57829. /**
  57830. * Gets the shadow projection scale against the optimal computed one.
  57831. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57832. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57833. */
  57834. get shadowOrthoScale(): number;
  57835. /**
  57836. * Sets the shadow projection scale against the optimal computed one.
  57837. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57838. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57839. */
  57840. set shadowOrthoScale(value: number);
  57841. /**
  57842. * Automatically compute the projection matrix to best fit (including all the casters)
  57843. * on each frame.
  57844. */
  57845. autoUpdateExtends: boolean;
  57846. /**
  57847. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57848. * on each frame. autoUpdateExtends must be set to true for this to work
  57849. */
  57850. autoCalcShadowZBounds: boolean;
  57851. private _orthoLeft;
  57852. private _orthoRight;
  57853. private _orthoTop;
  57854. private _orthoBottom;
  57855. /**
  57856. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57857. * The directional light is emitted from everywhere in the given direction.
  57858. * It can cast shadows.
  57859. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57860. * @param name The friendly name of the light
  57861. * @param direction The direction of the light
  57862. * @param scene The scene the light belongs to
  57863. */
  57864. constructor(name: string, direction: Vector3, scene: Scene);
  57865. /**
  57866. * Returns the string "DirectionalLight".
  57867. * @return The class name
  57868. */
  57869. getClassName(): string;
  57870. /**
  57871. * Returns the integer 1.
  57872. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57873. */
  57874. getTypeID(): number;
  57875. /**
  57876. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57877. * Returns the DirectionalLight Shadow projection matrix.
  57878. */
  57879. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57880. /**
  57881. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57882. * Returns the DirectionalLight Shadow projection matrix.
  57883. */
  57884. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57885. /**
  57886. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57887. * Returns the DirectionalLight Shadow projection matrix.
  57888. */
  57889. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57890. protected _buildUniformLayout(): void;
  57891. /**
  57892. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57893. * @param effect The effect to update
  57894. * @param lightIndex The index of the light in the effect to update
  57895. * @returns The directional light
  57896. */
  57897. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57898. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57899. /**
  57900. * Gets the minZ used for shadow according to both the scene and the light.
  57901. *
  57902. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57903. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57904. * @param activeCamera The camera we are returning the min for
  57905. * @returns the depth min z
  57906. */
  57907. getDepthMinZ(activeCamera: Camera): number;
  57908. /**
  57909. * Gets the maxZ used for shadow according to both the scene and the light.
  57910. *
  57911. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57912. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57913. * @param activeCamera The camera we are returning the max for
  57914. * @returns the depth max z
  57915. */
  57916. getDepthMaxZ(activeCamera: Camera): number;
  57917. /**
  57918. * Prepares the list of defines specific to the light type.
  57919. * @param defines the list of defines
  57920. * @param lightIndex defines the index of the light for the effect
  57921. */
  57922. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57923. }
  57924. }
  57925. declare module BABYLON {
  57926. /**
  57927. * Class containing static functions to help procedurally build meshes
  57928. */
  57929. export class HemisphereBuilder {
  57930. /**
  57931. * Creates a hemisphere mesh
  57932. * @param name defines the name of the mesh
  57933. * @param options defines the options used to create the mesh
  57934. * @param scene defines the hosting scene
  57935. * @returns the hemisphere mesh
  57936. */
  57937. static CreateHemisphere(name: string, options: {
  57938. segments?: number;
  57939. diameter?: number;
  57940. sideOrientation?: number;
  57941. }, scene: any): Mesh;
  57942. }
  57943. }
  57944. declare module BABYLON {
  57945. /**
  57946. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57947. * These values define a cone of light starting from the position, emitting toward the direction.
  57948. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57949. * and the exponent defines the speed of the decay of the light with distance (reach).
  57950. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57951. */
  57952. export class SpotLight extends ShadowLight {
  57953. private _angle;
  57954. private _innerAngle;
  57955. private _cosHalfAngle;
  57956. private _lightAngleScale;
  57957. private _lightAngleOffset;
  57958. /**
  57959. * Gets the cone angle of the spot light in Radians.
  57960. */
  57961. get angle(): number;
  57962. /**
  57963. * Sets the cone angle of the spot light in Radians.
  57964. */
  57965. set angle(value: number);
  57966. /**
  57967. * Only used in gltf falloff mode, this defines the angle where
  57968. * the directional falloff will start before cutting at angle which could be seen
  57969. * as outer angle.
  57970. */
  57971. get innerAngle(): number;
  57972. /**
  57973. * Only used in gltf falloff mode, this defines the angle where
  57974. * the directional falloff will start before cutting at angle which could be seen
  57975. * as outer angle.
  57976. */
  57977. set innerAngle(value: number);
  57978. private _shadowAngleScale;
  57979. /**
  57980. * Allows scaling the angle of the light for shadow generation only.
  57981. */
  57982. get shadowAngleScale(): number;
  57983. /**
  57984. * Allows scaling the angle of the light for shadow generation only.
  57985. */
  57986. set shadowAngleScale(value: number);
  57987. /**
  57988. * The light decay speed with the distance from the emission spot.
  57989. */
  57990. exponent: number;
  57991. private _projectionTextureMatrix;
  57992. /**
  57993. * Allows reading the projecton texture
  57994. */
  57995. get projectionTextureMatrix(): Matrix;
  57996. protected _projectionTextureLightNear: number;
  57997. /**
  57998. * Gets the near clip of the Spotlight for texture projection.
  57999. */
  58000. get projectionTextureLightNear(): number;
  58001. /**
  58002. * Sets the near clip of the Spotlight for texture projection.
  58003. */
  58004. set projectionTextureLightNear(value: number);
  58005. protected _projectionTextureLightFar: number;
  58006. /**
  58007. * Gets the far clip of the Spotlight for texture projection.
  58008. */
  58009. get projectionTextureLightFar(): number;
  58010. /**
  58011. * Sets the far clip of the Spotlight for texture projection.
  58012. */
  58013. set projectionTextureLightFar(value: number);
  58014. protected _projectionTextureUpDirection: Vector3;
  58015. /**
  58016. * Gets the Up vector of the Spotlight for texture projection.
  58017. */
  58018. get projectionTextureUpDirection(): Vector3;
  58019. /**
  58020. * Sets the Up vector of the Spotlight for texture projection.
  58021. */
  58022. set projectionTextureUpDirection(value: Vector3);
  58023. private _projectionTexture;
  58024. /**
  58025. * Gets the projection texture of the light.
  58026. */
  58027. get projectionTexture(): Nullable<BaseTexture>;
  58028. /**
  58029. * Sets the projection texture of the light.
  58030. */
  58031. set projectionTexture(value: Nullable<BaseTexture>);
  58032. private static _IsProceduralTexture;
  58033. private static _IsTexture;
  58034. private _projectionTextureViewLightDirty;
  58035. private _projectionTextureProjectionLightDirty;
  58036. private _projectionTextureDirty;
  58037. private _projectionTextureViewTargetVector;
  58038. private _projectionTextureViewLightMatrix;
  58039. private _projectionTextureProjectionLightMatrix;
  58040. private _projectionTextureScalingMatrix;
  58041. /**
  58042. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  58043. * It can cast shadows.
  58044. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58045. * @param name The light friendly name
  58046. * @param position The position of the spot light in the scene
  58047. * @param direction The direction of the light in the scene
  58048. * @param angle The cone angle of the light in Radians
  58049. * @param exponent The light decay speed with the distance from the emission spot
  58050. * @param scene The scene the lights belongs to
  58051. */
  58052. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58053. /**
  58054. * Returns the string "SpotLight".
  58055. * @returns the class name
  58056. */
  58057. getClassName(): string;
  58058. /**
  58059. * Returns the integer 2.
  58060. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58061. */
  58062. getTypeID(): number;
  58063. /**
  58064. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58065. */
  58066. protected _setDirection(value: Vector3): void;
  58067. /**
  58068. * Overrides the position setter to recompute the projection texture view light Matrix.
  58069. */
  58070. protected _setPosition(value: Vector3): void;
  58071. /**
  58072. * 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.
  58073. * Returns the SpotLight.
  58074. */
  58075. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58076. protected _computeProjectionTextureViewLightMatrix(): void;
  58077. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58078. /**
  58079. * Main function for light texture projection matrix computing.
  58080. */
  58081. protected _computeProjectionTextureMatrix(): void;
  58082. protected _buildUniformLayout(): void;
  58083. private _computeAngleValues;
  58084. /**
  58085. * Sets the passed Effect "effect" with the Light textures.
  58086. * @param effect The effect to update
  58087. * @param lightIndex The index of the light in the effect to update
  58088. * @returns The light
  58089. */
  58090. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58091. /**
  58092. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58093. * @param effect The effect to update
  58094. * @param lightIndex The index of the light in the effect to update
  58095. * @returns The spot light
  58096. */
  58097. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58098. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58099. /**
  58100. * Disposes the light and the associated resources.
  58101. */
  58102. dispose(): void;
  58103. /**
  58104. * Prepares the list of defines specific to the light type.
  58105. * @param defines the list of defines
  58106. * @param lightIndex defines the index of the light for the effect
  58107. */
  58108. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58109. }
  58110. }
  58111. declare module BABYLON {
  58112. /**
  58113. * Gizmo that enables viewing a light
  58114. */
  58115. export class LightGizmo extends Gizmo {
  58116. private _lightMesh;
  58117. private _material;
  58118. private _cachedPosition;
  58119. private _cachedForward;
  58120. private _attachedMeshParent;
  58121. private _pointerObserver;
  58122. /**
  58123. * Event that fires each time the gizmo is clicked
  58124. */
  58125. onClickedObservable: Observable<Light>;
  58126. /**
  58127. * Creates a LightGizmo
  58128. * @param gizmoLayer The utility layer the gizmo will be added to
  58129. */
  58130. constructor(gizmoLayer?: UtilityLayerRenderer);
  58131. private _light;
  58132. /**
  58133. * The light that the gizmo is attached to
  58134. */
  58135. set light(light: Nullable<Light>);
  58136. get light(): Nullable<Light>;
  58137. /**
  58138. * Gets the material used to render the light gizmo
  58139. */
  58140. get material(): StandardMaterial;
  58141. /**
  58142. * @hidden
  58143. * Updates the gizmo to match the attached mesh's position/rotation
  58144. */
  58145. protected _update(): void;
  58146. private static _Scale;
  58147. /**
  58148. * Creates the lines for a light mesh
  58149. */
  58150. private static _CreateLightLines;
  58151. /**
  58152. * Disposes of the light gizmo
  58153. */
  58154. dispose(): void;
  58155. private static _CreateHemisphericLightMesh;
  58156. private static _CreatePointLightMesh;
  58157. private static _CreateSpotLightMesh;
  58158. private static _CreateDirectionalLightMesh;
  58159. }
  58160. }
  58161. declare module BABYLON {
  58162. /**
  58163. * Gizmo that enables viewing a camera
  58164. */
  58165. export class CameraGizmo extends Gizmo {
  58166. private _cameraMesh;
  58167. private _cameraLinesMesh;
  58168. private _material;
  58169. private _pointerObserver;
  58170. /**
  58171. * Event that fires each time the gizmo is clicked
  58172. */
  58173. onClickedObservable: Observable<Camera>;
  58174. /**
  58175. * Creates a CameraGizmo
  58176. * @param gizmoLayer The utility layer the gizmo will be added to
  58177. */
  58178. constructor(gizmoLayer?: UtilityLayerRenderer);
  58179. private _camera;
  58180. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58181. get displayFrustum(): boolean;
  58182. set displayFrustum(value: boolean);
  58183. /**
  58184. * The camera that the gizmo is attached to
  58185. */
  58186. set camera(camera: Nullable<Camera>);
  58187. get camera(): Nullable<Camera>;
  58188. /**
  58189. * Gets the material used to render the camera gizmo
  58190. */
  58191. get material(): StandardMaterial;
  58192. /**
  58193. * @hidden
  58194. * Updates the gizmo to match the attached mesh's position/rotation
  58195. */
  58196. protected _update(): void;
  58197. private static _Scale;
  58198. private _invProjection;
  58199. /**
  58200. * Disposes of the camera gizmo
  58201. */
  58202. dispose(): void;
  58203. private static _CreateCameraMesh;
  58204. private static _CreateCameraFrustum;
  58205. }
  58206. }
  58207. declare module BABYLON {
  58208. /** @hidden */
  58209. export var backgroundFragmentDeclaration: {
  58210. name: string;
  58211. shader: string;
  58212. };
  58213. }
  58214. declare module BABYLON {
  58215. /** @hidden */
  58216. export var backgroundUboDeclaration: {
  58217. name: string;
  58218. shader: string;
  58219. };
  58220. }
  58221. declare module BABYLON {
  58222. /** @hidden */
  58223. export var backgroundPixelShader: {
  58224. name: string;
  58225. shader: string;
  58226. };
  58227. }
  58228. declare module BABYLON {
  58229. /** @hidden */
  58230. export var backgroundVertexDeclaration: {
  58231. name: string;
  58232. shader: string;
  58233. };
  58234. }
  58235. declare module BABYLON {
  58236. /** @hidden */
  58237. export var backgroundVertexShader: {
  58238. name: string;
  58239. shader: string;
  58240. };
  58241. }
  58242. declare module BABYLON {
  58243. /**
  58244. * Background material used to create an efficient environement around your scene.
  58245. */
  58246. export class BackgroundMaterial extends PushMaterial {
  58247. /**
  58248. * Standard reflectance value at parallel view angle.
  58249. */
  58250. static StandardReflectance0: number;
  58251. /**
  58252. * Standard reflectance value at grazing angle.
  58253. */
  58254. static StandardReflectance90: number;
  58255. protected _primaryColor: Color3;
  58256. /**
  58257. * Key light Color (multiply against the environement texture)
  58258. */
  58259. primaryColor: Color3;
  58260. protected __perceptualColor: Nullable<Color3>;
  58261. /**
  58262. * Experimental Internal Use Only.
  58263. *
  58264. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58265. * This acts as a helper to set the primary color to a more "human friendly" value.
  58266. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58267. * output color as close as possible from the chosen value.
  58268. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58269. * part of lighting setup.)
  58270. */
  58271. get _perceptualColor(): Nullable<Color3>;
  58272. set _perceptualColor(value: Nullable<Color3>);
  58273. protected _primaryColorShadowLevel: float;
  58274. /**
  58275. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58276. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58277. */
  58278. get primaryColorShadowLevel(): float;
  58279. set primaryColorShadowLevel(value: float);
  58280. protected _primaryColorHighlightLevel: float;
  58281. /**
  58282. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58283. * The primary color is used at the level chosen to define what the white area would look.
  58284. */
  58285. get primaryColorHighlightLevel(): float;
  58286. set primaryColorHighlightLevel(value: float);
  58287. protected _reflectionTexture: Nullable<BaseTexture>;
  58288. /**
  58289. * Reflection Texture used in the material.
  58290. * Should be author in a specific way for the best result (refer to the documentation).
  58291. */
  58292. reflectionTexture: Nullable<BaseTexture>;
  58293. protected _reflectionBlur: float;
  58294. /**
  58295. * Reflection Texture level of blur.
  58296. *
  58297. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58298. * texture twice.
  58299. */
  58300. reflectionBlur: float;
  58301. protected _diffuseTexture: Nullable<BaseTexture>;
  58302. /**
  58303. * Diffuse Texture used in the material.
  58304. * Should be author in a specific way for the best result (refer to the documentation).
  58305. */
  58306. diffuseTexture: Nullable<BaseTexture>;
  58307. protected _shadowLights: Nullable<IShadowLight[]>;
  58308. /**
  58309. * Specify the list of lights casting shadow on the material.
  58310. * All scene shadow lights will be included if null.
  58311. */
  58312. shadowLights: Nullable<IShadowLight[]>;
  58313. protected _shadowLevel: float;
  58314. /**
  58315. * Helps adjusting the shadow to a softer level if required.
  58316. * 0 means black shadows and 1 means no shadows.
  58317. */
  58318. shadowLevel: float;
  58319. protected _sceneCenter: Vector3;
  58320. /**
  58321. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58322. * It is usually zero but might be interesting to modify according to your setup.
  58323. */
  58324. sceneCenter: Vector3;
  58325. protected _opacityFresnel: boolean;
  58326. /**
  58327. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58328. * This helps ensuring a nice transition when the camera goes under the ground.
  58329. */
  58330. opacityFresnel: boolean;
  58331. protected _reflectionFresnel: boolean;
  58332. /**
  58333. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58334. * This helps adding a mirror texture on the ground.
  58335. */
  58336. reflectionFresnel: boolean;
  58337. protected _reflectionFalloffDistance: number;
  58338. /**
  58339. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58340. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58341. */
  58342. reflectionFalloffDistance: number;
  58343. protected _reflectionAmount: number;
  58344. /**
  58345. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58346. */
  58347. reflectionAmount: number;
  58348. protected _reflectionReflectance0: number;
  58349. /**
  58350. * This specifies the weight of the reflection at grazing angle.
  58351. */
  58352. reflectionReflectance0: number;
  58353. protected _reflectionReflectance90: number;
  58354. /**
  58355. * This specifies the weight of the reflection at a perpendicular point of view.
  58356. */
  58357. reflectionReflectance90: number;
  58358. /**
  58359. * Sets the reflection reflectance fresnel values according to the default standard
  58360. * empirically know to work well :-)
  58361. */
  58362. set reflectionStandardFresnelWeight(value: number);
  58363. protected _useRGBColor: boolean;
  58364. /**
  58365. * Helps to directly use the maps channels instead of their level.
  58366. */
  58367. useRGBColor: boolean;
  58368. protected _enableNoise: boolean;
  58369. /**
  58370. * This helps reducing the banding effect that could occur on the background.
  58371. */
  58372. enableNoise: boolean;
  58373. /**
  58374. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58375. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58376. * Recommended to be keep at 1.0 except for special cases.
  58377. */
  58378. get fovMultiplier(): number;
  58379. set fovMultiplier(value: number);
  58380. private _fovMultiplier;
  58381. /**
  58382. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58383. */
  58384. useEquirectangularFOV: boolean;
  58385. private _maxSimultaneousLights;
  58386. /**
  58387. * Number of Simultaneous lights allowed on the material.
  58388. */
  58389. maxSimultaneousLights: int;
  58390. private _shadowOnly;
  58391. /**
  58392. * Make the material only render shadows
  58393. */
  58394. shadowOnly: boolean;
  58395. /**
  58396. * Default configuration related to image processing available in the Background Material.
  58397. */
  58398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58399. /**
  58400. * Keep track of the image processing observer to allow dispose and replace.
  58401. */
  58402. private _imageProcessingObserver;
  58403. /**
  58404. * Attaches a new image processing configuration to the PBR Material.
  58405. * @param configuration (if null the scene configuration will be use)
  58406. */
  58407. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58408. /**
  58409. * Gets the image processing configuration used either in this material.
  58410. */
  58411. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58412. /**
  58413. * Sets the Default image processing configuration used either in the this material.
  58414. *
  58415. * If sets to null, the scene one is in use.
  58416. */
  58417. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58418. /**
  58419. * Gets wether the color curves effect is enabled.
  58420. */
  58421. get cameraColorCurvesEnabled(): boolean;
  58422. /**
  58423. * Sets wether the color curves effect is enabled.
  58424. */
  58425. set cameraColorCurvesEnabled(value: boolean);
  58426. /**
  58427. * Gets wether the color grading effect is enabled.
  58428. */
  58429. get cameraColorGradingEnabled(): boolean;
  58430. /**
  58431. * Gets wether the color grading effect is enabled.
  58432. */
  58433. set cameraColorGradingEnabled(value: boolean);
  58434. /**
  58435. * Gets wether tonemapping is enabled or not.
  58436. */
  58437. get cameraToneMappingEnabled(): boolean;
  58438. /**
  58439. * Sets wether tonemapping is enabled or not
  58440. */
  58441. set cameraToneMappingEnabled(value: boolean);
  58442. /**
  58443. * The camera exposure used on this material.
  58444. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58445. * This corresponds to a photographic exposure.
  58446. */
  58447. get cameraExposure(): float;
  58448. /**
  58449. * The camera exposure used on this material.
  58450. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58451. * This corresponds to a photographic exposure.
  58452. */
  58453. set cameraExposure(value: float);
  58454. /**
  58455. * Gets The camera contrast used on this material.
  58456. */
  58457. get cameraContrast(): float;
  58458. /**
  58459. * Sets The camera contrast used on this material.
  58460. */
  58461. set cameraContrast(value: float);
  58462. /**
  58463. * Gets the Color Grading 2D Lookup Texture.
  58464. */
  58465. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58466. /**
  58467. * Sets the Color Grading 2D Lookup Texture.
  58468. */
  58469. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58470. /**
  58471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58473. * 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;
  58474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58475. */
  58476. get cameraColorCurves(): Nullable<ColorCurves>;
  58477. /**
  58478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58480. * 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;
  58481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58482. */
  58483. set cameraColorCurves(value: Nullable<ColorCurves>);
  58484. /**
  58485. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58486. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58487. */
  58488. switchToBGR: boolean;
  58489. private _renderTargets;
  58490. private _reflectionControls;
  58491. private _white;
  58492. private _primaryShadowColor;
  58493. private _primaryHighlightColor;
  58494. /**
  58495. * Instantiates a Background Material in the given scene
  58496. * @param name The friendly name of the material
  58497. * @param scene The scene to add the material to
  58498. */
  58499. constructor(name: string, scene: Scene);
  58500. /**
  58501. * Gets a boolean indicating that current material needs to register RTT
  58502. */
  58503. get hasRenderTargetTextures(): boolean;
  58504. /**
  58505. * The entire material has been created in order to prevent overdraw.
  58506. * @returns false
  58507. */
  58508. needAlphaTesting(): boolean;
  58509. /**
  58510. * The entire material has been created in order to prevent overdraw.
  58511. * @returns true if blending is enable
  58512. */
  58513. needAlphaBlending(): boolean;
  58514. /**
  58515. * Checks wether the material is ready to be rendered for a given mesh.
  58516. * @param mesh The mesh to render
  58517. * @param subMesh The submesh to check against
  58518. * @param useInstances Specify wether or not the material is used with instances
  58519. * @returns true if all the dependencies are ready (Textures, Effects...)
  58520. */
  58521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58522. /**
  58523. * Compute the primary color according to the chosen perceptual color.
  58524. */
  58525. private _computePrimaryColorFromPerceptualColor;
  58526. /**
  58527. * Compute the highlights and shadow colors according to their chosen levels.
  58528. */
  58529. private _computePrimaryColors;
  58530. /**
  58531. * Build the uniform buffer used in the material.
  58532. */
  58533. buildUniformLayout(): void;
  58534. /**
  58535. * Unbind the material.
  58536. */
  58537. unbind(): void;
  58538. /**
  58539. * Bind only the world matrix to the material.
  58540. * @param world The world matrix to bind.
  58541. */
  58542. bindOnlyWorldMatrix(world: Matrix): void;
  58543. /**
  58544. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58545. * @param world The world matrix to bind.
  58546. * @param subMesh The submesh to bind for.
  58547. */
  58548. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58549. /**
  58550. * Checks to see if a texture is used in the material.
  58551. * @param texture - Base texture to use.
  58552. * @returns - Boolean specifying if a texture is used in the material.
  58553. */
  58554. hasTexture(texture: BaseTexture): boolean;
  58555. /**
  58556. * Dispose the material.
  58557. * @param forceDisposeEffect Force disposal of the associated effect.
  58558. * @param forceDisposeTextures Force disposal of the associated textures.
  58559. */
  58560. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58561. /**
  58562. * Clones the material.
  58563. * @param name The cloned name.
  58564. * @returns The cloned material.
  58565. */
  58566. clone(name: string): BackgroundMaterial;
  58567. /**
  58568. * Serializes the current material to its JSON representation.
  58569. * @returns The JSON representation.
  58570. */
  58571. serialize(): any;
  58572. /**
  58573. * Gets the class name of the material
  58574. * @returns "BackgroundMaterial"
  58575. */
  58576. getClassName(): string;
  58577. /**
  58578. * Parse a JSON input to create back a background material.
  58579. * @param source The JSON data to parse
  58580. * @param scene The scene to create the parsed material in
  58581. * @param rootUrl The root url of the assets the material depends upon
  58582. * @returns the instantiated BackgroundMaterial.
  58583. */
  58584. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58585. }
  58586. }
  58587. declare module BABYLON {
  58588. /**
  58589. * Represents the different options available during the creation of
  58590. * a Environment helper.
  58591. *
  58592. * This can control the default ground, skybox and image processing setup of your scene.
  58593. */
  58594. export interface IEnvironmentHelperOptions {
  58595. /**
  58596. * Specifies whether or not to create a ground.
  58597. * True by default.
  58598. */
  58599. createGround: boolean;
  58600. /**
  58601. * Specifies the ground size.
  58602. * 15 by default.
  58603. */
  58604. groundSize: number;
  58605. /**
  58606. * The texture used on the ground for the main color.
  58607. * Comes from the BabylonJS CDN by default.
  58608. *
  58609. * Remarks: Can be either a texture or a url.
  58610. */
  58611. groundTexture: string | BaseTexture;
  58612. /**
  58613. * The color mixed in the ground texture by default.
  58614. * BabylonJS clearColor by default.
  58615. */
  58616. groundColor: Color3;
  58617. /**
  58618. * Specifies the ground opacity.
  58619. * 1 by default.
  58620. */
  58621. groundOpacity: number;
  58622. /**
  58623. * Enables the ground to receive shadows.
  58624. * True by default.
  58625. */
  58626. enableGroundShadow: boolean;
  58627. /**
  58628. * Helps preventing the shadow to be fully black on the ground.
  58629. * 0.5 by default.
  58630. */
  58631. groundShadowLevel: number;
  58632. /**
  58633. * Creates a mirror texture attach to the ground.
  58634. * false by default.
  58635. */
  58636. enableGroundMirror: boolean;
  58637. /**
  58638. * Specifies the ground mirror size ratio.
  58639. * 0.3 by default as the default kernel is 64.
  58640. */
  58641. groundMirrorSizeRatio: number;
  58642. /**
  58643. * Specifies the ground mirror blur kernel size.
  58644. * 64 by default.
  58645. */
  58646. groundMirrorBlurKernel: number;
  58647. /**
  58648. * Specifies the ground mirror visibility amount.
  58649. * 1 by default
  58650. */
  58651. groundMirrorAmount: number;
  58652. /**
  58653. * Specifies the ground mirror reflectance weight.
  58654. * This uses the standard weight of the background material to setup the fresnel effect
  58655. * of the mirror.
  58656. * 1 by default.
  58657. */
  58658. groundMirrorFresnelWeight: number;
  58659. /**
  58660. * Specifies the ground mirror Falloff distance.
  58661. * This can helps reducing the size of the reflection.
  58662. * 0 by Default.
  58663. */
  58664. groundMirrorFallOffDistance: number;
  58665. /**
  58666. * Specifies the ground mirror texture type.
  58667. * Unsigned Int by Default.
  58668. */
  58669. groundMirrorTextureType: number;
  58670. /**
  58671. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58672. * the shown objects.
  58673. */
  58674. groundYBias: number;
  58675. /**
  58676. * Specifies whether or not to create a skybox.
  58677. * True by default.
  58678. */
  58679. createSkybox: boolean;
  58680. /**
  58681. * Specifies the skybox size.
  58682. * 20 by default.
  58683. */
  58684. skyboxSize: number;
  58685. /**
  58686. * The texture used on the skybox for the main color.
  58687. * Comes from the BabylonJS CDN by default.
  58688. *
  58689. * Remarks: Can be either a texture or a url.
  58690. */
  58691. skyboxTexture: string | BaseTexture;
  58692. /**
  58693. * The color mixed in the skybox texture by default.
  58694. * BabylonJS clearColor by default.
  58695. */
  58696. skyboxColor: Color3;
  58697. /**
  58698. * The background rotation around the Y axis of the scene.
  58699. * This helps aligning the key lights of your scene with the background.
  58700. * 0 by default.
  58701. */
  58702. backgroundYRotation: number;
  58703. /**
  58704. * Compute automatically the size of the elements to best fit with the scene.
  58705. */
  58706. sizeAuto: boolean;
  58707. /**
  58708. * Default position of the rootMesh if autoSize is not true.
  58709. */
  58710. rootPosition: Vector3;
  58711. /**
  58712. * Sets up the image processing in the scene.
  58713. * true by default.
  58714. */
  58715. setupImageProcessing: boolean;
  58716. /**
  58717. * The texture used as your environment texture in the scene.
  58718. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58719. *
  58720. * Remarks: Can be either a texture or a url.
  58721. */
  58722. environmentTexture: string | BaseTexture;
  58723. /**
  58724. * The value of the exposure to apply to the scene.
  58725. * 0.6 by default if setupImageProcessing is true.
  58726. */
  58727. cameraExposure: number;
  58728. /**
  58729. * The value of the contrast to apply to the scene.
  58730. * 1.6 by default if setupImageProcessing is true.
  58731. */
  58732. cameraContrast: number;
  58733. /**
  58734. * Specifies whether or not tonemapping should be enabled in the scene.
  58735. * true by default if setupImageProcessing is true.
  58736. */
  58737. toneMappingEnabled: boolean;
  58738. }
  58739. /**
  58740. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58741. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58742. * It also helps with the default setup of your imageProcessing configuration.
  58743. */
  58744. export class EnvironmentHelper {
  58745. /**
  58746. * Default ground texture URL.
  58747. */
  58748. private static _groundTextureCDNUrl;
  58749. /**
  58750. * Default skybox texture URL.
  58751. */
  58752. private static _skyboxTextureCDNUrl;
  58753. /**
  58754. * Default environment texture URL.
  58755. */
  58756. private static _environmentTextureCDNUrl;
  58757. /**
  58758. * Creates the default options for the helper.
  58759. */
  58760. private static _getDefaultOptions;
  58761. private _rootMesh;
  58762. /**
  58763. * Gets the root mesh created by the helper.
  58764. */
  58765. get rootMesh(): Mesh;
  58766. private _skybox;
  58767. /**
  58768. * Gets the skybox created by the helper.
  58769. */
  58770. get skybox(): Nullable<Mesh>;
  58771. private _skyboxTexture;
  58772. /**
  58773. * Gets the skybox texture created by the helper.
  58774. */
  58775. get skyboxTexture(): Nullable<BaseTexture>;
  58776. private _skyboxMaterial;
  58777. /**
  58778. * Gets the skybox material created by the helper.
  58779. */
  58780. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58781. private _ground;
  58782. /**
  58783. * Gets the ground mesh created by the helper.
  58784. */
  58785. get ground(): Nullable<Mesh>;
  58786. private _groundTexture;
  58787. /**
  58788. * Gets the ground texture created by the helper.
  58789. */
  58790. get groundTexture(): Nullable<BaseTexture>;
  58791. private _groundMirror;
  58792. /**
  58793. * Gets the ground mirror created by the helper.
  58794. */
  58795. get groundMirror(): Nullable<MirrorTexture>;
  58796. /**
  58797. * Gets the ground mirror render list to helps pushing the meshes
  58798. * you wish in the ground reflection.
  58799. */
  58800. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58801. private _groundMaterial;
  58802. /**
  58803. * Gets the ground material created by the helper.
  58804. */
  58805. get groundMaterial(): Nullable<BackgroundMaterial>;
  58806. /**
  58807. * Stores the creation options.
  58808. */
  58809. private readonly _scene;
  58810. private _options;
  58811. /**
  58812. * This observable will be notified with any error during the creation of the environment,
  58813. * mainly texture creation errors.
  58814. */
  58815. onErrorObservable: Observable<{
  58816. message?: string;
  58817. exception?: any;
  58818. }>;
  58819. /**
  58820. * constructor
  58821. * @param options Defines the options we want to customize the helper
  58822. * @param scene The scene to add the material to
  58823. */
  58824. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58825. /**
  58826. * Updates the background according to the new options
  58827. * @param options
  58828. */
  58829. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58830. /**
  58831. * Sets the primary color of all the available elements.
  58832. * @param color the main color to affect to the ground and the background
  58833. */
  58834. setMainColor(color: Color3): void;
  58835. /**
  58836. * Setup the image processing according to the specified options.
  58837. */
  58838. private _setupImageProcessing;
  58839. /**
  58840. * Setup the environment texture according to the specified options.
  58841. */
  58842. private _setupEnvironmentTexture;
  58843. /**
  58844. * Setup the background according to the specified options.
  58845. */
  58846. private _setupBackground;
  58847. /**
  58848. * Get the scene sizes according to the setup.
  58849. */
  58850. private _getSceneSize;
  58851. /**
  58852. * Setup the ground according to the specified options.
  58853. */
  58854. private _setupGround;
  58855. /**
  58856. * Setup the ground material according to the specified options.
  58857. */
  58858. private _setupGroundMaterial;
  58859. /**
  58860. * Setup the ground diffuse texture according to the specified options.
  58861. */
  58862. private _setupGroundDiffuseTexture;
  58863. /**
  58864. * Setup the ground mirror texture according to the specified options.
  58865. */
  58866. private _setupGroundMirrorTexture;
  58867. /**
  58868. * Setup the ground to receive the mirror texture.
  58869. */
  58870. private _setupMirrorInGroundMaterial;
  58871. /**
  58872. * Setup the skybox according to the specified options.
  58873. */
  58874. private _setupSkybox;
  58875. /**
  58876. * Setup the skybox material according to the specified options.
  58877. */
  58878. private _setupSkyboxMaterial;
  58879. /**
  58880. * Setup the skybox reflection texture according to the specified options.
  58881. */
  58882. private _setupSkyboxReflectionTexture;
  58883. private _errorHandler;
  58884. /**
  58885. * Dispose all the elements created by the Helper.
  58886. */
  58887. dispose(): void;
  58888. }
  58889. }
  58890. declare module BABYLON {
  58891. /**
  58892. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58893. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58894. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58895. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58896. */
  58897. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58898. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58899. /**
  58900. * Define the source as a Monoscopic panoramic 360/180.
  58901. */
  58902. static readonly MODE_MONOSCOPIC: number;
  58903. /**
  58904. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58905. */
  58906. static readonly MODE_TOPBOTTOM: number;
  58907. /**
  58908. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58909. */
  58910. static readonly MODE_SIDEBYSIDE: number;
  58911. private _halfDome;
  58912. private _crossEye;
  58913. protected _useDirectMapping: boolean;
  58914. /**
  58915. * The texture being displayed on the sphere
  58916. */
  58917. protected _texture: T;
  58918. /**
  58919. * Gets the texture being displayed on the sphere
  58920. */
  58921. get texture(): T;
  58922. /**
  58923. * Sets the texture being displayed on the sphere
  58924. */
  58925. set texture(newTexture: T);
  58926. /**
  58927. * The skybox material
  58928. */
  58929. protected _material: BackgroundMaterial;
  58930. /**
  58931. * The surface used for the dome
  58932. */
  58933. protected _mesh: Mesh;
  58934. /**
  58935. * Gets the mesh used for the dome.
  58936. */
  58937. get mesh(): Mesh;
  58938. /**
  58939. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58940. */
  58941. private _halfDomeMask;
  58942. /**
  58943. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58944. * Also see the options.resolution property.
  58945. */
  58946. get fovMultiplier(): number;
  58947. set fovMultiplier(value: number);
  58948. protected _textureMode: number;
  58949. /**
  58950. * Gets or set the current texture mode for the texture. It can be:
  58951. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58952. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58953. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58954. */
  58955. get textureMode(): number;
  58956. /**
  58957. * Sets the current texture mode for the texture. It can be:
  58958. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58959. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58960. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58961. */
  58962. set textureMode(value: number);
  58963. /**
  58964. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58965. */
  58966. get halfDome(): boolean;
  58967. /**
  58968. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58969. */
  58970. set halfDome(enabled: boolean);
  58971. /**
  58972. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58973. */
  58974. set crossEye(enabled: boolean);
  58975. /**
  58976. * Is it a cross-eye texture?
  58977. */
  58978. get crossEye(): boolean;
  58979. /**
  58980. * The background material of this dome.
  58981. */
  58982. get material(): BackgroundMaterial;
  58983. /**
  58984. * Oberserver used in Stereoscopic VR Mode.
  58985. */
  58986. private _onBeforeCameraRenderObserver;
  58987. /**
  58988. * Observable raised when an error occured while loading the 360 image
  58989. */
  58990. onLoadErrorObservable: Observable<string>;
  58991. /**
  58992. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58993. * @param name Element's name, child elements will append suffixes for their own names.
  58994. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58995. * @param options An object containing optional or exposed sub element properties
  58996. */
  58997. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58998. resolution?: number;
  58999. clickToPlay?: boolean;
  59000. autoPlay?: boolean;
  59001. loop?: boolean;
  59002. size?: number;
  59003. poster?: string;
  59004. faceForward?: boolean;
  59005. useDirectMapping?: boolean;
  59006. halfDomeMode?: boolean;
  59007. crossEyeMode?: boolean;
  59008. generateMipMaps?: boolean;
  59009. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  59010. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  59011. protected _changeTextureMode(value: number): void;
  59012. /**
  59013. * Releases resources associated with this node.
  59014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59016. */
  59017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  59023. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  59024. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  59025. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59026. */
  59027. export class PhotoDome extends TextureDome<Texture> {
  59028. /**
  59029. * Define the image as a Monoscopic panoramic 360 image.
  59030. */
  59031. static readonly MODE_MONOSCOPIC: number;
  59032. /**
  59033. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  59034. */
  59035. static readonly MODE_TOPBOTTOM: number;
  59036. /**
  59037. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  59038. */
  59039. static readonly MODE_SIDEBYSIDE: number;
  59040. /**
  59041. * Gets or sets the texture being displayed on the sphere
  59042. */
  59043. get photoTexture(): Texture;
  59044. /**
  59045. * sets the texture being displayed on the sphere
  59046. */
  59047. set photoTexture(value: Texture);
  59048. /**
  59049. * Gets the current video mode for the video. It can be:
  59050. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59051. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59052. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59053. */
  59054. get imageMode(): number;
  59055. /**
  59056. * Sets the current video mode for the video. It can be:
  59057. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59058. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59059. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59060. */
  59061. set imageMode(value: number);
  59062. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59063. }
  59064. }
  59065. declare module BABYLON {
  59066. /**
  59067. * Direct draw surface info
  59068. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59069. */
  59070. export interface DDSInfo {
  59071. /**
  59072. * Width of the texture
  59073. */
  59074. width: number;
  59075. /**
  59076. * Width of the texture
  59077. */
  59078. height: number;
  59079. /**
  59080. * Number of Mipmaps for the texture
  59081. * @see https://en.wikipedia.org/wiki/Mipmap
  59082. */
  59083. mipmapCount: number;
  59084. /**
  59085. * If the textures format is a known fourCC format
  59086. * @see https://www.fourcc.org/
  59087. */
  59088. isFourCC: boolean;
  59089. /**
  59090. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59091. */
  59092. isRGB: boolean;
  59093. /**
  59094. * If the texture is a lumincance format
  59095. */
  59096. isLuminance: boolean;
  59097. /**
  59098. * If this is a cube texture
  59099. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59100. */
  59101. isCube: boolean;
  59102. /**
  59103. * If the texture is a compressed format eg. FOURCC_DXT1
  59104. */
  59105. isCompressed: boolean;
  59106. /**
  59107. * The dxgiFormat of the texture
  59108. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59109. */
  59110. dxgiFormat: number;
  59111. /**
  59112. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59113. */
  59114. textureType: number;
  59115. /**
  59116. * Sphericle polynomial created for the dds texture
  59117. */
  59118. sphericalPolynomial?: SphericalPolynomial;
  59119. }
  59120. /**
  59121. * Class used to provide DDS decompression tools
  59122. */
  59123. export class DDSTools {
  59124. /**
  59125. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59126. */
  59127. static StoreLODInAlphaChannel: boolean;
  59128. /**
  59129. * Gets DDS information from an array buffer
  59130. * @param data defines the array buffer view to read data from
  59131. * @returns the DDS information
  59132. */
  59133. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59134. private static _FloatView;
  59135. private static _Int32View;
  59136. private static _ToHalfFloat;
  59137. private static _FromHalfFloat;
  59138. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59139. private static _GetHalfFloatRGBAArrayBuffer;
  59140. private static _GetFloatRGBAArrayBuffer;
  59141. private static _GetFloatAsUIntRGBAArrayBuffer;
  59142. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59143. private static _GetRGBAArrayBuffer;
  59144. private static _ExtractLongWordOrder;
  59145. private static _GetRGBArrayBuffer;
  59146. private static _GetLuminanceArrayBuffer;
  59147. /**
  59148. * Uploads DDS Levels to a Babylon Texture
  59149. * @hidden
  59150. */
  59151. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59152. }
  59153. interface ThinEngine {
  59154. /**
  59155. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59156. * @param rootUrl defines the url where the file to load is located
  59157. * @param scene defines the current scene
  59158. * @param lodScale defines scale to apply to the mip map selection
  59159. * @param lodOffset defines offset to apply to the mip map selection
  59160. * @param onLoad defines an optional callback raised when the texture is loaded
  59161. * @param onError defines an optional callback raised if there is an issue to load the texture
  59162. * @param format defines the format of the data
  59163. * @param forcedExtension defines the extension to use to pick the right loader
  59164. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59165. * @returns the cube texture as an InternalTexture
  59166. */
  59167. 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;
  59168. }
  59169. }
  59170. declare module BABYLON {
  59171. /**
  59172. * Implementation of the DDS Texture Loader.
  59173. * @hidden
  59174. */
  59175. export class _DDSTextureLoader implements IInternalTextureLoader {
  59176. /**
  59177. * Defines wether the loader supports cascade loading the different faces.
  59178. */
  59179. readonly supportCascades: boolean;
  59180. /**
  59181. * This returns if the loader support the current file information.
  59182. * @param extension defines the file extension of the file being loaded
  59183. * @returns true if the loader can load the specified file
  59184. */
  59185. canLoad(extension: string): boolean;
  59186. /**
  59187. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59188. * @param data contains the texture data
  59189. * @param texture defines the BabylonJS internal texture
  59190. * @param createPolynomials will be true if polynomials have been requested
  59191. * @param onLoad defines the callback to trigger once the texture is ready
  59192. * @param onError defines the callback to trigger in case of error
  59193. */
  59194. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59195. /**
  59196. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59197. * @param data contains the texture data
  59198. * @param texture defines the BabylonJS internal texture
  59199. * @param callback defines the method to call once ready to upload
  59200. */
  59201. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59202. }
  59203. }
  59204. declare module BABYLON {
  59205. /**
  59206. * Implementation of the ENV Texture Loader.
  59207. * @hidden
  59208. */
  59209. export class _ENVTextureLoader implements IInternalTextureLoader {
  59210. /**
  59211. * Defines wether the loader supports cascade loading the different faces.
  59212. */
  59213. readonly supportCascades: boolean;
  59214. /**
  59215. * This returns if the loader support the current file information.
  59216. * @param extension defines the file extension of the file being loaded
  59217. * @returns true if the loader can load the specified file
  59218. */
  59219. canLoad(extension: string): boolean;
  59220. /**
  59221. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59222. * @param data contains the texture data
  59223. * @param texture defines the BabylonJS internal texture
  59224. * @param createPolynomials will be true if polynomials have been requested
  59225. * @param onLoad defines the callback to trigger once the texture is ready
  59226. * @param onError defines the callback to trigger in case of error
  59227. */
  59228. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59229. /**
  59230. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59231. * @param data contains the texture data
  59232. * @param texture defines the BabylonJS internal texture
  59233. * @param callback defines the method to call once ready to upload
  59234. */
  59235. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59236. }
  59237. }
  59238. declare module BABYLON {
  59239. /**
  59240. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59241. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59242. */
  59243. export class KhronosTextureContainer {
  59244. /** contents of the KTX container file */
  59245. data: ArrayBufferView;
  59246. private static HEADER_LEN;
  59247. private static COMPRESSED_2D;
  59248. private static COMPRESSED_3D;
  59249. private static TEX_2D;
  59250. private static TEX_3D;
  59251. /**
  59252. * Gets the openGL type
  59253. */
  59254. glType: number;
  59255. /**
  59256. * Gets the openGL type size
  59257. */
  59258. glTypeSize: number;
  59259. /**
  59260. * Gets the openGL format
  59261. */
  59262. glFormat: number;
  59263. /**
  59264. * Gets the openGL internal format
  59265. */
  59266. glInternalFormat: number;
  59267. /**
  59268. * Gets the base internal format
  59269. */
  59270. glBaseInternalFormat: number;
  59271. /**
  59272. * Gets image width in pixel
  59273. */
  59274. pixelWidth: number;
  59275. /**
  59276. * Gets image height in pixel
  59277. */
  59278. pixelHeight: number;
  59279. /**
  59280. * Gets image depth in pixels
  59281. */
  59282. pixelDepth: number;
  59283. /**
  59284. * Gets the number of array elements
  59285. */
  59286. numberOfArrayElements: number;
  59287. /**
  59288. * Gets the number of faces
  59289. */
  59290. numberOfFaces: number;
  59291. /**
  59292. * Gets the number of mipmap levels
  59293. */
  59294. numberOfMipmapLevels: number;
  59295. /**
  59296. * Gets the bytes of key value data
  59297. */
  59298. bytesOfKeyValueData: number;
  59299. /**
  59300. * Gets the load type
  59301. */
  59302. loadType: number;
  59303. /**
  59304. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59305. */
  59306. isInvalid: boolean;
  59307. /**
  59308. * Creates a new KhronosTextureContainer
  59309. * @param data contents of the KTX container file
  59310. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59311. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59312. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59313. */
  59314. constructor(
  59315. /** contents of the KTX container file */
  59316. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59317. /**
  59318. * Uploads KTX content to a Babylon Texture.
  59319. * It is assumed that the texture has already been created & is currently bound
  59320. * @hidden
  59321. */
  59322. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59323. private _upload2DCompressedLevels;
  59324. /**
  59325. * Checks if the given data starts with a KTX file identifier.
  59326. * @param data the data to check
  59327. * @returns true if the data is a KTX file or false otherwise
  59328. */
  59329. static IsValid(data: ArrayBufferView): boolean;
  59330. }
  59331. }
  59332. declare module BABYLON {
  59333. /**
  59334. * Helper class to push actions to a pool of workers.
  59335. */
  59336. export class WorkerPool implements IDisposable {
  59337. private _workerInfos;
  59338. private _pendingActions;
  59339. /**
  59340. * Constructor
  59341. * @param workers Array of workers to use for actions
  59342. */
  59343. constructor(workers: Array<Worker>);
  59344. /**
  59345. * Terminates all workers and clears any pending actions.
  59346. */
  59347. dispose(): void;
  59348. /**
  59349. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59350. * pended until a worker has completed its action.
  59351. * @param action The action to perform. Call onComplete when the action is complete.
  59352. */
  59353. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59354. private _execute;
  59355. }
  59356. }
  59357. declare module BABYLON {
  59358. /**
  59359. * Class for loading KTX2 files
  59360. */
  59361. export class KhronosTextureContainer2 {
  59362. private static _WorkerPoolPromise?;
  59363. private static _Initialized;
  59364. private static _Ktx2Decoder;
  59365. /**
  59366. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59367. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59368. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59369. * Urls you can change:
  59370. * URLConfig.jsDecoderModule
  59371. * URLConfig.wasmUASTCToASTC
  59372. * URLConfig.wasmUASTCToBC7
  59373. * URLConfig.wasmUASTCToRGBA_UNORM
  59374. * URLConfig.wasmUASTCToRGBA_SRGB
  59375. * URLConfig.jsMSCTranscoder
  59376. * URLConfig.wasmMSCTranscoder
  59377. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59378. */
  59379. static URLConfig: {
  59380. jsDecoderModule: string;
  59381. wasmUASTCToASTC: null;
  59382. wasmUASTCToBC7: null;
  59383. wasmUASTCToRGBA_UNORM: null;
  59384. wasmUASTCToRGBA_SRGB: null;
  59385. jsMSCTranscoder: null;
  59386. wasmMSCTranscoder: null;
  59387. };
  59388. /**
  59389. * Default number of workers used to handle data decoding
  59390. */
  59391. static DefaultNumWorkers: number;
  59392. private static GetDefaultNumWorkers;
  59393. private _engine;
  59394. private static _CreateWorkerPool;
  59395. /**
  59396. * Constructor
  59397. * @param engine The engine to use
  59398. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59399. */
  59400. constructor(engine: ThinEngine, numWorkers?: number);
  59401. /** @hidden */
  59402. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59403. /**
  59404. * Stop all async operations and release resources.
  59405. */
  59406. dispose(): void;
  59407. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59408. /**
  59409. * Checks if the given data starts with a KTX2 file identifier.
  59410. * @param data the data to check
  59411. * @returns true if the data is a KTX2 file or false otherwise
  59412. */
  59413. static IsValid(data: ArrayBufferView): boolean;
  59414. }
  59415. }
  59416. declare module BABYLON {
  59417. /**
  59418. * Implementation of the KTX Texture Loader.
  59419. * @hidden
  59420. */
  59421. export class _KTXTextureLoader implements IInternalTextureLoader {
  59422. /**
  59423. * Defines wether the loader supports cascade loading the different faces.
  59424. */
  59425. readonly supportCascades: boolean;
  59426. /**
  59427. * This returns if the loader support the current file information.
  59428. * @param extension defines the file extension of the file being loaded
  59429. * @param mimeType defines the optional mime type of the file being loaded
  59430. * @returns true if the loader can load the specified file
  59431. */
  59432. canLoad(extension: string, mimeType?: string): boolean;
  59433. /**
  59434. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59435. * @param data contains the texture data
  59436. * @param texture defines the BabylonJS internal texture
  59437. * @param createPolynomials will be true if polynomials have been requested
  59438. * @param onLoad defines the callback to trigger once the texture is ready
  59439. * @param onError defines the callback to trigger in case of error
  59440. */
  59441. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59442. /**
  59443. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59444. * @param data contains the texture data
  59445. * @param texture defines the BabylonJS internal texture
  59446. * @param callback defines the method to call once ready to upload
  59447. */
  59448. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59449. }
  59450. }
  59451. declare module BABYLON {
  59452. /** @hidden */
  59453. export var _forceSceneHelpersToBundle: boolean;
  59454. interface Scene {
  59455. /**
  59456. * Creates a default light for the scene.
  59457. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59458. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59459. */
  59460. createDefaultLight(replace?: boolean): void;
  59461. /**
  59462. * Creates a default camera for the scene.
  59463. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59464. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59465. * @param replace has default false, when true replaces the active camera in the scene
  59466. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59467. */
  59468. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59469. /**
  59470. * Creates a default camera and a default light.
  59471. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59473. * @param replace has the default false, when true replaces the active camera/light in the scene
  59474. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59475. */
  59476. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59477. /**
  59478. * Creates a new sky box
  59479. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59480. * @param environmentTexture defines the texture to use as environment texture
  59481. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59482. * @param scale defines the overall scale of the skybox
  59483. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59484. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59485. * @returns a new mesh holding the sky box
  59486. */
  59487. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59488. /**
  59489. * Creates a new environment
  59490. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59491. * @param options defines the options you can use to configure the environment
  59492. * @returns the new EnvironmentHelper
  59493. */
  59494. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59495. /**
  59496. * Creates a new VREXperienceHelper
  59497. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59498. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59499. * @returns a new VREXperienceHelper
  59500. */
  59501. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59502. /**
  59503. * Creates a new WebXRDefaultExperience
  59504. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59505. * @param options experience options
  59506. * @returns a promise for a new WebXRDefaultExperience
  59507. */
  59508. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59509. }
  59510. }
  59511. declare module BABYLON {
  59512. /**
  59513. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59514. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59515. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59516. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59517. */
  59518. export class VideoDome extends TextureDome<VideoTexture> {
  59519. /**
  59520. * Define the video source as a Monoscopic panoramic 360 video.
  59521. */
  59522. static readonly MODE_MONOSCOPIC: number;
  59523. /**
  59524. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59525. */
  59526. static readonly MODE_TOPBOTTOM: number;
  59527. /**
  59528. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59529. */
  59530. static readonly MODE_SIDEBYSIDE: number;
  59531. /**
  59532. * Get the video texture associated with this video dome
  59533. */
  59534. get videoTexture(): VideoTexture;
  59535. /**
  59536. * Get the video mode of this dome
  59537. */
  59538. get videoMode(): number;
  59539. /**
  59540. * Set the video mode of this dome.
  59541. * @see textureMode
  59542. */
  59543. set videoMode(value: number);
  59544. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59545. }
  59546. }
  59547. declare module BABYLON {
  59548. /**
  59549. * This class can be used to get instrumentation data from a Babylon engine
  59550. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59551. */
  59552. export class EngineInstrumentation implements IDisposable {
  59553. /**
  59554. * Define the instrumented engine.
  59555. */
  59556. engine: Engine;
  59557. private _captureGPUFrameTime;
  59558. private _gpuFrameTimeToken;
  59559. private _gpuFrameTime;
  59560. private _captureShaderCompilationTime;
  59561. private _shaderCompilationTime;
  59562. private _onBeginFrameObserver;
  59563. private _onEndFrameObserver;
  59564. private _onBeforeShaderCompilationObserver;
  59565. private _onAfterShaderCompilationObserver;
  59566. /**
  59567. * Gets the perf counter used for GPU frame time
  59568. */
  59569. get gpuFrameTimeCounter(): PerfCounter;
  59570. /**
  59571. * Gets the GPU frame time capture status
  59572. */
  59573. get captureGPUFrameTime(): boolean;
  59574. /**
  59575. * Enable or disable the GPU frame time capture
  59576. */
  59577. set captureGPUFrameTime(value: boolean);
  59578. /**
  59579. * Gets the perf counter used for shader compilation time
  59580. */
  59581. get shaderCompilationTimeCounter(): PerfCounter;
  59582. /**
  59583. * Gets the shader compilation time capture status
  59584. */
  59585. get captureShaderCompilationTime(): boolean;
  59586. /**
  59587. * Enable or disable the shader compilation time capture
  59588. */
  59589. set captureShaderCompilationTime(value: boolean);
  59590. /**
  59591. * Instantiates a new engine instrumentation.
  59592. * This class can be used to get instrumentation data from a Babylon engine
  59593. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59594. * @param engine Defines the engine to instrument
  59595. */
  59596. constructor(
  59597. /**
  59598. * Define the instrumented engine.
  59599. */
  59600. engine: Engine);
  59601. /**
  59602. * Dispose and release associated resources.
  59603. */
  59604. dispose(): void;
  59605. }
  59606. }
  59607. declare module BABYLON {
  59608. /**
  59609. * This class can be used to get instrumentation data from a Babylon engine
  59610. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59611. */
  59612. export class SceneInstrumentation implements IDisposable {
  59613. /**
  59614. * Defines the scene to instrument
  59615. */
  59616. scene: Scene;
  59617. private _captureActiveMeshesEvaluationTime;
  59618. private _activeMeshesEvaluationTime;
  59619. private _captureRenderTargetsRenderTime;
  59620. private _renderTargetsRenderTime;
  59621. private _captureFrameTime;
  59622. private _frameTime;
  59623. private _captureRenderTime;
  59624. private _renderTime;
  59625. private _captureInterFrameTime;
  59626. private _interFrameTime;
  59627. private _captureParticlesRenderTime;
  59628. private _particlesRenderTime;
  59629. private _captureSpritesRenderTime;
  59630. private _spritesRenderTime;
  59631. private _capturePhysicsTime;
  59632. private _physicsTime;
  59633. private _captureAnimationsTime;
  59634. private _animationsTime;
  59635. private _captureCameraRenderTime;
  59636. private _cameraRenderTime;
  59637. private _onBeforeActiveMeshesEvaluationObserver;
  59638. private _onAfterActiveMeshesEvaluationObserver;
  59639. private _onBeforeRenderTargetsRenderObserver;
  59640. private _onAfterRenderTargetsRenderObserver;
  59641. private _onAfterRenderObserver;
  59642. private _onBeforeDrawPhaseObserver;
  59643. private _onAfterDrawPhaseObserver;
  59644. private _onBeforeAnimationsObserver;
  59645. private _onBeforeParticlesRenderingObserver;
  59646. private _onAfterParticlesRenderingObserver;
  59647. private _onBeforeSpritesRenderingObserver;
  59648. private _onAfterSpritesRenderingObserver;
  59649. private _onBeforePhysicsObserver;
  59650. private _onAfterPhysicsObserver;
  59651. private _onAfterAnimationsObserver;
  59652. private _onBeforeCameraRenderObserver;
  59653. private _onAfterCameraRenderObserver;
  59654. /**
  59655. * Gets the perf counter used for active meshes evaluation time
  59656. */
  59657. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59658. /**
  59659. * Gets the active meshes evaluation time capture status
  59660. */
  59661. get captureActiveMeshesEvaluationTime(): boolean;
  59662. /**
  59663. * Enable or disable the active meshes evaluation time capture
  59664. */
  59665. set captureActiveMeshesEvaluationTime(value: boolean);
  59666. /**
  59667. * Gets the perf counter used for render targets render time
  59668. */
  59669. get renderTargetsRenderTimeCounter(): PerfCounter;
  59670. /**
  59671. * Gets the render targets render time capture status
  59672. */
  59673. get captureRenderTargetsRenderTime(): boolean;
  59674. /**
  59675. * Enable or disable the render targets render time capture
  59676. */
  59677. set captureRenderTargetsRenderTime(value: boolean);
  59678. /**
  59679. * Gets the perf counter used for particles render time
  59680. */
  59681. get particlesRenderTimeCounter(): PerfCounter;
  59682. /**
  59683. * Gets the particles render time capture status
  59684. */
  59685. get captureParticlesRenderTime(): boolean;
  59686. /**
  59687. * Enable or disable the particles render time capture
  59688. */
  59689. set captureParticlesRenderTime(value: boolean);
  59690. /**
  59691. * Gets the perf counter used for sprites render time
  59692. */
  59693. get spritesRenderTimeCounter(): PerfCounter;
  59694. /**
  59695. * Gets the sprites render time capture status
  59696. */
  59697. get captureSpritesRenderTime(): boolean;
  59698. /**
  59699. * Enable or disable the sprites render time capture
  59700. */
  59701. set captureSpritesRenderTime(value: boolean);
  59702. /**
  59703. * Gets the perf counter used for physics time
  59704. */
  59705. get physicsTimeCounter(): PerfCounter;
  59706. /**
  59707. * Gets the physics time capture status
  59708. */
  59709. get capturePhysicsTime(): boolean;
  59710. /**
  59711. * Enable or disable the physics time capture
  59712. */
  59713. set capturePhysicsTime(value: boolean);
  59714. /**
  59715. * Gets the perf counter used for animations time
  59716. */
  59717. get animationsTimeCounter(): PerfCounter;
  59718. /**
  59719. * Gets the animations time capture status
  59720. */
  59721. get captureAnimationsTime(): boolean;
  59722. /**
  59723. * Enable or disable the animations time capture
  59724. */
  59725. set captureAnimationsTime(value: boolean);
  59726. /**
  59727. * Gets the perf counter used for frame time capture
  59728. */
  59729. get frameTimeCounter(): PerfCounter;
  59730. /**
  59731. * Gets the frame time capture status
  59732. */
  59733. get captureFrameTime(): boolean;
  59734. /**
  59735. * Enable or disable the frame time capture
  59736. */
  59737. set captureFrameTime(value: boolean);
  59738. /**
  59739. * Gets the perf counter used for inter-frames time capture
  59740. */
  59741. get interFrameTimeCounter(): PerfCounter;
  59742. /**
  59743. * Gets the inter-frames time capture status
  59744. */
  59745. get captureInterFrameTime(): boolean;
  59746. /**
  59747. * Enable or disable the inter-frames time capture
  59748. */
  59749. set captureInterFrameTime(value: boolean);
  59750. /**
  59751. * Gets the perf counter used for render time capture
  59752. */
  59753. get renderTimeCounter(): PerfCounter;
  59754. /**
  59755. * Gets the render time capture status
  59756. */
  59757. get captureRenderTime(): boolean;
  59758. /**
  59759. * Enable or disable the render time capture
  59760. */
  59761. set captureRenderTime(value: boolean);
  59762. /**
  59763. * Gets the perf counter used for camera render time capture
  59764. */
  59765. get cameraRenderTimeCounter(): PerfCounter;
  59766. /**
  59767. * Gets the camera render time capture status
  59768. */
  59769. get captureCameraRenderTime(): boolean;
  59770. /**
  59771. * Enable or disable the camera render time capture
  59772. */
  59773. set captureCameraRenderTime(value: boolean);
  59774. /**
  59775. * Gets the perf counter used for draw calls
  59776. */
  59777. get drawCallsCounter(): PerfCounter;
  59778. /**
  59779. * Instantiates a new scene instrumentation.
  59780. * This class can be used to get instrumentation data from a Babylon engine
  59781. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59782. * @param scene Defines the scene to instrument
  59783. */
  59784. constructor(
  59785. /**
  59786. * Defines the scene to instrument
  59787. */
  59788. scene: Scene);
  59789. /**
  59790. * Dispose and release associated resources.
  59791. */
  59792. dispose(): void;
  59793. }
  59794. }
  59795. declare module BABYLON {
  59796. /** @hidden */
  59797. export var glowMapGenerationPixelShader: {
  59798. name: string;
  59799. shader: string;
  59800. };
  59801. }
  59802. declare module BABYLON {
  59803. /** @hidden */
  59804. export var glowMapGenerationVertexShader: {
  59805. name: string;
  59806. shader: string;
  59807. };
  59808. }
  59809. declare module BABYLON {
  59810. /**
  59811. * Effect layer options. This helps customizing the behaviour
  59812. * of the effect layer.
  59813. */
  59814. export interface IEffectLayerOptions {
  59815. /**
  59816. * Multiplication factor apply to the canvas size to compute the render target size
  59817. * used to generated the objects (the smaller the faster).
  59818. */
  59819. mainTextureRatio: number;
  59820. /**
  59821. * Enforces a fixed size texture to ensure effect stability across devices.
  59822. */
  59823. mainTextureFixedSize?: number;
  59824. /**
  59825. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59826. */
  59827. alphaBlendingMode: number;
  59828. /**
  59829. * The camera attached to the layer.
  59830. */
  59831. camera: Nullable<Camera>;
  59832. /**
  59833. * The rendering group to draw the layer in.
  59834. */
  59835. renderingGroupId: number;
  59836. }
  59837. /**
  59838. * The effect layer Helps adding post process effect blended with the main pass.
  59839. *
  59840. * This can be for instance use to generate glow or higlight effects on the scene.
  59841. *
  59842. * The effect layer class can not be used directly and is intented to inherited from to be
  59843. * customized per effects.
  59844. */
  59845. export abstract class EffectLayer {
  59846. private _vertexBuffers;
  59847. private _indexBuffer;
  59848. private _cachedDefines;
  59849. private _effectLayerMapGenerationEffect;
  59850. private _effectLayerOptions;
  59851. private _mergeEffect;
  59852. protected _scene: Scene;
  59853. protected _engine: Engine;
  59854. protected _maxSize: number;
  59855. protected _mainTextureDesiredSize: ISize;
  59856. protected _mainTexture: RenderTargetTexture;
  59857. protected _shouldRender: boolean;
  59858. protected _postProcesses: PostProcess[];
  59859. protected _textures: BaseTexture[];
  59860. protected _emissiveTextureAndColor: {
  59861. texture: Nullable<BaseTexture>;
  59862. color: Color4;
  59863. };
  59864. /**
  59865. * The name of the layer
  59866. */
  59867. name: string;
  59868. /**
  59869. * The clear color of the texture used to generate the glow map.
  59870. */
  59871. neutralColor: Color4;
  59872. /**
  59873. * Specifies whether the highlight layer is enabled or not.
  59874. */
  59875. isEnabled: boolean;
  59876. /**
  59877. * Gets the camera attached to the layer.
  59878. */
  59879. get camera(): Nullable<Camera>;
  59880. /**
  59881. * Gets the rendering group id the layer should render in.
  59882. */
  59883. get renderingGroupId(): number;
  59884. set renderingGroupId(renderingGroupId: number);
  59885. /**
  59886. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59887. */
  59888. disableBoundingBoxesFromEffectLayer: boolean;
  59889. /**
  59890. * An event triggered when the effect layer has been disposed.
  59891. */
  59892. onDisposeObservable: Observable<EffectLayer>;
  59893. /**
  59894. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59895. */
  59896. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59897. /**
  59898. * An event triggered when the generated texture is being merged in the scene.
  59899. */
  59900. onBeforeComposeObservable: Observable<EffectLayer>;
  59901. /**
  59902. * An event triggered when the mesh is rendered into the effect render target.
  59903. */
  59904. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59905. /**
  59906. * An event triggered after the mesh has been rendered into the effect render target.
  59907. */
  59908. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59909. /**
  59910. * An event triggered when the generated texture has been merged in the scene.
  59911. */
  59912. onAfterComposeObservable: Observable<EffectLayer>;
  59913. /**
  59914. * An event triggered when the efffect layer changes its size.
  59915. */
  59916. onSizeChangedObservable: Observable<EffectLayer>;
  59917. /** @hidden */
  59918. static _SceneComponentInitialization: (scene: Scene) => void;
  59919. /**
  59920. * Instantiates a new effect Layer and references it in the scene.
  59921. * @param name The name of the layer
  59922. * @param scene The scene to use the layer in
  59923. */
  59924. constructor(
  59925. /** The Friendly of the effect in the scene */
  59926. name: string, scene: Scene);
  59927. /**
  59928. * Get the effect name of the layer.
  59929. * @return The effect name
  59930. */
  59931. abstract getEffectName(): string;
  59932. /**
  59933. * Checks for the readiness of the element composing the layer.
  59934. * @param subMesh the mesh to check for
  59935. * @param useInstances specify whether or not to use instances to render the mesh
  59936. * @return true if ready otherwise, false
  59937. */
  59938. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59939. /**
  59940. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59941. * @returns true if the effect requires stencil during the main canvas render pass.
  59942. */
  59943. abstract needStencil(): boolean;
  59944. /**
  59945. * Create the merge effect. This is the shader use to blit the information back
  59946. * to the main canvas at the end of the scene rendering.
  59947. * @returns The effect containing the shader used to merge the effect on the main canvas
  59948. */
  59949. protected abstract _createMergeEffect(): Effect;
  59950. /**
  59951. * Creates the render target textures and post processes used in the effect layer.
  59952. */
  59953. protected abstract _createTextureAndPostProcesses(): void;
  59954. /**
  59955. * Implementation specific of rendering the generating effect on the main canvas.
  59956. * @param effect The effect used to render through
  59957. */
  59958. protected abstract _internalRender(effect: Effect): void;
  59959. /**
  59960. * Sets the required values for both the emissive texture and and the main color.
  59961. */
  59962. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59963. /**
  59964. * Free any resources and references associated to a mesh.
  59965. * Internal use
  59966. * @param mesh The mesh to free.
  59967. */
  59968. abstract _disposeMesh(mesh: Mesh): void;
  59969. /**
  59970. * Serializes this layer (Glow or Highlight for example)
  59971. * @returns a serialized layer object
  59972. */
  59973. abstract serialize?(): any;
  59974. /**
  59975. * Initializes the effect layer with the required options.
  59976. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59977. */
  59978. protected _init(options: Partial<IEffectLayerOptions>): void;
  59979. /**
  59980. * Generates the index buffer of the full screen quad blending to the main canvas.
  59981. */
  59982. private _generateIndexBuffer;
  59983. /**
  59984. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59985. */
  59986. private _generateVertexBuffer;
  59987. /**
  59988. * Sets the main texture desired size which is the closest power of two
  59989. * of the engine canvas size.
  59990. */
  59991. private _setMainTextureSize;
  59992. /**
  59993. * Creates the main texture for the effect layer.
  59994. */
  59995. protected _createMainTexture(): void;
  59996. /**
  59997. * Adds specific effects defines.
  59998. * @param defines The defines to add specifics to.
  59999. */
  60000. protected _addCustomEffectDefines(defines: string[]): void;
  60001. /**
  60002. * Checks for the readiness of the element composing the layer.
  60003. * @param subMesh the mesh to check for
  60004. * @param useInstances specify whether or not to use instances to render the mesh
  60005. * @param emissiveTexture the associated emissive texture used to generate the glow
  60006. * @return true if ready otherwise, false
  60007. */
  60008. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60009. /**
  60010. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60011. */
  60012. render(): void;
  60013. /**
  60014. * Determine if a given mesh will be used in the current effect.
  60015. * @param mesh mesh to test
  60016. * @returns true if the mesh will be used
  60017. */
  60018. hasMesh(mesh: AbstractMesh): boolean;
  60019. /**
  60020. * Returns true if the layer contains information to display, otherwise false.
  60021. * @returns true if the glow layer should be rendered
  60022. */
  60023. shouldRender(): boolean;
  60024. /**
  60025. * Returns true if the mesh should render, otherwise false.
  60026. * @param mesh The mesh to render
  60027. * @returns true if it should render otherwise false
  60028. */
  60029. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60030. /**
  60031. * Returns true if the mesh can be rendered, otherwise false.
  60032. * @param mesh The mesh to render
  60033. * @param material The material used on the mesh
  60034. * @returns true if it can be rendered otherwise false
  60035. */
  60036. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60037. /**
  60038. * Returns true if the mesh should render, otherwise false.
  60039. * @param mesh The mesh to render
  60040. * @returns true if it should render otherwise false
  60041. */
  60042. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60043. /**
  60044. * Renders the submesh passed in parameter to the generation map.
  60045. */
  60046. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60047. /**
  60048. * Defines whether the current material of the mesh should be use to render the effect.
  60049. * @param mesh defines the current mesh to render
  60050. */
  60051. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60052. /**
  60053. * Rebuild the required buffers.
  60054. * @hidden Internal use only.
  60055. */
  60056. _rebuild(): void;
  60057. /**
  60058. * Dispose only the render target textures and post process.
  60059. */
  60060. private _disposeTextureAndPostProcesses;
  60061. /**
  60062. * Dispose the highlight layer and free resources.
  60063. */
  60064. dispose(): void;
  60065. /**
  60066. * Gets the class name of the effect layer
  60067. * @returns the string with the class name of the effect layer
  60068. */
  60069. getClassName(): string;
  60070. /**
  60071. * Creates an effect layer from parsed effect layer data
  60072. * @param parsedEffectLayer defines effect layer data
  60073. * @param scene defines the current scene
  60074. * @param rootUrl defines the root URL containing the effect layer information
  60075. * @returns a parsed effect Layer
  60076. */
  60077. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60078. }
  60079. }
  60080. declare module BABYLON {
  60081. interface AbstractScene {
  60082. /**
  60083. * The list of effect layers (highlights/glow) added to the scene
  60084. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60085. * @see https://doc.babylonjs.com/how_to/glow_layer
  60086. */
  60087. effectLayers: Array<EffectLayer>;
  60088. /**
  60089. * Removes the given effect layer from this scene.
  60090. * @param toRemove defines the effect layer to remove
  60091. * @returns the index of the removed effect layer
  60092. */
  60093. removeEffectLayer(toRemove: EffectLayer): number;
  60094. /**
  60095. * Adds the given effect layer to this scene
  60096. * @param newEffectLayer defines the effect layer to add
  60097. */
  60098. addEffectLayer(newEffectLayer: EffectLayer): void;
  60099. }
  60100. /**
  60101. * Defines the layer scene component responsible to manage any effect layers
  60102. * in a given scene.
  60103. */
  60104. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60105. /**
  60106. * The component name helpfull to identify the component in the list of scene components.
  60107. */
  60108. readonly name: string;
  60109. /**
  60110. * The scene the component belongs to.
  60111. */
  60112. scene: Scene;
  60113. private _engine;
  60114. private _renderEffects;
  60115. private _needStencil;
  60116. private _previousStencilState;
  60117. /**
  60118. * Creates a new instance of the component for the given scene
  60119. * @param scene Defines the scene to register the component in
  60120. */
  60121. constructor(scene: Scene);
  60122. /**
  60123. * Registers the component in a given scene
  60124. */
  60125. register(): void;
  60126. /**
  60127. * Rebuilds the elements related to this component in case of
  60128. * context lost for instance.
  60129. */
  60130. rebuild(): void;
  60131. /**
  60132. * Serializes the component data to the specified json object
  60133. * @param serializationObject The object to serialize to
  60134. */
  60135. serialize(serializationObject: any): void;
  60136. /**
  60137. * Adds all the elements from the container to the scene
  60138. * @param container the container holding the elements
  60139. */
  60140. addFromContainer(container: AbstractScene): void;
  60141. /**
  60142. * Removes all the elements in the container from the scene
  60143. * @param container contains the elements to remove
  60144. * @param dispose if the removed element should be disposed (default: false)
  60145. */
  60146. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60147. /**
  60148. * Disposes the component and the associated ressources.
  60149. */
  60150. dispose(): void;
  60151. private _isReadyForMesh;
  60152. private _renderMainTexture;
  60153. private _setStencil;
  60154. private _setStencilBack;
  60155. private _draw;
  60156. private _drawCamera;
  60157. private _drawRenderingGroup;
  60158. }
  60159. }
  60160. declare module BABYLON {
  60161. /** @hidden */
  60162. export var glowMapMergePixelShader: {
  60163. name: string;
  60164. shader: string;
  60165. };
  60166. }
  60167. declare module BABYLON {
  60168. /** @hidden */
  60169. export var glowMapMergeVertexShader: {
  60170. name: string;
  60171. shader: string;
  60172. };
  60173. }
  60174. declare module BABYLON {
  60175. interface AbstractScene {
  60176. /**
  60177. * Return a the first highlight layer of the scene with a given name.
  60178. * @param name The name of the highlight layer to look for.
  60179. * @return The highlight layer if found otherwise null.
  60180. */
  60181. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60182. }
  60183. /**
  60184. * Glow layer options. This helps customizing the behaviour
  60185. * of the glow layer.
  60186. */
  60187. export interface IGlowLayerOptions {
  60188. /**
  60189. * Multiplication factor apply to the canvas size to compute the render target size
  60190. * used to generated the glowing objects (the smaller the faster).
  60191. */
  60192. mainTextureRatio: number;
  60193. /**
  60194. * Enforces a fixed size texture to ensure resize independant blur.
  60195. */
  60196. mainTextureFixedSize?: number;
  60197. /**
  60198. * How big is the kernel of the blur texture.
  60199. */
  60200. blurKernelSize: number;
  60201. /**
  60202. * The camera attached to the layer.
  60203. */
  60204. camera: Nullable<Camera>;
  60205. /**
  60206. * Enable MSAA by chosing the number of samples.
  60207. */
  60208. mainTextureSamples?: number;
  60209. /**
  60210. * The rendering group to draw the layer in.
  60211. */
  60212. renderingGroupId: number;
  60213. }
  60214. /**
  60215. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60216. *
  60217. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60218. *
  60219. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60220. */
  60221. export class GlowLayer extends EffectLayer {
  60222. /**
  60223. * Effect Name of the layer.
  60224. */
  60225. static readonly EffectName: string;
  60226. /**
  60227. * The default blur kernel size used for the glow.
  60228. */
  60229. static DefaultBlurKernelSize: number;
  60230. /**
  60231. * The default texture size ratio used for the glow.
  60232. */
  60233. static DefaultTextureRatio: number;
  60234. /**
  60235. * Sets the kernel size of the blur.
  60236. */
  60237. set blurKernelSize(value: number);
  60238. /**
  60239. * Gets the kernel size of the blur.
  60240. */
  60241. get blurKernelSize(): number;
  60242. /**
  60243. * Sets the glow intensity.
  60244. */
  60245. set intensity(value: number);
  60246. /**
  60247. * Gets the glow intensity.
  60248. */
  60249. get intensity(): number;
  60250. private _options;
  60251. private _intensity;
  60252. private _horizontalBlurPostprocess1;
  60253. private _verticalBlurPostprocess1;
  60254. private _horizontalBlurPostprocess2;
  60255. private _verticalBlurPostprocess2;
  60256. private _blurTexture1;
  60257. private _blurTexture2;
  60258. private _postProcesses1;
  60259. private _postProcesses2;
  60260. private _includedOnlyMeshes;
  60261. private _excludedMeshes;
  60262. private _meshesUsingTheirOwnMaterials;
  60263. /**
  60264. * Callback used to let the user override the color selection on a per mesh basis
  60265. */
  60266. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60267. /**
  60268. * Callback used to let the user override the texture selection on a per mesh basis
  60269. */
  60270. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60271. /**
  60272. * Instantiates a new glow Layer and references it to the scene.
  60273. * @param name The name of the layer
  60274. * @param scene The scene to use the layer in
  60275. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60276. */
  60277. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60278. /**
  60279. * Get the effect name of the layer.
  60280. * @return The effect name
  60281. */
  60282. getEffectName(): string;
  60283. /**
  60284. * Create the merge effect. This is the shader use to blit the information back
  60285. * to the main canvas at the end of the scene rendering.
  60286. */
  60287. protected _createMergeEffect(): Effect;
  60288. /**
  60289. * Creates the render target textures and post processes used in the glow layer.
  60290. */
  60291. protected _createTextureAndPostProcesses(): void;
  60292. /**
  60293. * Checks for the readiness of the element composing the layer.
  60294. * @param subMesh the mesh to check for
  60295. * @param useInstances specify wether or not to use instances to render the mesh
  60296. * @param emissiveTexture the associated emissive texture used to generate the glow
  60297. * @return true if ready otherwise, false
  60298. */
  60299. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60300. /**
  60301. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60302. */
  60303. needStencil(): boolean;
  60304. /**
  60305. * Returns true if the mesh can be rendered, otherwise false.
  60306. * @param mesh The mesh to render
  60307. * @param material The material used on the mesh
  60308. * @returns true if it can be rendered otherwise false
  60309. */
  60310. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60311. /**
  60312. * Implementation specific of rendering the generating effect on the main canvas.
  60313. * @param effect The effect used to render through
  60314. */
  60315. protected _internalRender(effect: Effect): void;
  60316. /**
  60317. * Sets the required values for both the emissive texture and and the main color.
  60318. */
  60319. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60320. /**
  60321. * Returns true if the mesh should render, otherwise false.
  60322. * @param mesh The mesh to render
  60323. * @returns true if it should render otherwise false
  60324. */
  60325. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60326. /**
  60327. * Adds specific effects defines.
  60328. * @param defines The defines to add specifics to.
  60329. */
  60330. protected _addCustomEffectDefines(defines: string[]): void;
  60331. /**
  60332. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60333. * @param mesh The mesh to exclude from the glow layer
  60334. */
  60335. addExcludedMesh(mesh: Mesh): void;
  60336. /**
  60337. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60338. * @param mesh The mesh to remove
  60339. */
  60340. removeExcludedMesh(mesh: Mesh): void;
  60341. /**
  60342. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60343. * @param mesh The mesh to include in the glow layer
  60344. */
  60345. addIncludedOnlyMesh(mesh: Mesh): void;
  60346. /**
  60347. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60348. * @param mesh The mesh to remove
  60349. */
  60350. removeIncludedOnlyMesh(mesh: Mesh): void;
  60351. /**
  60352. * Determine if a given mesh will be used in the glow layer
  60353. * @param mesh The mesh to test
  60354. * @returns true if the mesh will be highlighted by the current glow layer
  60355. */
  60356. hasMesh(mesh: AbstractMesh): boolean;
  60357. /**
  60358. * Defines whether the current material of the mesh should be use to render the effect.
  60359. * @param mesh defines the current mesh to render
  60360. */
  60361. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60362. /**
  60363. * Add a mesh to be rendered through its own material and not with emissive only.
  60364. * @param mesh The mesh for which we need to use its material
  60365. */
  60366. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60367. /**
  60368. * Remove a mesh from being rendered through its own material and not with emissive only.
  60369. * @param mesh The mesh for which we need to not use its material
  60370. */
  60371. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60372. /**
  60373. * Free any resources and references associated to a mesh.
  60374. * Internal use
  60375. * @param mesh The mesh to free.
  60376. * @hidden
  60377. */
  60378. _disposeMesh(mesh: Mesh): void;
  60379. /**
  60380. * Gets the class name of the effect layer
  60381. * @returns the string with the class name of the effect layer
  60382. */
  60383. getClassName(): string;
  60384. /**
  60385. * Serializes this glow layer
  60386. * @returns a serialized glow layer object
  60387. */
  60388. serialize(): any;
  60389. /**
  60390. * Creates a Glow Layer from parsed glow layer data
  60391. * @param parsedGlowLayer defines glow layer data
  60392. * @param scene defines the current scene
  60393. * @param rootUrl defines the root URL containing the glow layer information
  60394. * @returns a parsed Glow Layer
  60395. */
  60396. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60397. }
  60398. }
  60399. declare module BABYLON {
  60400. /** @hidden */
  60401. export var glowBlurPostProcessPixelShader: {
  60402. name: string;
  60403. shader: string;
  60404. };
  60405. }
  60406. declare module BABYLON {
  60407. interface AbstractScene {
  60408. /**
  60409. * Return a the first highlight layer of the scene with a given name.
  60410. * @param name The name of the highlight layer to look for.
  60411. * @return The highlight layer if found otherwise null.
  60412. */
  60413. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60414. }
  60415. /**
  60416. * Highlight layer options. This helps customizing the behaviour
  60417. * of the highlight layer.
  60418. */
  60419. export interface IHighlightLayerOptions {
  60420. /**
  60421. * Multiplication factor apply to the canvas size to compute the render target size
  60422. * used to generated the glowing objects (the smaller the faster).
  60423. */
  60424. mainTextureRatio: number;
  60425. /**
  60426. * Enforces a fixed size texture to ensure resize independant blur.
  60427. */
  60428. mainTextureFixedSize?: number;
  60429. /**
  60430. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60431. * of the picture to blur (the smaller the faster).
  60432. */
  60433. blurTextureSizeRatio: number;
  60434. /**
  60435. * How big in texel of the blur texture is the vertical blur.
  60436. */
  60437. blurVerticalSize: number;
  60438. /**
  60439. * How big in texel of the blur texture is the horizontal blur.
  60440. */
  60441. blurHorizontalSize: number;
  60442. /**
  60443. * Alpha blending mode used to apply the blur. Default is combine.
  60444. */
  60445. alphaBlendingMode: number;
  60446. /**
  60447. * The camera attached to the layer.
  60448. */
  60449. camera: Nullable<Camera>;
  60450. /**
  60451. * Should we display highlight as a solid stroke?
  60452. */
  60453. isStroke?: boolean;
  60454. /**
  60455. * The rendering group to draw the layer in.
  60456. */
  60457. renderingGroupId: number;
  60458. }
  60459. /**
  60460. * The highlight layer Helps adding a glow effect around a mesh.
  60461. *
  60462. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60463. * glowy meshes to your scene.
  60464. *
  60465. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60466. */
  60467. export class HighlightLayer extends EffectLayer {
  60468. name: string;
  60469. /**
  60470. * Effect Name of the highlight layer.
  60471. */
  60472. static readonly EffectName: string;
  60473. /**
  60474. * The neutral color used during the preparation of the glow effect.
  60475. * This is black by default as the blend operation is a blend operation.
  60476. */
  60477. static NeutralColor: Color4;
  60478. /**
  60479. * Stencil value used for glowing meshes.
  60480. */
  60481. static GlowingMeshStencilReference: number;
  60482. /**
  60483. * Stencil value used for the other meshes in the scene.
  60484. */
  60485. static NormalMeshStencilReference: number;
  60486. /**
  60487. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60488. */
  60489. innerGlow: boolean;
  60490. /**
  60491. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60492. */
  60493. outerGlow: boolean;
  60494. /**
  60495. * Specifies the horizontal size of the blur.
  60496. */
  60497. set blurHorizontalSize(value: number);
  60498. /**
  60499. * Specifies the vertical size of the blur.
  60500. */
  60501. set blurVerticalSize(value: number);
  60502. /**
  60503. * Gets the horizontal size of the blur.
  60504. */
  60505. get blurHorizontalSize(): number;
  60506. /**
  60507. * Gets the vertical size of the blur.
  60508. */
  60509. get blurVerticalSize(): number;
  60510. /**
  60511. * An event triggered when the highlight layer is being blurred.
  60512. */
  60513. onBeforeBlurObservable: Observable<HighlightLayer>;
  60514. /**
  60515. * An event triggered when the highlight layer has been blurred.
  60516. */
  60517. onAfterBlurObservable: Observable<HighlightLayer>;
  60518. private _instanceGlowingMeshStencilReference;
  60519. private _options;
  60520. private _downSamplePostprocess;
  60521. private _horizontalBlurPostprocess;
  60522. private _verticalBlurPostprocess;
  60523. private _blurTexture;
  60524. private _meshes;
  60525. private _excludedMeshes;
  60526. /**
  60527. * Instantiates a new highlight Layer and references it to the scene..
  60528. * @param name The name of the layer
  60529. * @param scene The scene to use the layer in
  60530. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60531. */
  60532. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60533. /**
  60534. * Get the effect name of the layer.
  60535. * @return The effect name
  60536. */
  60537. getEffectName(): string;
  60538. /**
  60539. * Create the merge effect. This is the shader use to blit the information back
  60540. * to the main canvas at the end of the scene rendering.
  60541. */
  60542. protected _createMergeEffect(): Effect;
  60543. /**
  60544. * Creates the render target textures and post processes used in the highlight layer.
  60545. */
  60546. protected _createTextureAndPostProcesses(): void;
  60547. /**
  60548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60549. */
  60550. needStencil(): boolean;
  60551. /**
  60552. * Checks for the readiness of the element composing the layer.
  60553. * @param subMesh the mesh to check for
  60554. * @param useInstances specify wether or not to use instances to render the mesh
  60555. * @param emissiveTexture the associated emissive texture used to generate the glow
  60556. * @return true if ready otherwise, false
  60557. */
  60558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60559. /**
  60560. * Implementation specific of rendering the generating effect on the main canvas.
  60561. * @param effect The effect used to render through
  60562. */
  60563. protected _internalRender(effect: Effect): void;
  60564. /**
  60565. * Returns true if the layer contains information to display, otherwise false.
  60566. */
  60567. shouldRender(): boolean;
  60568. /**
  60569. * Returns true if the mesh should render, otherwise false.
  60570. * @param mesh The mesh to render
  60571. * @returns true if it should render otherwise false
  60572. */
  60573. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60574. /**
  60575. * Returns true if the mesh can be rendered, otherwise false.
  60576. * @param mesh The mesh to render
  60577. * @param material The material used on the mesh
  60578. * @returns true if it can be rendered otherwise false
  60579. */
  60580. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60581. /**
  60582. * Adds specific effects defines.
  60583. * @param defines The defines to add specifics to.
  60584. */
  60585. protected _addCustomEffectDefines(defines: string[]): void;
  60586. /**
  60587. * Sets the required values for both the emissive texture and and the main color.
  60588. */
  60589. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60590. /**
  60591. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60592. * @param mesh The mesh to exclude from the highlight layer
  60593. */
  60594. addExcludedMesh(mesh: Mesh): void;
  60595. /**
  60596. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60597. * @param mesh The mesh to highlight
  60598. */
  60599. removeExcludedMesh(mesh: Mesh): void;
  60600. /**
  60601. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60602. * @param mesh mesh to test
  60603. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60604. */
  60605. hasMesh(mesh: AbstractMesh): boolean;
  60606. /**
  60607. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60608. * @param mesh The mesh to highlight
  60609. * @param color The color of the highlight
  60610. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60611. */
  60612. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60613. /**
  60614. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60615. * @param mesh The mesh to highlight
  60616. */
  60617. removeMesh(mesh: Mesh): void;
  60618. /**
  60619. * Remove all the meshes currently referenced in the highlight layer
  60620. */
  60621. removeAllMeshes(): void;
  60622. /**
  60623. * Force the stencil to the normal expected value for none glowing parts
  60624. */
  60625. private _defaultStencilReference;
  60626. /**
  60627. * Free any resources and references associated to a mesh.
  60628. * Internal use
  60629. * @param mesh The mesh to free.
  60630. * @hidden
  60631. */
  60632. _disposeMesh(mesh: Mesh): void;
  60633. /**
  60634. * Dispose the highlight layer and free resources.
  60635. */
  60636. dispose(): void;
  60637. /**
  60638. * Gets the class name of the effect layer
  60639. * @returns the string with the class name of the effect layer
  60640. */
  60641. getClassName(): string;
  60642. /**
  60643. * Serializes this Highlight layer
  60644. * @returns a serialized Highlight layer object
  60645. */
  60646. serialize(): any;
  60647. /**
  60648. * Creates a Highlight layer from parsed Highlight layer data
  60649. * @param parsedHightlightLayer defines the Highlight layer data
  60650. * @param scene defines the current scene
  60651. * @param rootUrl defines the root URL containing the Highlight layer information
  60652. * @returns a parsed Highlight layer
  60653. */
  60654. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60655. }
  60656. }
  60657. declare module BABYLON {
  60658. interface AbstractScene {
  60659. /**
  60660. * The list of layers (background and foreground) of the scene
  60661. */
  60662. layers: Array<Layer>;
  60663. }
  60664. /**
  60665. * Defines the layer scene component responsible to manage any layers
  60666. * in a given scene.
  60667. */
  60668. export class LayerSceneComponent implements ISceneComponent {
  60669. /**
  60670. * The component name helpfull to identify the component in the list of scene components.
  60671. */
  60672. readonly name: string;
  60673. /**
  60674. * The scene the component belongs to.
  60675. */
  60676. scene: Scene;
  60677. private _engine;
  60678. /**
  60679. * Creates a new instance of the component for the given scene
  60680. * @param scene Defines the scene to register the component in
  60681. */
  60682. constructor(scene: Scene);
  60683. /**
  60684. * Registers the component in a given scene
  60685. */
  60686. register(): void;
  60687. /**
  60688. * Rebuilds the elements related to this component in case of
  60689. * context lost for instance.
  60690. */
  60691. rebuild(): void;
  60692. /**
  60693. * Disposes the component and the associated ressources.
  60694. */
  60695. dispose(): void;
  60696. private _draw;
  60697. private _drawCameraPredicate;
  60698. private _drawCameraBackground;
  60699. private _drawCameraForeground;
  60700. private _drawRenderTargetPredicate;
  60701. private _drawRenderTargetBackground;
  60702. private _drawRenderTargetForeground;
  60703. /**
  60704. * Adds all the elements from the container to the scene
  60705. * @param container the container holding the elements
  60706. */
  60707. addFromContainer(container: AbstractScene): void;
  60708. /**
  60709. * Removes all the elements in the container from the scene
  60710. * @param container contains the elements to remove
  60711. * @param dispose if the removed element should be disposed (default: false)
  60712. */
  60713. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60714. }
  60715. }
  60716. declare module BABYLON {
  60717. /** @hidden */
  60718. export var layerPixelShader: {
  60719. name: string;
  60720. shader: string;
  60721. };
  60722. }
  60723. declare module BABYLON {
  60724. /** @hidden */
  60725. export var layerVertexShader: {
  60726. name: string;
  60727. shader: string;
  60728. };
  60729. }
  60730. declare module BABYLON {
  60731. /**
  60732. * This represents a full screen 2d layer.
  60733. * This can be useful to display a picture in the background of your scene for instance.
  60734. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60735. */
  60736. export class Layer {
  60737. /**
  60738. * Define the name of the layer.
  60739. */
  60740. name: string;
  60741. /**
  60742. * Define the texture the layer should display.
  60743. */
  60744. texture: Nullable<Texture>;
  60745. /**
  60746. * Is the layer in background or foreground.
  60747. */
  60748. isBackground: boolean;
  60749. /**
  60750. * Define the color of the layer (instead of texture).
  60751. */
  60752. color: Color4;
  60753. /**
  60754. * Define the scale of the layer in order to zoom in out of the texture.
  60755. */
  60756. scale: Vector2;
  60757. /**
  60758. * Define an offset for the layer in order to shift the texture.
  60759. */
  60760. offset: Vector2;
  60761. /**
  60762. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60763. */
  60764. alphaBlendingMode: number;
  60765. /**
  60766. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60767. * Alpha test will not mix with the background color in case of transparency.
  60768. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60769. */
  60770. alphaTest: boolean;
  60771. /**
  60772. * Define a mask to restrict the layer to only some of the scene cameras.
  60773. */
  60774. layerMask: number;
  60775. /**
  60776. * Define the list of render target the layer is visible into.
  60777. */
  60778. renderTargetTextures: RenderTargetTexture[];
  60779. /**
  60780. * Define if the layer is only used in renderTarget or if it also
  60781. * renders in the main frame buffer of the canvas.
  60782. */
  60783. renderOnlyInRenderTargetTextures: boolean;
  60784. private _scene;
  60785. private _vertexBuffers;
  60786. private _indexBuffer;
  60787. private _effect;
  60788. private _previousDefines;
  60789. /**
  60790. * An event triggered when the layer is disposed.
  60791. */
  60792. onDisposeObservable: Observable<Layer>;
  60793. private _onDisposeObserver;
  60794. /**
  60795. * Back compatibility with callback before the onDisposeObservable existed.
  60796. * The set callback will be triggered when the layer has been disposed.
  60797. */
  60798. set onDispose(callback: () => void);
  60799. /**
  60800. * An event triggered before rendering the scene
  60801. */
  60802. onBeforeRenderObservable: Observable<Layer>;
  60803. private _onBeforeRenderObserver;
  60804. /**
  60805. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60806. * The set callback will be triggered just before rendering the layer.
  60807. */
  60808. set onBeforeRender(callback: () => void);
  60809. /**
  60810. * An event triggered after rendering the scene
  60811. */
  60812. onAfterRenderObservable: Observable<Layer>;
  60813. private _onAfterRenderObserver;
  60814. /**
  60815. * Back compatibility with callback before the onAfterRenderObservable existed.
  60816. * The set callback will be triggered just after rendering the layer.
  60817. */
  60818. set onAfterRender(callback: () => void);
  60819. /**
  60820. * Instantiates a new layer.
  60821. * This represents a full screen 2d layer.
  60822. * This can be useful to display a picture in the background of your scene for instance.
  60823. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60824. * @param name Define the name of the layer in the scene
  60825. * @param imgUrl Define the url of the texture to display in the layer
  60826. * @param scene Define the scene the layer belongs to
  60827. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60828. * @param color Defines a color for the layer
  60829. */
  60830. constructor(
  60831. /**
  60832. * Define the name of the layer.
  60833. */
  60834. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60835. private _createIndexBuffer;
  60836. /** @hidden */
  60837. _rebuild(): void;
  60838. /**
  60839. * Renders the layer in the scene.
  60840. */
  60841. render(): void;
  60842. /**
  60843. * Disposes and releases the associated ressources.
  60844. */
  60845. dispose(): void;
  60846. }
  60847. }
  60848. declare module BABYLON {
  60849. /** @hidden */
  60850. export var lensFlarePixelShader: {
  60851. name: string;
  60852. shader: string;
  60853. };
  60854. }
  60855. declare module BABYLON {
  60856. /** @hidden */
  60857. export var lensFlareVertexShader: {
  60858. name: string;
  60859. shader: string;
  60860. };
  60861. }
  60862. declare module BABYLON {
  60863. /**
  60864. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60865. * It is usually composed of several `lensFlare`.
  60866. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60867. */
  60868. export class LensFlareSystem {
  60869. /**
  60870. * Define the name of the lens flare system
  60871. */
  60872. name: string;
  60873. /**
  60874. * List of lens flares used in this system.
  60875. */
  60876. lensFlares: LensFlare[];
  60877. /**
  60878. * Define a limit from the border the lens flare can be visible.
  60879. */
  60880. borderLimit: number;
  60881. /**
  60882. * Define a viewport border we do not want to see the lens flare in.
  60883. */
  60884. viewportBorder: number;
  60885. /**
  60886. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60887. */
  60888. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60889. /**
  60890. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60891. */
  60892. layerMask: number;
  60893. /**
  60894. * Define the id of the lens flare system in the scene.
  60895. * (equal to name by default)
  60896. */
  60897. id: string;
  60898. private _scene;
  60899. private _emitter;
  60900. private _vertexBuffers;
  60901. private _indexBuffer;
  60902. private _effect;
  60903. private _positionX;
  60904. private _positionY;
  60905. private _isEnabled;
  60906. /** @hidden */
  60907. static _SceneComponentInitialization: (scene: Scene) => void;
  60908. /**
  60909. * Instantiates a lens flare system.
  60910. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60911. * It is usually composed of several `lensFlare`.
  60912. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60913. * @param name Define the name of the lens flare system in the scene
  60914. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60915. * @param scene Define the scene the lens flare system belongs to
  60916. */
  60917. constructor(
  60918. /**
  60919. * Define the name of the lens flare system
  60920. */
  60921. name: string, emitter: any, scene: Scene);
  60922. /**
  60923. * Define if the lens flare system is enabled.
  60924. */
  60925. get isEnabled(): boolean;
  60926. set isEnabled(value: boolean);
  60927. /**
  60928. * Get the scene the effects belongs to.
  60929. * @returns the scene holding the lens flare system
  60930. */
  60931. getScene(): Scene;
  60932. /**
  60933. * Get the emitter of the lens flare system.
  60934. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60935. * @returns the emitter of the lens flare system
  60936. */
  60937. getEmitter(): any;
  60938. /**
  60939. * Set the emitter of the lens flare system.
  60940. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60941. * @param newEmitter Define the new emitter of the system
  60942. */
  60943. setEmitter(newEmitter: any): void;
  60944. /**
  60945. * Get the lens flare system emitter position.
  60946. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60947. * @returns the position
  60948. */
  60949. getEmitterPosition(): Vector3;
  60950. /**
  60951. * @hidden
  60952. */
  60953. computeEffectivePosition(globalViewport: Viewport): boolean;
  60954. /** @hidden */
  60955. _isVisible(): boolean;
  60956. /**
  60957. * @hidden
  60958. */
  60959. render(): boolean;
  60960. /**
  60961. * Dispose and release the lens flare with its associated resources.
  60962. */
  60963. dispose(): void;
  60964. /**
  60965. * Parse a lens flare system from a JSON repressentation
  60966. * @param parsedLensFlareSystem Define the JSON to parse
  60967. * @param scene Define the scene the parsed system should be instantiated in
  60968. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60969. * @returns the parsed system
  60970. */
  60971. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60972. /**
  60973. * Serialize the current Lens Flare System into a JSON representation.
  60974. * @returns the serialized JSON
  60975. */
  60976. serialize(): any;
  60977. }
  60978. }
  60979. declare module BABYLON {
  60980. /**
  60981. * This represents one of the lens effect in a `lensFlareSystem`.
  60982. * It controls one of the indiviual texture used in the effect.
  60983. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60984. */
  60985. export class LensFlare {
  60986. /**
  60987. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60988. */
  60989. size: number;
  60990. /**
  60991. * 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.
  60992. */
  60993. position: number;
  60994. /**
  60995. * Define the lens color.
  60996. */
  60997. color: Color3;
  60998. /**
  60999. * Define the lens texture.
  61000. */
  61001. texture: Nullable<Texture>;
  61002. /**
  61003. * Define the alpha mode to render this particular lens.
  61004. */
  61005. alphaMode: number;
  61006. private _system;
  61007. /**
  61008. * Creates a new Lens Flare.
  61009. * This represents one of the lens effect in a `lensFlareSystem`.
  61010. * It controls one of the indiviual texture used in the effect.
  61011. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61012. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61013. * @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.
  61014. * @param color Define the lens color
  61015. * @param imgUrl Define the lens texture url
  61016. * @param system Define the `lensFlareSystem` this flare is part of
  61017. * @returns The newly created Lens Flare
  61018. */
  61019. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61020. /**
  61021. * Instantiates a new Lens Flare.
  61022. * This represents one of the lens effect in a `lensFlareSystem`.
  61023. * It controls one of the indiviual texture used in the effect.
  61024. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61025. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61026. * @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.
  61027. * @param color Define the lens color
  61028. * @param imgUrl Define the lens texture url
  61029. * @param system Define the `lensFlareSystem` this flare is part of
  61030. */
  61031. constructor(
  61032. /**
  61033. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61034. */
  61035. size: number,
  61036. /**
  61037. * 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.
  61038. */
  61039. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61040. /**
  61041. * Dispose and release the lens flare with its associated resources.
  61042. */
  61043. dispose(): void;
  61044. }
  61045. }
  61046. declare module BABYLON {
  61047. interface AbstractScene {
  61048. /**
  61049. * The list of lens flare system added to the scene
  61050. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61051. */
  61052. lensFlareSystems: Array<LensFlareSystem>;
  61053. /**
  61054. * Removes the given lens flare system from this scene.
  61055. * @param toRemove The lens flare system to remove
  61056. * @returns The index of the removed lens flare system
  61057. */
  61058. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61059. /**
  61060. * Adds the given lens flare system to this scene
  61061. * @param newLensFlareSystem The lens flare system to add
  61062. */
  61063. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61064. /**
  61065. * Gets a lens flare system using its name
  61066. * @param name defines the name to look for
  61067. * @returns the lens flare system or null if not found
  61068. */
  61069. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61070. /**
  61071. * Gets a lens flare system using its id
  61072. * @param id defines the id to look for
  61073. * @returns the lens flare system or null if not found
  61074. */
  61075. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61076. }
  61077. /**
  61078. * Defines the lens flare scene component responsible to manage any lens flares
  61079. * in a given scene.
  61080. */
  61081. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61082. /**
  61083. * The component name helpfull to identify the component in the list of scene components.
  61084. */
  61085. readonly name: string;
  61086. /**
  61087. * The scene the component belongs to.
  61088. */
  61089. scene: Scene;
  61090. /**
  61091. * Creates a new instance of the component for the given scene
  61092. * @param scene Defines the scene to register the component in
  61093. */
  61094. constructor(scene: Scene);
  61095. /**
  61096. * Registers the component in a given scene
  61097. */
  61098. register(): void;
  61099. /**
  61100. * Rebuilds the elements related to this component in case of
  61101. * context lost for instance.
  61102. */
  61103. rebuild(): void;
  61104. /**
  61105. * Adds all the elements from the container to the scene
  61106. * @param container the container holding the elements
  61107. */
  61108. addFromContainer(container: AbstractScene): void;
  61109. /**
  61110. * Removes all the elements in the container from the scene
  61111. * @param container contains the elements to remove
  61112. * @param dispose if the removed element should be disposed (default: false)
  61113. */
  61114. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61115. /**
  61116. * Serializes the component data to the specified json object
  61117. * @param serializationObject The object to serialize to
  61118. */
  61119. serialize(serializationObject: any): void;
  61120. /**
  61121. * Disposes the component and the associated ressources.
  61122. */
  61123. dispose(): void;
  61124. private _draw;
  61125. }
  61126. }
  61127. declare module BABYLON {
  61128. /** @hidden */
  61129. export var depthPixelShader: {
  61130. name: string;
  61131. shader: string;
  61132. };
  61133. }
  61134. declare module BABYLON {
  61135. /** @hidden */
  61136. export var depthVertexShader: {
  61137. name: string;
  61138. shader: string;
  61139. };
  61140. }
  61141. declare module BABYLON {
  61142. /**
  61143. * This represents a depth renderer in Babylon.
  61144. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61145. */
  61146. export class DepthRenderer {
  61147. private _scene;
  61148. private _depthMap;
  61149. private _effect;
  61150. private readonly _storeNonLinearDepth;
  61151. private readonly _clearColor;
  61152. /** Get if the depth renderer is using packed depth or not */
  61153. readonly isPacked: boolean;
  61154. private _cachedDefines;
  61155. private _camera;
  61156. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61157. enabled: boolean;
  61158. /**
  61159. * Specifiess that the depth renderer will only be used within
  61160. * the camera it is created for.
  61161. * This can help forcing its rendering during the camera processing.
  61162. */
  61163. useOnlyInActiveCamera: boolean;
  61164. /** @hidden */
  61165. static _SceneComponentInitialization: (scene: Scene) => void;
  61166. /**
  61167. * Instantiates a depth renderer
  61168. * @param scene The scene the renderer belongs to
  61169. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61170. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61171. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61172. */
  61173. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61174. /**
  61175. * Creates the depth rendering effect and checks if the effect is ready.
  61176. * @param subMesh The submesh to be used to render the depth map of
  61177. * @param useInstances If multiple world instances should be used
  61178. * @returns if the depth renderer is ready to render the depth map
  61179. */
  61180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61181. /**
  61182. * Gets the texture which the depth map will be written to.
  61183. * @returns The depth map texture
  61184. */
  61185. getDepthMap(): RenderTargetTexture;
  61186. /**
  61187. * Disposes of the depth renderer.
  61188. */
  61189. dispose(): void;
  61190. }
  61191. }
  61192. declare module BABYLON {
  61193. /** @hidden */
  61194. export var minmaxReduxPixelShader: {
  61195. name: string;
  61196. shader: string;
  61197. };
  61198. }
  61199. declare module BABYLON {
  61200. /**
  61201. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61202. * and maximum values from all values of the texture.
  61203. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61204. * The source values are read from the red channel of the texture.
  61205. */
  61206. export class MinMaxReducer {
  61207. /**
  61208. * Observable triggered when the computation has been performed
  61209. */
  61210. onAfterReductionPerformed: Observable<{
  61211. min: number;
  61212. max: number;
  61213. }>;
  61214. protected _camera: Camera;
  61215. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61216. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61217. protected _postProcessManager: PostProcessManager;
  61218. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61219. protected _forceFullscreenViewport: boolean;
  61220. /**
  61221. * Creates a min/max reducer
  61222. * @param camera The camera to use for the post processes
  61223. */
  61224. constructor(camera: Camera);
  61225. /**
  61226. * Gets the texture used to read the values from.
  61227. */
  61228. get sourceTexture(): Nullable<RenderTargetTexture>;
  61229. /**
  61230. * Sets the source texture to read the values from.
  61231. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61232. * because in such textures '1' value must not be taken into account to compute the maximum
  61233. * as this value is used to clear the texture.
  61234. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61235. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61236. * @param depthRedux Indicates if the texture is a depth texture or not
  61237. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61238. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61239. */
  61240. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61241. /**
  61242. * Defines the refresh rate of the computation.
  61243. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61244. */
  61245. get refreshRate(): number;
  61246. set refreshRate(value: number);
  61247. protected _activated: boolean;
  61248. /**
  61249. * Gets the activation status of the reducer
  61250. */
  61251. get activated(): boolean;
  61252. /**
  61253. * Activates the reduction computation.
  61254. * When activated, the observers registered in onAfterReductionPerformed are
  61255. * called after the compuation is performed
  61256. */
  61257. activate(): void;
  61258. /**
  61259. * Deactivates the reduction computation.
  61260. */
  61261. deactivate(): void;
  61262. /**
  61263. * Disposes the min/max reducer
  61264. * @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.
  61265. */
  61266. dispose(disposeAll?: boolean): void;
  61267. }
  61268. }
  61269. declare module BABYLON {
  61270. /**
  61271. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61272. */
  61273. export class DepthReducer extends MinMaxReducer {
  61274. private _depthRenderer;
  61275. private _depthRendererId;
  61276. /**
  61277. * Gets the depth renderer used for the computation.
  61278. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61279. */
  61280. get depthRenderer(): Nullable<DepthRenderer>;
  61281. /**
  61282. * Creates a depth reducer
  61283. * @param camera The camera used to render the depth texture
  61284. */
  61285. constructor(camera: Camera);
  61286. /**
  61287. * Sets the depth renderer to use to generate the depth map
  61288. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61289. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61290. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61291. */
  61292. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61293. /** @hidden */
  61294. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61295. /**
  61296. * Activates the reduction computation.
  61297. * When activated, the observers registered in onAfterReductionPerformed are
  61298. * called after the compuation is performed
  61299. */
  61300. activate(): void;
  61301. /**
  61302. * Deactivates the reduction computation.
  61303. */
  61304. deactivate(): void;
  61305. /**
  61306. * Disposes the depth reducer
  61307. * @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.
  61308. */
  61309. dispose(disposeAll?: boolean): void;
  61310. }
  61311. }
  61312. declare module BABYLON {
  61313. /**
  61314. * A CSM implementation allowing casting shadows on large scenes.
  61315. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61316. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61317. */
  61318. export class CascadedShadowGenerator extends ShadowGenerator {
  61319. private static readonly frustumCornersNDCSpace;
  61320. /**
  61321. * Name of the CSM class
  61322. */
  61323. static CLASSNAME: string;
  61324. /**
  61325. * Defines the default number of cascades used by the CSM.
  61326. */
  61327. static readonly DEFAULT_CASCADES_COUNT: number;
  61328. /**
  61329. * Defines the minimum number of cascades used by the CSM.
  61330. */
  61331. static readonly MIN_CASCADES_COUNT: number;
  61332. /**
  61333. * Defines the maximum number of cascades used by the CSM.
  61334. */
  61335. static readonly MAX_CASCADES_COUNT: number;
  61336. protected _validateFilter(filter: number): number;
  61337. /**
  61338. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61339. */
  61340. penumbraDarkness: number;
  61341. private _numCascades;
  61342. /**
  61343. * Gets or set the number of cascades used by the CSM.
  61344. */
  61345. get numCascades(): number;
  61346. set numCascades(value: number);
  61347. /**
  61348. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61349. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61350. */
  61351. stabilizeCascades: boolean;
  61352. private _freezeShadowCastersBoundingInfo;
  61353. private _freezeShadowCastersBoundingInfoObservable;
  61354. /**
  61355. * Enables or disables the shadow casters bounding info computation.
  61356. * If your shadow casters don't move, you can disable this feature.
  61357. * If it is enabled, the bounding box computation is done every frame.
  61358. */
  61359. get freezeShadowCastersBoundingInfo(): boolean;
  61360. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61361. private _scbiMin;
  61362. private _scbiMax;
  61363. protected _computeShadowCastersBoundingInfo(): void;
  61364. protected _shadowCastersBoundingInfo: BoundingInfo;
  61365. /**
  61366. * Gets or sets the shadow casters bounding info.
  61367. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61368. * so that the system won't overwrite the bounds you provide
  61369. */
  61370. get shadowCastersBoundingInfo(): BoundingInfo;
  61371. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61372. protected _breaksAreDirty: boolean;
  61373. protected _minDistance: number;
  61374. protected _maxDistance: number;
  61375. /**
  61376. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61377. *
  61378. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61379. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61380. * @param min minimal distance for the breaks (default to 0.)
  61381. * @param max maximal distance for the breaks (default to 1.)
  61382. */
  61383. setMinMaxDistance(min: number, max: number): void;
  61384. /** Gets the minimal distance used in the cascade break computation */
  61385. get minDistance(): number;
  61386. /** Gets the maximal distance used in the cascade break computation */
  61387. get maxDistance(): number;
  61388. /**
  61389. * Gets the class name of that object
  61390. * @returns "CascadedShadowGenerator"
  61391. */
  61392. getClassName(): string;
  61393. private _cascadeMinExtents;
  61394. private _cascadeMaxExtents;
  61395. /**
  61396. * Gets a cascade minimum extents
  61397. * @param cascadeIndex index of the cascade
  61398. * @returns the minimum cascade extents
  61399. */
  61400. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61401. /**
  61402. * Gets a cascade maximum extents
  61403. * @param cascadeIndex index of the cascade
  61404. * @returns the maximum cascade extents
  61405. */
  61406. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61407. private _cascades;
  61408. private _currentLayer;
  61409. private _viewSpaceFrustumsZ;
  61410. private _viewMatrices;
  61411. private _projectionMatrices;
  61412. private _transformMatrices;
  61413. private _transformMatricesAsArray;
  61414. private _frustumLengths;
  61415. private _lightSizeUVCorrection;
  61416. private _depthCorrection;
  61417. private _frustumCornersWorldSpace;
  61418. private _frustumCenter;
  61419. private _shadowCameraPos;
  61420. private _shadowMaxZ;
  61421. /**
  61422. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61423. * It defaults to camera.maxZ
  61424. */
  61425. get shadowMaxZ(): number;
  61426. /**
  61427. * Sets the shadow max z distance.
  61428. */
  61429. set shadowMaxZ(value: number);
  61430. protected _debug: boolean;
  61431. /**
  61432. * Gets or sets the debug flag.
  61433. * When enabled, the cascades are materialized by different colors on the screen.
  61434. */
  61435. get debug(): boolean;
  61436. set debug(dbg: boolean);
  61437. private _depthClamp;
  61438. /**
  61439. * Gets or sets the depth clamping value.
  61440. *
  61441. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61442. * to account for the shadow casters far away.
  61443. *
  61444. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61445. */
  61446. get depthClamp(): boolean;
  61447. set depthClamp(value: boolean);
  61448. private _cascadeBlendPercentage;
  61449. /**
  61450. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61451. * It defaults to 0.1 (10% blending).
  61452. */
  61453. get cascadeBlendPercentage(): number;
  61454. set cascadeBlendPercentage(value: number);
  61455. private _lambda;
  61456. /**
  61457. * Gets or set the lambda parameter.
  61458. * This parameter is used to split the camera frustum and create the cascades.
  61459. * 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.
  61460. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61461. */
  61462. get lambda(): number;
  61463. set lambda(value: number);
  61464. /**
  61465. * Gets the view matrix corresponding to a given cascade
  61466. * @param cascadeNum cascade to retrieve the view matrix from
  61467. * @returns the cascade view matrix
  61468. */
  61469. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61470. /**
  61471. * Gets the projection matrix corresponding to a given cascade
  61472. * @param cascadeNum cascade to retrieve the projection matrix from
  61473. * @returns the cascade projection matrix
  61474. */
  61475. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61476. /**
  61477. * Gets the transformation matrix corresponding to a given cascade
  61478. * @param cascadeNum cascade to retrieve the transformation matrix from
  61479. * @returns the cascade transformation matrix
  61480. */
  61481. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61482. private _depthRenderer;
  61483. /**
  61484. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61485. *
  61486. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61487. *
  61488. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61489. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61490. * @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
  61491. */
  61492. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61493. private _depthReducer;
  61494. private _autoCalcDepthBounds;
  61495. /**
  61496. * Gets or sets the autoCalcDepthBounds property.
  61497. *
  61498. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61499. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61500. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61501. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61502. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61503. */
  61504. get autoCalcDepthBounds(): boolean;
  61505. set autoCalcDepthBounds(value: boolean);
  61506. /**
  61507. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61508. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61509. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61510. * for setting the refresh rate on the renderer yourself!
  61511. */
  61512. get autoCalcDepthBoundsRefreshRate(): number;
  61513. set autoCalcDepthBoundsRefreshRate(value: number);
  61514. /**
  61515. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61516. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61517. * you change the camera near/far planes!
  61518. */
  61519. splitFrustum(): void;
  61520. private _splitFrustum;
  61521. private _computeMatrices;
  61522. private _computeFrustumInWorldSpace;
  61523. private _computeCascadeFrustum;
  61524. /**
  61525. * Support test.
  61526. */
  61527. static get IsSupported(): boolean;
  61528. /** @hidden */
  61529. static _SceneComponentInitialization: (scene: Scene) => void;
  61530. /**
  61531. * Creates a Cascaded Shadow Generator object.
  61532. * A ShadowGenerator is the required tool to use the shadows.
  61533. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61534. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61535. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61536. * @param light The directional light object generating the shadows.
  61537. * @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.
  61538. */
  61539. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61540. protected _initializeGenerator(): void;
  61541. protected _createTargetRenderTexture(): void;
  61542. protected _initializeShadowMap(): void;
  61543. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61544. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61545. /**
  61546. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61547. * @param defines Defines of the material we want to update
  61548. * @param lightIndex Index of the light in the enabled light list of the material
  61549. */
  61550. prepareDefines(defines: any, lightIndex: number): void;
  61551. /**
  61552. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61553. * defined in the generator but impacting the effect).
  61554. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61555. * @param effect The effect we are binfing the information for
  61556. */
  61557. bindShadowLight(lightIndex: string, effect: Effect): void;
  61558. /**
  61559. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61560. * (eq to view projection * shadow projection matrices)
  61561. * @returns The transform matrix used to create the shadow map
  61562. */
  61563. getTransformMatrix(): Matrix;
  61564. /**
  61565. * Disposes the ShadowGenerator.
  61566. * Returns nothing.
  61567. */
  61568. dispose(): void;
  61569. /**
  61570. * Serializes the shadow generator setup to a json object.
  61571. * @returns The serialized JSON object
  61572. */
  61573. serialize(): any;
  61574. /**
  61575. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61576. * @param parsedShadowGenerator The JSON object to parse
  61577. * @param scene The scene to create the shadow map for
  61578. * @returns The parsed shadow generator
  61579. */
  61580. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61581. }
  61582. }
  61583. declare module BABYLON {
  61584. /**
  61585. * Defines the shadow generator component responsible to manage any shadow generators
  61586. * in a given scene.
  61587. */
  61588. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61589. /**
  61590. * The component name helpfull to identify the component in the list of scene components.
  61591. */
  61592. readonly name: string;
  61593. /**
  61594. * The scene the component belongs to.
  61595. */
  61596. scene: Scene;
  61597. /**
  61598. * Creates a new instance of the component for the given scene
  61599. * @param scene Defines the scene to register the component in
  61600. */
  61601. constructor(scene: Scene);
  61602. /**
  61603. * Registers the component in a given scene
  61604. */
  61605. register(): void;
  61606. /**
  61607. * Rebuilds the elements related to this component in case of
  61608. * context lost for instance.
  61609. */
  61610. rebuild(): void;
  61611. /**
  61612. * Serializes the component data to the specified json object
  61613. * @param serializationObject The object to serialize to
  61614. */
  61615. serialize(serializationObject: any): void;
  61616. /**
  61617. * Adds all the elements from the container to the scene
  61618. * @param container the container holding the elements
  61619. */
  61620. addFromContainer(container: AbstractScene): void;
  61621. /**
  61622. * Removes all the elements in the container from the scene
  61623. * @param container contains the elements to remove
  61624. * @param dispose if the removed element should be disposed (default: false)
  61625. */
  61626. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61627. /**
  61628. * Rebuilds the elements related to this component in case of
  61629. * context lost for instance.
  61630. */
  61631. dispose(): void;
  61632. private _gatherRenderTargets;
  61633. }
  61634. }
  61635. declare module BABYLON {
  61636. /**
  61637. * A point light is a light defined by an unique point in world space.
  61638. * The light is emitted in every direction from this point.
  61639. * A good example of a point light is a standard light bulb.
  61640. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61641. */
  61642. export class PointLight extends ShadowLight {
  61643. private _shadowAngle;
  61644. /**
  61645. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61646. * This specifies what angle the shadow will use to be created.
  61647. *
  61648. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61649. */
  61650. get shadowAngle(): number;
  61651. /**
  61652. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61653. * This specifies what angle the shadow will use to be created.
  61654. *
  61655. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61656. */
  61657. set shadowAngle(value: number);
  61658. /**
  61659. * Gets the direction if it has been set.
  61660. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61661. */
  61662. get direction(): Vector3;
  61663. /**
  61664. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61665. */
  61666. set direction(value: Vector3);
  61667. /**
  61668. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61669. * A PointLight emits the light in every direction.
  61670. * It can cast shadows.
  61671. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61672. * ```javascript
  61673. * var pointLight = new PointLight("pl", camera.position, scene);
  61674. * ```
  61675. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61676. * @param name The light friendly name
  61677. * @param position The position of the point light in the scene
  61678. * @param scene The scene the lights belongs to
  61679. */
  61680. constructor(name: string, position: Vector3, scene: Scene);
  61681. /**
  61682. * Returns the string "PointLight"
  61683. * @returns the class name
  61684. */
  61685. getClassName(): string;
  61686. /**
  61687. * Returns the integer 0.
  61688. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61689. */
  61690. getTypeID(): number;
  61691. /**
  61692. * Specifies wether or not the shadowmap should be a cube texture.
  61693. * @returns true if the shadowmap needs to be a cube texture.
  61694. */
  61695. needCube(): boolean;
  61696. /**
  61697. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61698. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61699. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61700. */
  61701. getShadowDirection(faceIndex?: number): Vector3;
  61702. /**
  61703. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61704. * - fov = PI / 2
  61705. * - aspect ratio : 1.0
  61706. * - z-near and far equal to the active camera minZ and maxZ.
  61707. * Returns the PointLight.
  61708. */
  61709. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61710. protected _buildUniformLayout(): void;
  61711. /**
  61712. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61713. * @param effect The effect to update
  61714. * @param lightIndex The index of the light in the effect to update
  61715. * @returns The point light
  61716. */
  61717. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61718. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61719. /**
  61720. * Prepares the list of defines specific to the light type.
  61721. * @param defines the list of defines
  61722. * @param lightIndex defines the index of the light for the effect
  61723. */
  61724. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61725. }
  61726. }
  61727. declare module BABYLON {
  61728. /**
  61729. * Header information of HDR texture files.
  61730. */
  61731. export interface HDRInfo {
  61732. /**
  61733. * The height of the texture in pixels.
  61734. */
  61735. height: number;
  61736. /**
  61737. * The width of the texture in pixels.
  61738. */
  61739. width: number;
  61740. /**
  61741. * The index of the beginning of the data in the binary file.
  61742. */
  61743. dataPosition: number;
  61744. }
  61745. /**
  61746. * This groups tools to convert HDR texture to native colors array.
  61747. */
  61748. export class HDRTools {
  61749. private static Ldexp;
  61750. private static Rgbe2float;
  61751. private static readStringLine;
  61752. /**
  61753. * Reads header information from an RGBE texture stored in a native array.
  61754. * More information on this format are available here:
  61755. * https://en.wikipedia.org/wiki/RGBE_image_format
  61756. *
  61757. * @param uint8array The binary file stored in native array.
  61758. * @return The header information.
  61759. */
  61760. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61761. /**
  61762. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61763. * This RGBE texture needs to store the information as a panorama.
  61764. *
  61765. * More information on this format are available here:
  61766. * https://en.wikipedia.org/wiki/RGBE_image_format
  61767. *
  61768. * @param buffer The binary file stored in an array buffer.
  61769. * @param size The expected size of the extracted cubemap.
  61770. * @return The Cube Map information.
  61771. */
  61772. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61773. /**
  61774. * Returns the pixels data extracted from an RGBE texture.
  61775. * This pixels will be stored left to right up to down in the R G B order in one array.
  61776. *
  61777. * More information on this format are available here:
  61778. * https://en.wikipedia.org/wiki/RGBE_image_format
  61779. *
  61780. * @param uint8array The binary file stored in an array buffer.
  61781. * @param hdrInfo The header information of the file.
  61782. * @return The pixels data in RGB right to left up to down order.
  61783. */
  61784. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61785. private static RGBE_ReadPixels_RLE;
  61786. private static RGBE_ReadPixels_NOT_RLE;
  61787. }
  61788. }
  61789. declare module BABYLON {
  61790. /**
  61791. * Effect Render Options
  61792. */
  61793. export interface IEffectRendererOptions {
  61794. /**
  61795. * Defines the vertices positions.
  61796. */
  61797. positions?: number[];
  61798. /**
  61799. * Defines the indices.
  61800. */
  61801. indices?: number[];
  61802. }
  61803. /**
  61804. * Helper class to render one or more effects.
  61805. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61806. */
  61807. export class EffectRenderer {
  61808. private engine;
  61809. private static _DefaultOptions;
  61810. private _vertexBuffers;
  61811. private _indexBuffer;
  61812. private _fullscreenViewport;
  61813. /**
  61814. * Creates an effect renderer
  61815. * @param engine the engine to use for rendering
  61816. * @param options defines the options of the effect renderer
  61817. */
  61818. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61819. /**
  61820. * Sets the current viewport in normalized coordinates 0-1
  61821. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61822. */
  61823. setViewport(viewport?: Viewport): void;
  61824. /**
  61825. * Binds the embedded attributes buffer to the effect.
  61826. * @param effect Defines the effect to bind the attributes for
  61827. */
  61828. bindBuffers(effect: Effect): void;
  61829. /**
  61830. * Sets the current effect wrapper to use during draw.
  61831. * The effect needs to be ready before calling this api.
  61832. * This also sets the default full screen position attribute.
  61833. * @param effectWrapper Defines the effect to draw with
  61834. */
  61835. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61836. /**
  61837. * Restores engine states
  61838. */
  61839. restoreStates(): void;
  61840. /**
  61841. * Draws a full screen quad.
  61842. */
  61843. draw(): void;
  61844. private isRenderTargetTexture;
  61845. /**
  61846. * renders one or more effects to a specified texture
  61847. * @param effectWrapper the effect to renderer
  61848. * @param outputTexture texture to draw to, if null it will render to the screen.
  61849. */
  61850. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61851. /**
  61852. * Disposes of the effect renderer
  61853. */
  61854. dispose(): void;
  61855. }
  61856. /**
  61857. * Options to create an EffectWrapper
  61858. */
  61859. interface EffectWrapperCreationOptions {
  61860. /**
  61861. * Engine to use to create the effect
  61862. */
  61863. engine: ThinEngine;
  61864. /**
  61865. * Fragment shader for the effect
  61866. */
  61867. fragmentShader: string;
  61868. /**
  61869. * Use the shader store instead of direct source code
  61870. */
  61871. useShaderStore?: boolean;
  61872. /**
  61873. * Vertex shader for the effect
  61874. */
  61875. vertexShader?: string;
  61876. /**
  61877. * Attributes to use in the shader
  61878. */
  61879. attributeNames?: Array<string>;
  61880. /**
  61881. * Uniforms to use in the shader
  61882. */
  61883. uniformNames?: Array<string>;
  61884. /**
  61885. * Texture sampler names to use in the shader
  61886. */
  61887. samplerNames?: Array<string>;
  61888. /**
  61889. * Defines to use in the shader
  61890. */
  61891. defines?: Array<string>;
  61892. /**
  61893. * Callback when effect is compiled
  61894. */
  61895. onCompiled?: Nullable<(effect: Effect) => void>;
  61896. /**
  61897. * The friendly name of the effect displayed in Spector.
  61898. */
  61899. name?: string;
  61900. }
  61901. /**
  61902. * Wraps an effect to be used for rendering
  61903. */
  61904. export class EffectWrapper {
  61905. /**
  61906. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61907. */
  61908. onApplyObservable: Observable<{}>;
  61909. /**
  61910. * The underlying effect
  61911. */
  61912. effect: Effect;
  61913. /**
  61914. * Creates an effect to be renderer
  61915. * @param creationOptions options to create the effect
  61916. */
  61917. constructor(creationOptions: EffectWrapperCreationOptions);
  61918. /**
  61919. * Disposes of the effect wrapper
  61920. */
  61921. dispose(): void;
  61922. }
  61923. }
  61924. declare module BABYLON {
  61925. /** @hidden */
  61926. export var hdrFilteringVertexShader: {
  61927. name: string;
  61928. shader: string;
  61929. };
  61930. }
  61931. declare module BABYLON {
  61932. /** @hidden */
  61933. export var hdrFilteringPixelShader: {
  61934. name: string;
  61935. shader: string;
  61936. };
  61937. }
  61938. declare module BABYLON {
  61939. /**
  61940. * Options for texture filtering
  61941. */
  61942. interface IHDRFilteringOptions {
  61943. /**
  61944. * Scales pixel intensity for the input HDR map.
  61945. */
  61946. hdrScale?: number;
  61947. /**
  61948. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61949. */
  61950. quality?: number;
  61951. }
  61952. /**
  61953. * Filters HDR maps to get correct renderings of PBR reflections
  61954. */
  61955. export class HDRFiltering {
  61956. private _engine;
  61957. private _effectRenderer;
  61958. private _effectWrapper;
  61959. private _lodGenerationOffset;
  61960. private _lodGenerationScale;
  61961. /**
  61962. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61963. * you care about baking speed.
  61964. */
  61965. quality: number;
  61966. /**
  61967. * Scales pixel intensity for the input HDR map.
  61968. */
  61969. hdrScale: number;
  61970. /**
  61971. * Instantiates HDR filter for reflection maps
  61972. *
  61973. * @param engine Thin engine
  61974. * @param options Options
  61975. */
  61976. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61977. private _createRenderTarget;
  61978. private _prefilterInternal;
  61979. private _createEffect;
  61980. /**
  61981. * Get a value indicating if the filter is ready to be used
  61982. * @param texture Texture to filter
  61983. * @returns true if the filter is ready
  61984. */
  61985. isReady(texture: BaseTexture): boolean;
  61986. /**
  61987. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61988. * Prefiltering will be invoked at the end of next rendering pass.
  61989. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61990. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61991. * @param texture Texture to filter
  61992. * @param onFinished Callback when filtering is done
  61993. * @return Promise called when prefiltering is done
  61994. */
  61995. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61996. }
  61997. }
  61998. declare module BABYLON {
  61999. /**
  62000. * This represents a texture coming from an HDR input.
  62001. *
  62002. * The only supported format is currently panorama picture stored in RGBE format.
  62003. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62004. */
  62005. export class HDRCubeTexture extends BaseTexture {
  62006. private static _facesMapping;
  62007. private _generateHarmonics;
  62008. private _noMipmap;
  62009. private _prefilterOnLoad;
  62010. private _textureMatrix;
  62011. private _size;
  62012. private _onLoad;
  62013. private _onError;
  62014. /**
  62015. * The texture URL.
  62016. */
  62017. url: string;
  62018. protected _isBlocking: boolean;
  62019. /**
  62020. * Sets wether or not the texture is blocking during loading.
  62021. */
  62022. set isBlocking(value: boolean);
  62023. /**
  62024. * Gets wether or not the texture is blocking during loading.
  62025. */
  62026. get isBlocking(): boolean;
  62027. protected _rotationY: number;
  62028. /**
  62029. * Sets texture matrix rotation angle around Y axis in radians.
  62030. */
  62031. set rotationY(value: number);
  62032. /**
  62033. * Gets texture matrix rotation angle around Y axis radians.
  62034. */
  62035. get rotationY(): number;
  62036. /**
  62037. * Gets or sets the center of the bounding box associated with the cube texture
  62038. * It must define where the camera used to render the texture was set
  62039. */
  62040. boundingBoxPosition: Vector3;
  62041. private _boundingBoxSize;
  62042. /**
  62043. * Gets or sets the size of the bounding box associated with the cube texture
  62044. * When defined, the cubemap will switch to local mode
  62045. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62046. * @example https://www.babylonjs-playground.com/#RNASML
  62047. */
  62048. set boundingBoxSize(value: Vector3);
  62049. get boundingBoxSize(): Vector3;
  62050. /**
  62051. * Instantiates an HDRTexture from the following parameters.
  62052. *
  62053. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62054. * @param sceneOrEngine The scene or engine the texture will be used in
  62055. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62056. * @param noMipmap Forces to not generate the mipmap if true
  62057. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62058. * @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)
  62059. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62060. */
  62061. 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>);
  62062. /**
  62063. * Get the current class name of the texture useful for serialization or dynamic coding.
  62064. * @returns "HDRCubeTexture"
  62065. */
  62066. getClassName(): string;
  62067. /**
  62068. * Occurs when the file is raw .hdr file.
  62069. */
  62070. private loadTexture;
  62071. clone(): HDRCubeTexture;
  62072. delayLoad(): void;
  62073. /**
  62074. * Get the texture reflection matrix used to rotate/transform the reflection.
  62075. * @returns the reflection matrix
  62076. */
  62077. getReflectionTextureMatrix(): Matrix;
  62078. /**
  62079. * Set the texture reflection matrix used to rotate/transform the reflection.
  62080. * @param value Define the reflection matrix to set
  62081. */
  62082. setReflectionTextureMatrix(value: Matrix): void;
  62083. /**
  62084. * Parses a JSON representation of an HDR Texture in order to create the texture
  62085. * @param parsedTexture Define the JSON representation
  62086. * @param scene Define the scene the texture should be created in
  62087. * @param rootUrl Define the root url in case we need to load relative dependencies
  62088. * @returns the newly created texture after parsing
  62089. */
  62090. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62091. serialize(): any;
  62092. }
  62093. }
  62094. declare module BABYLON {
  62095. /**
  62096. * Class used to control physics engine
  62097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62098. */
  62099. export class PhysicsEngine implements IPhysicsEngine {
  62100. private _physicsPlugin;
  62101. /**
  62102. * Global value used to control the smallest number supported by the simulation
  62103. */
  62104. static Epsilon: number;
  62105. private _impostors;
  62106. private _joints;
  62107. private _subTimeStep;
  62108. /**
  62109. * Gets the gravity vector used by the simulation
  62110. */
  62111. gravity: Vector3;
  62112. /**
  62113. * Factory used to create the default physics plugin.
  62114. * @returns The default physics plugin
  62115. */
  62116. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62117. /**
  62118. * Creates a new Physics Engine
  62119. * @param gravity defines the gravity vector used by the simulation
  62120. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62121. */
  62122. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62123. /**
  62124. * Sets the gravity vector used by the simulation
  62125. * @param gravity defines the gravity vector to use
  62126. */
  62127. setGravity(gravity: Vector3): void;
  62128. /**
  62129. * Set the time step of the physics engine.
  62130. * Default is 1/60.
  62131. * To slow it down, enter 1/600 for example.
  62132. * To speed it up, 1/30
  62133. * @param newTimeStep defines the new timestep to apply to this world.
  62134. */
  62135. setTimeStep(newTimeStep?: number): void;
  62136. /**
  62137. * Get the time step of the physics engine.
  62138. * @returns the current time step
  62139. */
  62140. getTimeStep(): number;
  62141. /**
  62142. * Set the sub time step of the physics engine.
  62143. * Default is 0 meaning there is no sub steps
  62144. * To increase physics resolution precision, set a small value (like 1 ms)
  62145. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62146. */
  62147. setSubTimeStep(subTimeStep?: number): void;
  62148. /**
  62149. * Get the sub time step of the physics engine.
  62150. * @returns the current sub time step
  62151. */
  62152. getSubTimeStep(): number;
  62153. /**
  62154. * Release all resources
  62155. */
  62156. dispose(): void;
  62157. /**
  62158. * Gets the name of the current physics plugin
  62159. * @returns the name of the plugin
  62160. */
  62161. getPhysicsPluginName(): string;
  62162. /**
  62163. * Adding a new impostor for the impostor tracking.
  62164. * This will be done by the impostor itself.
  62165. * @param impostor the impostor to add
  62166. */
  62167. addImpostor(impostor: PhysicsImpostor): void;
  62168. /**
  62169. * Remove an impostor from the engine.
  62170. * This impostor and its mesh will not longer be updated by the physics engine.
  62171. * @param impostor the impostor to remove
  62172. */
  62173. removeImpostor(impostor: PhysicsImpostor): void;
  62174. /**
  62175. * Add a joint to the physics engine
  62176. * @param mainImpostor defines the main impostor to which the joint is added.
  62177. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62178. * @param joint defines the joint that will connect both impostors.
  62179. */
  62180. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62181. /**
  62182. * Removes a joint from the simulation
  62183. * @param mainImpostor defines the impostor used with the joint
  62184. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62185. * @param joint defines the joint to remove
  62186. */
  62187. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62188. /**
  62189. * Called by the scene. No need to call it.
  62190. * @param delta defines the timespam between frames
  62191. */
  62192. _step(delta: number): void;
  62193. /**
  62194. * Gets the current plugin used to run the simulation
  62195. * @returns current plugin
  62196. */
  62197. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62198. /**
  62199. * Gets the list of physic impostors
  62200. * @returns an array of PhysicsImpostor
  62201. */
  62202. getImpostors(): Array<PhysicsImpostor>;
  62203. /**
  62204. * Gets the impostor for a physics enabled object
  62205. * @param object defines the object impersonated by the impostor
  62206. * @returns the PhysicsImpostor or null if not found
  62207. */
  62208. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62209. /**
  62210. * Gets the impostor for a physics body object
  62211. * @param body defines physics body used by the impostor
  62212. * @returns the PhysicsImpostor or null if not found
  62213. */
  62214. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62215. /**
  62216. * Does a raycast in the physics world
  62217. * @param from when should the ray start?
  62218. * @param to when should the ray end?
  62219. * @returns PhysicsRaycastResult
  62220. */
  62221. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62222. }
  62223. }
  62224. declare module BABYLON {
  62225. /** @hidden */
  62226. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62227. private _useDeltaForWorldStep;
  62228. world: any;
  62229. name: string;
  62230. private _physicsMaterials;
  62231. private _fixedTimeStep;
  62232. private _cannonRaycastResult;
  62233. private _raycastResult;
  62234. private _physicsBodysToRemoveAfterStep;
  62235. private _firstFrame;
  62236. BJSCANNON: any;
  62237. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62238. setGravity(gravity: Vector3): void;
  62239. setTimeStep(timeStep: number): void;
  62240. getTimeStep(): number;
  62241. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62242. private _removeMarkedPhysicsBodiesFromWorld;
  62243. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62244. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62245. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62246. private _processChildMeshes;
  62247. removePhysicsBody(impostor: PhysicsImpostor): void;
  62248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62249. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62250. private _addMaterial;
  62251. private _checkWithEpsilon;
  62252. private _createShape;
  62253. private _createHeightmap;
  62254. private _minus90X;
  62255. private _plus90X;
  62256. private _tmpPosition;
  62257. private _tmpDeltaPosition;
  62258. private _tmpUnityRotation;
  62259. private _updatePhysicsBodyTransformation;
  62260. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62262. isSupported(): boolean;
  62263. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62264. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62266. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62267. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62268. getBodyMass(impostor: PhysicsImpostor): number;
  62269. getBodyFriction(impostor: PhysicsImpostor): number;
  62270. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62271. getBodyRestitution(impostor: PhysicsImpostor): number;
  62272. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62273. sleepBody(impostor: PhysicsImpostor): void;
  62274. wakeUpBody(impostor: PhysicsImpostor): void;
  62275. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62276. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62277. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62278. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62279. getRadius(impostor: PhysicsImpostor): number;
  62280. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62281. dispose(): void;
  62282. private _extendNamespace;
  62283. /**
  62284. * Does a raycast in the physics world
  62285. * @param from when should the ray start?
  62286. * @param to when should the ray end?
  62287. * @returns PhysicsRaycastResult
  62288. */
  62289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62290. }
  62291. }
  62292. declare module BABYLON {
  62293. /** @hidden */
  62294. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62295. private _useDeltaForWorldStep;
  62296. world: any;
  62297. name: string;
  62298. BJSOIMO: any;
  62299. private _raycastResult;
  62300. private _fixedTimeStep;
  62301. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62302. setGravity(gravity: Vector3): void;
  62303. setTimeStep(timeStep: number): void;
  62304. getTimeStep(): number;
  62305. private _tmpImpostorsArray;
  62306. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62307. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62308. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62309. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62310. private _tmpPositionVector;
  62311. removePhysicsBody(impostor: PhysicsImpostor): void;
  62312. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62313. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62314. isSupported(): boolean;
  62315. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62316. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62317. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62318. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62319. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62320. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62321. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62322. getBodyMass(impostor: PhysicsImpostor): number;
  62323. getBodyFriction(impostor: PhysicsImpostor): number;
  62324. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62325. getBodyRestitution(impostor: PhysicsImpostor): number;
  62326. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62327. sleepBody(impostor: PhysicsImpostor): void;
  62328. wakeUpBody(impostor: PhysicsImpostor): void;
  62329. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62330. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62331. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62332. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62333. getRadius(impostor: PhysicsImpostor): number;
  62334. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62335. dispose(): void;
  62336. /**
  62337. * Does a raycast in the physics world
  62338. * @param from when should the ray start?
  62339. * @param to when should the ray end?
  62340. * @returns PhysicsRaycastResult
  62341. */
  62342. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62343. }
  62344. }
  62345. declare module BABYLON {
  62346. /**
  62347. * AmmoJS Physics plugin
  62348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62349. * @see https://github.com/kripken/ammo.js/
  62350. */
  62351. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62352. private _useDeltaForWorldStep;
  62353. /**
  62354. * Reference to the Ammo library
  62355. */
  62356. bjsAMMO: any;
  62357. /**
  62358. * Created ammoJS world which physics bodies are added to
  62359. */
  62360. world: any;
  62361. /**
  62362. * Name of the plugin
  62363. */
  62364. name: string;
  62365. private _timeStep;
  62366. private _fixedTimeStep;
  62367. private _maxSteps;
  62368. private _tmpQuaternion;
  62369. private _tmpAmmoTransform;
  62370. private _tmpAmmoQuaternion;
  62371. private _tmpAmmoConcreteContactResultCallback;
  62372. private _collisionConfiguration;
  62373. private _dispatcher;
  62374. private _overlappingPairCache;
  62375. private _solver;
  62376. private _softBodySolver;
  62377. private _tmpAmmoVectorA;
  62378. private _tmpAmmoVectorB;
  62379. private _tmpAmmoVectorC;
  62380. private _tmpAmmoVectorD;
  62381. private _tmpContactCallbackResult;
  62382. private _tmpAmmoVectorRCA;
  62383. private _tmpAmmoVectorRCB;
  62384. private _raycastResult;
  62385. private _tmpContactPoint;
  62386. private static readonly DISABLE_COLLISION_FLAG;
  62387. private static readonly KINEMATIC_FLAG;
  62388. private static readonly DISABLE_DEACTIVATION_FLAG;
  62389. /**
  62390. * Initializes the ammoJS plugin
  62391. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62392. * @param ammoInjection can be used to inject your own ammo reference
  62393. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62394. */
  62395. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62396. /**
  62397. * Sets the gravity of the physics world (m/(s^2))
  62398. * @param gravity Gravity to set
  62399. */
  62400. setGravity(gravity: Vector3): void;
  62401. /**
  62402. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62403. * @param timeStep timestep to use in seconds
  62404. */
  62405. setTimeStep(timeStep: number): void;
  62406. /**
  62407. * 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)
  62408. * @param fixedTimeStep fixedTimeStep to use in seconds
  62409. */
  62410. setFixedTimeStep(fixedTimeStep: number): void;
  62411. /**
  62412. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62413. * @param maxSteps the maximum number of steps by the physics engine per frame
  62414. */
  62415. setMaxSteps(maxSteps: number): void;
  62416. /**
  62417. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62418. * @returns the current timestep in seconds
  62419. */
  62420. getTimeStep(): number;
  62421. /**
  62422. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62423. */
  62424. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62425. private _isImpostorInContact;
  62426. private _isImpostorPairInContact;
  62427. private _stepSimulation;
  62428. /**
  62429. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62430. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62431. * After the step the babylon meshes are set to the position of the physics imposters
  62432. * @param delta amount of time to step forward
  62433. * @param impostors array of imposters to update before/after the step
  62434. */
  62435. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62436. /**
  62437. * Update babylon mesh to match physics world object
  62438. * @param impostor imposter to match
  62439. */
  62440. private _afterSoftStep;
  62441. /**
  62442. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62443. * @param impostor imposter to match
  62444. */
  62445. private _ropeStep;
  62446. /**
  62447. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62448. * @param impostor imposter to match
  62449. */
  62450. private _softbodyOrClothStep;
  62451. private _tmpMatrix;
  62452. /**
  62453. * Applies an impulse on the imposter
  62454. * @param impostor imposter to apply impulse to
  62455. * @param force amount of force to be applied to the imposter
  62456. * @param contactPoint the location to apply the impulse on the imposter
  62457. */
  62458. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62459. /**
  62460. * Applies a force on the imposter
  62461. * @param impostor imposter to apply force
  62462. * @param force amount of force to be applied to the imposter
  62463. * @param contactPoint the location to apply the force on the imposter
  62464. */
  62465. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62466. /**
  62467. * Creates a physics body using the plugin
  62468. * @param impostor the imposter to create the physics body on
  62469. */
  62470. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62471. /**
  62472. * Removes the physics body from the imposter and disposes of the body's memory
  62473. * @param impostor imposter to remove the physics body from
  62474. */
  62475. removePhysicsBody(impostor: PhysicsImpostor): void;
  62476. /**
  62477. * Generates a joint
  62478. * @param impostorJoint the imposter joint to create the joint with
  62479. */
  62480. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62481. /**
  62482. * Removes a joint
  62483. * @param impostorJoint the imposter joint to remove the joint from
  62484. */
  62485. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62486. private _addMeshVerts;
  62487. /**
  62488. * Initialise the soft body vertices to match its object's (mesh) vertices
  62489. * Softbody vertices (nodes) are in world space and to match this
  62490. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62491. * @param impostor to create the softbody for
  62492. */
  62493. private _softVertexData;
  62494. /**
  62495. * Create an impostor's soft body
  62496. * @param impostor to create the softbody for
  62497. */
  62498. private _createSoftbody;
  62499. /**
  62500. * Create cloth for an impostor
  62501. * @param impostor to create the softbody for
  62502. */
  62503. private _createCloth;
  62504. /**
  62505. * Create rope for an impostor
  62506. * @param impostor to create the softbody for
  62507. */
  62508. private _createRope;
  62509. /**
  62510. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62511. * @param impostor to create the custom physics shape for
  62512. */
  62513. private _createCustom;
  62514. private _addHullVerts;
  62515. private _createShape;
  62516. /**
  62517. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62518. * @param impostor imposter containing the physics body and babylon object
  62519. */
  62520. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62521. /**
  62522. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62523. * @param impostor imposter containing the physics body and babylon object
  62524. * @param newPosition new position
  62525. * @param newRotation new rotation
  62526. */
  62527. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62528. /**
  62529. * If this plugin is supported
  62530. * @returns true if its supported
  62531. */
  62532. isSupported(): boolean;
  62533. /**
  62534. * Sets the linear velocity of the physics body
  62535. * @param impostor imposter to set the velocity on
  62536. * @param velocity velocity to set
  62537. */
  62538. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62539. /**
  62540. * Sets the angular velocity of the physics body
  62541. * @param impostor imposter to set the velocity on
  62542. * @param velocity velocity to set
  62543. */
  62544. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62545. /**
  62546. * gets the linear velocity
  62547. * @param impostor imposter to get linear velocity from
  62548. * @returns linear velocity
  62549. */
  62550. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62551. /**
  62552. * gets the angular velocity
  62553. * @param impostor imposter to get angular velocity from
  62554. * @returns angular velocity
  62555. */
  62556. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62557. /**
  62558. * Sets the mass of physics body
  62559. * @param impostor imposter to set the mass on
  62560. * @param mass mass to set
  62561. */
  62562. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62563. /**
  62564. * Gets the mass of the physics body
  62565. * @param impostor imposter to get the mass from
  62566. * @returns mass
  62567. */
  62568. getBodyMass(impostor: PhysicsImpostor): number;
  62569. /**
  62570. * Gets friction of the impostor
  62571. * @param impostor impostor to get friction from
  62572. * @returns friction value
  62573. */
  62574. getBodyFriction(impostor: PhysicsImpostor): number;
  62575. /**
  62576. * Sets friction of the impostor
  62577. * @param impostor impostor to set friction on
  62578. * @param friction friction value
  62579. */
  62580. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62581. /**
  62582. * Gets restitution of the impostor
  62583. * @param impostor impostor to get restitution from
  62584. * @returns restitution value
  62585. */
  62586. getBodyRestitution(impostor: PhysicsImpostor): number;
  62587. /**
  62588. * Sets resitution of the impostor
  62589. * @param impostor impostor to set resitution on
  62590. * @param restitution resitution value
  62591. */
  62592. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62593. /**
  62594. * Gets pressure inside the impostor
  62595. * @param impostor impostor to get pressure from
  62596. * @returns pressure value
  62597. */
  62598. getBodyPressure(impostor: PhysicsImpostor): number;
  62599. /**
  62600. * Sets pressure inside a soft body impostor
  62601. * Cloth and rope must remain 0 pressure
  62602. * @param impostor impostor to set pressure on
  62603. * @param pressure pressure value
  62604. */
  62605. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62606. /**
  62607. * Gets stiffness of the impostor
  62608. * @param impostor impostor to get stiffness from
  62609. * @returns pressure value
  62610. */
  62611. getBodyStiffness(impostor: PhysicsImpostor): number;
  62612. /**
  62613. * Sets stiffness of the impostor
  62614. * @param impostor impostor to set stiffness on
  62615. * @param stiffness stiffness value from 0 to 1
  62616. */
  62617. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62618. /**
  62619. * Gets velocityIterations of the impostor
  62620. * @param impostor impostor to get velocity iterations from
  62621. * @returns velocityIterations value
  62622. */
  62623. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62624. /**
  62625. * Sets velocityIterations of the impostor
  62626. * @param impostor impostor to set velocity iterations on
  62627. * @param velocityIterations velocityIterations value
  62628. */
  62629. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62630. /**
  62631. * Gets positionIterations of the impostor
  62632. * @param impostor impostor to get position iterations from
  62633. * @returns positionIterations value
  62634. */
  62635. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62636. /**
  62637. * Sets positionIterations of the impostor
  62638. * @param impostor impostor to set position on
  62639. * @param positionIterations positionIterations value
  62640. */
  62641. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62642. /**
  62643. * Append an anchor to a cloth object
  62644. * @param impostor is the cloth impostor to add anchor to
  62645. * @param otherImpostor is the rigid impostor to anchor to
  62646. * @param width ratio across width from 0 to 1
  62647. * @param height ratio up height from 0 to 1
  62648. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62649. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62650. */
  62651. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62652. /**
  62653. * Append an hook to a rope object
  62654. * @param impostor is the rope impostor to add hook to
  62655. * @param otherImpostor is the rigid impostor to hook to
  62656. * @param length ratio along the rope from 0 to 1
  62657. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62658. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62659. */
  62660. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62661. /**
  62662. * Sleeps the physics body and stops it from being active
  62663. * @param impostor impostor to sleep
  62664. */
  62665. sleepBody(impostor: PhysicsImpostor): void;
  62666. /**
  62667. * Activates the physics body
  62668. * @param impostor impostor to activate
  62669. */
  62670. wakeUpBody(impostor: PhysicsImpostor): void;
  62671. /**
  62672. * Updates the distance parameters of the joint
  62673. * @param joint joint to update
  62674. * @param maxDistance maximum distance of the joint
  62675. * @param minDistance minimum distance of the joint
  62676. */
  62677. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62678. /**
  62679. * Sets a motor on the joint
  62680. * @param joint joint to set motor on
  62681. * @param speed speed of the motor
  62682. * @param maxForce maximum force of the motor
  62683. * @param motorIndex index of the motor
  62684. */
  62685. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62686. /**
  62687. * Sets the motors limit
  62688. * @param joint joint to set limit on
  62689. * @param upperLimit upper limit
  62690. * @param lowerLimit lower limit
  62691. */
  62692. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62693. /**
  62694. * Syncs the position and rotation of a mesh with the impostor
  62695. * @param mesh mesh to sync
  62696. * @param impostor impostor to update the mesh with
  62697. */
  62698. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62699. /**
  62700. * Gets the radius of the impostor
  62701. * @param impostor impostor to get radius from
  62702. * @returns the radius
  62703. */
  62704. getRadius(impostor: PhysicsImpostor): number;
  62705. /**
  62706. * Gets the box size of the impostor
  62707. * @param impostor impostor to get box size from
  62708. * @param result the resulting box size
  62709. */
  62710. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62711. /**
  62712. * Disposes of the impostor
  62713. */
  62714. dispose(): void;
  62715. /**
  62716. * Does a raycast in the physics world
  62717. * @param from when should the ray start?
  62718. * @param to when should the ray end?
  62719. * @returns PhysicsRaycastResult
  62720. */
  62721. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62722. }
  62723. }
  62724. declare module BABYLON {
  62725. interface AbstractScene {
  62726. /**
  62727. * The list of reflection probes added to the scene
  62728. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62729. */
  62730. reflectionProbes: Array<ReflectionProbe>;
  62731. /**
  62732. * Removes the given reflection probe from this scene.
  62733. * @param toRemove The reflection probe to remove
  62734. * @returns The index of the removed reflection probe
  62735. */
  62736. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62737. /**
  62738. * Adds the given reflection probe to this scene.
  62739. * @param newReflectionProbe The reflection probe to add
  62740. */
  62741. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62742. }
  62743. /**
  62744. * Class used to generate realtime reflection / refraction cube textures
  62745. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62746. */
  62747. export class ReflectionProbe {
  62748. /** defines the name of the probe */
  62749. name: string;
  62750. private _scene;
  62751. private _renderTargetTexture;
  62752. private _projectionMatrix;
  62753. private _viewMatrix;
  62754. private _target;
  62755. private _add;
  62756. private _attachedMesh;
  62757. private _invertYAxis;
  62758. /** Gets or sets probe position (center of the cube map) */
  62759. position: Vector3;
  62760. /**
  62761. * Creates a new reflection probe
  62762. * @param name defines the name of the probe
  62763. * @param size defines the texture resolution (for each face)
  62764. * @param scene defines the hosting scene
  62765. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62766. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62767. */
  62768. constructor(
  62769. /** defines the name of the probe */
  62770. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62771. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62772. get samples(): number;
  62773. set samples(value: number);
  62774. /** Gets or sets the refresh rate to use (on every frame by default) */
  62775. get refreshRate(): number;
  62776. set refreshRate(value: number);
  62777. /**
  62778. * Gets the hosting scene
  62779. * @returns a Scene
  62780. */
  62781. getScene(): Scene;
  62782. /** Gets the internal CubeTexture used to render to */
  62783. get cubeTexture(): RenderTargetTexture;
  62784. /** Gets the list of meshes to render */
  62785. get renderList(): Nullable<AbstractMesh[]>;
  62786. /**
  62787. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62788. * @param mesh defines the mesh to attach to
  62789. */
  62790. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62791. /**
  62792. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62793. * @param renderingGroupId The rendering group id corresponding to its index
  62794. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62795. */
  62796. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62797. /**
  62798. * Clean all associated resources
  62799. */
  62800. dispose(): void;
  62801. /**
  62802. * Converts the reflection probe information to a readable string for debug purpose.
  62803. * @param fullDetails Supports for multiple levels of logging within scene loading
  62804. * @returns the human readable reflection probe info
  62805. */
  62806. toString(fullDetails?: boolean): string;
  62807. /**
  62808. * Get the class name of the relfection probe.
  62809. * @returns "ReflectionProbe"
  62810. */
  62811. getClassName(): string;
  62812. /**
  62813. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62814. * @returns The JSON representation of the texture
  62815. */
  62816. serialize(): any;
  62817. /**
  62818. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62819. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62820. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62821. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62822. * @returns The parsed reflection probe if successful
  62823. */
  62824. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62825. }
  62826. }
  62827. declare module BABYLON {
  62828. /** @hidden */
  62829. export var _BabylonLoaderRegistered: boolean;
  62830. /**
  62831. * Helps setting up some configuration for the babylon file loader.
  62832. */
  62833. export class BabylonFileLoaderConfiguration {
  62834. /**
  62835. * The loader does not allow injecting custom physix engine into the plugins.
  62836. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62837. * So you could set this variable to your engine import to make it work.
  62838. */
  62839. static LoaderInjectedPhysicsEngine: any;
  62840. }
  62841. }
  62842. declare module BABYLON {
  62843. /**
  62844. * A material to use for fast depth-only rendering.
  62845. */
  62846. export class OcclusionMaterial extends ShaderMaterial {
  62847. constructor(name: string, scene: Scene);
  62848. }
  62849. }
  62850. declare module BABYLON {
  62851. /**
  62852. * The Physically based simple base material of BJS.
  62853. *
  62854. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62855. * It is used as the base class for both the specGloss and metalRough conventions.
  62856. */
  62857. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62858. /**
  62859. * Number of Simultaneous lights allowed on the material.
  62860. */
  62861. maxSimultaneousLights: number;
  62862. /**
  62863. * If sets to true, disables all the lights affecting the material.
  62864. */
  62865. disableLighting: boolean;
  62866. /**
  62867. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62868. */
  62869. environmentTexture: BaseTexture;
  62870. /**
  62871. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62872. */
  62873. invertNormalMapX: boolean;
  62874. /**
  62875. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62876. */
  62877. invertNormalMapY: boolean;
  62878. /**
  62879. * Normal map used in the model.
  62880. */
  62881. normalTexture: BaseTexture;
  62882. /**
  62883. * Emissivie color used to self-illuminate the model.
  62884. */
  62885. emissiveColor: Color3;
  62886. /**
  62887. * Emissivie texture used to self-illuminate the model.
  62888. */
  62889. emissiveTexture: BaseTexture;
  62890. /**
  62891. * Occlusion Channel Strenght.
  62892. */
  62893. occlusionStrength: number;
  62894. /**
  62895. * Occlusion Texture of the material (adding extra occlusion effects).
  62896. */
  62897. occlusionTexture: BaseTexture;
  62898. /**
  62899. * Defines the alpha limits in alpha test mode.
  62900. */
  62901. alphaCutOff: number;
  62902. /**
  62903. * Gets the current double sided mode.
  62904. */
  62905. get doubleSided(): boolean;
  62906. /**
  62907. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62908. */
  62909. set doubleSided(value: boolean);
  62910. /**
  62911. * Stores the pre-calculated light information of a mesh in a texture.
  62912. */
  62913. lightmapTexture: BaseTexture;
  62914. /**
  62915. * If true, the light map contains occlusion information instead of lighting info.
  62916. */
  62917. useLightmapAsShadowmap: boolean;
  62918. /**
  62919. * Instantiates a new PBRMaterial instance.
  62920. *
  62921. * @param name The material name
  62922. * @param scene The scene the material will be use in.
  62923. */
  62924. constructor(name: string, scene: Scene);
  62925. getClassName(): string;
  62926. }
  62927. }
  62928. declare module BABYLON {
  62929. /**
  62930. * The PBR material of BJS following the metal roughness convention.
  62931. *
  62932. * This fits to the PBR convention in the GLTF definition:
  62933. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62934. */
  62935. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62936. /**
  62937. * The base color has two different interpretations depending on the value of metalness.
  62938. * When the material is a metal, the base color is the specific measured reflectance value
  62939. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62940. * of the material.
  62941. */
  62942. baseColor: Color3;
  62943. /**
  62944. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62945. * well as opacity information in the alpha channel.
  62946. */
  62947. baseTexture: BaseTexture;
  62948. /**
  62949. * Specifies the metallic scalar value of the material.
  62950. * Can also be used to scale the metalness values of the metallic texture.
  62951. */
  62952. metallic: number;
  62953. /**
  62954. * Specifies the roughness scalar value of the material.
  62955. * Can also be used to scale the roughness values of the metallic texture.
  62956. */
  62957. roughness: number;
  62958. /**
  62959. * Texture containing both the metallic value in the B channel and the
  62960. * roughness value in the G channel to keep better precision.
  62961. */
  62962. metallicRoughnessTexture: BaseTexture;
  62963. /**
  62964. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62965. *
  62966. * @param name The material name
  62967. * @param scene The scene the material will be use in.
  62968. */
  62969. constructor(name: string, scene: Scene);
  62970. /**
  62971. * Return the currrent class name of the material.
  62972. */
  62973. getClassName(): string;
  62974. /**
  62975. * Makes a duplicate of the current material.
  62976. * @param name - name to use for the new material.
  62977. */
  62978. clone(name: string): PBRMetallicRoughnessMaterial;
  62979. /**
  62980. * Serialize the material to a parsable JSON object.
  62981. */
  62982. serialize(): any;
  62983. /**
  62984. * Parses a JSON object correponding to the serialize function.
  62985. */
  62986. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62987. }
  62988. }
  62989. declare module BABYLON {
  62990. /**
  62991. * The PBR material of BJS following the specular glossiness convention.
  62992. *
  62993. * This fits to the PBR convention in the GLTF definition:
  62994. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62995. */
  62996. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62997. /**
  62998. * Specifies the diffuse color of the material.
  62999. */
  63000. diffuseColor: Color3;
  63001. /**
  63002. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63003. * channel.
  63004. */
  63005. diffuseTexture: BaseTexture;
  63006. /**
  63007. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63008. */
  63009. specularColor: Color3;
  63010. /**
  63011. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63012. */
  63013. glossiness: number;
  63014. /**
  63015. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63016. */
  63017. specularGlossinessTexture: BaseTexture;
  63018. /**
  63019. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63020. *
  63021. * @param name The material name
  63022. * @param scene The scene the material will be use in.
  63023. */
  63024. constructor(name: string, scene: Scene);
  63025. /**
  63026. * Return the currrent class name of the material.
  63027. */
  63028. getClassName(): string;
  63029. /**
  63030. * Makes a duplicate of the current material.
  63031. * @param name - name to use for the new material.
  63032. */
  63033. clone(name: string): PBRSpecularGlossinessMaterial;
  63034. /**
  63035. * Serialize the material to a parsable JSON object.
  63036. */
  63037. serialize(): any;
  63038. /**
  63039. * Parses a JSON object correponding to the serialize function.
  63040. */
  63041. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63042. }
  63043. }
  63044. declare module BABYLON {
  63045. /**
  63046. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63047. * It can help converting any input color in a desired output one. This can then be used to create effects
  63048. * from sepia, black and white to sixties or futuristic rendering...
  63049. *
  63050. * The only supported format is currently 3dl.
  63051. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63052. */
  63053. export class ColorGradingTexture extends BaseTexture {
  63054. /**
  63055. * The texture URL.
  63056. */
  63057. url: string;
  63058. /**
  63059. * Empty line regex stored for GC.
  63060. */
  63061. private static _noneEmptyLineRegex;
  63062. private _textureMatrix;
  63063. private _onLoad;
  63064. /**
  63065. * Instantiates a ColorGradingTexture from the following parameters.
  63066. *
  63067. * @param url The location of the color gradind data (currently only supporting 3dl)
  63068. * @param sceneOrEngine The scene or engine the texture will be used in
  63069. * @param onLoad defines a callback triggered when the texture has been loaded
  63070. */
  63071. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63072. /**
  63073. * Fires the onload event from the constructor if requested.
  63074. */
  63075. private _triggerOnLoad;
  63076. /**
  63077. * Returns the texture matrix used in most of the material.
  63078. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63079. */
  63080. getTextureMatrix(): Matrix;
  63081. /**
  63082. * Occurs when the file being loaded is a .3dl LUT file.
  63083. */
  63084. private load3dlTexture;
  63085. /**
  63086. * Starts the loading process of the texture.
  63087. */
  63088. private loadTexture;
  63089. /**
  63090. * Clones the color gradind texture.
  63091. */
  63092. clone(): ColorGradingTexture;
  63093. /**
  63094. * Called during delayed load for textures.
  63095. */
  63096. delayLoad(): void;
  63097. /**
  63098. * Parses a color grading texture serialized by Babylon.
  63099. * @param parsedTexture The texture information being parsedTexture
  63100. * @param scene The scene to load the texture in
  63101. * @param rootUrl The root url of the data assets to load
  63102. * @return A color gradind texture
  63103. */
  63104. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63105. /**
  63106. * Serializes the LUT texture to json format.
  63107. */
  63108. serialize(): any;
  63109. }
  63110. }
  63111. declare module BABYLON {
  63112. /**
  63113. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63114. */
  63115. export class EquiRectangularCubeTexture extends BaseTexture {
  63116. /** The six faces of the cube. */
  63117. private static _FacesMapping;
  63118. private _noMipmap;
  63119. private _onLoad;
  63120. private _onError;
  63121. /** The size of the cubemap. */
  63122. private _size;
  63123. /** The buffer of the image. */
  63124. private _buffer;
  63125. /** The width of the input image. */
  63126. private _width;
  63127. /** The height of the input image. */
  63128. private _height;
  63129. /** The URL to the image. */
  63130. url: string;
  63131. /**
  63132. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63133. * @param url The location of the image
  63134. * @param scene The scene the texture will be used in
  63135. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63136. * @param noMipmap Forces to not generate the mipmap if true
  63137. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63138. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63139. * @param onLoad — defines a callback called when texture is loaded
  63140. * @param onError — defines a callback called if there is an error
  63141. */
  63142. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63143. /**
  63144. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63145. */
  63146. private loadImage;
  63147. /**
  63148. * Convert the image buffer into a cubemap and create a CubeTexture.
  63149. */
  63150. private loadTexture;
  63151. /**
  63152. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63153. * @param buffer The ArrayBuffer that should be converted.
  63154. * @returns The buffer as Float32Array.
  63155. */
  63156. private getFloat32ArrayFromArrayBuffer;
  63157. /**
  63158. * Get the current class name of the texture useful for serialization or dynamic coding.
  63159. * @returns "EquiRectangularCubeTexture"
  63160. */
  63161. getClassName(): string;
  63162. /**
  63163. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63164. * @returns A clone of the current EquiRectangularCubeTexture.
  63165. */
  63166. clone(): EquiRectangularCubeTexture;
  63167. }
  63168. }
  63169. declare module BABYLON {
  63170. /**
  63171. * Defines the options related to the creation of an HtmlElementTexture
  63172. */
  63173. export interface IHtmlElementTextureOptions {
  63174. /**
  63175. * Defines wether mip maps should be created or not.
  63176. */
  63177. generateMipMaps?: boolean;
  63178. /**
  63179. * Defines the sampling mode of the texture.
  63180. */
  63181. samplingMode?: number;
  63182. /**
  63183. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63184. */
  63185. engine: Nullable<ThinEngine>;
  63186. /**
  63187. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63188. */
  63189. scene: Nullable<Scene>;
  63190. }
  63191. /**
  63192. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63193. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63194. * is automatically managed.
  63195. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63196. * in your application.
  63197. *
  63198. * As the update is not automatic, you need to call them manually.
  63199. */
  63200. export class HtmlElementTexture extends BaseTexture {
  63201. /**
  63202. * The texture URL.
  63203. */
  63204. element: HTMLVideoElement | HTMLCanvasElement;
  63205. private static readonly DefaultOptions;
  63206. private _textureMatrix;
  63207. private _isVideo;
  63208. private _generateMipMaps;
  63209. private _samplingMode;
  63210. /**
  63211. * Instantiates a HtmlElementTexture from the following parameters.
  63212. *
  63213. * @param name Defines the name of the texture
  63214. * @param element Defines the video or canvas the texture is filled with
  63215. * @param options Defines the other none mandatory texture creation options
  63216. */
  63217. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63218. private _createInternalTexture;
  63219. /**
  63220. * Returns the texture matrix used in most of the material.
  63221. */
  63222. getTextureMatrix(): Matrix;
  63223. /**
  63224. * Updates the content of the texture.
  63225. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63226. */
  63227. update(invertY?: Nullable<boolean>): void;
  63228. }
  63229. }
  63230. declare module BABYLON {
  63231. /**
  63232. * Based on jsTGALoader - Javascript loader for TGA file
  63233. * By Vincent Thibault
  63234. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63235. */
  63236. export class TGATools {
  63237. private static _TYPE_INDEXED;
  63238. private static _TYPE_RGB;
  63239. private static _TYPE_GREY;
  63240. private static _TYPE_RLE_INDEXED;
  63241. private static _TYPE_RLE_RGB;
  63242. private static _TYPE_RLE_GREY;
  63243. private static _ORIGIN_MASK;
  63244. private static _ORIGIN_SHIFT;
  63245. private static _ORIGIN_BL;
  63246. private static _ORIGIN_BR;
  63247. private static _ORIGIN_UL;
  63248. private static _ORIGIN_UR;
  63249. /**
  63250. * Gets the header of a TGA file
  63251. * @param data defines the TGA data
  63252. * @returns the header
  63253. */
  63254. static GetTGAHeader(data: Uint8Array): any;
  63255. /**
  63256. * Uploads TGA content to a Babylon Texture
  63257. * @hidden
  63258. */
  63259. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63260. /** @hidden */
  63261. 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;
  63262. /** @hidden */
  63263. 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;
  63264. /** @hidden */
  63265. 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;
  63266. /** @hidden */
  63267. 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;
  63268. /** @hidden */
  63269. 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;
  63270. /** @hidden */
  63271. 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;
  63272. }
  63273. }
  63274. declare module BABYLON {
  63275. /**
  63276. * Implementation of the TGA Texture Loader.
  63277. * @hidden
  63278. */
  63279. export class _TGATextureLoader implements IInternalTextureLoader {
  63280. /**
  63281. * Defines wether the loader supports cascade loading the different faces.
  63282. */
  63283. readonly supportCascades: boolean;
  63284. /**
  63285. * This returns if the loader support the current file information.
  63286. * @param extension defines the file extension of the file being loaded
  63287. * @returns true if the loader can load the specified file
  63288. */
  63289. canLoad(extension: string): boolean;
  63290. /**
  63291. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63292. * @param data contains the texture data
  63293. * @param texture defines the BabylonJS internal texture
  63294. * @param createPolynomials will be true if polynomials have been requested
  63295. * @param onLoad defines the callback to trigger once the texture is ready
  63296. * @param onError defines the callback to trigger in case of error
  63297. */
  63298. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63299. /**
  63300. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63301. * @param data contains the texture data
  63302. * @param texture defines the BabylonJS internal texture
  63303. * @param callback defines the method to call once ready to upload
  63304. */
  63305. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63306. }
  63307. }
  63308. declare module BABYLON {
  63309. /**
  63310. * Info about the .basis files
  63311. */
  63312. class BasisFileInfo {
  63313. /**
  63314. * If the file has alpha
  63315. */
  63316. hasAlpha: boolean;
  63317. /**
  63318. * Info about each image of the basis file
  63319. */
  63320. images: Array<{
  63321. levels: Array<{
  63322. width: number;
  63323. height: number;
  63324. transcodedPixels: ArrayBufferView;
  63325. }>;
  63326. }>;
  63327. }
  63328. /**
  63329. * Result of transcoding a basis file
  63330. */
  63331. class TranscodeResult {
  63332. /**
  63333. * Info about the .basis file
  63334. */
  63335. fileInfo: BasisFileInfo;
  63336. /**
  63337. * Format to use when loading the file
  63338. */
  63339. format: number;
  63340. }
  63341. /**
  63342. * Configuration options for the Basis transcoder
  63343. */
  63344. export class BasisTranscodeConfiguration {
  63345. /**
  63346. * Supported compression formats used to determine the supported output format of the transcoder
  63347. */
  63348. supportedCompressionFormats?: {
  63349. /**
  63350. * etc1 compression format
  63351. */
  63352. etc1?: boolean;
  63353. /**
  63354. * s3tc compression format
  63355. */
  63356. s3tc?: boolean;
  63357. /**
  63358. * pvrtc compression format
  63359. */
  63360. pvrtc?: boolean;
  63361. /**
  63362. * etc2 compression format
  63363. */
  63364. etc2?: boolean;
  63365. };
  63366. /**
  63367. * If mipmap levels should be loaded for transcoded images (Default: true)
  63368. */
  63369. loadMipmapLevels?: boolean;
  63370. /**
  63371. * Index of a single image to load (Default: all images)
  63372. */
  63373. loadSingleImage?: number;
  63374. }
  63375. /**
  63376. * Used to load .Basis files
  63377. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63378. */
  63379. export class BasisTools {
  63380. private static _IgnoreSupportedFormats;
  63381. /**
  63382. * URL to use when loading the basis transcoder
  63383. */
  63384. static JSModuleURL: string;
  63385. /**
  63386. * URL to use when loading the wasm module for the transcoder
  63387. */
  63388. static WasmModuleURL: string;
  63389. /**
  63390. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63391. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63392. * @returns internal format corresponding to the Basis format
  63393. */
  63394. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63395. private static _WorkerPromise;
  63396. private static _Worker;
  63397. private static _actionId;
  63398. private static _CreateWorkerAsync;
  63399. /**
  63400. * Transcodes a loaded image file to compressed pixel data
  63401. * @param data image data to transcode
  63402. * @param config configuration options for the transcoding
  63403. * @returns a promise resulting in the transcoded image
  63404. */
  63405. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63406. /**
  63407. * Loads a texture from the transcode result
  63408. * @param texture texture load to
  63409. * @param transcodeResult the result of transcoding the basis file to load from
  63410. */
  63411. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63412. }
  63413. }
  63414. declare module BABYLON {
  63415. /**
  63416. * Loader for .basis file format
  63417. */
  63418. export class _BasisTextureLoader implements IInternalTextureLoader {
  63419. /**
  63420. * Defines whether the loader supports cascade loading the different faces.
  63421. */
  63422. readonly supportCascades: boolean;
  63423. /**
  63424. * This returns if the loader support the current file information.
  63425. * @param extension defines the file extension of the file being loaded
  63426. * @returns true if the loader can load the specified file
  63427. */
  63428. canLoad(extension: string): boolean;
  63429. /**
  63430. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63431. * @param data contains the texture data
  63432. * @param texture defines the BabylonJS internal texture
  63433. * @param createPolynomials will be true if polynomials have been requested
  63434. * @param onLoad defines the callback to trigger once the texture is ready
  63435. * @param onError defines the callback to trigger in case of error
  63436. */
  63437. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63438. /**
  63439. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63440. * @param data contains the texture data
  63441. * @param texture defines the BabylonJS internal texture
  63442. * @param callback defines the method to call once ready to upload
  63443. */
  63444. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63445. }
  63446. }
  63447. declare module BABYLON {
  63448. /**
  63449. * Defines the basic options interface of a TexturePacker Frame
  63450. */
  63451. export interface ITexturePackerFrame {
  63452. /**
  63453. * The frame ID
  63454. */
  63455. id: number;
  63456. /**
  63457. * The frames Scale
  63458. */
  63459. scale: Vector2;
  63460. /**
  63461. * The Frames offset
  63462. */
  63463. offset: Vector2;
  63464. }
  63465. /**
  63466. * This is a support class for frame Data on texture packer sets.
  63467. */
  63468. export class TexturePackerFrame implements ITexturePackerFrame {
  63469. /**
  63470. * The frame ID
  63471. */
  63472. id: number;
  63473. /**
  63474. * The frames Scale
  63475. */
  63476. scale: Vector2;
  63477. /**
  63478. * The Frames offset
  63479. */
  63480. offset: Vector2;
  63481. /**
  63482. * Initializes a texture package frame.
  63483. * @param id The numerical frame identifier
  63484. * @param scale Scalar Vector2 for UV frame
  63485. * @param offset Vector2 for the frame position in UV units.
  63486. * @returns TexturePackerFrame
  63487. */
  63488. constructor(id: number, scale: Vector2, offset: Vector2);
  63489. }
  63490. }
  63491. declare module BABYLON {
  63492. /**
  63493. * Defines the basic options interface of a TexturePacker
  63494. */
  63495. export interface ITexturePackerOptions {
  63496. /**
  63497. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63498. */
  63499. map?: string[];
  63500. /**
  63501. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63502. */
  63503. uvsIn?: string;
  63504. /**
  63505. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63506. */
  63507. uvsOut?: string;
  63508. /**
  63509. * number representing the layout style. Defaults to LAYOUT_STRIP
  63510. */
  63511. layout?: number;
  63512. /**
  63513. * number of columns if using custom column count layout(2). This defaults to 4.
  63514. */
  63515. colnum?: number;
  63516. /**
  63517. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63518. */
  63519. updateInputMeshes?: boolean;
  63520. /**
  63521. * boolean flag to dispose all the source textures. Defaults to true.
  63522. */
  63523. disposeSources?: boolean;
  63524. /**
  63525. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63526. */
  63527. fillBlanks?: boolean;
  63528. /**
  63529. * string value representing the context fill style color. Defaults to 'black'.
  63530. */
  63531. customFillColor?: string;
  63532. /**
  63533. * Width and Height Value of each Frame in the TexturePacker Sets
  63534. */
  63535. frameSize?: number;
  63536. /**
  63537. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63538. */
  63539. paddingRatio?: number;
  63540. /**
  63541. * Number that declares the fill method for the padding gutter.
  63542. */
  63543. paddingMode?: number;
  63544. /**
  63545. * If in SUBUV_COLOR padding mode what color to use.
  63546. */
  63547. paddingColor?: Color3 | Color4;
  63548. }
  63549. /**
  63550. * Defines the basic interface of a TexturePacker JSON File
  63551. */
  63552. export interface ITexturePackerJSON {
  63553. /**
  63554. * The frame ID
  63555. */
  63556. name: string;
  63557. /**
  63558. * The base64 channel data
  63559. */
  63560. sets: any;
  63561. /**
  63562. * The options of the Packer
  63563. */
  63564. options: ITexturePackerOptions;
  63565. /**
  63566. * The frame data of the Packer
  63567. */
  63568. frames: Array<number>;
  63569. }
  63570. /**
  63571. * This is a support class that generates a series of packed texture sets.
  63572. * @see https://doc.babylonjs.com/babylon101/materials
  63573. */
  63574. export class TexturePacker {
  63575. /** Packer Layout Constant 0 */
  63576. static readonly LAYOUT_STRIP: number;
  63577. /** Packer Layout Constant 1 */
  63578. static readonly LAYOUT_POWER2: number;
  63579. /** Packer Layout Constant 2 */
  63580. static readonly LAYOUT_COLNUM: number;
  63581. /** Packer Layout Constant 0 */
  63582. static readonly SUBUV_WRAP: number;
  63583. /** Packer Layout Constant 1 */
  63584. static readonly SUBUV_EXTEND: number;
  63585. /** Packer Layout Constant 2 */
  63586. static readonly SUBUV_COLOR: number;
  63587. /** The Name of the Texture Package */
  63588. name: string;
  63589. /** The scene scope of the TexturePacker */
  63590. scene: Scene;
  63591. /** The Meshes to target */
  63592. meshes: AbstractMesh[];
  63593. /** Arguments passed with the Constructor */
  63594. options: ITexturePackerOptions;
  63595. /** The promise that is started upon initialization */
  63596. promise: Nullable<Promise<TexturePacker | string>>;
  63597. /** The Container object for the channel sets that are generated */
  63598. sets: object;
  63599. /** The Container array for the frames that are generated */
  63600. frames: TexturePackerFrame[];
  63601. /** The expected number of textures the system is parsing. */
  63602. private _expecting;
  63603. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63604. private _paddingValue;
  63605. /**
  63606. * Initializes a texture package series from an array of meshes or a single mesh.
  63607. * @param name The name of the package
  63608. * @param meshes The target meshes to compose the package from
  63609. * @param options The arguments that texture packer should follow while building.
  63610. * @param scene The scene which the textures are scoped to.
  63611. * @returns TexturePacker
  63612. */
  63613. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63614. /**
  63615. * Starts the package process
  63616. * @param resolve The promises resolution function
  63617. * @returns TexturePacker
  63618. */
  63619. private _createFrames;
  63620. /**
  63621. * Calculates the Size of the Channel Sets
  63622. * @returns Vector2
  63623. */
  63624. private _calculateSize;
  63625. /**
  63626. * Calculates the UV data for the frames.
  63627. * @param baseSize the base frameSize
  63628. * @param padding the base frame padding
  63629. * @param dtSize size of the Dynamic Texture for that channel
  63630. * @param dtUnits is 1/dtSize
  63631. * @param update flag to update the input meshes
  63632. */
  63633. private _calculateMeshUVFrames;
  63634. /**
  63635. * Calculates the frames Offset.
  63636. * @param index of the frame
  63637. * @returns Vector2
  63638. */
  63639. private _getFrameOffset;
  63640. /**
  63641. * Updates a Mesh to the frame data
  63642. * @param mesh that is the target
  63643. * @param frameID or the frame index
  63644. */
  63645. private _updateMeshUV;
  63646. /**
  63647. * Updates a Meshes materials to use the texture packer channels
  63648. * @param m is the mesh to target
  63649. * @param force all channels on the packer to be set.
  63650. */
  63651. private _updateTextureReferences;
  63652. /**
  63653. * Public method to set a Mesh to a frame
  63654. * @param m that is the target
  63655. * @param frameID or the frame index
  63656. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63657. */
  63658. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63659. /**
  63660. * Starts the async promise to compile the texture packer.
  63661. * @returns Promise<void>
  63662. */
  63663. processAsync(): Promise<void>;
  63664. /**
  63665. * Disposes all textures associated with this packer
  63666. */
  63667. dispose(): void;
  63668. /**
  63669. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63670. * @param imageType is the image type to use.
  63671. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63672. */
  63673. download(imageType?: string, quality?: number): void;
  63674. /**
  63675. * Public method to load a texturePacker JSON file.
  63676. * @param data of the JSON file in string format.
  63677. */
  63678. updateFromJSON(data: string): void;
  63679. }
  63680. }
  63681. declare module BABYLON {
  63682. /**
  63683. * 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.
  63684. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63685. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63686. */
  63687. export class CustomProceduralTexture extends ProceduralTexture {
  63688. private _animate;
  63689. private _time;
  63690. private _config;
  63691. private _texturePath;
  63692. /**
  63693. * Instantiates a new Custom Procedural Texture.
  63694. * 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.
  63695. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63696. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63697. * @param name Define the name of the texture
  63698. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63699. * @param size Define the size of the texture to create
  63700. * @param scene Define the scene the texture belongs to
  63701. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63702. * @param generateMipMaps Define if the texture should creates mip maps or not
  63703. */
  63704. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63705. private _loadJson;
  63706. /**
  63707. * Is the texture ready to be used ? (rendered at least once)
  63708. * @returns true if ready, otherwise, false.
  63709. */
  63710. isReady(): boolean;
  63711. /**
  63712. * Render the texture to its associated render target.
  63713. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63714. */
  63715. render(useCameraPostProcess?: boolean): void;
  63716. /**
  63717. * Update the list of dependant textures samplers in the shader.
  63718. */
  63719. updateTextures(): void;
  63720. /**
  63721. * Update the uniform values of the procedural texture in the shader.
  63722. */
  63723. updateShaderUniforms(): void;
  63724. /**
  63725. * Define if the texture animates or not.
  63726. */
  63727. get animate(): boolean;
  63728. set animate(value: boolean);
  63729. }
  63730. }
  63731. declare module BABYLON {
  63732. /** @hidden */
  63733. export var noisePixelShader: {
  63734. name: string;
  63735. shader: string;
  63736. };
  63737. }
  63738. declare module BABYLON {
  63739. /**
  63740. * Class used to generate noise procedural textures
  63741. */
  63742. export class NoiseProceduralTexture extends ProceduralTexture {
  63743. /** Gets or sets the start time (default is 0) */
  63744. time: number;
  63745. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63746. brightness: number;
  63747. /** Defines the number of octaves to process */
  63748. octaves: number;
  63749. /** Defines the level of persistence (0.8 by default) */
  63750. persistence: number;
  63751. /** Gets or sets animation speed factor (default is 1) */
  63752. animationSpeedFactor: number;
  63753. /**
  63754. * Creates a new NoiseProceduralTexture
  63755. * @param name defines the name fo the texture
  63756. * @param size defines the size of the texture (default is 256)
  63757. * @param scene defines the hosting scene
  63758. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63759. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63760. */
  63761. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63762. private _updateShaderUniforms;
  63763. protected _getDefines(): string;
  63764. /** Generate the current state of the procedural texture */
  63765. render(useCameraPostProcess?: boolean): void;
  63766. /**
  63767. * Serializes this noise procedural texture
  63768. * @returns a serialized noise procedural texture object
  63769. */
  63770. serialize(): any;
  63771. /**
  63772. * Clone the texture.
  63773. * @returns the cloned texture
  63774. */
  63775. clone(): NoiseProceduralTexture;
  63776. /**
  63777. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63778. * @param parsedTexture defines parsed texture data
  63779. * @param scene defines the current scene
  63780. * @param rootUrl defines the root URL containing noise procedural texture information
  63781. * @returns a parsed NoiseProceduralTexture
  63782. */
  63783. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63784. }
  63785. }
  63786. declare module BABYLON {
  63787. /**
  63788. * Raw cube texture where the raw buffers are passed in
  63789. */
  63790. export class RawCubeTexture extends CubeTexture {
  63791. /**
  63792. * Creates a cube texture where the raw buffers are passed in.
  63793. * @param scene defines the scene the texture is attached to
  63794. * @param data defines the array of data to use to create each face
  63795. * @param size defines the size of the textures
  63796. * @param format defines the format of the data
  63797. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63798. * @param generateMipMaps defines if the engine should generate the mip levels
  63799. * @param invertY defines if data must be stored with Y axis inverted
  63800. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63801. * @param compression defines the compression used (null by default)
  63802. */
  63803. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63804. /**
  63805. * Updates the raw cube texture.
  63806. * @param data defines the data to store
  63807. * @param format defines the data format
  63808. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63809. * @param invertY defines if data must be stored with Y axis inverted
  63810. * @param compression defines the compression used (null by default)
  63811. * @param level defines which level of the texture to update
  63812. */
  63813. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63814. /**
  63815. * Updates a raw cube texture with RGBD encoded data.
  63816. * @param data defines the array of data [mipmap][face] to use to create each face
  63817. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63820. * @returns a promsie that resolves when the operation is complete
  63821. */
  63822. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63823. /**
  63824. * Clones the raw cube texture.
  63825. * @return a new cube texture
  63826. */
  63827. clone(): CubeTexture;
  63828. /** @hidden */
  63829. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63830. }
  63831. }
  63832. declare module BABYLON {
  63833. /**
  63834. * Class used to store 2D array textures containing user data
  63835. */
  63836. export class RawTexture2DArray extends Texture {
  63837. /** Gets or sets the texture format to use */
  63838. format: number;
  63839. /**
  63840. * Create a new RawTexture2DArray
  63841. * @param data defines the data of the texture
  63842. * @param width defines the width of the texture
  63843. * @param height defines the height of the texture
  63844. * @param depth defines the number of layers of the texture
  63845. * @param format defines the texture format to use
  63846. * @param scene defines the hosting scene
  63847. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63848. * @param invertY defines if texture must be stored with Y axis inverted
  63849. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63851. */
  63852. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63853. /** Gets or sets the texture format to use */
  63854. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63855. /**
  63856. * Update the texture with new data
  63857. * @param data defines the data to store in the texture
  63858. */
  63859. update(data: ArrayBufferView): void;
  63860. }
  63861. }
  63862. declare module BABYLON {
  63863. /**
  63864. * Class used to store 3D textures containing user data
  63865. */
  63866. export class RawTexture3D extends Texture {
  63867. /** Gets or sets the texture format to use */
  63868. format: number;
  63869. /**
  63870. * Create a new RawTexture3D
  63871. * @param data defines the data of the texture
  63872. * @param width defines the width of the texture
  63873. * @param height defines the height of the texture
  63874. * @param depth defines the depth of the texture
  63875. * @param format defines the texture format to use
  63876. * @param scene defines the hosting scene
  63877. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63878. * @param invertY defines if texture must be stored with Y axis inverted
  63879. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63880. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63881. */
  63882. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63883. /** Gets or sets the texture format to use */
  63884. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63885. /**
  63886. * Update the texture with new data
  63887. * @param data defines the data to store in the texture
  63888. */
  63889. update(data: ArrayBufferView): void;
  63890. }
  63891. }
  63892. declare module BABYLON {
  63893. /**
  63894. * Creates a refraction texture used by refraction channel of the standard material.
  63895. * It is like a mirror but to see through a material.
  63896. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63897. */
  63898. export class RefractionTexture extends RenderTargetTexture {
  63899. /**
  63900. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63901. * 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.
  63902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63903. */
  63904. refractionPlane: Plane;
  63905. /**
  63906. * Define how deep under the surface we should see.
  63907. */
  63908. depth: number;
  63909. /**
  63910. * Creates a refraction texture used by refraction channel of the standard material.
  63911. * It is like a mirror but to see through a material.
  63912. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63913. * @param name Define the texture name
  63914. * @param size Define the size of the underlying texture
  63915. * @param scene Define the scene the refraction belongs to
  63916. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63917. */
  63918. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63919. /**
  63920. * Clone the refraction texture.
  63921. * @returns the cloned texture
  63922. */
  63923. clone(): RefractionTexture;
  63924. /**
  63925. * Serialize the texture to a JSON representation you could use in Parse later on
  63926. * @returns the serialized JSON representation
  63927. */
  63928. serialize(): any;
  63929. }
  63930. }
  63931. declare module BABYLON {
  63932. /**
  63933. * Block used to add support for vertex skinning (bones)
  63934. */
  63935. export class BonesBlock extends NodeMaterialBlock {
  63936. /**
  63937. * Creates a new BonesBlock
  63938. * @param name defines the block name
  63939. */
  63940. constructor(name: string);
  63941. /**
  63942. * Initialize the block and prepare the context for build
  63943. * @param state defines the state that will be used for the build
  63944. */
  63945. initialize(state: NodeMaterialBuildState): void;
  63946. /**
  63947. * Gets the current class name
  63948. * @returns the class name
  63949. */
  63950. getClassName(): string;
  63951. /**
  63952. * Gets the matrix indices input component
  63953. */
  63954. get matricesIndices(): NodeMaterialConnectionPoint;
  63955. /**
  63956. * Gets the matrix weights input component
  63957. */
  63958. get matricesWeights(): NodeMaterialConnectionPoint;
  63959. /**
  63960. * Gets the extra matrix indices input component
  63961. */
  63962. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63963. /**
  63964. * Gets the extra matrix weights input component
  63965. */
  63966. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63967. /**
  63968. * Gets the world input component
  63969. */
  63970. get world(): NodeMaterialConnectionPoint;
  63971. /**
  63972. * Gets the output component
  63973. */
  63974. get output(): NodeMaterialConnectionPoint;
  63975. autoConfigure(material: NodeMaterial): void;
  63976. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63979. protected _buildBlock(state: NodeMaterialBuildState): this;
  63980. }
  63981. }
  63982. declare module BABYLON {
  63983. /**
  63984. * Block used to add support for instances
  63985. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63986. */
  63987. export class InstancesBlock extends NodeMaterialBlock {
  63988. /**
  63989. * Creates a new InstancesBlock
  63990. * @param name defines the block name
  63991. */
  63992. constructor(name: string);
  63993. /**
  63994. * Gets the current class name
  63995. * @returns the class name
  63996. */
  63997. getClassName(): string;
  63998. /**
  63999. * Gets the first world row input component
  64000. */
  64001. get world0(): NodeMaterialConnectionPoint;
  64002. /**
  64003. * Gets the second world row input component
  64004. */
  64005. get world1(): NodeMaterialConnectionPoint;
  64006. /**
  64007. * Gets the third world row input component
  64008. */
  64009. get world2(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the forth world row input component
  64012. */
  64013. get world3(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Gets the world input component
  64016. */
  64017. get world(): NodeMaterialConnectionPoint;
  64018. /**
  64019. * Gets the output component
  64020. */
  64021. get output(): NodeMaterialConnectionPoint;
  64022. /**
  64023. * Gets the isntanceID component
  64024. */
  64025. get instanceID(): NodeMaterialConnectionPoint;
  64026. autoConfigure(material: NodeMaterial): void;
  64027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64028. protected _buildBlock(state: NodeMaterialBuildState): this;
  64029. }
  64030. }
  64031. declare module BABYLON {
  64032. /**
  64033. * Block used to add morph targets support to vertex shader
  64034. */
  64035. export class MorphTargetsBlock extends NodeMaterialBlock {
  64036. private _repeatableContentAnchor;
  64037. /**
  64038. * Create a new MorphTargetsBlock
  64039. * @param name defines the block name
  64040. */
  64041. constructor(name: string);
  64042. /**
  64043. * Gets the current class name
  64044. * @returns the class name
  64045. */
  64046. getClassName(): string;
  64047. /**
  64048. * Gets the position input component
  64049. */
  64050. get position(): NodeMaterialConnectionPoint;
  64051. /**
  64052. * Gets the normal input component
  64053. */
  64054. get normal(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the tangent input component
  64057. */
  64058. get tangent(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the tangent input component
  64061. */
  64062. get uv(): NodeMaterialConnectionPoint;
  64063. /**
  64064. * Gets the position output component
  64065. */
  64066. get positionOutput(): NodeMaterialConnectionPoint;
  64067. /**
  64068. * Gets the normal output component
  64069. */
  64070. get normalOutput(): NodeMaterialConnectionPoint;
  64071. /**
  64072. * Gets the tangent output component
  64073. */
  64074. get tangentOutput(): NodeMaterialConnectionPoint;
  64075. /**
  64076. * Gets the tangent output component
  64077. */
  64078. get uvOutput(): NodeMaterialConnectionPoint;
  64079. initialize(state: NodeMaterialBuildState): void;
  64080. autoConfigure(material: NodeMaterial): void;
  64081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64083. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64084. protected _buildBlock(state: NodeMaterialBuildState): this;
  64085. }
  64086. }
  64087. declare module BABYLON {
  64088. /**
  64089. * Block used to get data information from a light
  64090. */
  64091. export class LightInformationBlock extends NodeMaterialBlock {
  64092. private _lightDataUniformName;
  64093. private _lightColorUniformName;
  64094. private _lightTypeDefineName;
  64095. /**
  64096. * Gets or sets the light associated with this block
  64097. */
  64098. light: Nullable<Light>;
  64099. /**
  64100. * Creates a new LightInformationBlock
  64101. * @param name defines the block name
  64102. */
  64103. constructor(name: string);
  64104. /**
  64105. * Gets the current class name
  64106. * @returns the class name
  64107. */
  64108. getClassName(): string;
  64109. /**
  64110. * Gets the world position input component
  64111. */
  64112. get worldPosition(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the direction output component
  64115. */
  64116. get direction(): NodeMaterialConnectionPoint;
  64117. /**
  64118. * Gets the direction output component
  64119. */
  64120. get color(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the direction output component
  64123. */
  64124. get intensity(): NodeMaterialConnectionPoint;
  64125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64127. protected _buildBlock(state: NodeMaterialBuildState): this;
  64128. serialize(): any;
  64129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * Block used to add image processing support to fragment shader
  64135. */
  64136. export class ImageProcessingBlock extends NodeMaterialBlock {
  64137. /**
  64138. * Create a new ImageProcessingBlock
  64139. * @param name defines the block name
  64140. */
  64141. constructor(name: string);
  64142. /**
  64143. * Gets the current class name
  64144. * @returns the class name
  64145. */
  64146. getClassName(): string;
  64147. /**
  64148. * Gets the color input component
  64149. */
  64150. get color(): NodeMaterialConnectionPoint;
  64151. /**
  64152. * Gets the output component
  64153. */
  64154. get output(): NodeMaterialConnectionPoint;
  64155. /**
  64156. * Initialize the block and prepare the context for build
  64157. * @param state defines the state that will be used for the build
  64158. */
  64159. initialize(state: NodeMaterialBuildState): void;
  64160. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64162. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64163. protected _buildBlock(state: NodeMaterialBuildState): this;
  64164. }
  64165. }
  64166. declare module BABYLON {
  64167. /**
  64168. * Block used to pertub normals based on a normal map
  64169. */
  64170. export class PerturbNormalBlock extends NodeMaterialBlock {
  64171. private _tangentSpaceParameterName;
  64172. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64173. invertX: boolean;
  64174. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64175. invertY: boolean;
  64176. /**
  64177. * Create a new PerturbNormalBlock
  64178. * @param name defines the block name
  64179. */
  64180. constructor(name: string);
  64181. /**
  64182. * Gets the current class name
  64183. * @returns the class name
  64184. */
  64185. getClassName(): string;
  64186. /**
  64187. * Gets the world position input component
  64188. */
  64189. get worldPosition(): NodeMaterialConnectionPoint;
  64190. /**
  64191. * Gets the world normal input component
  64192. */
  64193. get worldNormal(): NodeMaterialConnectionPoint;
  64194. /**
  64195. * Gets the world tangent input component
  64196. */
  64197. get worldTangent(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the uv input component
  64200. */
  64201. get uv(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the normal map color input component
  64204. */
  64205. get normalMapColor(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the strength input component
  64208. */
  64209. get strength(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the output component
  64212. */
  64213. get output(): NodeMaterialConnectionPoint;
  64214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64216. autoConfigure(material: NodeMaterial): void;
  64217. protected _buildBlock(state: NodeMaterialBuildState): this;
  64218. protected _dumpPropertiesCode(): string;
  64219. serialize(): any;
  64220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64221. }
  64222. }
  64223. declare module BABYLON {
  64224. /**
  64225. * Block used to discard a pixel if a value is smaller than a cutoff
  64226. */
  64227. export class DiscardBlock extends NodeMaterialBlock {
  64228. /**
  64229. * Create a new DiscardBlock
  64230. * @param name defines the block name
  64231. */
  64232. constructor(name: string);
  64233. /**
  64234. * Gets the current class name
  64235. * @returns the class name
  64236. */
  64237. getClassName(): string;
  64238. /**
  64239. * Gets the color input component
  64240. */
  64241. get value(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the cutoff input component
  64244. */
  64245. get cutoff(): NodeMaterialConnectionPoint;
  64246. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64247. }
  64248. }
  64249. declare module BABYLON {
  64250. /**
  64251. * Block used to test if the fragment shader is front facing
  64252. */
  64253. export class FrontFacingBlock extends NodeMaterialBlock {
  64254. /**
  64255. * Creates a new FrontFacingBlock
  64256. * @param name defines the block name
  64257. */
  64258. constructor(name: string);
  64259. /**
  64260. * Gets the current class name
  64261. * @returns the class name
  64262. */
  64263. getClassName(): string;
  64264. /**
  64265. * Gets the output component
  64266. */
  64267. get output(): NodeMaterialConnectionPoint;
  64268. protected _buildBlock(state: NodeMaterialBuildState): this;
  64269. }
  64270. }
  64271. declare module BABYLON {
  64272. /**
  64273. * Block used to get the derivative value on x and y of a given input
  64274. */
  64275. export class DerivativeBlock extends NodeMaterialBlock {
  64276. /**
  64277. * Create a new DerivativeBlock
  64278. * @param name defines the block name
  64279. */
  64280. constructor(name: string);
  64281. /**
  64282. * Gets the current class name
  64283. * @returns the class name
  64284. */
  64285. getClassName(): string;
  64286. /**
  64287. * Gets the input component
  64288. */
  64289. get input(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the derivative output on x
  64292. */
  64293. get dx(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the derivative output on y
  64296. */
  64297. get dy(): NodeMaterialConnectionPoint;
  64298. protected _buildBlock(state: NodeMaterialBuildState): this;
  64299. }
  64300. }
  64301. declare module BABYLON {
  64302. /**
  64303. * Block used to make gl_FragCoord available
  64304. */
  64305. export class FragCoordBlock extends NodeMaterialBlock {
  64306. /**
  64307. * Creates a new FragCoordBlock
  64308. * @param name defines the block name
  64309. */
  64310. constructor(name: string);
  64311. /**
  64312. * Gets the current class name
  64313. * @returns the class name
  64314. */
  64315. getClassName(): string;
  64316. /**
  64317. * Gets the xy component
  64318. */
  64319. get xy(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the xyz component
  64322. */
  64323. get xyz(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the xyzw component
  64326. */
  64327. get xyzw(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the x component
  64330. */
  64331. get x(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the y component
  64334. */
  64335. get y(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the z component
  64338. */
  64339. get z(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the w component
  64342. */
  64343. get output(): NodeMaterialConnectionPoint;
  64344. protected writeOutputs(state: NodeMaterialBuildState): string;
  64345. protected _buildBlock(state: NodeMaterialBuildState): this;
  64346. }
  64347. }
  64348. declare module BABYLON {
  64349. /**
  64350. * Block used to get the screen sizes
  64351. */
  64352. export class ScreenSizeBlock extends NodeMaterialBlock {
  64353. private _varName;
  64354. private _scene;
  64355. /**
  64356. * Creates a new ScreenSizeBlock
  64357. * @param name defines the block name
  64358. */
  64359. constructor(name: string);
  64360. /**
  64361. * Gets the current class name
  64362. * @returns the class name
  64363. */
  64364. getClassName(): string;
  64365. /**
  64366. * Gets the xy component
  64367. */
  64368. get xy(): NodeMaterialConnectionPoint;
  64369. /**
  64370. * Gets the x component
  64371. */
  64372. get x(): NodeMaterialConnectionPoint;
  64373. /**
  64374. * Gets the y component
  64375. */
  64376. get y(): NodeMaterialConnectionPoint;
  64377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64378. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64379. protected _buildBlock(state: NodeMaterialBuildState): this;
  64380. }
  64381. }
  64382. declare module BABYLON {
  64383. /**
  64384. * Block used to add support for scene fog
  64385. */
  64386. export class FogBlock extends NodeMaterialBlock {
  64387. private _fogDistanceName;
  64388. private _fogParameters;
  64389. /**
  64390. * Create a new FogBlock
  64391. * @param name defines the block name
  64392. */
  64393. constructor(name: string);
  64394. /**
  64395. * Gets the current class name
  64396. * @returns the class name
  64397. */
  64398. getClassName(): string;
  64399. /**
  64400. * Gets the world position input component
  64401. */
  64402. get worldPosition(): NodeMaterialConnectionPoint;
  64403. /**
  64404. * Gets the view input component
  64405. */
  64406. get view(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the color input component
  64409. */
  64410. get input(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the fog color input component
  64413. */
  64414. get fogColor(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the output component
  64417. */
  64418. get output(): NodeMaterialConnectionPoint;
  64419. autoConfigure(material: NodeMaterial): void;
  64420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64422. protected _buildBlock(state: NodeMaterialBuildState): this;
  64423. }
  64424. }
  64425. declare module BABYLON {
  64426. /**
  64427. * Block used to add light in the fragment shader
  64428. */
  64429. export class LightBlock extends NodeMaterialBlock {
  64430. private _lightId;
  64431. /**
  64432. * Gets or sets the light associated with this block
  64433. */
  64434. light: Nullable<Light>;
  64435. /**
  64436. * Create a new LightBlock
  64437. * @param name defines the block name
  64438. */
  64439. constructor(name: string);
  64440. /**
  64441. * Gets the current class name
  64442. * @returns the class name
  64443. */
  64444. getClassName(): string;
  64445. /**
  64446. * Gets the world position input component
  64447. */
  64448. get worldPosition(): NodeMaterialConnectionPoint;
  64449. /**
  64450. * Gets the world normal input component
  64451. */
  64452. get worldNormal(): NodeMaterialConnectionPoint;
  64453. /**
  64454. * Gets the camera (or eye) position component
  64455. */
  64456. get cameraPosition(): NodeMaterialConnectionPoint;
  64457. /**
  64458. * Gets the glossiness component
  64459. */
  64460. get glossiness(): NodeMaterialConnectionPoint;
  64461. /**
  64462. * Gets the glossinness power component
  64463. */
  64464. get glossPower(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the diffuse color component
  64467. */
  64468. get diffuseColor(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the specular color component
  64471. */
  64472. get specularColor(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the view matrix component
  64475. */
  64476. get view(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the diffuse output component
  64479. */
  64480. get diffuseOutput(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the specular output component
  64483. */
  64484. get specularOutput(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the shadow output component
  64487. */
  64488. get shadow(): NodeMaterialConnectionPoint;
  64489. autoConfigure(material: NodeMaterial): void;
  64490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64491. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64493. private _injectVertexCode;
  64494. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64495. serialize(): any;
  64496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64497. }
  64498. }
  64499. declare module BABYLON {
  64500. /**
  64501. * Block used to read a reflection texture from a sampler
  64502. */
  64503. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64504. /**
  64505. * Create a new ReflectionTextureBlock
  64506. * @param name defines the block name
  64507. */
  64508. constructor(name: string);
  64509. /**
  64510. * Gets the current class name
  64511. * @returns the class name
  64512. */
  64513. getClassName(): string;
  64514. /**
  64515. * Gets the world position input component
  64516. */
  64517. get position(): NodeMaterialConnectionPoint;
  64518. /**
  64519. * Gets the world position input component
  64520. */
  64521. get worldPosition(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the world normal input component
  64524. */
  64525. get worldNormal(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the world input component
  64528. */
  64529. get world(): NodeMaterialConnectionPoint;
  64530. /**
  64531. * Gets the camera (or eye) position component
  64532. */
  64533. get cameraPosition(): NodeMaterialConnectionPoint;
  64534. /**
  64535. * Gets the view input component
  64536. */
  64537. get view(): NodeMaterialConnectionPoint;
  64538. /**
  64539. * Gets the rgb output component
  64540. */
  64541. get rgb(): NodeMaterialConnectionPoint;
  64542. /**
  64543. * Gets the rgba output component
  64544. */
  64545. get rgba(): NodeMaterialConnectionPoint;
  64546. /**
  64547. * Gets the r output component
  64548. */
  64549. get r(): NodeMaterialConnectionPoint;
  64550. /**
  64551. * Gets the g output component
  64552. */
  64553. get g(): NodeMaterialConnectionPoint;
  64554. /**
  64555. * Gets the b output component
  64556. */
  64557. get b(): NodeMaterialConnectionPoint;
  64558. /**
  64559. * Gets the a output component
  64560. */
  64561. get a(): NodeMaterialConnectionPoint;
  64562. autoConfigure(material: NodeMaterial): void;
  64563. protected _buildBlock(state: NodeMaterialBuildState): this;
  64564. }
  64565. }
  64566. declare module BABYLON {
  64567. /**
  64568. * Block used to add 2 vectors
  64569. */
  64570. export class AddBlock extends NodeMaterialBlock {
  64571. /**
  64572. * Creates a new AddBlock
  64573. * @param name defines the block name
  64574. */
  64575. constructor(name: string);
  64576. /**
  64577. * Gets the current class name
  64578. * @returns the class name
  64579. */
  64580. getClassName(): string;
  64581. /**
  64582. * Gets the left operand input component
  64583. */
  64584. get left(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the right operand input component
  64587. */
  64588. get right(): NodeMaterialConnectionPoint;
  64589. /**
  64590. * Gets the output component
  64591. */
  64592. get output(): NodeMaterialConnectionPoint;
  64593. protected _buildBlock(state: NodeMaterialBuildState): this;
  64594. }
  64595. }
  64596. declare module BABYLON {
  64597. /**
  64598. * Block used to scale a vector by a float
  64599. */
  64600. export class ScaleBlock extends NodeMaterialBlock {
  64601. /**
  64602. * Creates a new ScaleBlock
  64603. * @param name defines the block name
  64604. */
  64605. constructor(name: string);
  64606. /**
  64607. * Gets the current class name
  64608. * @returns the class name
  64609. */
  64610. getClassName(): string;
  64611. /**
  64612. * Gets the input component
  64613. */
  64614. get input(): NodeMaterialConnectionPoint;
  64615. /**
  64616. * Gets the factor input component
  64617. */
  64618. get factor(): NodeMaterialConnectionPoint;
  64619. /**
  64620. * Gets the output component
  64621. */
  64622. get output(): NodeMaterialConnectionPoint;
  64623. protected _buildBlock(state: NodeMaterialBuildState): this;
  64624. }
  64625. }
  64626. declare module BABYLON {
  64627. /**
  64628. * Block used to clamp a float
  64629. */
  64630. export class ClampBlock extends NodeMaterialBlock {
  64631. /** Gets or sets the minimum range */
  64632. minimum: number;
  64633. /** Gets or sets the maximum range */
  64634. maximum: number;
  64635. /**
  64636. * Creates a new ClampBlock
  64637. * @param name defines the block name
  64638. */
  64639. constructor(name: string);
  64640. /**
  64641. * Gets the current class name
  64642. * @returns the class name
  64643. */
  64644. getClassName(): string;
  64645. /**
  64646. * Gets the value input component
  64647. */
  64648. get value(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Gets the output component
  64651. */
  64652. get output(): NodeMaterialConnectionPoint;
  64653. protected _buildBlock(state: NodeMaterialBuildState): this;
  64654. protected _dumpPropertiesCode(): string;
  64655. serialize(): any;
  64656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64657. }
  64658. }
  64659. declare module BABYLON {
  64660. /**
  64661. * Block used to apply a cross product between 2 vectors
  64662. */
  64663. export class CrossBlock extends NodeMaterialBlock {
  64664. /**
  64665. * Creates a new CrossBlock
  64666. * @param name defines the block name
  64667. */
  64668. constructor(name: string);
  64669. /**
  64670. * Gets the current class name
  64671. * @returns the class name
  64672. */
  64673. getClassName(): string;
  64674. /**
  64675. * Gets the left operand input component
  64676. */
  64677. get left(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the right operand input component
  64680. */
  64681. get right(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the output component
  64684. */
  64685. get output(): NodeMaterialConnectionPoint;
  64686. protected _buildBlock(state: NodeMaterialBuildState): this;
  64687. }
  64688. }
  64689. declare module BABYLON {
  64690. /**
  64691. * Block used to apply a dot product between 2 vectors
  64692. */
  64693. export class DotBlock extends NodeMaterialBlock {
  64694. /**
  64695. * Creates a new DotBlock
  64696. * @param name defines the block name
  64697. */
  64698. constructor(name: string);
  64699. /**
  64700. * Gets the current class name
  64701. * @returns the class name
  64702. */
  64703. getClassName(): string;
  64704. /**
  64705. * Gets the left operand input component
  64706. */
  64707. get left(): NodeMaterialConnectionPoint;
  64708. /**
  64709. * Gets the right operand input component
  64710. */
  64711. get right(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the output component
  64714. */
  64715. get output(): NodeMaterialConnectionPoint;
  64716. protected _buildBlock(state: NodeMaterialBuildState): this;
  64717. }
  64718. }
  64719. declare module BABYLON {
  64720. /**
  64721. * Block used to normalize a vector
  64722. */
  64723. export class NormalizeBlock extends NodeMaterialBlock {
  64724. /**
  64725. * Creates a new NormalizeBlock
  64726. * @param name defines the block name
  64727. */
  64728. constructor(name: string);
  64729. /**
  64730. * Gets the current class name
  64731. * @returns the class name
  64732. */
  64733. getClassName(): string;
  64734. /**
  64735. * Gets the input component
  64736. */
  64737. get input(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the output component
  64740. */
  64741. get output(): NodeMaterialConnectionPoint;
  64742. protected _buildBlock(state: NodeMaterialBuildState): this;
  64743. }
  64744. }
  64745. declare module BABYLON {
  64746. /**
  64747. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64748. */
  64749. export class ColorMergerBlock extends NodeMaterialBlock {
  64750. /**
  64751. * Create a new ColorMergerBlock
  64752. * @param name defines the block name
  64753. */
  64754. constructor(name: string);
  64755. /**
  64756. * Gets the current class name
  64757. * @returns the class name
  64758. */
  64759. getClassName(): string;
  64760. /**
  64761. * Gets the rgb component (input)
  64762. */
  64763. get rgbIn(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the r component (input)
  64766. */
  64767. get r(): NodeMaterialConnectionPoint;
  64768. /**
  64769. * Gets the g component (input)
  64770. */
  64771. get g(): NodeMaterialConnectionPoint;
  64772. /**
  64773. * Gets the b component (input)
  64774. */
  64775. get b(): NodeMaterialConnectionPoint;
  64776. /**
  64777. * Gets the a component (input)
  64778. */
  64779. get a(): NodeMaterialConnectionPoint;
  64780. /**
  64781. * Gets the rgba component (output)
  64782. */
  64783. get rgba(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the rgb component (output)
  64786. */
  64787. get rgbOut(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the rgb component (output)
  64790. * @deprecated Please use rgbOut instead.
  64791. */
  64792. get rgb(): NodeMaterialConnectionPoint;
  64793. protected _buildBlock(state: NodeMaterialBuildState): this;
  64794. }
  64795. }
  64796. declare module BABYLON {
  64797. /**
  64798. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64799. */
  64800. export class VectorSplitterBlock extends NodeMaterialBlock {
  64801. /**
  64802. * Create a new VectorSplitterBlock
  64803. * @param name defines the block name
  64804. */
  64805. constructor(name: string);
  64806. /**
  64807. * Gets the current class name
  64808. * @returns the class name
  64809. */
  64810. getClassName(): string;
  64811. /**
  64812. * Gets the xyzw component (input)
  64813. */
  64814. get xyzw(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the xyz component (input)
  64817. */
  64818. get xyzIn(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the xy component (input)
  64821. */
  64822. get xyIn(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the xyz component (output)
  64825. */
  64826. get xyzOut(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the xy component (output)
  64829. */
  64830. get xyOut(): NodeMaterialConnectionPoint;
  64831. /**
  64832. * Gets the x component (output)
  64833. */
  64834. get x(): NodeMaterialConnectionPoint;
  64835. /**
  64836. * Gets the y component (output)
  64837. */
  64838. get y(): NodeMaterialConnectionPoint;
  64839. /**
  64840. * Gets the z component (output)
  64841. */
  64842. get z(): NodeMaterialConnectionPoint;
  64843. /**
  64844. * Gets the w component (output)
  64845. */
  64846. get w(): NodeMaterialConnectionPoint;
  64847. protected _inputRename(name: string): string;
  64848. protected _outputRename(name: string): string;
  64849. protected _buildBlock(state: NodeMaterialBuildState): this;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /**
  64854. * Block used to lerp between 2 values
  64855. */
  64856. export class LerpBlock extends NodeMaterialBlock {
  64857. /**
  64858. * Creates a new LerpBlock
  64859. * @param name defines the block name
  64860. */
  64861. constructor(name: string);
  64862. /**
  64863. * Gets the current class name
  64864. * @returns the class name
  64865. */
  64866. getClassName(): string;
  64867. /**
  64868. * Gets the left operand input component
  64869. */
  64870. get left(): NodeMaterialConnectionPoint;
  64871. /**
  64872. * Gets the right operand input component
  64873. */
  64874. get right(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the gradient operand input component
  64877. */
  64878. get gradient(): NodeMaterialConnectionPoint;
  64879. /**
  64880. * Gets the output component
  64881. */
  64882. get output(): NodeMaterialConnectionPoint;
  64883. protected _buildBlock(state: NodeMaterialBuildState): this;
  64884. }
  64885. }
  64886. declare module BABYLON {
  64887. /**
  64888. * Block used to divide 2 vectors
  64889. */
  64890. export class DivideBlock extends NodeMaterialBlock {
  64891. /**
  64892. * Creates a new DivideBlock
  64893. * @param name defines the block name
  64894. */
  64895. constructor(name: string);
  64896. /**
  64897. * Gets the current class name
  64898. * @returns the class name
  64899. */
  64900. getClassName(): string;
  64901. /**
  64902. * Gets the left operand input component
  64903. */
  64904. get left(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the right operand input component
  64907. */
  64908. get right(): NodeMaterialConnectionPoint;
  64909. /**
  64910. * Gets the output component
  64911. */
  64912. get output(): NodeMaterialConnectionPoint;
  64913. protected _buildBlock(state: NodeMaterialBuildState): this;
  64914. }
  64915. }
  64916. declare module BABYLON {
  64917. /**
  64918. * Block used to subtract 2 vectors
  64919. */
  64920. export class SubtractBlock extends NodeMaterialBlock {
  64921. /**
  64922. * Creates a new SubtractBlock
  64923. * @param name defines the block name
  64924. */
  64925. constructor(name: string);
  64926. /**
  64927. * Gets the current class name
  64928. * @returns the class name
  64929. */
  64930. getClassName(): string;
  64931. /**
  64932. * Gets the left operand input component
  64933. */
  64934. get left(): NodeMaterialConnectionPoint;
  64935. /**
  64936. * Gets the right operand input component
  64937. */
  64938. get right(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the output component
  64941. */
  64942. get output(): NodeMaterialConnectionPoint;
  64943. protected _buildBlock(state: NodeMaterialBuildState): this;
  64944. }
  64945. }
  64946. declare module BABYLON {
  64947. /**
  64948. * Block used to step a value
  64949. */
  64950. export class StepBlock extends NodeMaterialBlock {
  64951. /**
  64952. * Creates a new StepBlock
  64953. * @param name defines the block name
  64954. */
  64955. constructor(name: string);
  64956. /**
  64957. * Gets the current class name
  64958. * @returns the class name
  64959. */
  64960. getClassName(): string;
  64961. /**
  64962. * Gets the value operand input component
  64963. */
  64964. get value(): NodeMaterialConnectionPoint;
  64965. /**
  64966. * Gets the edge operand input component
  64967. */
  64968. get edge(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the output component
  64971. */
  64972. get output(): NodeMaterialConnectionPoint;
  64973. protected _buildBlock(state: NodeMaterialBuildState): this;
  64974. }
  64975. }
  64976. declare module BABYLON {
  64977. /**
  64978. * Block used to get the opposite (1 - x) of a value
  64979. */
  64980. export class OneMinusBlock extends NodeMaterialBlock {
  64981. /**
  64982. * Creates a new OneMinusBlock
  64983. * @param name defines the block name
  64984. */
  64985. constructor(name: string);
  64986. /**
  64987. * Gets the current class name
  64988. * @returns the class name
  64989. */
  64990. getClassName(): string;
  64991. /**
  64992. * Gets the input component
  64993. */
  64994. get input(): NodeMaterialConnectionPoint;
  64995. /**
  64996. * Gets the output component
  64997. */
  64998. get output(): NodeMaterialConnectionPoint;
  64999. protected _buildBlock(state: NodeMaterialBuildState): this;
  65000. }
  65001. }
  65002. declare module BABYLON {
  65003. /**
  65004. * Block used to get the view direction
  65005. */
  65006. export class ViewDirectionBlock extends NodeMaterialBlock {
  65007. /**
  65008. * Creates a new ViewDirectionBlock
  65009. * @param name defines the block name
  65010. */
  65011. constructor(name: string);
  65012. /**
  65013. * Gets the current class name
  65014. * @returns the class name
  65015. */
  65016. getClassName(): string;
  65017. /**
  65018. * Gets the world position component
  65019. */
  65020. get worldPosition(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the camera position component
  65023. */
  65024. get cameraPosition(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the output component
  65027. */
  65028. get output(): NodeMaterialConnectionPoint;
  65029. autoConfigure(material: NodeMaterial): void;
  65030. protected _buildBlock(state: NodeMaterialBuildState): this;
  65031. }
  65032. }
  65033. declare module BABYLON {
  65034. /**
  65035. * Block used to compute fresnel value
  65036. */
  65037. export class FresnelBlock extends NodeMaterialBlock {
  65038. /**
  65039. * Create a new FresnelBlock
  65040. * @param name defines the block name
  65041. */
  65042. constructor(name: string);
  65043. /**
  65044. * Gets the current class name
  65045. * @returns the class name
  65046. */
  65047. getClassName(): string;
  65048. /**
  65049. * Gets the world normal input component
  65050. */
  65051. get worldNormal(): NodeMaterialConnectionPoint;
  65052. /**
  65053. * Gets the view direction input component
  65054. */
  65055. get viewDirection(): NodeMaterialConnectionPoint;
  65056. /**
  65057. * Gets the bias input component
  65058. */
  65059. get bias(): NodeMaterialConnectionPoint;
  65060. /**
  65061. * Gets the camera (or eye) position component
  65062. */
  65063. get power(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the fresnel output component
  65066. */
  65067. get fresnel(): NodeMaterialConnectionPoint;
  65068. autoConfigure(material: NodeMaterial): void;
  65069. protected _buildBlock(state: NodeMaterialBuildState): this;
  65070. }
  65071. }
  65072. declare module BABYLON {
  65073. /**
  65074. * Block used to get the max of 2 values
  65075. */
  65076. export class MaxBlock extends NodeMaterialBlock {
  65077. /**
  65078. * Creates a new MaxBlock
  65079. * @param name defines the block name
  65080. */
  65081. constructor(name: string);
  65082. /**
  65083. * Gets the current class name
  65084. * @returns the class name
  65085. */
  65086. getClassName(): string;
  65087. /**
  65088. * Gets the left operand input component
  65089. */
  65090. get left(): NodeMaterialConnectionPoint;
  65091. /**
  65092. * Gets the right operand input component
  65093. */
  65094. get right(): NodeMaterialConnectionPoint;
  65095. /**
  65096. * Gets the output component
  65097. */
  65098. get output(): NodeMaterialConnectionPoint;
  65099. protected _buildBlock(state: NodeMaterialBuildState): this;
  65100. }
  65101. }
  65102. declare module BABYLON {
  65103. /**
  65104. * Block used to get the min of 2 values
  65105. */
  65106. export class MinBlock extends NodeMaterialBlock {
  65107. /**
  65108. * Creates a new MinBlock
  65109. * @param name defines the block name
  65110. */
  65111. constructor(name: string);
  65112. /**
  65113. * Gets the current class name
  65114. * @returns the class name
  65115. */
  65116. getClassName(): string;
  65117. /**
  65118. * Gets the left operand input component
  65119. */
  65120. get left(): NodeMaterialConnectionPoint;
  65121. /**
  65122. * Gets the right operand input component
  65123. */
  65124. get right(): NodeMaterialConnectionPoint;
  65125. /**
  65126. * Gets the output component
  65127. */
  65128. get output(): NodeMaterialConnectionPoint;
  65129. protected _buildBlock(state: NodeMaterialBuildState): this;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * Block used to get the distance between 2 values
  65135. */
  65136. export class DistanceBlock extends NodeMaterialBlock {
  65137. /**
  65138. * Creates a new DistanceBlock
  65139. * @param name defines the block name
  65140. */
  65141. constructor(name: string);
  65142. /**
  65143. * Gets the current class name
  65144. * @returns the class name
  65145. */
  65146. getClassName(): string;
  65147. /**
  65148. * Gets the left operand input component
  65149. */
  65150. get left(): NodeMaterialConnectionPoint;
  65151. /**
  65152. * Gets the right operand input component
  65153. */
  65154. get right(): NodeMaterialConnectionPoint;
  65155. /**
  65156. * Gets the output component
  65157. */
  65158. get output(): NodeMaterialConnectionPoint;
  65159. protected _buildBlock(state: NodeMaterialBuildState): this;
  65160. }
  65161. }
  65162. declare module BABYLON {
  65163. /**
  65164. * Block used to get the length of a vector
  65165. */
  65166. export class LengthBlock extends NodeMaterialBlock {
  65167. /**
  65168. * Creates a new LengthBlock
  65169. * @param name defines the block name
  65170. */
  65171. constructor(name: string);
  65172. /**
  65173. * Gets the current class name
  65174. * @returns the class name
  65175. */
  65176. getClassName(): string;
  65177. /**
  65178. * Gets the value input component
  65179. */
  65180. get value(): NodeMaterialConnectionPoint;
  65181. /**
  65182. * Gets the output component
  65183. */
  65184. get output(): NodeMaterialConnectionPoint;
  65185. protected _buildBlock(state: NodeMaterialBuildState): this;
  65186. }
  65187. }
  65188. declare module BABYLON {
  65189. /**
  65190. * Block used to get negative version of a value (i.e. x * -1)
  65191. */
  65192. export class NegateBlock extends NodeMaterialBlock {
  65193. /**
  65194. * Creates a new NegateBlock
  65195. * @param name defines the block name
  65196. */
  65197. constructor(name: string);
  65198. /**
  65199. * Gets the current class name
  65200. * @returns the class name
  65201. */
  65202. getClassName(): string;
  65203. /**
  65204. * Gets the value input component
  65205. */
  65206. get value(): NodeMaterialConnectionPoint;
  65207. /**
  65208. * Gets the output component
  65209. */
  65210. get output(): NodeMaterialConnectionPoint;
  65211. protected _buildBlock(state: NodeMaterialBuildState): this;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /**
  65216. * Block used to get the value of the first parameter raised to the power of the second
  65217. */
  65218. export class PowBlock extends NodeMaterialBlock {
  65219. /**
  65220. * Creates a new PowBlock
  65221. * @param name defines the block name
  65222. */
  65223. constructor(name: string);
  65224. /**
  65225. * Gets the current class name
  65226. * @returns the class name
  65227. */
  65228. getClassName(): string;
  65229. /**
  65230. * Gets the value operand input component
  65231. */
  65232. get value(): NodeMaterialConnectionPoint;
  65233. /**
  65234. * Gets the power operand input component
  65235. */
  65236. get power(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the output component
  65239. */
  65240. get output(): NodeMaterialConnectionPoint;
  65241. protected _buildBlock(state: NodeMaterialBuildState): this;
  65242. }
  65243. }
  65244. declare module BABYLON {
  65245. /**
  65246. * Block used to get a random number
  65247. */
  65248. export class RandomNumberBlock extends NodeMaterialBlock {
  65249. /**
  65250. * Creates a new RandomNumberBlock
  65251. * @param name defines the block name
  65252. */
  65253. constructor(name: string);
  65254. /**
  65255. * Gets the current class name
  65256. * @returns the class name
  65257. */
  65258. getClassName(): string;
  65259. /**
  65260. * Gets the seed input component
  65261. */
  65262. get seed(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the output component
  65265. */
  65266. get output(): NodeMaterialConnectionPoint;
  65267. protected _buildBlock(state: NodeMaterialBuildState): this;
  65268. }
  65269. }
  65270. declare module BABYLON {
  65271. /**
  65272. * Block used to compute arc tangent of 2 values
  65273. */
  65274. export class ArcTan2Block extends NodeMaterialBlock {
  65275. /**
  65276. * Creates a new ArcTan2Block
  65277. * @param name defines the block name
  65278. */
  65279. constructor(name: string);
  65280. /**
  65281. * Gets the current class name
  65282. * @returns the class name
  65283. */
  65284. getClassName(): string;
  65285. /**
  65286. * Gets the x operand input component
  65287. */
  65288. get x(): NodeMaterialConnectionPoint;
  65289. /**
  65290. * Gets the y operand input component
  65291. */
  65292. get y(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the output component
  65295. */
  65296. get output(): NodeMaterialConnectionPoint;
  65297. protected _buildBlock(state: NodeMaterialBuildState): this;
  65298. }
  65299. }
  65300. declare module BABYLON {
  65301. /**
  65302. * Block used to smooth step a value
  65303. */
  65304. export class SmoothStepBlock extends NodeMaterialBlock {
  65305. /**
  65306. * Creates a new SmoothStepBlock
  65307. * @param name defines the block name
  65308. */
  65309. constructor(name: string);
  65310. /**
  65311. * Gets the current class name
  65312. * @returns the class name
  65313. */
  65314. getClassName(): string;
  65315. /**
  65316. * Gets the value operand input component
  65317. */
  65318. get value(): NodeMaterialConnectionPoint;
  65319. /**
  65320. * Gets the first edge operand input component
  65321. */
  65322. get edge0(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the second edge operand input component
  65325. */
  65326. get edge1(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the output component
  65329. */
  65330. get output(): NodeMaterialConnectionPoint;
  65331. protected _buildBlock(state: NodeMaterialBuildState): this;
  65332. }
  65333. }
  65334. declare module BABYLON {
  65335. /**
  65336. * Block used to get the reciprocal (1 / x) of a value
  65337. */
  65338. export class ReciprocalBlock extends NodeMaterialBlock {
  65339. /**
  65340. * Creates a new ReciprocalBlock
  65341. * @param name defines the block name
  65342. */
  65343. constructor(name: string);
  65344. /**
  65345. * Gets the current class name
  65346. * @returns the class name
  65347. */
  65348. getClassName(): string;
  65349. /**
  65350. * Gets the input component
  65351. */
  65352. get input(): NodeMaterialConnectionPoint;
  65353. /**
  65354. * Gets the output component
  65355. */
  65356. get output(): NodeMaterialConnectionPoint;
  65357. protected _buildBlock(state: NodeMaterialBuildState): this;
  65358. }
  65359. }
  65360. declare module BABYLON {
  65361. /**
  65362. * Block used to replace a color by another one
  65363. */
  65364. export class ReplaceColorBlock extends NodeMaterialBlock {
  65365. /**
  65366. * Creates a new ReplaceColorBlock
  65367. * @param name defines the block name
  65368. */
  65369. constructor(name: string);
  65370. /**
  65371. * Gets the current class name
  65372. * @returns the class name
  65373. */
  65374. getClassName(): string;
  65375. /**
  65376. * Gets the value input component
  65377. */
  65378. get value(): NodeMaterialConnectionPoint;
  65379. /**
  65380. * Gets the reference input component
  65381. */
  65382. get reference(): NodeMaterialConnectionPoint;
  65383. /**
  65384. * Gets the distance input component
  65385. */
  65386. get distance(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the replacement input component
  65389. */
  65390. get replacement(): NodeMaterialConnectionPoint;
  65391. /**
  65392. * Gets the output component
  65393. */
  65394. get output(): NodeMaterialConnectionPoint;
  65395. protected _buildBlock(state: NodeMaterialBuildState): this;
  65396. }
  65397. }
  65398. declare module BABYLON {
  65399. /**
  65400. * Block used to posterize a value
  65401. * @see https://en.wikipedia.org/wiki/Posterization
  65402. */
  65403. export class PosterizeBlock extends NodeMaterialBlock {
  65404. /**
  65405. * Creates a new PosterizeBlock
  65406. * @param name defines the block name
  65407. */
  65408. constructor(name: string);
  65409. /**
  65410. * Gets the current class name
  65411. * @returns the class name
  65412. */
  65413. getClassName(): string;
  65414. /**
  65415. * Gets the value input component
  65416. */
  65417. get value(): NodeMaterialConnectionPoint;
  65418. /**
  65419. * Gets the steps input component
  65420. */
  65421. get steps(): NodeMaterialConnectionPoint;
  65422. /**
  65423. * Gets the output component
  65424. */
  65425. get output(): NodeMaterialConnectionPoint;
  65426. protected _buildBlock(state: NodeMaterialBuildState): this;
  65427. }
  65428. }
  65429. declare module BABYLON {
  65430. /**
  65431. * Operations supported by the Wave block
  65432. */
  65433. export enum WaveBlockKind {
  65434. /** SawTooth */
  65435. SawTooth = 0,
  65436. /** Square */
  65437. Square = 1,
  65438. /** Triangle */
  65439. Triangle = 2
  65440. }
  65441. /**
  65442. * Block used to apply wave operation to floats
  65443. */
  65444. export class WaveBlock extends NodeMaterialBlock {
  65445. /**
  65446. * Gets or sets the kibnd of wave to be applied by the block
  65447. */
  65448. kind: WaveBlockKind;
  65449. /**
  65450. * Creates a new WaveBlock
  65451. * @param name defines the block name
  65452. */
  65453. constructor(name: string);
  65454. /**
  65455. * Gets the current class name
  65456. * @returns the class name
  65457. */
  65458. getClassName(): string;
  65459. /**
  65460. * Gets the input component
  65461. */
  65462. get input(): NodeMaterialConnectionPoint;
  65463. /**
  65464. * Gets the output component
  65465. */
  65466. get output(): NodeMaterialConnectionPoint;
  65467. protected _buildBlock(state: NodeMaterialBuildState): this;
  65468. serialize(): any;
  65469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65470. }
  65471. }
  65472. declare module BABYLON {
  65473. /**
  65474. * Class used to store a color step for the GradientBlock
  65475. */
  65476. export class GradientBlockColorStep {
  65477. private _step;
  65478. /**
  65479. * Gets value indicating which step this color is associated with (between 0 and 1)
  65480. */
  65481. get step(): number;
  65482. /**
  65483. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65484. */
  65485. set step(val: number);
  65486. private _color;
  65487. /**
  65488. * Gets the color associated with this step
  65489. */
  65490. get color(): Color3;
  65491. /**
  65492. * Sets the color associated with this step
  65493. */
  65494. set color(val: Color3);
  65495. /**
  65496. * Creates a new GradientBlockColorStep
  65497. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65498. * @param color defines the color associated with this step
  65499. */
  65500. constructor(step: number, color: Color3);
  65501. }
  65502. /**
  65503. * Block used to return a color from a gradient based on an input value between 0 and 1
  65504. */
  65505. export class GradientBlock extends NodeMaterialBlock {
  65506. /**
  65507. * Gets or sets the list of color steps
  65508. */
  65509. colorSteps: GradientBlockColorStep[];
  65510. /** Gets an observable raised when the value is changed */
  65511. onValueChangedObservable: Observable<GradientBlock>;
  65512. /** calls observable when the value is changed*/
  65513. colorStepsUpdated(): void;
  65514. /**
  65515. * Creates a new GradientBlock
  65516. * @param name defines the block name
  65517. */
  65518. constructor(name: string);
  65519. /**
  65520. * Gets the current class name
  65521. * @returns the class name
  65522. */
  65523. getClassName(): string;
  65524. /**
  65525. * Gets the gradient input component
  65526. */
  65527. get gradient(): NodeMaterialConnectionPoint;
  65528. /**
  65529. * Gets the output component
  65530. */
  65531. get output(): NodeMaterialConnectionPoint;
  65532. private _writeColorConstant;
  65533. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65534. serialize(): any;
  65535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65536. protected _dumpPropertiesCode(): string;
  65537. }
  65538. }
  65539. declare module BABYLON {
  65540. /**
  65541. * Block used to normalize lerp between 2 values
  65542. */
  65543. export class NLerpBlock extends NodeMaterialBlock {
  65544. /**
  65545. * Creates a new NLerpBlock
  65546. * @param name defines the block name
  65547. */
  65548. constructor(name: string);
  65549. /**
  65550. * Gets the current class name
  65551. * @returns the class name
  65552. */
  65553. getClassName(): string;
  65554. /**
  65555. * Gets the left operand input component
  65556. */
  65557. get left(): NodeMaterialConnectionPoint;
  65558. /**
  65559. * Gets the right operand input component
  65560. */
  65561. get right(): NodeMaterialConnectionPoint;
  65562. /**
  65563. * Gets the gradient operand input component
  65564. */
  65565. get gradient(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the output component
  65568. */
  65569. get output(): NodeMaterialConnectionPoint;
  65570. protected _buildBlock(state: NodeMaterialBuildState): this;
  65571. }
  65572. }
  65573. declare module BABYLON {
  65574. /**
  65575. * block used to Generate a Worley Noise 3D Noise Pattern
  65576. */
  65577. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65578. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65579. manhattanDistance: boolean;
  65580. /**
  65581. * Creates a new WorleyNoise3DBlock
  65582. * @param name defines the block name
  65583. */
  65584. constructor(name: string);
  65585. /**
  65586. * Gets the current class name
  65587. * @returns the class name
  65588. */
  65589. getClassName(): string;
  65590. /**
  65591. * Gets the seed input component
  65592. */
  65593. get seed(): NodeMaterialConnectionPoint;
  65594. /**
  65595. * Gets the jitter input component
  65596. */
  65597. get jitter(): NodeMaterialConnectionPoint;
  65598. /**
  65599. * Gets the output component
  65600. */
  65601. get output(): NodeMaterialConnectionPoint;
  65602. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65603. /**
  65604. * Exposes the properties to the UI?
  65605. */
  65606. protected _dumpPropertiesCode(): string;
  65607. /**
  65608. * Exposes the properties to the Seralize?
  65609. */
  65610. serialize(): any;
  65611. /**
  65612. * Exposes the properties to the deseralize?
  65613. */
  65614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65615. }
  65616. }
  65617. declare module BABYLON {
  65618. /**
  65619. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65620. */
  65621. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65622. /**
  65623. * Creates a new SimplexPerlin3DBlock
  65624. * @param name defines the block name
  65625. */
  65626. constructor(name: string);
  65627. /**
  65628. * Gets the current class name
  65629. * @returns the class name
  65630. */
  65631. getClassName(): string;
  65632. /**
  65633. * Gets the seed operand input component
  65634. */
  65635. get seed(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the output component
  65638. */
  65639. get output(): NodeMaterialConnectionPoint;
  65640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65641. }
  65642. }
  65643. declare module BABYLON {
  65644. /**
  65645. * Block used to blend normals
  65646. */
  65647. export class NormalBlendBlock extends NodeMaterialBlock {
  65648. /**
  65649. * Creates a new NormalBlendBlock
  65650. * @param name defines the block name
  65651. */
  65652. constructor(name: string);
  65653. /**
  65654. * Gets the current class name
  65655. * @returns the class name
  65656. */
  65657. getClassName(): string;
  65658. /**
  65659. * Gets the first input component
  65660. */
  65661. get normalMap0(): NodeMaterialConnectionPoint;
  65662. /**
  65663. * Gets the second input component
  65664. */
  65665. get normalMap1(): NodeMaterialConnectionPoint;
  65666. /**
  65667. * Gets the output component
  65668. */
  65669. get output(): NodeMaterialConnectionPoint;
  65670. protected _buildBlock(state: NodeMaterialBuildState): this;
  65671. }
  65672. }
  65673. declare module BABYLON {
  65674. /**
  65675. * Block used to rotate a 2d vector by a given angle
  65676. */
  65677. export class Rotate2dBlock extends NodeMaterialBlock {
  65678. /**
  65679. * Creates a new Rotate2dBlock
  65680. * @param name defines the block name
  65681. */
  65682. constructor(name: string);
  65683. /**
  65684. * Gets the current class name
  65685. * @returns the class name
  65686. */
  65687. getClassName(): string;
  65688. /**
  65689. * Gets the input vector
  65690. */
  65691. get input(): NodeMaterialConnectionPoint;
  65692. /**
  65693. * Gets the input angle
  65694. */
  65695. get angle(): NodeMaterialConnectionPoint;
  65696. /**
  65697. * Gets the output component
  65698. */
  65699. get output(): NodeMaterialConnectionPoint;
  65700. autoConfigure(material: NodeMaterial): void;
  65701. protected _buildBlock(state: NodeMaterialBuildState): this;
  65702. }
  65703. }
  65704. declare module BABYLON {
  65705. /**
  65706. * Block used to get the reflected vector from a direction and a normal
  65707. */
  65708. export class ReflectBlock extends NodeMaterialBlock {
  65709. /**
  65710. * Creates a new ReflectBlock
  65711. * @param name defines the block name
  65712. */
  65713. constructor(name: string);
  65714. /**
  65715. * Gets the current class name
  65716. * @returns the class name
  65717. */
  65718. getClassName(): string;
  65719. /**
  65720. * Gets the incident component
  65721. */
  65722. get incident(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the normal component
  65725. */
  65726. get normal(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the output component
  65729. */
  65730. get output(): NodeMaterialConnectionPoint;
  65731. protected _buildBlock(state: NodeMaterialBuildState): this;
  65732. }
  65733. }
  65734. declare module BABYLON {
  65735. /**
  65736. * Block used to get the refracted vector from a direction and a normal
  65737. */
  65738. export class RefractBlock extends NodeMaterialBlock {
  65739. /**
  65740. * Creates a new RefractBlock
  65741. * @param name defines the block name
  65742. */
  65743. constructor(name: string);
  65744. /**
  65745. * Gets the current class name
  65746. * @returns the class name
  65747. */
  65748. getClassName(): string;
  65749. /**
  65750. * Gets the incident component
  65751. */
  65752. get incident(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the normal component
  65755. */
  65756. get normal(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the index of refraction component
  65759. */
  65760. get ior(): NodeMaterialConnectionPoint;
  65761. /**
  65762. * Gets the output component
  65763. */
  65764. get output(): NodeMaterialConnectionPoint;
  65765. protected _buildBlock(state: NodeMaterialBuildState): this;
  65766. }
  65767. }
  65768. declare module BABYLON {
  65769. /**
  65770. * Block used to desaturate a color
  65771. */
  65772. export class DesaturateBlock extends NodeMaterialBlock {
  65773. /**
  65774. * Creates a new DesaturateBlock
  65775. * @param name defines the block name
  65776. */
  65777. constructor(name: string);
  65778. /**
  65779. * Gets the current class name
  65780. * @returns the class name
  65781. */
  65782. getClassName(): string;
  65783. /**
  65784. * Gets the color operand input component
  65785. */
  65786. get color(): NodeMaterialConnectionPoint;
  65787. /**
  65788. * Gets the level operand input component
  65789. */
  65790. get level(): NodeMaterialConnectionPoint;
  65791. /**
  65792. * Gets the output component
  65793. */
  65794. get output(): NodeMaterialConnectionPoint;
  65795. protected _buildBlock(state: NodeMaterialBuildState): this;
  65796. }
  65797. }
  65798. declare module BABYLON {
  65799. /**
  65800. * Block used to implement the reflection module of the PBR material
  65801. */
  65802. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65803. /** @hidden */
  65804. _defineLODReflectionAlpha: string;
  65805. /** @hidden */
  65806. _defineLinearSpecularReflection: string;
  65807. private _vEnvironmentIrradianceName;
  65808. /** @hidden */
  65809. _vReflectionMicrosurfaceInfosName: string;
  65810. /** @hidden */
  65811. _vReflectionInfosName: string;
  65812. /** @hidden */
  65813. _vReflectionFilteringInfoName: string;
  65814. private _scene;
  65815. /**
  65816. * The properties below are set by the main PBR block prior to calling methods of this class.
  65817. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65818. * It's less burden on the user side in the editor part.
  65819. */
  65820. /** @hidden */
  65821. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65822. /** @hidden */
  65823. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65824. /** @hidden */
  65825. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65826. /** @hidden */
  65827. viewConnectionPoint: NodeMaterialConnectionPoint;
  65828. /**
  65829. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65830. * diffuse part of the IBL.
  65831. */
  65832. useSphericalHarmonics: boolean;
  65833. /**
  65834. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65835. */
  65836. forceIrradianceInFragment: boolean;
  65837. /**
  65838. * Create a new ReflectionBlock
  65839. * @param name defines the block name
  65840. */
  65841. constructor(name: string);
  65842. /**
  65843. * Gets the current class name
  65844. * @returns the class name
  65845. */
  65846. getClassName(): string;
  65847. /**
  65848. * Gets the position input component
  65849. */
  65850. get position(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the world position input component
  65853. */
  65854. get worldPosition(): NodeMaterialConnectionPoint;
  65855. /**
  65856. * Gets the world normal input component
  65857. */
  65858. get worldNormal(): NodeMaterialConnectionPoint;
  65859. /**
  65860. * Gets the world input component
  65861. */
  65862. get world(): NodeMaterialConnectionPoint;
  65863. /**
  65864. * Gets the camera (or eye) position component
  65865. */
  65866. get cameraPosition(): NodeMaterialConnectionPoint;
  65867. /**
  65868. * Gets the view input component
  65869. */
  65870. get view(): NodeMaterialConnectionPoint;
  65871. /**
  65872. * Gets the color input component
  65873. */
  65874. get color(): NodeMaterialConnectionPoint;
  65875. /**
  65876. * Gets the reflection object output component
  65877. */
  65878. get reflection(): NodeMaterialConnectionPoint;
  65879. /**
  65880. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65881. */
  65882. get hasTexture(): boolean;
  65883. /**
  65884. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65885. */
  65886. get reflectionColor(): string;
  65887. protected _getTexture(): Nullable<BaseTexture>;
  65888. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65889. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65890. /**
  65891. * Gets the code to inject in the vertex shader
  65892. * @param state current state of the node material building
  65893. * @returns the shader code
  65894. */
  65895. handleVertexSide(state: NodeMaterialBuildState): string;
  65896. /**
  65897. * Gets the main code of the block (fragment side)
  65898. * @param state current state of the node material building
  65899. * @param normalVarName name of the existing variable corresponding to the normal
  65900. * @returns the shader code
  65901. */
  65902. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65903. protected _buildBlock(state: NodeMaterialBuildState): this;
  65904. protected _dumpPropertiesCode(): string;
  65905. serialize(): any;
  65906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65907. }
  65908. }
  65909. declare module BABYLON {
  65910. /**
  65911. * Block used to implement the sheen module of the PBR material
  65912. */
  65913. export class SheenBlock extends NodeMaterialBlock {
  65914. /**
  65915. * Create a new SheenBlock
  65916. * @param name defines the block name
  65917. */
  65918. constructor(name: string);
  65919. /**
  65920. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65921. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65922. * making it easier to setup and tweak the effect
  65923. */
  65924. albedoScaling: boolean;
  65925. /**
  65926. * Defines if the sheen is linked to the sheen color.
  65927. */
  65928. linkSheenWithAlbedo: boolean;
  65929. /**
  65930. * Initialize the block and prepare the context for build
  65931. * @param state defines the state that will be used for the build
  65932. */
  65933. initialize(state: NodeMaterialBuildState): void;
  65934. /**
  65935. * Gets the current class name
  65936. * @returns the class name
  65937. */
  65938. getClassName(): string;
  65939. /**
  65940. * Gets the intensity input component
  65941. */
  65942. get intensity(): NodeMaterialConnectionPoint;
  65943. /**
  65944. * Gets the color input component
  65945. */
  65946. get color(): NodeMaterialConnectionPoint;
  65947. /**
  65948. * Gets the roughness input component
  65949. */
  65950. get roughness(): NodeMaterialConnectionPoint;
  65951. /**
  65952. * Gets the sheen object output component
  65953. */
  65954. get sheen(): NodeMaterialConnectionPoint;
  65955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65956. /**
  65957. * Gets the main code of the block (fragment side)
  65958. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65959. * @returns the shader code
  65960. */
  65961. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65962. protected _buildBlock(state: NodeMaterialBuildState): this;
  65963. protected _dumpPropertiesCode(): string;
  65964. serialize(): any;
  65965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65966. }
  65967. }
  65968. declare module BABYLON {
  65969. /**
  65970. * Block used to implement the anisotropy module of the PBR material
  65971. */
  65972. export class AnisotropyBlock extends NodeMaterialBlock {
  65973. /**
  65974. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65975. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65976. * It's less burden on the user side in the editor part.
  65977. */
  65978. /** @hidden */
  65979. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65980. /** @hidden */
  65981. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65982. /**
  65983. * Create a new AnisotropyBlock
  65984. * @param name defines the block name
  65985. */
  65986. constructor(name: string);
  65987. /**
  65988. * Initialize the block and prepare the context for build
  65989. * @param state defines the state that will be used for the build
  65990. */
  65991. initialize(state: NodeMaterialBuildState): void;
  65992. /**
  65993. * Gets the current class name
  65994. * @returns the class name
  65995. */
  65996. getClassName(): string;
  65997. /**
  65998. * Gets the intensity input component
  65999. */
  66000. get intensity(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the direction input component
  66003. */
  66004. get direction(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the uv input component
  66007. */
  66008. get uv(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the worldTangent input component
  66011. */
  66012. get worldTangent(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the anisotropy object output component
  66015. */
  66016. get anisotropy(): NodeMaterialConnectionPoint;
  66017. private _generateTBNSpace;
  66018. /**
  66019. * Gets the main code of the block (fragment side)
  66020. * @param state current state of the node material building
  66021. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66022. * @returns the shader code
  66023. */
  66024. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66026. protected _buildBlock(state: NodeMaterialBuildState): this;
  66027. }
  66028. }
  66029. declare module BABYLON {
  66030. /**
  66031. * Block used to implement the clear coat module of the PBR material
  66032. */
  66033. export class ClearCoatBlock extends NodeMaterialBlock {
  66034. private _scene;
  66035. /**
  66036. * Create a new ClearCoatBlock
  66037. * @param name defines the block name
  66038. */
  66039. constructor(name: string);
  66040. /**
  66041. * Defines if the F0 value should be remapped to account for the interface change in the material.
  66042. */
  66043. remapF0OnInterfaceChange: boolean;
  66044. /**
  66045. * Initialize the block and prepare the context for build
  66046. * @param state defines the state that will be used for the build
  66047. */
  66048. initialize(state: NodeMaterialBuildState): void;
  66049. /**
  66050. * Gets the current class name
  66051. * @returns the class name
  66052. */
  66053. getClassName(): string;
  66054. /**
  66055. * Gets the intensity input component
  66056. */
  66057. get intensity(): NodeMaterialConnectionPoint;
  66058. /**
  66059. * Gets the roughness input component
  66060. */
  66061. get roughness(): NodeMaterialConnectionPoint;
  66062. /**
  66063. * Gets the ior input component
  66064. */
  66065. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66066. /**
  66067. * Gets the bump texture input component
  66068. */
  66069. get normalMapColor(): NodeMaterialConnectionPoint;
  66070. /**
  66071. * Gets the uv input component
  66072. */
  66073. get uv(): NodeMaterialConnectionPoint;
  66074. /**
  66075. * Gets the tint color input component
  66076. */
  66077. get tintColor(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the tint "at distance" input component
  66080. */
  66081. get tintAtDistance(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the tint thickness input component
  66084. */
  66085. get tintThickness(): NodeMaterialConnectionPoint;
  66086. /**
  66087. * Gets the world tangent input component
  66088. */
  66089. get worldTangent(): NodeMaterialConnectionPoint;
  66090. /**
  66091. * Gets the clear coat object output component
  66092. */
  66093. get clearcoat(): NodeMaterialConnectionPoint;
  66094. autoConfigure(material: NodeMaterial): void;
  66095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66096. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66097. private _generateTBNSpace;
  66098. /**
  66099. * Gets the main code of the block (fragment side)
  66100. * @param state current state of the node material building
  66101. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66102. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66103. * @param worldPosVarName name of the variable holding the world position
  66104. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66105. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66106. * @param worldNormalVarName name of the variable holding the world normal
  66107. * @returns the shader code
  66108. */
  66109. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66110. protected _buildBlock(state: NodeMaterialBuildState): this;
  66111. protected _dumpPropertiesCode(): string;
  66112. serialize(): any;
  66113. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66114. }
  66115. }
  66116. declare module BABYLON {
  66117. /**
  66118. * Block used to implement the sub surface module of the PBR material
  66119. */
  66120. export class SubSurfaceBlock extends NodeMaterialBlock {
  66121. /**
  66122. * Create a new SubSurfaceBlock
  66123. * @param name defines the block name
  66124. */
  66125. constructor(name: string);
  66126. /**
  66127. * Initialize the block and prepare the context for build
  66128. * @param state defines the state that will be used for the build
  66129. */
  66130. initialize(state: NodeMaterialBuildState): void;
  66131. /**
  66132. * Gets the current class name
  66133. * @returns the class name
  66134. */
  66135. getClassName(): string;
  66136. /**
  66137. * Gets the thickness component
  66138. */
  66139. get thickness(): NodeMaterialConnectionPoint;
  66140. /**
  66141. * Gets the tint color input component
  66142. */
  66143. get tintColor(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the translucency intensity input component
  66146. */
  66147. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the translucency diffusion distance input component
  66150. */
  66151. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the refraction object parameters
  66154. */
  66155. get refraction(): NodeMaterialConnectionPoint;
  66156. /**
  66157. * Gets the sub surface object output component
  66158. */
  66159. get subsurface(): NodeMaterialConnectionPoint;
  66160. autoConfigure(material: NodeMaterial): void;
  66161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66162. /**
  66163. * Gets the main code of the block (fragment side)
  66164. * @param state current state of the node material building
  66165. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66166. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66167. * @param worldPosVarName name of the variable holding the world position
  66168. * @returns the shader code
  66169. */
  66170. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66171. protected _buildBlock(state: NodeMaterialBuildState): this;
  66172. }
  66173. }
  66174. declare module BABYLON {
  66175. /**
  66176. * Block used to implement the PBR metallic/roughness model
  66177. */
  66178. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66179. /**
  66180. * Gets or sets the light associated with this block
  66181. */
  66182. light: Nullable<Light>;
  66183. private _lightId;
  66184. private _scene;
  66185. private _environmentBRDFTexture;
  66186. private _environmentBrdfSamplerName;
  66187. private _vNormalWName;
  66188. private _invertNormalName;
  66189. private _metallicReflectanceColor;
  66190. private _metallicF0Factor;
  66191. private _vMetallicReflectanceFactorsName;
  66192. /**
  66193. * Create a new ReflectionBlock
  66194. * @param name defines the block name
  66195. */
  66196. constructor(name: string);
  66197. /**
  66198. * Intensity of the direct lights e.g. the four lights available in your scene.
  66199. * This impacts both the direct diffuse and specular highlights.
  66200. */
  66201. directIntensity: number;
  66202. /**
  66203. * Intensity of the environment e.g. how much the environment will light the object
  66204. * either through harmonics for rough material or through the refelction for shiny ones.
  66205. */
  66206. environmentIntensity: number;
  66207. /**
  66208. * This is a special control allowing the reduction of the specular highlights coming from the
  66209. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66210. */
  66211. specularIntensity: number;
  66212. /**
  66213. * Defines the falloff type used in this material.
  66214. * It by default is Physical.
  66215. */
  66216. lightFalloff: number;
  66217. /**
  66218. * Specifies that alpha test should be used
  66219. */
  66220. useAlphaTest: boolean;
  66221. /**
  66222. * Defines the alpha limits in alpha test mode.
  66223. */
  66224. alphaTestCutoff: number;
  66225. /**
  66226. * Specifies that alpha blending should be used
  66227. */
  66228. useAlphaBlending: boolean;
  66229. /**
  66230. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66231. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66232. */
  66233. useRadianceOverAlpha: boolean;
  66234. /**
  66235. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66236. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66237. */
  66238. useSpecularOverAlpha: boolean;
  66239. /**
  66240. * Enables specular anti aliasing in the PBR shader.
  66241. * It will both interacts on the Geometry for analytical and IBL lighting.
  66242. * It also prefilter the roughness map based on the bump values.
  66243. */
  66244. enableSpecularAntiAliasing: boolean;
  66245. /**
  66246. * Enables realtime filtering on the texture.
  66247. */
  66248. realTimeFiltering: boolean;
  66249. /**
  66250. * Quality switch for realtime filtering
  66251. */
  66252. realTimeFilteringQuality: number;
  66253. /**
  66254. * Defines if the material uses energy conservation.
  66255. */
  66256. useEnergyConservation: boolean;
  66257. /**
  66258. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66259. * too much the area relying on ambient texture to define their ambient occlusion.
  66260. */
  66261. useRadianceOcclusion: boolean;
  66262. /**
  66263. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66264. * makes the reflect vector face the model (under horizon).
  66265. */
  66266. useHorizonOcclusion: boolean;
  66267. /**
  66268. * If set to true, no lighting calculations will be applied.
  66269. */
  66270. unlit: boolean;
  66271. /**
  66272. * Force normal to face away from face.
  66273. */
  66274. forceNormalForward: boolean;
  66275. /**
  66276. * Defines the material debug mode.
  66277. * It helps seeing only some components of the material while troubleshooting.
  66278. */
  66279. debugMode: number;
  66280. /**
  66281. * Specify from where on screen the debug mode should start.
  66282. * The value goes from -1 (full screen) to 1 (not visible)
  66283. * It helps with side by side comparison against the final render
  66284. * This defaults to 0
  66285. */
  66286. debugLimit: number;
  66287. /**
  66288. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66289. * You can use the factor to better multiply the final value.
  66290. */
  66291. debugFactor: number;
  66292. /**
  66293. * Initialize the block and prepare the context for build
  66294. * @param state defines the state that will be used for the build
  66295. */
  66296. initialize(state: NodeMaterialBuildState): void;
  66297. /**
  66298. * Gets the current class name
  66299. * @returns the class name
  66300. */
  66301. getClassName(): string;
  66302. /**
  66303. * Gets the world position input component
  66304. */
  66305. get worldPosition(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the world normal input component
  66308. */
  66309. get worldNormal(): NodeMaterialConnectionPoint;
  66310. /**
  66311. * Gets the view matrix parameter
  66312. */
  66313. get view(): NodeMaterialConnectionPoint;
  66314. /**
  66315. * Gets the camera position input component
  66316. */
  66317. get cameraPosition(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the perturbed normal input component
  66320. */
  66321. get perturbedNormal(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the base color input component
  66324. */
  66325. get baseColor(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the metallic input component
  66328. */
  66329. get metallic(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the roughness input component
  66332. */
  66333. get roughness(): NodeMaterialConnectionPoint;
  66334. /**
  66335. * Gets the ambient occlusion input component
  66336. */
  66337. get ambientOcc(): NodeMaterialConnectionPoint;
  66338. /**
  66339. * Gets the opacity input component
  66340. */
  66341. get opacity(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the index of refraction input component
  66344. */
  66345. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the ambient color input component
  66348. */
  66349. get ambientColor(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the reflection object parameters
  66352. */
  66353. get reflection(): NodeMaterialConnectionPoint;
  66354. /**
  66355. * Gets the clear coat object parameters
  66356. */
  66357. get clearcoat(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the sheen object parameters
  66360. */
  66361. get sheen(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the sub surface object parameters
  66364. */
  66365. get subsurface(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the anisotropy object parameters
  66368. */
  66369. get anisotropy(): NodeMaterialConnectionPoint;
  66370. /**
  66371. * Gets the ambient output component
  66372. */
  66373. get ambientClr(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the diffuse output component
  66376. */
  66377. get diffuseDir(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the specular output component
  66380. */
  66381. get specularDir(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the clear coat output component
  66384. */
  66385. get clearcoatDir(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the sheen output component
  66388. */
  66389. get sheenDir(): NodeMaterialConnectionPoint;
  66390. /**
  66391. * Gets the indirect diffuse output component
  66392. */
  66393. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66394. /**
  66395. * Gets the indirect specular output component
  66396. */
  66397. get specularIndirect(): NodeMaterialConnectionPoint;
  66398. /**
  66399. * Gets the indirect clear coat output component
  66400. */
  66401. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the indirect sheen output component
  66404. */
  66405. get sheenIndirect(): NodeMaterialConnectionPoint;
  66406. /**
  66407. * Gets the refraction output component
  66408. */
  66409. get refraction(): NodeMaterialConnectionPoint;
  66410. /**
  66411. * Gets the global lighting output component
  66412. */
  66413. get lighting(): NodeMaterialConnectionPoint;
  66414. /**
  66415. * Gets the shadow output component
  66416. */
  66417. get shadow(): NodeMaterialConnectionPoint;
  66418. /**
  66419. * Gets the alpha output component
  66420. */
  66421. get alpha(): NodeMaterialConnectionPoint;
  66422. autoConfigure(material: NodeMaterial): void;
  66423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66424. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66426. private _injectVertexCode;
  66427. private _getAlbedoOpacityCode;
  66428. private _getAmbientOcclusionCode;
  66429. private _getReflectivityCode;
  66430. protected _buildBlock(state: NodeMaterialBuildState): this;
  66431. protected _dumpPropertiesCode(): string;
  66432. serialize(): any;
  66433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66434. }
  66435. }
  66436. declare module BABYLON {
  66437. /**
  66438. * Block used to compute value of one parameter modulo another
  66439. */
  66440. export class ModBlock extends NodeMaterialBlock {
  66441. /**
  66442. * Creates a new ModBlock
  66443. * @param name defines the block name
  66444. */
  66445. constructor(name: string);
  66446. /**
  66447. * Gets the current class name
  66448. * @returns the class name
  66449. */
  66450. getClassName(): string;
  66451. /**
  66452. * Gets the left operand input component
  66453. */
  66454. get left(): NodeMaterialConnectionPoint;
  66455. /**
  66456. * Gets the right operand input component
  66457. */
  66458. get right(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the output component
  66461. */
  66462. get output(): NodeMaterialConnectionPoint;
  66463. protected _buildBlock(state: NodeMaterialBuildState): this;
  66464. }
  66465. }
  66466. declare module BABYLON {
  66467. /**
  66468. * Configuration for Draco compression
  66469. */
  66470. export interface IDracoCompressionConfiguration {
  66471. /**
  66472. * Configuration for the decoder.
  66473. */
  66474. decoder: {
  66475. /**
  66476. * The url to the WebAssembly module.
  66477. */
  66478. wasmUrl?: string;
  66479. /**
  66480. * The url to the WebAssembly binary.
  66481. */
  66482. wasmBinaryUrl?: string;
  66483. /**
  66484. * The url to the fallback JavaScript module.
  66485. */
  66486. fallbackUrl?: string;
  66487. };
  66488. }
  66489. /**
  66490. * Draco compression (https://google.github.io/draco/)
  66491. *
  66492. * This class wraps the Draco module.
  66493. *
  66494. * **Encoder**
  66495. *
  66496. * The encoder is not currently implemented.
  66497. *
  66498. * **Decoder**
  66499. *
  66500. * 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.
  66501. *
  66502. * To update the configuration, use the following code:
  66503. * ```javascript
  66504. * DracoCompression.Configuration = {
  66505. * decoder: {
  66506. * wasmUrl: "<url to the WebAssembly library>",
  66507. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66508. * fallbackUrl: "<url to the fallback JavaScript library>",
  66509. * }
  66510. * };
  66511. * ```
  66512. *
  66513. * 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.
  66514. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66515. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66516. *
  66517. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66518. * ```javascript
  66519. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66520. * ```
  66521. *
  66522. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66523. */
  66524. export class DracoCompression implements IDisposable {
  66525. private _workerPoolPromise?;
  66526. private _decoderModulePromise?;
  66527. /**
  66528. * The configuration. Defaults to the following urls:
  66529. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66530. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66531. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66532. */
  66533. static Configuration: IDracoCompressionConfiguration;
  66534. /**
  66535. * Returns true if the decoder configuration is available.
  66536. */
  66537. static get DecoderAvailable(): boolean;
  66538. /**
  66539. * Default number of workers to create when creating the draco compression object.
  66540. */
  66541. static DefaultNumWorkers: number;
  66542. private static GetDefaultNumWorkers;
  66543. private static _Default;
  66544. /**
  66545. * Default instance for the draco compression object.
  66546. */
  66547. static get Default(): DracoCompression;
  66548. /**
  66549. * Constructor
  66550. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66551. */
  66552. constructor(numWorkers?: number);
  66553. /**
  66554. * Stop all async operations and release resources.
  66555. */
  66556. dispose(): void;
  66557. /**
  66558. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66559. * @returns a promise that resolves when ready
  66560. */
  66561. whenReadyAsync(): Promise<void>;
  66562. /**
  66563. * Decode Draco compressed mesh data to vertex data.
  66564. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66565. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66566. * @returns A promise that resolves with the decoded vertex data
  66567. */
  66568. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66569. [kind: string]: number;
  66570. }): Promise<VertexData>;
  66571. }
  66572. }
  66573. declare module BABYLON {
  66574. /**
  66575. * Class for building Constructive Solid Geometry
  66576. */
  66577. export class CSG {
  66578. private polygons;
  66579. /**
  66580. * The world matrix
  66581. */
  66582. matrix: Matrix;
  66583. /**
  66584. * Stores the position
  66585. */
  66586. position: Vector3;
  66587. /**
  66588. * Stores the rotation
  66589. */
  66590. rotation: Vector3;
  66591. /**
  66592. * Stores the rotation quaternion
  66593. */
  66594. rotationQuaternion: Nullable<Quaternion>;
  66595. /**
  66596. * Stores the scaling vector
  66597. */
  66598. scaling: Vector3;
  66599. /**
  66600. * Convert the Mesh to CSG
  66601. * @param mesh The Mesh to convert to CSG
  66602. * @returns A new CSG from the Mesh
  66603. */
  66604. static FromMesh(mesh: Mesh): CSG;
  66605. /**
  66606. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66607. * @param polygons Polygons used to construct a CSG solid
  66608. */
  66609. private static FromPolygons;
  66610. /**
  66611. * Clones, or makes a deep copy, of the CSG
  66612. * @returns A new CSG
  66613. */
  66614. clone(): CSG;
  66615. /**
  66616. * Unions this CSG with another CSG
  66617. * @param csg The CSG to union against this CSG
  66618. * @returns The unioned CSG
  66619. */
  66620. union(csg: CSG): CSG;
  66621. /**
  66622. * Unions this CSG with another CSG in place
  66623. * @param csg The CSG to union against this CSG
  66624. */
  66625. unionInPlace(csg: CSG): void;
  66626. /**
  66627. * Subtracts this CSG with another CSG
  66628. * @param csg The CSG to subtract against this CSG
  66629. * @returns A new CSG
  66630. */
  66631. subtract(csg: CSG): CSG;
  66632. /**
  66633. * Subtracts this CSG with another CSG in place
  66634. * @param csg The CSG to subtact against this CSG
  66635. */
  66636. subtractInPlace(csg: CSG): void;
  66637. /**
  66638. * Intersect this CSG with another CSG
  66639. * @param csg The CSG to intersect against this CSG
  66640. * @returns A new CSG
  66641. */
  66642. intersect(csg: CSG): CSG;
  66643. /**
  66644. * Intersects this CSG with another CSG in place
  66645. * @param csg The CSG to intersect against this CSG
  66646. */
  66647. intersectInPlace(csg: CSG): void;
  66648. /**
  66649. * Return a new CSG solid with solid and empty space switched. This solid is
  66650. * not modified.
  66651. * @returns A new CSG solid with solid and empty space switched
  66652. */
  66653. inverse(): CSG;
  66654. /**
  66655. * Inverses the CSG in place
  66656. */
  66657. inverseInPlace(): void;
  66658. /**
  66659. * This is used to keep meshes transformations so they can be restored
  66660. * when we build back a Babylon Mesh
  66661. * NB : All CSG operations are performed in world coordinates
  66662. * @param csg The CSG to copy the transform attributes from
  66663. * @returns This CSG
  66664. */
  66665. copyTransformAttributes(csg: CSG): CSG;
  66666. /**
  66667. * Build Raw mesh from CSG
  66668. * Coordinates here are in world space
  66669. * @param name The name of the mesh geometry
  66670. * @param scene The Scene
  66671. * @param keepSubMeshes Specifies if the submeshes should be kept
  66672. * @returns A new Mesh
  66673. */
  66674. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66675. /**
  66676. * Build Mesh from CSG taking material and transforms into account
  66677. * @param name The name of the Mesh
  66678. * @param material The material of the Mesh
  66679. * @param scene The Scene
  66680. * @param keepSubMeshes Specifies if submeshes should be kept
  66681. * @returns The new Mesh
  66682. */
  66683. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66684. }
  66685. }
  66686. declare module BABYLON {
  66687. /**
  66688. * Class used to create a trail following a mesh
  66689. */
  66690. export class TrailMesh extends Mesh {
  66691. private _generator;
  66692. private _autoStart;
  66693. private _running;
  66694. private _diameter;
  66695. private _length;
  66696. private _sectionPolygonPointsCount;
  66697. private _sectionVectors;
  66698. private _sectionNormalVectors;
  66699. private _beforeRenderObserver;
  66700. /**
  66701. * @constructor
  66702. * @param name The value used by scene.getMeshByName() to do a lookup.
  66703. * @param generator The mesh or transform node to generate a trail.
  66704. * @param scene The scene to add this mesh to.
  66705. * @param diameter Diameter of trailing mesh. Default is 1.
  66706. * @param length Length of trailing mesh. Default is 60.
  66707. * @param autoStart Automatically start trailing mesh. Default true.
  66708. */
  66709. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66710. /**
  66711. * "TrailMesh"
  66712. * @returns "TrailMesh"
  66713. */
  66714. getClassName(): string;
  66715. private _createMesh;
  66716. /**
  66717. * Start trailing mesh.
  66718. */
  66719. start(): void;
  66720. /**
  66721. * Stop trailing mesh.
  66722. */
  66723. stop(): void;
  66724. /**
  66725. * Update trailing mesh geometry.
  66726. */
  66727. update(): void;
  66728. /**
  66729. * Returns a new TrailMesh object.
  66730. * @param name is a string, the name given to the new mesh
  66731. * @param newGenerator use new generator object for cloned trail mesh
  66732. * @returns a new mesh
  66733. */
  66734. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66735. /**
  66736. * Serializes this trail mesh
  66737. * @param serializationObject object to write serialization to
  66738. */
  66739. serialize(serializationObject: any): void;
  66740. /**
  66741. * Parses a serialized trail mesh
  66742. * @param parsedMesh the serialized mesh
  66743. * @param scene the scene to create the trail mesh in
  66744. * @returns the created trail mesh
  66745. */
  66746. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66747. }
  66748. }
  66749. declare module BABYLON {
  66750. /**
  66751. * Class containing static functions to help procedurally build meshes
  66752. */
  66753. export class TiledBoxBuilder {
  66754. /**
  66755. * Creates a box mesh
  66756. * 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)
  66757. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66759. * * 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
  66760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66761. * @param name defines the name of the mesh
  66762. * @param options defines the options used to create the mesh
  66763. * @param scene defines the hosting scene
  66764. * @returns the box mesh
  66765. */
  66766. static CreateTiledBox(name: string, options: {
  66767. pattern?: number;
  66768. width?: number;
  66769. height?: number;
  66770. depth?: number;
  66771. tileSize?: number;
  66772. tileWidth?: number;
  66773. tileHeight?: number;
  66774. alignHorizontal?: number;
  66775. alignVertical?: number;
  66776. faceUV?: Vector4[];
  66777. faceColors?: Color4[];
  66778. sideOrientation?: number;
  66779. updatable?: boolean;
  66780. }, scene?: Nullable<Scene>): Mesh;
  66781. }
  66782. }
  66783. declare module BABYLON {
  66784. /**
  66785. * Class containing static functions to help procedurally build meshes
  66786. */
  66787. export class TorusKnotBuilder {
  66788. /**
  66789. * Creates a torus knot mesh
  66790. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66791. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66792. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66793. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66795. * * 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
  66796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66797. * @param name defines the name of the mesh
  66798. * @param options defines the options used to create the mesh
  66799. * @param scene defines the hosting scene
  66800. * @returns the torus knot mesh
  66801. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66802. */
  66803. static CreateTorusKnot(name: string, options: {
  66804. radius?: number;
  66805. tube?: number;
  66806. radialSegments?: number;
  66807. tubularSegments?: number;
  66808. p?: number;
  66809. q?: number;
  66810. updatable?: boolean;
  66811. sideOrientation?: number;
  66812. frontUVs?: Vector4;
  66813. backUVs?: Vector4;
  66814. }, scene: any): Mesh;
  66815. }
  66816. }
  66817. declare module BABYLON {
  66818. /**
  66819. * Polygon
  66820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66821. */
  66822. export class Polygon {
  66823. /**
  66824. * Creates a rectangle
  66825. * @param xmin bottom X coord
  66826. * @param ymin bottom Y coord
  66827. * @param xmax top X coord
  66828. * @param ymax top Y coord
  66829. * @returns points that make the resulting rectation
  66830. */
  66831. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66832. /**
  66833. * Creates a circle
  66834. * @param radius radius of circle
  66835. * @param cx scale in x
  66836. * @param cy scale in y
  66837. * @param numberOfSides number of sides that make up the circle
  66838. * @returns points that make the resulting circle
  66839. */
  66840. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66841. /**
  66842. * Creates a polygon from input string
  66843. * @param input Input polygon data
  66844. * @returns the parsed points
  66845. */
  66846. static Parse(input: string): Vector2[];
  66847. /**
  66848. * Starts building a polygon from x and y coordinates
  66849. * @param x x coordinate
  66850. * @param y y coordinate
  66851. * @returns the started path2
  66852. */
  66853. static StartingAt(x: number, y: number): Path2;
  66854. }
  66855. /**
  66856. * Builds a polygon
  66857. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66858. */
  66859. export class PolygonMeshBuilder {
  66860. private _points;
  66861. private _outlinepoints;
  66862. private _holes;
  66863. private _name;
  66864. private _scene;
  66865. private _epoints;
  66866. private _eholes;
  66867. private _addToepoint;
  66868. /**
  66869. * Babylon reference to the earcut plugin.
  66870. */
  66871. bjsEarcut: any;
  66872. /**
  66873. * Creates a PolygonMeshBuilder
  66874. * @param name name of the builder
  66875. * @param contours Path of the polygon
  66876. * @param scene scene to add to when creating the mesh
  66877. * @param earcutInjection can be used to inject your own earcut reference
  66878. */
  66879. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66880. /**
  66881. * Adds a whole within the polygon
  66882. * @param hole Array of points defining the hole
  66883. * @returns this
  66884. */
  66885. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66886. /**
  66887. * Creates the polygon
  66888. * @param updatable If the mesh should be updatable
  66889. * @param depth The depth of the mesh created
  66890. * @returns the created mesh
  66891. */
  66892. build(updatable?: boolean, depth?: number): Mesh;
  66893. /**
  66894. * Creates the polygon
  66895. * @param depth The depth of the mesh created
  66896. * @returns the created VertexData
  66897. */
  66898. buildVertexData(depth?: number): VertexData;
  66899. /**
  66900. * Adds a side to the polygon
  66901. * @param positions points that make the polygon
  66902. * @param normals normals of the polygon
  66903. * @param uvs uvs of the polygon
  66904. * @param indices indices of the polygon
  66905. * @param bounds bounds of the polygon
  66906. * @param points points of the polygon
  66907. * @param depth depth of the polygon
  66908. * @param flip flip of the polygon
  66909. */
  66910. private addSide;
  66911. }
  66912. }
  66913. declare module BABYLON {
  66914. /**
  66915. * Class containing static functions to help procedurally build meshes
  66916. */
  66917. export class PolygonBuilder {
  66918. /**
  66919. * Creates a polygon mesh
  66920. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66921. * * 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
  66922. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66924. * * 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)
  66925. * * Remember you can only change the shape positions, not their number when updating a polygon
  66926. * @param name defines the name of the mesh
  66927. * @param options defines the options used to create the mesh
  66928. * @param scene defines the hosting scene
  66929. * @param earcutInjection can be used to inject your own earcut reference
  66930. * @returns the polygon mesh
  66931. */
  66932. static CreatePolygon(name: string, options: {
  66933. shape: Vector3[];
  66934. holes?: Vector3[][];
  66935. depth?: number;
  66936. faceUV?: Vector4[];
  66937. faceColors?: Color4[];
  66938. updatable?: boolean;
  66939. sideOrientation?: number;
  66940. frontUVs?: Vector4;
  66941. backUVs?: Vector4;
  66942. wrap?: boolean;
  66943. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66944. /**
  66945. * Creates an extruded polygon mesh, with depth in the Y direction.
  66946. * * 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)
  66947. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66948. * @param name defines the name of the mesh
  66949. * @param options defines the options used to create the mesh
  66950. * @param scene defines the hosting scene
  66951. * @param earcutInjection can be used to inject your own earcut reference
  66952. * @returns the polygon mesh
  66953. */
  66954. static ExtrudePolygon(name: string, options: {
  66955. shape: Vector3[];
  66956. holes?: Vector3[][];
  66957. depth?: number;
  66958. faceUV?: Vector4[];
  66959. faceColors?: Color4[];
  66960. updatable?: boolean;
  66961. sideOrientation?: number;
  66962. frontUVs?: Vector4;
  66963. backUVs?: Vector4;
  66964. wrap?: boolean;
  66965. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66966. }
  66967. }
  66968. declare module BABYLON {
  66969. /**
  66970. * Class containing static functions to help procedurally build meshes
  66971. */
  66972. export class LatheBuilder {
  66973. /**
  66974. * Creates lathe mesh.
  66975. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66976. * * 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
  66977. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66978. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66979. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66980. * * 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
  66981. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66982. * * 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
  66983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66984. * * 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
  66985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66987. * @param name defines the name of the mesh
  66988. * @param options defines the options used to create the mesh
  66989. * @param scene defines the hosting scene
  66990. * @returns the lathe mesh
  66991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66992. */
  66993. static CreateLathe(name: string, options: {
  66994. shape: Vector3[];
  66995. radius?: number;
  66996. tessellation?: number;
  66997. clip?: number;
  66998. arc?: number;
  66999. closed?: boolean;
  67000. updatable?: boolean;
  67001. sideOrientation?: number;
  67002. frontUVs?: Vector4;
  67003. backUVs?: Vector4;
  67004. cap?: number;
  67005. invertUV?: boolean;
  67006. }, scene?: Nullable<Scene>): Mesh;
  67007. }
  67008. }
  67009. declare module BABYLON {
  67010. /**
  67011. * Class containing static functions to help procedurally build meshes
  67012. */
  67013. export class TiledPlaneBuilder {
  67014. /**
  67015. * Creates a tiled plane mesh
  67016. * * The parameter `pattern` will, depending on value, do nothing or
  67017. * * * flip (reflect about central vertical) alternate tiles across and up
  67018. * * * flip every tile on alternate rows
  67019. * * * rotate (180 degs) alternate tiles across and up
  67020. * * * rotate every tile on alternate rows
  67021. * * * flip and rotate alternate tiles across and up
  67022. * * * flip and rotate every tile on alternate rows
  67023. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67024. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67025. * * 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
  67026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67027. * * 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)
  67028. * * 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)
  67029. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67030. * @param name defines the name of the mesh
  67031. * @param options defines the options used to create the mesh
  67032. * @param scene defines the hosting scene
  67033. * @returns the box mesh
  67034. */
  67035. static CreateTiledPlane(name: string, options: {
  67036. pattern?: number;
  67037. tileSize?: number;
  67038. tileWidth?: number;
  67039. tileHeight?: number;
  67040. size?: number;
  67041. width?: number;
  67042. height?: number;
  67043. alignHorizontal?: number;
  67044. alignVertical?: number;
  67045. sideOrientation?: number;
  67046. frontUVs?: Vector4;
  67047. backUVs?: Vector4;
  67048. updatable?: boolean;
  67049. }, scene?: Nullable<Scene>): Mesh;
  67050. }
  67051. }
  67052. declare module BABYLON {
  67053. /**
  67054. * Class containing static functions to help procedurally build meshes
  67055. */
  67056. export class TubeBuilder {
  67057. /**
  67058. * Creates a tube mesh.
  67059. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67060. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67061. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67062. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67063. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67064. * * 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)
  67065. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67066. * * 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
  67067. * * 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
  67068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67069. * * 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
  67070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67072. * @param name defines the name of the mesh
  67073. * @param options defines the options used to create the mesh
  67074. * @param scene defines the hosting scene
  67075. * @returns the tube mesh
  67076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67077. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67078. */
  67079. static CreateTube(name: string, options: {
  67080. path: Vector3[];
  67081. radius?: number;
  67082. tessellation?: number;
  67083. radiusFunction?: {
  67084. (i: number, distance: number): number;
  67085. };
  67086. cap?: number;
  67087. arc?: number;
  67088. updatable?: boolean;
  67089. sideOrientation?: number;
  67090. frontUVs?: Vector4;
  67091. backUVs?: Vector4;
  67092. instance?: Mesh;
  67093. invertUV?: boolean;
  67094. }, scene?: Nullable<Scene>): Mesh;
  67095. }
  67096. }
  67097. declare module BABYLON {
  67098. /**
  67099. * Class containing static functions to help procedurally build meshes
  67100. */
  67101. export class IcoSphereBuilder {
  67102. /**
  67103. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67104. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67105. * * 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`)
  67106. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67107. * * 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
  67108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67109. * * 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
  67110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67111. * @param name defines the name of the mesh
  67112. * @param options defines the options used to create the mesh
  67113. * @param scene defines the hosting scene
  67114. * @returns the icosahedron mesh
  67115. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67116. */
  67117. static CreateIcoSphere(name: string, options: {
  67118. radius?: number;
  67119. radiusX?: number;
  67120. radiusY?: number;
  67121. radiusZ?: number;
  67122. flat?: boolean;
  67123. subdivisions?: number;
  67124. sideOrientation?: number;
  67125. frontUVs?: Vector4;
  67126. backUVs?: Vector4;
  67127. updatable?: boolean;
  67128. }, scene?: Nullable<Scene>): Mesh;
  67129. }
  67130. }
  67131. declare module BABYLON {
  67132. /**
  67133. * Class containing static functions to help procedurally build meshes
  67134. */
  67135. export class DecalBuilder {
  67136. /**
  67137. * Creates a decal mesh.
  67138. * 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
  67139. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67140. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67141. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67142. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67143. * @param name defines the name of the mesh
  67144. * @param sourceMesh defines the mesh where the decal must be applied
  67145. * @param options defines the options used to create the mesh
  67146. * @param scene defines the hosting scene
  67147. * @returns the decal mesh
  67148. * @see https://doc.babylonjs.com/how_to/decals
  67149. */
  67150. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67151. position?: Vector3;
  67152. normal?: Vector3;
  67153. size?: Vector3;
  67154. angle?: number;
  67155. }): Mesh;
  67156. }
  67157. }
  67158. declare module BABYLON {
  67159. /**
  67160. * Class containing static functions to help procedurally build meshes
  67161. */
  67162. export class MeshBuilder {
  67163. /**
  67164. * Creates a box mesh
  67165. * * The parameter `size` sets the size (float) of each box side (default 1)
  67166. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67167. * * 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)
  67168. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67170. * * 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
  67171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67172. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67173. * @param name defines the name of the mesh
  67174. * @param options defines the options used to create the mesh
  67175. * @param scene defines the hosting scene
  67176. * @returns the box mesh
  67177. */
  67178. static CreateBox(name: string, options: {
  67179. size?: number;
  67180. width?: number;
  67181. height?: number;
  67182. depth?: number;
  67183. faceUV?: Vector4[];
  67184. faceColors?: Color4[];
  67185. sideOrientation?: number;
  67186. frontUVs?: Vector4;
  67187. backUVs?: Vector4;
  67188. wrap?: boolean;
  67189. topBaseAt?: number;
  67190. bottomBaseAt?: number;
  67191. updatable?: boolean;
  67192. }, scene?: Nullable<Scene>): Mesh;
  67193. /**
  67194. * Creates a tiled box mesh
  67195. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67197. * @param name defines the name of the mesh
  67198. * @param options defines the options used to create the mesh
  67199. * @param scene defines the hosting scene
  67200. * @returns the tiled box mesh
  67201. */
  67202. static CreateTiledBox(name: string, options: {
  67203. pattern?: number;
  67204. size?: number;
  67205. width?: number;
  67206. height?: number;
  67207. depth: number;
  67208. tileSize?: number;
  67209. tileWidth?: number;
  67210. tileHeight?: number;
  67211. faceUV?: Vector4[];
  67212. faceColors?: Color4[];
  67213. alignHorizontal?: number;
  67214. alignVertical?: number;
  67215. sideOrientation?: number;
  67216. updatable?: boolean;
  67217. }, scene?: Nullable<Scene>): Mesh;
  67218. /**
  67219. * Creates a sphere mesh
  67220. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67221. * * 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`)
  67222. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67223. * * 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
  67224. * * 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)
  67225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67226. * * 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
  67227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67228. * @param name defines the name of the mesh
  67229. * @param options defines the options used to create the mesh
  67230. * @param scene defines the hosting scene
  67231. * @returns the sphere mesh
  67232. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67233. */
  67234. static CreateSphere(name: string, options: {
  67235. segments?: number;
  67236. diameter?: number;
  67237. diameterX?: number;
  67238. diameterY?: number;
  67239. diameterZ?: number;
  67240. arc?: number;
  67241. slice?: number;
  67242. sideOrientation?: number;
  67243. frontUVs?: Vector4;
  67244. backUVs?: Vector4;
  67245. updatable?: boolean;
  67246. }, scene?: Nullable<Scene>): Mesh;
  67247. /**
  67248. * Creates a plane polygonal mesh. By default, this is a disc
  67249. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67250. * * 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
  67251. * * 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
  67252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67253. * * 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
  67254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67255. * @param name defines the name of the mesh
  67256. * @param options defines the options used to create the mesh
  67257. * @param scene defines the hosting scene
  67258. * @returns the plane polygonal mesh
  67259. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67260. */
  67261. static CreateDisc(name: string, options: {
  67262. radius?: number;
  67263. tessellation?: number;
  67264. arc?: number;
  67265. updatable?: boolean;
  67266. sideOrientation?: number;
  67267. frontUVs?: Vector4;
  67268. backUVs?: Vector4;
  67269. }, scene?: Nullable<Scene>): Mesh;
  67270. /**
  67271. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67272. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67273. * * 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`)
  67274. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67275. * * 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
  67276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67277. * * 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
  67278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67279. * @param name defines the name of the mesh
  67280. * @param options defines the options used to create the mesh
  67281. * @param scene defines the hosting scene
  67282. * @returns the icosahedron mesh
  67283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67284. */
  67285. static CreateIcoSphere(name: string, options: {
  67286. radius?: number;
  67287. radiusX?: number;
  67288. radiusY?: number;
  67289. radiusZ?: number;
  67290. flat?: boolean;
  67291. subdivisions?: number;
  67292. sideOrientation?: number;
  67293. frontUVs?: Vector4;
  67294. backUVs?: Vector4;
  67295. updatable?: boolean;
  67296. }, scene?: Nullable<Scene>): Mesh;
  67297. /**
  67298. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67299. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67300. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67301. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67302. * * 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
  67303. * * 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
  67304. * * 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
  67305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67306. * * 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
  67307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67308. * * 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
  67309. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67310. * * 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
  67311. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67313. * @param name defines the name of the mesh
  67314. * @param options defines the options used to create the mesh
  67315. * @param scene defines the hosting scene
  67316. * @returns the ribbon mesh
  67317. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67319. */
  67320. static CreateRibbon(name: string, options: {
  67321. pathArray: Vector3[][];
  67322. closeArray?: boolean;
  67323. closePath?: boolean;
  67324. offset?: number;
  67325. updatable?: boolean;
  67326. sideOrientation?: number;
  67327. frontUVs?: Vector4;
  67328. backUVs?: Vector4;
  67329. instance?: Mesh;
  67330. invertUV?: boolean;
  67331. uvs?: Vector2[];
  67332. colors?: Color4[];
  67333. }, scene?: Nullable<Scene>): Mesh;
  67334. /**
  67335. * Creates a cylinder or a cone mesh
  67336. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67337. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67338. * * 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.
  67339. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67340. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67341. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67342. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67343. * * 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).
  67344. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67345. * * 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).
  67346. * * 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
  67347. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67348. * * 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
  67349. * * 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.
  67350. * * If `enclose` is false, a ring surface is one element.
  67351. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67352. * * 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
  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 cylinder mesh
  67360. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67361. */
  67362. static CreateCylinder(name: string, options: {
  67363. height?: number;
  67364. diameterTop?: number;
  67365. diameterBottom?: number;
  67366. diameter?: number;
  67367. tessellation?: number;
  67368. subdivisions?: number;
  67369. arc?: number;
  67370. faceColors?: Color4[];
  67371. faceUV?: Vector4[];
  67372. updatable?: boolean;
  67373. hasRings?: boolean;
  67374. enclose?: boolean;
  67375. cap?: number;
  67376. sideOrientation?: number;
  67377. frontUVs?: Vector4;
  67378. backUVs?: Vector4;
  67379. }, scene?: Nullable<Scene>): Mesh;
  67380. /**
  67381. * Creates a torus mesh
  67382. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67383. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67384. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67386. * * 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
  67387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67388. * @param name defines the name of the mesh
  67389. * @param options defines the options used to create the mesh
  67390. * @param scene defines the hosting scene
  67391. * @returns the torus mesh
  67392. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67393. */
  67394. static CreateTorus(name: string, options: {
  67395. diameter?: number;
  67396. thickness?: number;
  67397. tessellation?: number;
  67398. updatable?: boolean;
  67399. sideOrientation?: number;
  67400. frontUVs?: Vector4;
  67401. backUVs?: Vector4;
  67402. }, scene?: Nullable<Scene>): Mesh;
  67403. /**
  67404. * Creates a torus knot mesh
  67405. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67406. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67407. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67408. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67410. * * 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
  67411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67412. * @param name defines the name of the mesh
  67413. * @param options defines the options used to create the mesh
  67414. * @param scene defines the hosting scene
  67415. * @returns the torus knot mesh
  67416. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67417. */
  67418. static CreateTorusKnot(name: string, options: {
  67419. radius?: number;
  67420. tube?: number;
  67421. radialSegments?: number;
  67422. tubularSegments?: number;
  67423. p?: number;
  67424. q?: number;
  67425. updatable?: boolean;
  67426. sideOrientation?: number;
  67427. frontUVs?: Vector4;
  67428. backUVs?: Vector4;
  67429. }, scene?: Nullable<Scene>): Mesh;
  67430. /**
  67431. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67432. * * 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
  67433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67434. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67435. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67436. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67437. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67438. * * 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
  67439. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67442. * @param name defines the name of the new line system
  67443. * @param options defines the options used to create the line system
  67444. * @param scene defines the hosting scene
  67445. * @returns a new line system mesh
  67446. */
  67447. static CreateLineSystem(name: string, options: {
  67448. lines: Vector3[][];
  67449. updatable?: boolean;
  67450. instance?: Nullable<LinesMesh>;
  67451. colors?: Nullable<Color4[][]>;
  67452. useVertexAlpha?: boolean;
  67453. }, scene: Nullable<Scene>): LinesMesh;
  67454. /**
  67455. * Creates a line mesh
  67456. * 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
  67457. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67458. * * The parameter `points` is an array successive Vector3
  67459. * * 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
  67460. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67461. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67462. * * When updating an instance, remember that only point positions can change, not the number of points
  67463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67465. * @param name defines the name of the new line system
  67466. * @param options defines the options used to create the line system
  67467. * @param scene defines the hosting scene
  67468. * @returns a new line mesh
  67469. */
  67470. static CreateLines(name: string, options: {
  67471. points: Vector3[];
  67472. updatable?: boolean;
  67473. instance?: Nullable<LinesMesh>;
  67474. colors?: Color4[];
  67475. useVertexAlpha?: boolean;
  67476. }, scene?: Nullable<Scene>): LinesMesh;
  67477. /**
  67478. * Creates a dashed line mesh
  67479. * * 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
  67480. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67481. * * The parameter `points` is an array successive Vector3
  67482. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67483. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67484. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67485. * * 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
  67486. * * When updating an instance, remember that only point positions can change, not the number of points
  67487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67488. * @param name defines the name of the mesh
  67489. * @param options defines the options used to create the mesh
  67490. * @param scene defines the hosting scene
  67491. * @returns the dashed line mesh
  67492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67493. */
  67494. static CreateDashedLines(name: string, options: {
  67495. points: Vector3[];
  67496. dashSize?: number;
  67497. gapSize?: number;
  67498. dashNb?: number;
  67499. updatable?: boolean;
  67500. instance?: LinesMesh;
  67501. }, scene?: Nullable<Scene>): LinesMesh;
  67502. /**
  67503. * 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.
  67504. * * 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.
  67505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67506. * * 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.
  67507. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67508. * * 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
  67509. * * 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
  67510. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67512. * * 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
  67513. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67515. * @param name defines the name of the mesh
  67516. * @param options defines the options used to create the mesh
  67517. * @param scene defines the hosting scene
  67518. * @returns the extruded shape mesh
  67519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67521. */
  67522. static ExtrudeShape(name: string, options: {
  67523. shape: Vector3[];
  67524. path: Vector3[];
  67525. scale?: number;
  67526. rotation?: number;
  67527. cap?: number;
  67528. updatable?: boolean;
  67529. sideOrientation?: number;
  67530. frontUVs?: Vector4;
  67531. backUVs?: Vector4;
  67532. instance?: Mesh;
  67533. invertUV?: boolean;
  67534. }, scene?: Nullable<Scene>): Mesh;
  67535. /**
  67536. * Creates an custom extruded shape mesh.
  67537. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67538. * * 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.
  67539. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67540. * * 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
  67541. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67542. * * 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
  67543. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67544. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67545. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67546. * * 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
  67547. * * 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
  67548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67550. * * 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
  67551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67553. * @param name defines the name of the mesh
  67554. * @param options defines the options used to create the mesh
  67555. * @param scene defines the hosting scene
  67556. * @returns the custom extruded shape mesh
  67557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67560. */
  67561. static ExtrudeShapeCustom(name: string, options: {
  67562. shape: Vector3[];
  67563. path: Vector3[];
  67564. scaleFunction?: any;
  67565. rotationFunction?: any;
  67566. ribbonCloseArray?: boolean;
  67567. ribbonClosePath?: boolean;
  67568. cap?: number;
  67569. updatable?: boolean;
  67570. sideOrientation?: number;
  67571. frontUVs?: Vector4;
  67572. backUVs?: Vector4;
  67573. instance?: Mesh;
  67574. invertUV?: boolean;
  67575. }, scene?: Nullable<Scene>): Mesh;
  67576. /**
  67577. * Creates lathe mesh.
  67578. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67579. * * 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
  67580. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67581. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67582. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67583. * * 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
  67584. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67585. * * 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
  67586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67587. * * 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
  67588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67590. * @param name defines the name of the mesh
  67591. * @param options defines the options used to create the mesh
  67592. * @param scene defines the hosting scene
  67593. * @returns the lathe mesh
  67594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67595. */
  67596. static CreateLathe(name: string, options: {
  67597. shape: Vector3[];
  67598. radius?: number;
  67599. tessellation?: number;
  67600. clip?: number;
  67601. arc?: number;
  67602. closed?: boolean;
  67603. updatable?: boolean;
  67604. sideOrientation?: number;
  67605. frontUVs?: Vector4;
  67606. backUVs?: Vector4;
  67607. cap?: number;
  67608. invertUV?: boolean;
  67609. }, scene?: Nullable<Scene>): Mesh;
  67610. /**
  67611. * Creates a tiled plane mesh
  67612. * * You can set a limited pattern arrangement with the tiles
  67613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67614. * * 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
  67615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67616. * @param name defines the name of the mesh
  67617. * @param options defines the options used to create the mesh
  67618. * @param scene defines the hosting scene
  67619. * @returns the plane mesh
  67620. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67621. */
  67622. static CreateTiledPlane(name: string, options: {
  67623. pattern?: number;
  67624. tileSize?: number;
  67625. tileWidth?: number;
  67626. tileHeight?: number;
  67627. size?: number;
  67628. width?: number;
  67629. height?: number;
  67630. alignHorizontal?: number;
  67631. alignVertical?: number;
  67632. sideOrientation?: number;
  67633. frontUVs?: Vector4;
  67634. backUVs?: Vector4;
  67635. updatable?: boolean;
  67636. }, scene?: Nullable<Scene>): Mesh;
  67637. /**
  67638. * Creates a plane mesh
  67639. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67640. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67641. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67643. * * 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
  67644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67645. * @param name defines the name of the mesh
  67646. * @param options defines the options used to create the mesh
  67647. * @param scene defines the hosting scene
  67648. * @returns the plane mesh
  67649. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67650. */
  67651. static CreatePlane(name: string, options: {
  67652. size?: number;
  67653. width?: number;
  67654. height?: number;
  67655. sideOrientation?: number;
  67656. frontUVs?: Vector4;
  67657. backUVs?: Vector4;
  67658. updatable?: boolean;
  67659. sourcePlane?: Plane;
  67660. }, scene?: Nullable<Scene>): Mesh;
  67661. /**
  67662. * Creates a ground mesh
  67663. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67664. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67666. * @param name defines the name of the mesh
  67667. * @param options defines the options used to create the mesh
  67668. * @param scene defines the hosting scene
  67669. * @returns the ground mesh
  67670. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67671. */
  67672. static CreateGround(name: string, options: {
  67673. width?: number;
  67674. height?: number;
  67675. subdivisions?: number;
  67676. subdivisionsX?: number;
  67677. subdivisionsY?: number;
  67678. updatable?: boolean;
  67679. }, scene?: Nullable<Scene>): Mesh;
  67680. /**
  67681. * Creates a tiled ground mesh
  67682. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67683. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67684. * * 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
  67685. * * 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
  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 options defines the options used to create the mesh
  67689. * @param scene defines the hosting scene
  67690. * @returns the tiled ground mesh
  67691. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67692. */
  67693. static CreateTiledGround(name: string, options: {
  67694. xmin: number;
  67695. zmin: number;
  67696. xmax: number;
  67697. zmax: number;
  67698. subdivisions?: {
  67699. w: number;
  67700. h: number;
  67701. };
  67702. precision?: {
  67703. w: number;
  67704. h: number;
  67705. };
  67706. updatable?: boolean;
  67707. }, scene?: Nullable<Scene>): Mesh;
  67708. /**
  67709. * Creates a ground mesh from a height map
  67710. * * The parameter `url` sets the URL of the height map image resource.
  67711. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67712. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67713. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67714. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67715. * * 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.
  67716. * * 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).
  67717. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67719. * @param name defines the name of the mesh
  67720. * @param url defines the url to the height map
  67721. * @param options defines the options used to create the mesh
  67722. * @param scene defines the hosting scene
  67723. * @returns the ground mesh
  67724. * @see https://doc.babylonjs.com/babylon101/height_map
  67725. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67726. */
  67727. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67728. width?: number;
  67729. height?: number;
  67730. subdivisions?: number;
  67731. minHeight?: number;
  67732. maxHeight?: number;
  67733. colorFilter?: Color3;
  67734. alphaFilter?: number;
  67735. updatable?: boolean;
  67736. onReady?: (mesh: GroundMesh) => void;
  67737. }, scene?: Nullable<Scene>): GroundMesh;
  67738. /**
  67739. * Creates a polygon mesh
  67740. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67741. * * 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
  67742. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67744. * * 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)
  67745. * * Remember you can only change the shape positions, not their number when updating a polygon
  67746. * @param name defines the name of the mesh
  67747. * @param options defines the options used to create the mesh
  67748. * @param scene defines the hosting scene
  67749. * @param earcutInjection can be used to inject your own earcut reference
  67750. * @returns the polygon mesh
  67751. */
  67752. static CreatePolygon(name: string, options: {
  67753. shape: Vector3[];
  67754. holes?: Vector3[][];
  67755. depth?: number;
  67756. faceUV?: Vector4[];
  67757. faceColors?: Color4[];
  67758. updatable?: boolean;
  67759. sideOrientation?: number;
  67760. frontUVs?: Vector4;
  67761. backUVs?: Vector4;
  67762. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67763. /**
  67764. * Creates an extruded polygon mesh, with depth in the Y direction.
  67765. * * 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)
  67766. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67767. * @param name defines the name of the mesh
  67768. * @param options defines the options used to create the mesh
  67769. * @param scene defines the hosting scene
  67770. * @param earcutInjection can be used to inject your own earcut reference
  67771. * @returns the polygon mesh
  67772. */
  67773. static ExtrudePolygon(name: string, options: {
  67774. shape: Vector3[];
  67775. holes?: Vector3[][];
  67776. depth?: number;
  67777. faceUV?: Vector4[];
  67778. faceColors?: Color4[];
  67779. updatable?: boolean;
  67780. sideOrientation?: number;
  67781. frontUVs?: Vector4;
  67782. backUVs?: Vector4;
  67783. wrap?: boolean;
  67784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67785. /**
  67786. * Creates a tube mesh.
  67787. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67788. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67789. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67790. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67791. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67792. * * 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)
  67793. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67794. * * 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
  67795. * * 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
  67796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67797. * * 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
  67798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67800. * @param name defines the name of the mesh
  67801. * @param options defines the options used to create the mesh
  67802. * @param scene defines the hosting scene
  67803. * @returns the tube mesh
  67804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67805. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67806. */
  67807. static CreateTube(name: string, options: {
  67808. path: Vector3[];
  67809. radius?: number;
  67810. tessellation?: number;
  67811. radiusFunction?: {
  67812. (i: number, distance: number): number;
  67813. };
  67814. cap?: number;
  67815. arc?: number;
  67816. updatable?: boolean;
  67817. sideOrientation?: number;
  67818. frontUVs?: Vector4;
  67819. backUVs?: Vector4;
  67820. instance?: Mesh;
  67821. invertUV?: boolean;
  67822. }, scene?: Nullable<Scene>): Mesh;
  67823. /**
  67824. * Creates a polyhedron mesh
  67825. * * 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
  67826. * * The parameter `size` (positive float, default 1) sets the polygon size
  67827. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67828. * * 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`
  67829. * * 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
  67830. * * 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)`)
  67831. * * 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
  67832. * * 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
  67833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67834. * * 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
  67835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67836. * @param name defines the name of the mesh
  67837. * @param options defines the options used to create the mesh
  67838. * @param scene defines the hosting scene
  67839. * @returns the polyhedron mesh
  67840. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67841. */
  67842. static CreatePolyhedron(name: string, options: {
  67843. type?: number;
  67844. size?: number;
  67845. sizeX?: number;
  67846. sizeY?: number;
  67847. sizeZ?: number;
  67848. custom?: any;
  67849. faceUV?: Vector4[];
  67850. faceColors?: Color4[];
  67851. flat?: boolean;
  67852. updatable?: boolean;
  67853. sideOrientation?: number;
  67854. frontUVs?: Vector4;
  67855. backUVs?: Vector4;
  67856. }, scene?: Nullable<Scene>): Mesh;
  67857. /**
  67858. * Creates a decal mesh.
  67859. * 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
  67860. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67861. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67862. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67863. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67864. * @param name defines the name of the mesh
  67865. * @param sourceMesh defines the mesh where the decal must be applied
  67866. * @param options defines the options used to create the mesh
  67867. * @param scene defines the hosting scene
  67868. * @returns the decal mesh
  67869. * @see https://doc.babylonjs.com/how_to/decals
  67870. */
  67871. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67872. position?: Vector3;
  67873. normal?: Vector3;
  67874. size?: Vector3;
  67875. angle?: number;
  67876. }): Mesh;
  67877. /**
  67878. * Creates a Capsule Mesh
  67879. * @param name defines the name of the mesh.
  67880. * @param options the constructors options used to shape the mesh.
  67881. * @param scene defines the scene the mesh is scoped to.
  67882. * @returns the capsule mesh
  67883. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67884. */
  67885. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67886. }
  67887. }
  67888. declare module BABYLON {
  67889. /**
  67890. * A simplifier interface for future simplification implementations
  67891. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67892. */
  67893. export interface ISimplifier {
  67894. /**
  67895. * Simplification of a given mesh according to the given settings.
  67896. * Since this requires computation, it is assumed that the function runs async.
  67897. * @param settings The settings of the simplification, including quality and distance
  67898. * @param successCallback A callback that will be called after the mesh was simplified.
  67899. * @param errorCallback in case of an error, this callback will be called. optional.
  67900. */
  67901. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67902. }
  67903. /**
  67904. * Expected simplification settings.
  67905. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67906. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67907. */
  67908. export interface ISimplificationSettings {
  67909. /**
  67910. * Gets or sets the expected quality
  67911. */
  67912. quality: number;
  67913. /**
  67914. * Gets or sets the distance when this optimized version should be used
  67915. */
  67916. distance: number;
  67917. /**
  67918. * Gets an already optimized mesh
  67919. */
  67920. optimizeMesh?: boolean;
  67921. }
  67922. /**
  67923. * Class used to specify simplification options
  67924. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67925. */
  67926. export class SimplificationSettings implements ISimplificationSettings {
  67927. /** expected quality */
  67928. quality: number;
  67929. /** distance when this optimized version should be used */
  67930. distance: number;
  67931. /** already optimized mesh */
  67932. optimizeMesh?: boolean | undefined;
  67933. /**
  67934. * Creates a SimplificationSettings
  67935. * @param quality expected quality
  67936. * @param distance distance when this optimized version should be used
  67937. * @param optimizeMesh already optimized mesh
  67938. */
  67939. constructor(
  67940. /** expected quality */
  67941. quality: number,
  67942. /** distance when this optimized version should be used */
  67943. distance: number,
  67944. /** already optimized mesh */
  67945. optimizeMesh?: boolean | undefined);
  67946. }
  67947. /**
  67948. * Interface used to define a simplification task
  67949. */
  67950. export interface ISimplificationTask {
  67951. /**
  67952. * Array of settings
  67953. */
  67954. settings: Array<ISimplificationSettings>;
  67955. /**
  67956. * Simplification type
  67957. */
  67958. simplificationType: SimplificationType;
  67959. /**
  67960. * Mesh to simplify
  67961. */
  67962. mesh: Mesh;
  67963. /**
  67964. * Callback called on success
  67965. */
  67966. successCallback?: () => void;
  67967. /**
  67968. * Defines if parallel processing can be used
  67969. */
  67970. parallelProcessing: boolean;
  67971. }
  67972. /**
  67973. * Queue used to order the simplification tasks
  67974. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67975. */
  67976. export class SimplificationQueue {
  67977. private _simplificationArray;
  67978. /**
  67979. * Gets a boolean indicating that the process is still running
  67980. */
  67981. running: boolean;
  67982. /**
  67983. * Creates a new queue
  67984. */
  67985. constructor();
  67986. /**
  67987. * Adds a new simplification task
  67988. * @param task defines a task to add
  67989. */
  67990. addTask(task: ISimplificationTask): void;
  67991. /**
  67992. * Execute next task
  67993. */
  67994. executeNext(): void;
  67995. /**
  67996. * Execute a simplification task
  67997. * @param task defines the task to run
  67998. */
  67999. runSimplification(task: ISimplificationTask): void;
  68000. private getSimplifier;
  68001. }
  68002. /**
  68003. * The implemented types of simplification
  68004. * At the moment only Quadratic Error Decimation is implemented
  68005. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68006. */
  68007. export enum SimplificationType {
  68008. /** Quadratic error decimation */
  68009. QUADRATIC = 0
  68010. }
  68011. /**
  68012. * An implementation of the Quadratic Error simplification algorithm.
  68013. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68014. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68015. * @author RaananW
  68016. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68017. */
  68018. export class QuadraticErrorSimplification implements ISimplifier {
  68019. private _mesh;
  68020. private triangles;
  68021. private vertices;
  68022. private references;
  68023. private _reconstructedMesh;
  68024. /** Gets or sets the number pf sync interations */
  68025. syncIterations: number;
  68026. /** Gets or sets the aggressiveness of the simplifier */
  68027. aggressiveness: number;
  68028. /** Gets or sets the number of allowed iterations for decimation */
  68029. decimationIterations: number;
  68030. /** Gets or sets the espilon to use for bounding box computation */
  68031. boundingBoxEpsilon: number;
  68032. /**
  68033. * Creates a new QuadraticErrorSimplification
  68034. * @param _mesh defines the target mesh
  68035. */
  68036. constructor(_mesh: Mesh);
  68037. /**
  68038. * Simplification of a given mesh according to the given settings.
  68039. * Since this requires computation, it is assumed that the function runs async.
  68040. * @param settings The settings of the simplification, including quality and distance
  68041. * @param successCallback A callback that will be called after the mesh was simplified.
  68042. */
  68043. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68044. private runDecimation;
  68045. private initWithMesh;
  68046. private init;
  68047. private reconstructMesh;
  68048. private initDecimatedMesh;
  68049. private isFlipped;
  68050. private updateTriangles;
  68051. private identifyBorder;
  68052. private updateMesh;
  68053. private vertexError;
  68054. private calculateError;
  68055. }
  68056. }
  68057. declare module BABYLON {
  68058. interface Scene {
  68059. /** @hidden (Backing field) */
  68060. _simplificationQueue: SimplificationQueue;
  68061. /**
  68062. * Gets or sets the simplification queue attached to the scene
  68063. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68064. */
  68065. simplificationQueue: SimplificationQueue;
  68066. }
  68067. interface Mesh {
  68068. /**
  68069. * Simplify the mesh according to the given array of settings.
  68070. * Function will return immediately and will simplify async
  68071. * @param settings a collection of simplification settings
  68072. * @param parallelProcessing should all levels calculate parallel or one after the other
  68073. * @param simplificationType the type of simplification to run
  68074. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68075. * @returns the current mesh
  68076. */
  68077. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68078. }
  68079. /**
  68080. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68081. * created in a scene
  68082. */
  68083. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68084. /**
  68085. * The component name helpfull to identify the component in the list of scene components.
  68086. */
  68087. readonly name: string;
  68088. /**
  68089. * The scene the component belongs to.
  68090. */
  68091. scene: Scene;
  68092. /**
  68093. * Creates a new instance of the component for the given scene
  68094. * @param scene Defines the scene to register the component in
  68095. */
  68096. constructor(scene: Scene);
  68097. /**
  68098. * Registers the component in a given scene
  68099. */
  68100. register(): void;
  68101. /**
  68102. * Rebuilds the elements related to this component in case of
  68103. * context lost for instance.
  68104. */
  68105. rebuild(): void;
  68106. /**
  68107. * Disposes the component and the associated ressources
  68108. */
  68109. dispose(): void;
  68110. private _beforeCameraUpdate;
  68111. }
  68112. }
  68113. declare module BABYLON {
  68114. interface Mesh {
  68115. /**
  68116. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68117. */
  68118. thinInstanceEnablePicking: boolean;
  68119. /**
  68120. * Creates a new thin instance
  68121. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68122. * @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
  68123. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68124. */
  68125. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68126. /**
  68127. * Adds the transformation (matrix) of the current mesh as a thin instance
  68128. * @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
  68129. * @returns the thin instance index number
  68130. */
  68131. thinInstanceAddSelf(refresh: boolean): number;
  68132. /**
  68133. * Registers a custom attribute to be used with thin instances
  68134. * @param kind name of the attribute
  68135. * @param stride size in floats of the attribute
  68136. */
  68137. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68138. /**
  68139. * Sets the matrix of a thin instance
  68140. * @param index index of the thin instance
  68141. * @param matrix matrix to set
  68142. * @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
  68143. */
  68144. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68145. /**
  68146. * Sets the value of a custom attribute for a thin instance
  68147. * @param kind name of the attribute
  68148. * @param index index of the thin instance
  68149. * @param value value to set
  68150. * @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
  68151. */
  68152. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68153. /**
  68154. * 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.
  68155. */
  68156. thinInstanceCount: number;
  68157. /**
  68158. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68159. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68160. * @param buffer buffer to set
  68161. * @param stride size in floats of each value of the buffer
  68162. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68163. */
  68164. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68165. /**
  68166. * Gets the list of world matrices
  68167. * @return an array containing all the world matrices from the thin instances
  68168. */
  68169. thinInstanceGetWorldMatrices(): Matrix[];
  68170. /**
  68171. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68172. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68173. */
  68174. thinInstanceBufferUpdated(kind: string): void;
  68175. /**
  68176. * Applies a partial update to a buffer directly on the GPU
  68177. * 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
  68178. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68179. * @param data the data to set in the GPU buffer
  68180. * @param offset the offset in the GPU buffer where to update the data
  68181. */
  68182. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68183. /**
  68184. * Refreshes the bounding info, taking into account all the thin instances defined
  68185. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68186. */
  68187. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68188. /** @hidden */
  68189. _thinInstanceInitializeUserStorage(): void;
  68190. /** @hidden */
  68191. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68192. /** @hidden */
  68193. _userThinInstanceBuffersStorage: {
  68194. data: {
  68195. [key: string]: Float32Array;
  68196. };
  68197. sizes: {
  68198. [key: string]: number;
  68199. };
  68200. vertexBuffers: {
  68201. [key: string]: Nullable<VertexBuffer>;
  68202. };
  68203. strides: {
  68204. [key: string]: number;
  68205. };
  68206. };
  68207. }
  68208. }
  68209. declare module BABYLON {
  68210. /**
  68211. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68212. */
  68213. export interface INavigationEnginePlugin {
  68214. /**
  68215. * plugin name
  68216. */
  68217. name: string;
  68218. /**
  68219. * Creates a navigation mesh
  68220. * @param meshes array of all the geometry used to compute the navigatio mesh
  68221. * @param parameters bunch of parameters used to filter geometry
  68222. */
  68223. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68224. /**
  68225. * Create a navigation mesh debug mesh
  68226. * @param scene is where the mesh will be added
  68227. * @returns debug display mesh
  68228. */
  68229. createDebugNavMesh(scene: Scene): Mesh;
  68230. /**
  68231. * Get a navigation mesh constrained position, closest to the parameter position
  68232. * @param position world position
  68233. * @returns the closest point to position constrained by the navigation mesh
  68234. */
  68235. getClosestPoint(position: Vector3): Vector3;
  68236. /**
  68237. * Get a navigation mesh constrained position, closest to the parameter position
  68238. * @param position world position
  68239. * @param result output the closest point to position constrained by the navigation mesh
  68240. */
  68241. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68242. /**
  68243. * Get a navigation mesh constrained position, within a particular radius
  68244. * @param position world position
  68245. * @param maxRadius the maximum distance to the constrained world position
  68246. * @returns the closest point to position constrained by the navigation mesh
  68247. */
  68248. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68249. /**
  68250. * Get a navigation mesh constrained position, within a particular radius
  68251. * @param position world position
  68252. * @param maxRadius the maximum distance to the constrained world position
  68253. * @param result output the closest point to position constrained by the navigation mesh
  68254. */
  68255. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68256. /**
  68257. * Compute the final position from a segment made of destination-position
  68258. * @param position world position
  68259. * @param destination world position
  68260. * @returns the resulting point along the navmesh
  68261. */
  68262. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68263. /**
  68264. * Compute the final position from a segment made of destination-position
  68265. * @param position world position
  68266. * @param destination world position
  68267. * @param result output the resulting point along the navmesh
  68268. */
  68269. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68270. /**
  68271. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68272. * @param start world position
  68273. * @param end world position
  68274. * @returns array containing world position composing the path
  68275. */
  68276. computePath(start: Vector3, end: Vector3): Vector3[];
  68277. /**
  68278. * If this plugin is supported
  68279. * @returns true if plugin is supported
  68280. */
  68281. isSupported(): boolean;
  68282. /**
  68283. * Create a new Crowd so you can add agents
  68284. * @param maxAgents the maximum agent count in the crowd
  68285. * @param maxAgentRadius the maximum radius an agent can have
  68286. * @param scene to attach the crowd to
  68287. * @returns the crowd you can add agents to
  68288. */
  68289. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68290. /**
  68291. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68292. * The queries will try to find a solution within those bounds
  68293. * default is (1,1,1)
  68294. * @param extent x,y,z value that define the extent around the queries point of reference
  68295. */
  68296. setDefaultQueryExtent(extent: Vector3): void;
  68297. /**
  68298. * Get the Bounding box extent specified by setDefaultQueryExtent
  68299. * @returns the box extent values
  68300. */
  68301. getDefaultQueryExtent(): Vector3;
  68302. /**
  68303. * build the navmesh from a previously saved state using getNavmeshData
  68304. * @param data the Uint8Array returned by getNavmeshData
  68305. */
  68306. buildFromNavmeshData(data: Uint8Array): void;
  68307. /**
  68308. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68309. * @returns data the Uint8Array that can be saved and reused
  68310. */
  68311. getNavmeshData(): Uint8Array;
  68312. /**
  68313. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68314. * @param result output the box extent values
  68315. */
  68316. getDefaultQueryExtentToRef(result: Vector3): void;
  68317. /**
  68318. * Set the time step of the navigation tick update.
  68319. * Default is 1/60.
  68320. * A value of 0 will disable fixed time update
  68321. * @param newTimeStep the new timestep to apply to this world.
  68322. */
  68323. setTimeStep(newTimeStep: number): void;
  68324. /**
  68325. * Get the time step of the navigation tick update.
  68326. * @returns the current time step
  68327. */
  68328. getTimeStep(): number;
  68329. /**
  68330. * If delta time in navigation tick update is greater than the time step
  68331. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68332. * they will be discarded.
  68333. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68334. * @param newStepCount the maximum number of iterations
  68335. */
  68336. setMaximumSubStepCount(newStepCount: number): void;
  68337. /**
  68338. * Get the maximum number of iterations per navigation tick update
  68339. * @returns the maximum number of iterations
  68340. */
  68341. getMaximumSubStepCount(): number;
  68342. /**
  68343. * Release all resources
  68344. */
  68345. dispose(): void;
  68346. }
  68347. /**
  68348. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68349. */
  68350. export interface ICrowd {
  68351. /**
  68352. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68353. * You can attach anything to that node. The node position is updated in the scene update tick.
  68354. * @param pos world position that will be constrained by the navigation mesh
  68355. * @param parameters agent parameters
  68356. * @param transform hooked to the agent that will be update by the scene
  68357. * @returns agent index
  68358. */
  68359. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68360. /**
  68361. * Returns the agent position in world space
  68362. * @param index agent index returned by addAgent
  68363. * @returns world space position
  68364. */
  68365. getAgentPosition(index: number): Vector3;
  68366. /**
  68367. * Gets the agent position result in world space
  68368. * @param index agent index returned by addAgent
  68369. * @param result output world space position
  68370. */
  68371. getAgentPositionToRef(index: number, result: Vector3): void;
  68372. /**
  68373. * Gets the agent velocity in world space
  68374. * @param index agent index returned by addAgent
  68375. * @returns world space velocity
  68376. */
  68377. getAgentVelocity(index: number): Vector3;
  68378. /**
  68379. * Gets the agent velocity result in world space
  68380. * @param index agent index returned by addAgent
  68381. * @param result output world space velocity
  68382. */
  68383. getAgentVelocityToRef(index: number, result: Vector3): void;
  68384. /**
  68385. * Gets the agent next target point on the path
  68386. * @param index agent index returned by addAgent
  68387. * @returns world space position
  68388. */
  68389. getAgentNextTargetPath(index: number): Vector3;
  68390. /**
  68391. * Gets the agent state
  68392. * @param index agent index returned by addAgent
  68393. * @returns agent state
  68394. */
  68395. getAgentState(index: number): number;
  68396. /**
  68397. * returns true if the agent in over an off mesh link connection
  68398. * @param index agent index returned by addAgent
  68399. * @returns true if over an off mesh link connection
  68400. */
  68401. overOffmeshConnection(index: number): boolean;
  68402. /**
  68403. * Gets the agent next target point on the path
  68404. * @param index agent index returned by addAgent
  68405. * @param result output world space position
  68406. */
  68407. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68408. /**
  68409. * remove a particular agent previously created
  68410. * @param index agent index returned by addAgent
  68411. */
  68412. removeAgent(index: number): void;
  68413. /**
  68414. * get the list of all agents attached to this crowd
  68415. * @returns list of agent indices
  68416. */
  68417. getAgents(): number[];
  68418. /**
  68419. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68420. * @param deltaTime in seconds
  68421. */
  68422. update(deltaTime: number): void;
  68423. /**
  68424. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68425. * @param index agent index returned by addAgent
  68426. * @param destination targeted world position
  68427. */
  68428. agentGoto(index: number, destination: Vector3): void;
  68429. /**
  68430. * Teleport the agent to a new position
  68431. * @param index agent index returned by addAgent
  68432. * @param destination targeted world position
  68433. */
  68434. agentTeleport(index: number, destination: Vector3): void;
  68435. /**
  68436. * Update agent parameters
  68437. * @param index agent index returned by addAgent
  68438. * @param parameters agent parameters
  68439. */
  68440. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68441. /**
  68442. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68443. * The queries will try to find a solution within those bounds
  68444. * default is (1,1,1)
  68445. * @param extent x,y,z value that define the extent around the queries point of reference
  68446. */
  68447. setDefaultQueryExtent(extent: Vector3): void;
  68448. /**
  68449. * Get the Bounding box extent specified by setDefaultQueryExtent
  68450. * @returns the box extent values
  68451. */
  68452. getDefaultQueryExtent(): Vector3;
  68453. /**
  68454. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68455. * @param result output the box extent values
  68456. */
  68457. getDefaultQueryExtentToRef(result: Vector3): void;
  68458. /**
  68459. * Release all resources
  68460. */
  68461. dispose(): void;
  68462. }
  68463. /**
  68464. * Configures an agent
  68465. */
  68466. export interface IAgentParameters {
  68467. /**
  68468. * Agent radius. [Limit: >= 0]
  68469. */
  68470. radius: number;
  68471. /**
  68472. * Agent height. [Limit: > 0]
  68473. */
  68474. height: number;
  68475. /**
  68476. * Maximum allowed acceleration. [Limit: >= 0]
  68477. */
  68478. maxAcceleration: number;
  68479. /**
  68480. * Maximum allowed speed. [Limit: >= 0]
  68481. */
  68482. maxSpeed: number;
  68483. /**
  68484. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68485. */
  68486. collisionQueryRange: number;
  68487. /**
  68488. * The path visibility optimization range. [Limit: > 0]
  68489. */
  68490. pathOptimizationRange: number;
  68491. /**
  68492. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68493. */
  68494. separationWeight: number;
  68495. }
  68496. /**
  68497. * Configures the navigation mesh creation
  68498. */
  68499. export interface INavMeshParameters {
  68500. /**
  68501. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68502. */
  68503. cs: number;
  68504. /**
  68505. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68506. */
  68507. ch: number;
  68508. /**
  68509. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68510. */
  68511. walkableSlopeAngle: number;
  68512. /**
  68513. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68514. * be considered walkable. [Limit: >= 3] [Units: vx]
  68515. */
  68516. walkableHeight: number;
  68517. /**
  68518. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68519. */
  68520. walkableClimb: number;
  68521. /**
  68522. * The distance to erode/shrink the walkable area of the heightfield away from
  68523. * obstructions. [Limit: >=0] [Units: vx]
  68524. */
  68525. walkableRadius: number;
  68526. /**
  68527. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68528. */
  68529. maxEdgeLen: number;
  68530. /**
  68531. * The maximum distance a simplfied contour's border edges should deviate
  68532. * the original raw contour. [Limit: >=0] [Units: vx]
  68533. */
  68534. maxSimplificationError: number;
  68535. /**
  68536. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68537. */
  68538. minRegionArea: number;
  68539. /**
  68540. * Any regions with a span count smaller than this value will, if possible,
  68541. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68542. */
  68543. mergeRegionArea: number;
  68544. /**
  68545. * The maximum number of vertices allowed for polygons generated during the
  68546. * contour to polygon conversion process. [Limit: >= 3]
  68547. */
  68548. maxVertsPerPoly: number;
  68549. /**
  68550. * Sets the sampling distance to use when generating the detail mesh.
  68551. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68552. */
  68553. detailSampleDist: number;
  68554. /**
  68555. * The maximum distance the detail mesh surface should deviate from heightfield
  68556. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68557. */
  68558. detailSampleMaxError: number;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * RecastJS navigation plugin
  68564. */
  68565. export class RecastJSPlugin implements INavigationEnginePlugin {
  68566. /**
  68567. * Reference to the Recast library
  68568. */
  68569. bjsRECAST: any;
  68570. /**
  68571. * plugin name
  68572. */
  68573. name: string;
  68574. /**
  68575. * the first navmesh created. We might extend this to support multiple navmeshes
  68576. */
  68577. navMesh: any;
  68578. private _maximumSubStepCount;
  68579. private _timeStep;
  68580. /**
  68581. * Initializes the recastJS plugin
  68582. * @param recastInjection can be used to inject your own recast reference
  68583. */
  68584. constructor(recastInjection?: any);
  68585. /**
  68586. * Set the time step of the navigation tick update.
  68587. * Default is 1/60.
  68588. * A value of 0 will disable fixed time update
  68589. * @param newTimeStep the new timestep to apply to this world.
  68590. */
  68591. setTimeStep(newTimeStep?: number): void;
  68592. /**
  68593. * Get the time step of the navigation tick update.
  68594. * @returns the current time step
  68595. */
  68596. getTimeStep(): number;
  68597. /**
  68598. * If delta time in navigation tick update is greater than the time step
  68599. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68600. * they will be discarded.
  68601. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68602. * @param newStepCount the maximum number of iterations
  68603. */
  68604. setMaximumSubStepCount(newStepCount?: number): void;
  68605. /**
  68606. * Get the maximum number of iterations per navigation tick update
  68607. * @returns the maximum number of iterations
  68608. */
  68609. getMaximumSubStepCount(): number;
  68610. /**
  68611. * Creates a navigation mesh
  68612. * @param meshes array of all the geometry used to compute the navigatio mesh
  68613. * @param parameters bunch of parameters used to filter geometry
  68614. */
  68615. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68616. /**
  68617. * Create a navigation mesh debug mesh
  68618. * @param scene is where the mesh will be added
  68619. * @returns debug display mesh
  68620. */
  68621. createDebugNavMesh(scene: Scene): Mesh;
  68622. /**
  68623. * Get a navigation mesh constrained position, closest to the parameter position
  68624. * @param position world position
  68625. * @returns the closest point to position constrained by the navigation mesh
  68626. */
  68627. getClosestPoint(position: Vector3): Vector3;
  68628. /**
  68629. * Get a navigation mesh constrained position, closest to the parameter position
  68630. * @param position world position
  68631. * @param result output the closest point to position constrained by the navigation mesh
  68632. */
  68633. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68634. /**
  68635. * Get a navigation mesh constrained position, within a particular radius
  68636. * @param position world position
  68637. * @param maxRadius the maximum distance to the constrained world position
  68638. * @returns the closest point to position constrained by the navigation mesh
  68639. */
  68640. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68641. /**
  68642. * Get a navigation mesh constrained position, within a particular radius
  68643. * @param position world position
  68644. * @param maxRadius the maximum distance to the constrained world position
  68645. * @param result output the closest point to position constrained by the navigation mesh
  68646. */
  68647. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68648. /**
  68649. * Compute the final position from a segment made of destination-position
  68650. * @param position world position
  68651. * @param destination world position
  68652. * @returns the resulting point along the navmesh
  68653. */
  68654. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68655. /**
  68656. * Compute the final position from a segment made of destination-position
  68657. * @param position world position
  68658. * @param destination world position
  68659. * @param result output the resulting point along the navmesh
  68660. */
  68661. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68662. /**
  68663. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68664. * @param start world position
  68665. * @param end world position
  68666. * @returns array containing world position composing the path
  68667. */
  68668. computePath(start: Vector3, end: Vector3): Vector3[];
  68669. /**
  68670. * Create a new Crowd so you can add agents
  68671. * @param maxAgents the maximum agent count in the crowd
  68672. * @param maxAgentRadius the maximum radius an agent can have
  68673. * @param scene to attach the crowd to
  68674. * @returns the crowd you can add agents to
  68675. */
  68676. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68677. /**
  68678. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68679. * The queries will try to find a solution within those bounds
  68680. * default is (1,1,1)
  68681. * @param extent x,y,z value that define the extent around the queries point of reference
  68682. */
  68683. setDefaultQueryExtent(extent: Vector3): void;
  68684. /**
  68685. * Get the Bounding box extent specified by setDefaultQueryExtent
  68686. * @returns the box extent values
  68687. */
  68688. getDefaultQueryExtent(): Vector3;
  68689. /**
  68690. * build the navmesh from a previously saved state using getNavmeshData
  68691. * @param data the Uint8Array returned by getNavmeshData
  68692. */
  68693. buildFromNavmeshData(data: Uint8Array): void;
  68694. /**
  68695. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68696. * @returns data the Uint8Array that can be saved and reused
  68697. */
  68698. getNavmeshData(): Uint8Array;
  68699. /**
  68700. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68701. * @param result output the box extent values
  68702. */
  68703. getDefaultQueryExtentToRef(result: Vector3): void;
  68704. /**
  68705. * Disposes
  68706. */
  68707. dispose(): void;
  68708. /**
  68709. * If this plugin is supported
  68710. * @returns true if plugin is supported
  68711. */
  68712. isSupported(): boolean;
  68713. }
  68714. /**
  68715. * Recast detour crowd implementation
  68716. */
  68717. export class RecastJSCrowd implements ICrowd {
  68718. /**
  68719. * Recast/detour plugin
  68720. */
  68721. bjsRECASTPlugin: RecastJSPlugin;
  68722. /**
  68723. * Link to the detour crowd
  68724. */
  68725. recastCrowd: any;
  68726. /**
  68727. * One transform per agent
  68728. */
  68729. transforms: TransformNode[];
  68730. /**
  68731. * All agents created
  68732. */
  68733. agents: number[];
  68734. /**
  68735. * Link to the scene is kept to unregister the crowd from the scene
  68736. */
  68737. private _scene;
  68738. /**
  68739. * Observer for crowd updates
  68740. */
  68741. private _onBeforeAnimationsObserver;
  68742. /**
  68743. * Constructor
  68744. * @param plugin recastJS plugin
  68745. * @param maxAgents the maximum agent count in the crowd
  68746. * @param maxAgentRadius the maximum radius an agent can have
  68747. * @param scene to attach the crowd to
  68748. * @returns the crowd you can add agents to
  68749. */
  68750. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68751. /**
  68752. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68753. * You can attach anything to that node. The node position is updated in the scene update tick.
  68754. * @param pos world position that will be constrained by the navigation mesh
  68755. * @param parameters agent parameters
  68756. * @param transform hooked to the agent that will be update by the scene
  68757. * @returns agent index
  68758. */
  68759. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68760. /**
  68761. * Returns the agent position in world space
  68762. * @param index agent index returned by addAgent
  68763. * @returns world space position
  68764. */
  68765. getAgentPosition(index: number): Vector3;
  68766. /**
  68767. * Returns the agent position result in world space
  68768. * @param index agent index returned by addAgent
  68769. * @param result output world space position
  68770. */
  68771. getAgentPositionToRef(index: number, result: Vector3): void;
  68772. /**
  68773. * Returns the agent velocity in world space
  68774. * @param index agent index returned by addAgent
  68775. * @returns world space velocity
  68776. */
  68777. getAgentVelocity(index: number): Vector3;
  68778. /**
  68779. * Returns the agent velocity result in world space
  68780. * @param index agent index returned by addAgent
  68781. * @param result output world space velocity
  68782. */
  68783. getAgentVelocityToRef(index: number, result: Vector3): void;
  68784. /**
  68785. * Returns the agent next target point on the path
  68786. * @param index agent index returned by addAgent
  68787. * @returns world space position
  68788. */
  68789. getAgentNextTargetPath(index: number): Vector3;
  68790. /**
  68791. * Returns the agent next target point on the path
  68792. * @param index agent index returned by addAgent
  68793. * @param result output world space position
  68794. */
  68795. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68796. /**
  68797. * Gets the agent state
  68798. * @param index agent index returned by addAgent
  68799. * @returns agent state
  68800. */
  68801. getAgentState(index: number): number;
  68802. /**
  68803. * returns true if the agent in over an off mesh link connection
  68804. * @param index agent index returned by addAgent
  68805. * @returns true if over an off mesh link connection
  68806. */
  68807. overOffmeshConnection(index: number): boolean;
  68808. /**
  68809. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68810. * @param index agent index returned by addAgent
  68811. * @param destination targeted world position
  68812. */
  68813. agentGoto(index: number, destination: Vector3): void;
  68814. /**
  68815. * Teleport the agent to a new position
  68816. * @param index agent index returned by addAgent
  68817. * @param destination targeted world position
  68818. */
  68819. agentTeleport(index: number, destination: Vector3): void;
  68820. /**
  68821. * Update agent parameters
  68822. * @param index agent index returned by addAgent
  68823. * @param parameters agent parameters
  68824. */
  68825. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68826. /**
  68827. * remove a particular agent previously created
  68828. * @param index agent index returned by addAgent
  68829. */
  68830. removeAgent(index: number): void;
  68831. /**
  68832. * get the list of all agents attached to this crowd
  68833. * @returns list of agent indices
  68834. */
  68835. getAgents(): number[];
  68836. /**
  68837. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68838. * @param deltaTime in seconds
  68839. */
  68840. update(deltaTime: number): void;
  68841. /**
  68842. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68843. * The queries will try to find a solution within those bounds
  68844. * default is (1,1,1)
  68845. * @param extent x,y,z value that define the extent around the queries point of reference
  68846. */
  68847. setDefaultQueryExtent(extent: Vector3): void;
  68848. /**
  68849. * Get the Bounding box extent specified by setDefaultQueryExtent
  68850. * @returns the box extent values
  68851. */
  68852. getDefaultQueryExtent(): Vector3;
  68853. /**
  68854. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68855. * @param result output the box extent values
  68856. */
  68857. getDefaultQueryExtentToRef(result: Vector3): void;
  68858. /**
  68859. * Release all resources
  68860. */
  68861. dispose(): void;
  68862. }
  68863. }
  68864. declare module BABYLON {
  68865. /**
  68866. * Class used to enable access to IndexedDB
  68867. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68868. */
  68869. export class Database implements IOfflineProvider {
  68870. private _callbackManifestChecked;
  68871. private _currentSceneUrl;
  68872. private _db;
  68873. private _enableSceneOffline;
  68874. private _enableTexturesOffline;
  68875. private _manifestVersionFound;
  68876. private _mustUpdateRessources;
  68877. private _hasReachedQuota;
  68878. private _isSupported;
  68879. private _idbFactory;
  68880. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68881. private static IsUASupportingBlobStorage;
  68882. /**
  68883. * Gets a boolean indicating if Database storate is enabled (off by default)
  68884. */
  68885. static IDBStorageEnabled: boolean;
  68886. /**
  68887. * Gets a boolean indicating if scene must be saved in the database
  68888. */
  68889. get enableSceneOffline(): boolean;
  68890. /**
  68891. * Gets a boolean indicating if textures must be saved in the database
  68892. */
  68893. get enableTexturesOffline(): boolean;
  68894. /**
  68895. * Creates a new Database
  68896. * @param urlToScene defines the url to load the scene
  68897. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68898. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68899. */
  68900. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68901. private static _ParseURL;
  68902. private static _ReturnFullUrlLocation;
  68903. private _checkManifestFile;
  68904. /**
  68905. * Open the database and make it available
  68906. * @param successCallback defines the callback to call on success
  68907. * @param errorCallback defines the callback to call on error
  68908. */
  68909. open(successCallback: () => void, errorCallback: () => void): void;
  68910. /**
  68911. * Loads an image from the database
  68912. * @param url defines the url to load from
  68913. * @param image defines the target DOM image
  68914. */
  68915. loadImage(url: string, image: HTMLImageElement): void;
  68916. private _loadImageFromDBAsync;
  68917. private _saveImageIntoDBAsync;
  68918. private _checkVersionFromDB;
  68919. private _loadVersionFromDBAsync;
  68920. private _saveVersionIntoDBAsync;
  68921. /**
  68922. * Loads a file from database
  68923. * @param url defines the URL to load from
  68924. * @param sceneLoaded defines a callback to call on success
  68925. * @param progressCallBack defines a callback to call when progress changed
  68926. * @param errorCallback defines a callback to call on error
  68927. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68928. */
  68929. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68930. private _loadFileAsync;
  68931. private _saveFileAsync;
  68932. /**
  68933. * Validates if xhr data is correct
  68934. * @param xhr defines the request to validate
  68935. * @param dataType defines the expected data type
  68936. * @returns true if data is correct
  68937. */
  68938. private static _ValidateXHRData;
  68939. }
  68940. }
  68941. declare module BABYLON {
  68942. /** @hidden */
  68943. export var gpuUpdateParticlesPixelShader: {
  68944. name: string;
  68945. shader: string;
  68946. };
  68947. }
  68948. declare module BABYLON {
  68949. /** @hidden */
  68950. export var gpuUpdateParticlesVertexShader: {
  68951. name: string;
  68952. shader: string;
  68953. };
  68954. }
  68955. declare module BABYLON {
  68956. /** @hidden */
  68957. export var clipPlaneFragmentDeclaration2: {
  68958. name: string;
  68959. shader: string;
  68960. };
  68961. }
  68962. declare module BABYLON {
  68963. /** @hidden */
  68964. export var gpuRenderParticlesPixelShader: {
  68965. name: string;
  68966. shader: string;
  68967. };
  68968. }
  68969. declare module BABYLON {
  68970. /** @hidden */
  68971. export var clipPlaneVertexDeclaration2: {
  68972. name: string;
  68973. shader: string;
  68974. };
  68975. }
  68976. declare module BABYLON {
  68977. /** @hidden */
  68978. export var gpuRenderParticlesVertexShader: {
  68979. name: string;
  68980. shader: string;
  68981. };
  68982. }
  68983. declare module BABYLON {
  68984. /**
  68985. * This represents a GPU particle system in Babylon
  68986. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68987. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68988. */
  68989. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68990. /**
  68991. * The layer mask we are rendering the particles through.
  68992. */
  68993. layerMask: number;
  68994. private _capacity;
  68995. private _activeCount;
  68996. private _currentActiveCount;
  68997. private _accumulatedCount;
  68998. private _renderEffect;
  68999. private _updateEffect;
  69000. private _buffer0;
  69001. private _buffer1;
  69002. private _spriteBuffer;
  69003. private _updateVAO;
  69004. private _renderVAO;
  69005. private _targetIndex;
  69006. private _sourceBuffer;
  69007. private _targetBuffer;
  69008. private _currentRenderId;
  69009. private _started;
  69010. private _stopped;
  69011. private _timeDelta;
  69012. private _randomTexture;
  69013. private _randomTexture2;
  69014. private _attributesStrideSize;
  69015. private _updateEffectOptions;
  69016. private _randomTextureSize;
  69017. private _actualFrame;
  69018. private _customEffect;
  69019. private readonly _rawTextureWidth;
  69020. /**
  69021. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69022. */
  69023. static get IsSupported(): boolean;
  69024. /**
  69025. * An event triggered when the system is disposed.
  69026. */
  69027. onDisposeObservable: Observable<IParticleSystem>;
  69028. /**
  69029. * An event triggered when the system is stopped
  69030. */
  69031. onStoppedObservable: Observable<IParticleSystem>;
  69032. /**
  69033. * Gets the maximum number of particles active at the same time.
  69034. * @returns The max number of active particles.
  69035. */
  69036. getCapacity(): number;
  69037. /**
  69038. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69039. * to override the particles.
  69040. */
  69041. forceDepthWrite: boolean;
  69042. /**
  69043. * Gets or set the number of active particles
  69044. */
  69045. get activeParticleCount(): number;
  69046. set activeParticleCount(value: number);
  69047. private _preWarmDone;
  69048. /**
  69049. * Specifies if the particles are updated in emitter local space or world space.
  69050. */
  69051. isLocal: boolean;
  69052. /** Gets or sets a matrix to use to compute projection */
  69053. defaultProjectionMatrix: Matrix;
  69054. /**
  69055. * Is this system ready to be used/rendered
  69056. * @return true if the system is ready
  69057. */
  69058. isReady(): boolean;
  69059. /**
  69060. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69061. * @returns True if it has been started, otherwise false.
  69062. */
  69063. isStarted(): boolean;
  69064. /**
  69065. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69066. * @returns True if it has been stopped, otherwise false.
  69067. */
  69068. isStopped(): boolean;
  69069. /**
  69070. * Gets a boolean indicating that the system is stopping
  69071. * @returns true if the system is currently stopping
  69072. */
  69073. isStopping(): boolean;
  69074. /**
  69075. * Gets the number of particles active at the same time.
  69076. * @returns The number of active particles.
  69077. */
  69078. getActiveCount(): number;
  69079. /**
  69080. * Starts the particle system and begins to emit
  69081. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69082. */
  69083. start(delay?: number): void;
  69084. /**
  69085. * Stops the particle system.
  69086. */
  69087. stop(): void;
  69088. /**
  69089. * Remove all active particles
  69090. */
  69091. reset(): void;
  69092. /**
  69093. * Returns the string "GPUParticleSystem"
  69094. * @returns a string containing the class name
  69095. */
  69096. getClassName(): string;
  69097. /**
  69098. * Gets the custom effect used to render the particles
  69099. * @param blendMode Blend mode for which the effect should be retrieved
  69100. * @returns The effect
  69101. */
  69102. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69103. /**
  69104. * Sets the custom effect used to render the particles
  69105. * @param effect The effect to set
  69106. * @param blendMode Blend mode for which the effect should be set
  69107. */
  69108. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69109. /** @hidden */
  69110. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69111. /**
  69112. * Observable that will be called just before the particles are drawn
  69113. */
  69114. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69115. /**
  69116. * Gets the name of the particle vertex shader
  69117. */
  69118. get vertexShaderName(): string;
  69119. private _colorGradientsTexture;
  69120. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69121. /**
  69122. * Adds a new color gradient
  69123. * @param gradient defines the gradient to use (between 0 and 1)
  69124. * @param color1 defines the color to affect to the specified gradient
  69125. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69126. * @returns the current particle system
  69127. */
  69128. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69129. private _refreshColorGradient;
  69130. /** Force the system to rebuild all gradients that need to be resync */
  69131. forceRefreshGradients(): void;
  69132. /**
  69133. * Remove a specific color gradient
  69134. * @param gradient defines the gradient to remove
  69135. * @returns the current particle system
  69136. */
  69137. removeColorGradient(gradient: number): GPUParticleSystem;
  69138. private _angularSpeedGradientsTexture;
  69139. private _sizeGradientsTexture;
  69140. private _velocityGradientsTexture;
  69141. private _limitVelocityGradientsTexture;
  69142. private _dragGradientsTexture;
  69143. private _addFactorGradient;
  69144. /**
  69145. * Adds a new size gradient
  69146. * @param gradient defines the gradient to use (between 0 and 1)
  69147. * @param factor defines the size factor to affect to the specified gradient
  69148. * @returns the current particle system
  69149. */
  69150. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69151. /**
  69152. * Remove a specific size gradient
  69153. * @param gradient defines the gradient to remove
  69154. * @returns the current particle system
  69155. */
  69156. removeSizeGradient(gradient: number): GPUParticleSystem;
  69157. private _refreshFactorGradient;
  69158. /**
  69159. * Adds a new angular speed gradient
  69160. * @param gradient defines the gradient to use (between 0 and 1)
  69161. * @param factor defines the angular speed to affect to the specified gradient
  69162. * @returns the current particle system
  69163. */
  69164. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69165. /**
  69166. * Remove a specific angular speed gradient
  69167. * @param gradient defines the gradient to remove
  69168. * @returns the current particle system
  69169. */
  69170. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69171. /**
  69172. * Adds a new velocity gradient
  69173. * @param gradient defines the gradient to use (between 0 and 1)
  69174. * @param factor defines the velocity to affect to the specified gradient
  69175. * @returns the current particle system
  69176. */
  69177. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69178. /**
  69179. * Remove a specific velocity gradient
  69180. * @param gradient defines the gradient to remove
  69181. * @returns the current particle system
  69182. */
  69183. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69184. /**
  69185. * Adds a new limit velocity gradient
  69186. * @param gradient defines the gradient to use (between 0 and 1)
  69187. * @param factor defines the limit velocity value to affect to the specified gradient
  69188. * @returns the current particle system
  69189. */
  69190. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69191. /**
  69192. * Remove a specific limit velocity gradient
  69193. * @param gradient defines the gradient to remove
  69194. * @returns the current particle system
  69195. */
  69196. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69197. /**
  69198. * Adds a new drag gradient
  69199. * @param gradient defines the gradient to use (between 0 and 1)
  69200. * @param factor defines the drag value to affect to the specified gradient
  69201. * @returns the current particle system
  69202. */
  69203. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69204. /**
  69205. * Remove a specific drag gradient
  69206. * @param gradient defines the gradient to remove
  69207. * @returns the current particle system
  69208. */
  69209. removeDragGradient(gradient: number): GPUParticleSystem;
  69210. /**
  69211. * Not supported by GPUParticleSystem
  69212. * @param gradient defines the gradient to use (between 0 and 1)
  69213. * @param factor defines the emit rate value to affect to the specified gradient
  69214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69215. * @returns the current particle system
  69216. */
  69217. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69218. /**
  69219. * Not supported by GPUParticleSystem
  69220. * @param gradient defines the gradient to remove
  69221. * @returns the current particle system
  69222. */
  69223. removeEmitRateGradient(gradient: number): IParticleSystem;
  69224. /**
  69225. * Not supported by GPUParticleSystem
  69226. * @param gradient defines the gradient to use (between 0 and 1)
  69227. * @param factor defines the start size value to affect to the specified gradient
  69228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69229. * @returns the current particle system
  69230. */
  69231. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69232. /**
  69233. * Not supported by GPUParticleSystem
  69234. * @param gradient defines the gradient to remove
  69235. * @returns the current particle system
  69236. */
  69237. removeStartSizeGradient(gradient: number): IParticleSystem;
  69238. /**
  69239. * Not supported by GPUParticleSystem
  69240. * @param gradient defines the gradient to use (between 0 and 1)
  69241. * @param min defines the color remap minimal range
  69242. * @param max defines the color remap maximal range
  69243. * @returns the current particle system
  69244. */
  69245. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69246. /**
  69247. * Not supported by GPUParticleSystem
  69248. * @param gradient defines the gradient to remove
  69249. * @returns the current particle system
  69250. */
  69251. removeColorRemapGradient(): IParticleSystem;
  69252. /**
  69253. * Not supported by GPUParticleSystem
  69254. * @param gradient defines the gradient to use (between 0 and 1)
  69255. * @param min defines the alpha remap minimal range
  69256. * @param max defines the alpha remap maximal range
  69257. * @returns the current particle system
  69258. */
  69259. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69260. /**
  69261. * Not supported by GPUParticleSystem
  69262. * @param gradient defines the gradient to remove
  69263. * @returns the current particle system
  69264. */
  69265. removeAlphaRemapGradient(): IParticleSystem;
  69266. /**
  69267. * Not supported by GPUParticleSystem
  69268. * @param gradient defines the gradient to use (between 0 and 1)
  69269. * @param color defines the color to affect to the specified gradient
  69270. * @returns the current particle system
  69271. */
  69272. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69273. /**
  69274. * Not supported by GPUParticleSystem
  69275. * @param gradient defines the gradient to remove
  69276. * @returns the current particle system
  69277. */
  69278. removeRampGradient(): IParticleSystem;
  69279. /**
  69280. * Not supported by GPUParticleSystem
  69281. * @returns the list of ramp gradients
  69282. */
  69283. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69284. /**
  69285. * Not supported by GPUParticleSystem
  69286. * Gets or sets a boolean indicating that ramp gradients must be used
  69287. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69288. */
  69289. get useRampGradients(): boolean;
  69290. set useRampGradients(value: boolean);
  69291. /**
  69292. * Not supported by GPUParticleSystem
  69293. * @param gradient defines the gradient to use (between 0 and 1)
  69294. * @param factor defines the life time factor to affect to the specified gradient
  69295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69296. * @returns the current particle system
  69297. */
  69298. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69299. /**
  69300. * Not supported by GPUParticleSystem
  69301. * @param gradient defines the gradient to remove
  69302. * @returns the current particle system
  69303. */
  69304. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69305. /**
  69306. * Instantiates a GPU particle system.
  69307. * 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.
  69308. * @param name The name of the particle system
  69309. * @param options The options used to create the system
  69310. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69311. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69312. * @param customEffect a custom effect used to change the way particles are rendered by default
  69313. */
  69314. constructor(name: string, options: Partial<{
  69315. capacity: number;
  69316. randomTextureSize: number;
  69317. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69318. protected _reset(): void;
  69319. private _createUpdateVAO;
  69320. private _createRenderVAO;
  69321. private _initialize;
  69322. /** @hidden */
  69323. _recreateUpdateEffect(): void;
  69324. private _getEffect;
  69325. /**
  69326. * Fill the defines array according to the current settings of the particle system
  69327. * @param defines Array to be updated
  69328. * @param blendMode blend mode to take into account when updating the array
  69329. */
  69330. fillDefines(defines: Array<string>, blendMode?: number): void;
  69331. /**
  69332. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69333. * @param uniforms Uniforms array to fill
  69334. * @param attributes Attributes array to fill
  69335. * @param samplers Samplers array to fill
  69336. */
  69337. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69338. /** @hidden */
  69339. _recreateRenderEffect(): Effect;
  69340. /**
  69341. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69342. * @param preWarm defines if we are in the pre-warmimg phase
  69343. */
  69344. animate(preWarm?: boolean): void;
  69345. private _createFactorGradientTexture;
  69346. private _createSizeGradientTexture;
  69347. private _createAngularSpeedGradientTexture;
  69348. private _createVelocityGradientTexture;
  69349. private _createLimitVelocityGradientTexture;
  69350. private _createDragGradientTexture;
  69351. private _createColorGradientTexture;
  69352. /**
  69353. * Renders the particle system in its current state
  69354. * @param preWarm defines if the system should only update the particles but not render them
  69355. * @returns the current number of particles
  69356. */
  69357. render(preWarm?: boolean): number;
  69358. /**
  69359. * Rebuilds the particle system
  69360. */
  69361. rebuild(): void;
  69362. private _releaseBuffers;
  69363. private _releaseVAOs;
  69364. /**
  69365. * Disposes the particle system and free the associated resources
  69366. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69367. */
  69368. dispose(disposeTexture?: boolean): void;
  69369. /**
  69370. * Clones the particle system.
  69371. * @param name The name of the cloned object
  69372. * @param newEmitter The new emitter to use
  69373. * @returns the cloned particle system
  69374. */
  69375. clone(name: string, newEmitter: any): GPUParticleSystem;
  69376. /**
  69377. * Serializes the particle system to a JSON object
  69378. * @param serializeTexture defines if the texture must be serialized as well
  69379. * @returns the JSON object
  69380. */
  69381. serialize(serializeTexture?: boolean): any;
  69382. /**
  69383. * Parses a JSON object to create a GPU particle system.
  69384. * @param parsedParticleSystem The JSON object to parse
  69385. * @param sceneOrEngine The scene or the engine to create the particle system in
  69386. * @param rootUrl The root url to use to load external dependencies like texture
  69387. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69388. * @returns the parsed GPU particle system
  69389. */
  69390. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69391. }
  69392. }
  69393. declare module BABYLON {
  69394. /**
  69395. * Represents a set of particle systems working together to create a specific effect
  69396. */
  69397. export class ParticleSystemSet implements IDisposable {
  69398. /**
  69399. * Gets or sets base Assets URL
  69400. */
  69401. static BaseAssetsUrl: string;
  69402. private _emitterCreationOptions;
  69403. private _emitterNode;
  69404. /**
  69405. * Gets the particle system list
  69406. */
  69407. systems: IParticleSystem[];
  69408. /**
  69409. * Gets the emitter node used with this set
  69410. */
  69411. get emitterNode(): Nullable<TransformNode>;
  69412. /**
  69413. * Creates a new emitter mesh as a sphere
  69414. * @param options defines the options used to create the sphere
  69415. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69416. * @param scene defines the hosting scene
  69417. */
  69418. setEmitterAsSphere(options: {
  69419. diameter: number;
  69420. segments: number;
  69421. color: Color3;
  69422. }, renderingGroupId: number, scene: Scene): void;
  69423. /**
  69424. * Starts all particle systems of the set
  69425. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69426. */
  69427. start(emitter?: AbstractMesh): void;
  69428. /**
  69429. * Release all associated resources
  69430. */
  69431. dispose(): void;
  69432. /**
  69433. * Serialize the set into a JSON compatible object
  69434. * @param serializeTexture defines if the texture must be serialized as well
  69435. * @returns a JSON compatible representation of the set
  69436. */
  69437. serialize(serializeTexture?: boolean): any;
  69438. /**
  69439. * Parse a new ParticleSystemSet from a serialized source
  69440. * @param data defines a JSON compatible representation of the set
  69441. * @param scene defines the hosting scene
  69442. * @param gpu defines if we want GPU particles or CPU particles
  69443. * @returns a new ParticleSystemSet
  69444. */
  69445. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69446. }
  69447. }
  69448. declare module BABYLON {
  69449. /**
  69450. * This class is made for on one-liner static method to help creating particle system set.
  69451. */
  69452. export class ParticleHelper {
  69453. /**
  69454. * Gets or sets base Assets URL
  69455. */
  69456. static BaseAssetsUrl: string;
  69457. /** Define the Url to load snippets */
  69458. static SnippetUrl: string;
  69459. /**
  69460. * Create a default particle system that you can tweak
  69461. * @param emitter defines the emitter to use
  69462. * @param capacity defines the system capacity (default is 500 particles)
  69463. * @param scene defines the hosting scene
  69464. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69465. * @returns the new Particle system
  69466. */
  69467. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69468. /**
  69469. * This is the main static method (one-liner) of this helper to create different particle systems
  69470. * @param type This string represents the type to the particle system to create
  69471. * @param scene The scene where the particle system should live
  69472. * @param gpu If the system will use gpu
  69473. * @returns the ParticleSystemSet created
  69474. */
  69475. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69476. /**
  69477. * Static function used to export a particle system to a ParticleSystemSet variable.
  69478. * Please note that the emitter shape is not exported
  69479. * @param systems defines the particle systems to export
  69480. * @returns the created particle system set
  69481. */
  69482. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69483. /**
  69484. * Creates a particle system from a snippet saved in a remote file
  69485. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69486. * @param url defines the url to load from
  69487. * @param scene defines the hosting scene
  69488. * @param gpu If the system will use gpu
  69489. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69490. * @returns a promise that will resolve to the new particle system
  69491. */
  69492. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69493. /**
  69494. * Creates a particle system from a snippet saved by the particle system editor
  69495. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69496. * @param scene defines the hosting scene
  69497. * @param gpu If the system will use gpu
  69498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69499. * @returns a promise that will resolve to the new particle system
  69500. */
  69501. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69502. }
  69503. }
  69504. declare module BABYLON {
  69505. interface Engine {
  69506. /**
  69507. * Create an effect to use with particle systems.
  69508. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69509. * the particle system for which you want to create a custom effect in the last parameter
  69510. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69511. * @param uniformsNames defines a list of attribute names
  69512. * @param samplers defines an array of string used to represent textures
  69513. * @param defines defines the string containing the defines to use to compile the shaders
  69514. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69515. * @param onCompiled defines a function to call when the effect creation is successful
  69516. * @param onError defines a function to call when the effect creation has failed
  69517. * @param particleSystem the particle system you want to create the effect for
  69518. * @returns the new Effect
  69519. */
  69520. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69521. }
  69522. interface Mesh {
  69523. /**
  69524. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69525. * @returns an array of IParticleSystem
  69526. */
  69527. getEmittedParticleSystems(): IParticleSystem[];
  69528. /**
  69529. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69530. * @returns an array of IParticleSystem
  69531. */
  69532. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69533. }
  69534. }
  69535. declare module BABYLON {
  69536. /** Defines the 4 color options */
  69537. export enum PointColor {
  69538. /** color value */
  69539. Color = 2,
  69540. /** uv value */
  69541. UV = 1,
  69542. /** random value */
  69543. Random = 0,
  69544. /** stated value */
  69545. Stated = 3
  69546. }
  69547. /**
  69548. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69549. * 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.
  69550. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69551. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69552. *
  69553. * Full documentation here : TO BE ENTERED
  69554. */
  69555. export class PointsCloudSystem implements IDisposable {
  69556. /**
  69557. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69558. * Example : var p = SPS.particles[i];
  69559. */
  69560. particles: CloudPoint[];
  69561. /**
  69562. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69563. */
  69564. nbParticles: number;
  69565. /**
  69566. * This a counter for your own usage. It's not set by any SPS functions.
  69567. */
  69568. counter: number;
  69569. /**
  69570. * The PCS name. This name is also given to the underlying mesh.
  69571. */
  69572. name: string;
  69573. /**
  69574. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69575. */
  69576. mesh: Mesh;
  69577. /**
  69578. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69579. * Please read :
  69580. */
  69581. vars: any;
  69582. /**
  69583. * @hidden
  69584. */
  69585. _size: number;
  69586. private _scene;
  69587. private _promises;
  69588. private _positions;
  69589. private _indices;
  69590. private _normals;
  69591. private _colors;
  69592. private _uvs;
  69593. private _indices32;
  69594. private _positions32;
  69595. private _colors32;
  69596. private _uvs32;
  69597. private _updatable;
  69598. private _isVisibilityBoxLocked;
  69599. private _alwaysVisible;
  69600. private _groups;
  69601. private _groupCounter;
  69602. private _computeParticleColor;
  69603. private _computeParticleTexture;
  69604. private _computeParticleRotation;
  69605. private _computeBoundingBox;
  69606. private _isReady;
  69607. /**
  69608. * Creates a PCS (Points Cloud System) object
  69609. * @param name (String) is the PCS name, this will be the underlying mesh name
  69610. * @param pointSize (number) is the size for each point
  69611. * @param scene (Scene) is the scene in which the PCS is added
  69612. * @param options defines the options of the PCS e.g.
  69613. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69614. */
  69615. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69616. updatable?: boolean;
  69617. });
  69618. /**
  69619. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69620. * If no points were added to the PCS, the returned mesh is just a single point.
  69621. * @returns a promise for the created mesh
  69622. */
  69623. buildMeshAsync(): Promise<Mesh>;
  69624. /**
  69625. * @hidden
  69626. */
  69627. private _buildMesh;
  69628. private _addParticle;
  69629. private _randomUnitVector;
  69630. private _getColorIndicesForCoord;
  69631. private _setPointsColorOrUV;
  69632. private _colorFromTexture;
  69633. private _calculateDensity;
  69634. /**
  69635. * Adds points to the PCS in random positions within a unit sphere
  69636. * @param nb (positive integer) the number of particles to be created from this model
  69637. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69638. * @returns the number of groups in the system
  69639. */
  69640. addPoints(nb: number, pointFunction?: any): number;
  69641. /**
  69642. * Adds points to the PCS from the surface of the model shape
  69643. * @param mesh is any Mesh object that will be used as a surface model for the points
  69644. * @param nb (positive integer) the number of particles to be created from this model
  69645. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69646. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69647. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69648. * @returns the number of groups in the system
  69649. */
  69650. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69651. /**
  69652. * Adds points to the PCS inside the model shape
  69653. * @param mesh is any Mesh object that will be used as a surface model for the points
  69654. * @param nb (positive integer) the number of particles to be created from this model
  69655. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69656. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69657. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69658. * @returns the number of groups in the system
  69659. */
  69660. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69661. /**
  69662. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69663. * This method calls `updateParticle()` for each particle of the SPS.
  69664. * For an animated SPS, it is usually called within the render loop.
  69665. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69666. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69667. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69668. * @returns the PCS.
  69669. */
  69670. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69671. /**
  69672. * Disposes the PCS.
  69673. */
  69674. dispose(): void;
  69675. /**
  69676. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69677. * doc :
  69678. * @returns the PCS.
  69679. */
  69680. refreshVisibleSize(): PointsCloudSystem;
  69681. /**
  69682. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69683. * @param size the size (float) of the visibility box
  69684. * note : this doesn't lock the PCS mesh bounding box.
  69685. * doc :
  69686. */
  69687. setVisibilityBox(size: number): void;
  69688. /**
  69689. * Gets whether the PCS is always visible or not
  69690. * doc :
  69691. */
  69692. get isAlwaysVisible(): boolean;
  69693. /**
  69694. * Sets the PCS as always visible or not
  69695. * doc :
  69696. */
  69697. set isAlwaysVisible(val: boolean);
  69698. /**
  69699. * Tells to `setParticles()` to compute the particle rotations or not
  69700. * Default value : false. The PCS is faster when it's set to false
  69701. * Note : particle rotations are only applied to parent particles
  69702. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69703. */
  69704. set computeParticleRotation(val: boolean);
  69705. /**
  69706. * Tells to `setParticles()` to compute the particle colors or not.
  69707. * Default value : true. The PCS is faster when it's set to false.
  69708. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69709. */
  69710. set computeParticleColor(val: boolean);
  69711. set computeParticleTexture(val: boolean);
  69712. /**
  69713. * Gets if `setParticles()` computes the particle colors or not.
  69714. * Default value : false. The PCS is faster when it's set to false.
  69715. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69716. */
  69717. get computeParticleColor(): boolean;
  69718. /**
  69719. * Gets if `setParticles()` computes the particle textures or not.
  69720. * Default value : false. The PCS is faster when it's set to false.
  69721. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69722. */
  69723. get computeParticleTexture(): boolean;
  69724. /**
  69725. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69726. */
  69727. set computeBoundingBox(val: boolean);
  69728. /**
  69729. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69730. */
  69731. get computeBoundingBox(): boolean;
  69732. /**
  69733. * This function does nothing. It may be overwritten to set all the particle first values.
  69734. * The PCS doesn't call this function, you may have to call it by your own.
  69735. * doc :
  69736. */
  69737. initParticles(): void;
  69738. /**
  69739. * This function does nothing. It may be overwritten to recycle a particle
  69740. * The PCS doesn't call this function, you can to call it
  69741. * doc :
  69742. * @param particle The particle to recycle
  69743. * @returns the recycled particle
  69744. */
  69745. recycleParticle(particle: CloudPoint): CloudPoint;
  69746. /**
  69747. * Updates a particle : this function should be overwritten by the user.
  69748. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69749. * doc :
  69750. * @example : just set a particle position or velocity and recycle conditions
  69751. * @param particle The particle to update
  69752. * @returns the updated particle
  69753. */
  69754. updateParticle(particle: CloudPoint): CloudPoint;
  69755. /**
  69756. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69757. * This does nothing and may be overwritten by the user.
  69758. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69759. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69760. * @param update the boolean update value actually passed to setParticles()
  69761. */
  69762. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69763. /**
  69764. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69765. * This will be passed three parameters.
  69766. * This does nothing and may be overwritten by the user.
  69767. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69768. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69769. * @param update the boolean update value actually passed to setParticles()
  69770. */
  69771. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69772. }
  69773. }
  69774. declare module BABYLON {
  69775. /**
  69776. * Represents one particle of a points cloud system.
  69777. */
  69778. export class CloudPoint {
  69779. /**
  69780. * particle global index
  69781. */
  69782. idx: number;
  69783. /**
  69784. * The color of the particle
  69785. */
  69786. color: Nullable<Color4>;
  69787. /**
  69788. * The world space position of the particle.
  69789. */
  69790. position: Vector3;
  69791. /**
  69792. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69793. */
  69794. rotation: Vector3;
  69795. /**
  69796. * The world space rotation quaternion of the particle.
  69797. */
  69798. rotationQuaternion: Nullable<Quaternion>;
  69799. /**
  69800. * The uv of the particle.
  69801. */
  69802. uv: Nullable<Vector2>;
  69803. /**
  69804. * The current speed of the particle.
  69805. */
  69806. velocity: Vector3;
  69807. /**
  69808. * The pivot point in the particle local space.
  69809. */
  69810. pivot: Vector3;
  69811. /**
  69812. * Must the particle be translated from its pivot point in its local space ?
  69813. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69814. * Default : false
  69815. */
  69816. translateFromPivot: boolean;
  69817. /**
  69818. * Index of this particle in the global "positions" array (Internal use)
  69819. * @hidden
  69820. */
  69821. _pos: number;
  69822. /**
  69823. * @hidden Index of this particle in the global "indices" array (Internal use)
  69824. */
  69825. _ind: number;
  69826. /**
  69827. * Group this particle belongs to
  69828. */
  69829. _group: PointsGroup;
  69830. /**
  69831. * Group id of this particle
  69832. */
  69833. groupId: number;
  69834. /**
  69835. * Index of the particle in its group id (Internal use)
  69836. */
  69837. idxInGroup: number;
  69838. /**
  69839. * @hidden Particle BoundingInfo object (Internal use)
  69840. */
  69841. _boundingInfo: BoundingInfo;
  69842. /**
  69843. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69844. */
  69845. _pcs: PointsCloudSystem;
  69846. /**
  69847. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69848. */
  69849. _stillInvisible: boolean;
  69850. /**
  69851. * @hidden Last computed particle rotation matrix
  69852. */
  69853. _rotationMatrix: number[];
  69854. /**
  69855. * Parent particle Id, if any.
  69856. * Default null.
  69857. */
  69858. parentId: Nullable<number>;
  69859. /**
  69860. * @hidden Internal global position in the PCS.
  69861. */
  69862. _globalPosition: Vector3;
  69863. /**
  69864. * Creates a Point Cloud object.
  69865. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69866. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69867. * @param group (PointsGroup) is the group the particle belongs to
  69868. * @param groupId (integer) is the group identifier in the PCS.
  69869. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69870. * @param pcs defines the PCS it is associated to
  69871. */
  69872. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69873. /**
  69874. * get point size
  69875. */
  69876. get size(): Vector3;
  69877. /**
  69878. * Set point size
  69879. */
  69880. set size(scale: Vector3);
  69881. /**
  69882. * Legacy support, changed quaternion to rotationQuaternion
  69883. */
  69884. get quaternion(): Nullable<Quaternion>;
  69885. /**
  69886. * Legacy support, changed quaternion to rotationQuaternion
  69887. */
  69888. set quaternion(q: Nullable<Quaternion>);
  69889. /**
  69890. * Returns a boolean. True if the particle intersects a mesh, else false
  69891. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69892. * @param target is the object (point or mesh) what the intersection is computed against
  69893. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69894. * @returns true if it intersects
  69895. */
  69896. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69897. /**
  69898. * get the rotation matrix of the particle
  69899. * @hidden
  69900. */
  69901. getRotationMatrix(m: Matrix): void;
  69902. }
  69903. /**
  69904. * Represents a group of points in a points cloud system
  69905. * * PCS internal tool, don't use it manually.
  69906. */
  69907. export class PointsGroup {
  69908. /**
  69909. * The group id
  69910. * @hidden
  69911. */
  69912. groupID: number;
  69913. /**
  69914. * image data for group (internal use)
  69915. * @hidden
  69916. */
  69917. _groupImageData: Nullable<ArrayBufferView>;
  69918. /**
  69919. * Image Width (internal use)
  69920. * @hidden
  69921. */
  69922. _groupImgWidth: number;
  69923. /**
  69924. * Image Height (internal use)
  69925. * @hidden
  69926. */
  69927. _groupImgHeight: number;
  69928. /**
  69929. * Custom position function (internal use)
  69930. * @hidden
  69931. */
  69932. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69933. /**
  69934. * density per facet for surface points
  69935. * @hidden
  69936. */
  69937. _groupDensity: number[];
  69938. /**
  69939. * Only when points are colored by texture carries pointer to texture list array
  69940. * @hidden
  69941. */
  69942. _textureNb: number;
  69943. /**
  69944. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69945. * PCS internal tool, don't use it manually.
  69946. * @hidden
  69947. */
  69948. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69949. }
  69950. }
  69951. declare module BABYLON {
  69952. interface Scene {
  69953. /** @hidden (Backing field) */
  69954. _physicsEngine: Nullable<IPhysicsEngine>;
  69955. /** @hidden */
  69956. _physicsTimeAccumulator: number;
  69957. /**
  69958. * Gets the current physics engine
  69959. * @returns a IPhysicsEngine or null if none attached
  69960. */
  69961. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69962. /**
  69963. * Enables physics to the current scene
  69964. * @param gravity defines the scene's gravity for the physics engine
  69965. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69966. * @return a boolean indicating if the physics engine was initialized
  69967. */
  69968. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69969. /**
  69970. * Disables and disposes the physics engine associated with the scene
  69971. */
  69972. disablePhysicsEngine(): void;
  69973. /**
  69974. * Gets a boolean indicating if there is an active physics engine
  69975. * @returns a boolean indicating if there is an active physics engine
  69976. */
  69977. isPhysicsEnabled(): boolean;
  69978. /**
  69979. * Deletes a physics compound impostor
  69980. * @param compound defines the compound to delete
  69981. */
  69982. deleteCompoundImpostor(compound: any): void;
  69983. /**
  69984. * An event triggered when physic simulation is about to be run
  69985. */
  69986. onBeforePhysicsObservable: Observable<Scene>;
  69987. /**
  69988. * An event triggered when physic simulation has been done
  69989. */
  69990. onAfterPhysicsObservable: Observable<Scene>;
  69991. }
  69992. interface AbstractMesh {
  69993. /** @hidden */
  69994. _physicsImpostor: Nullable<PhysicsImpostor>;
  69995. /**
  69996. * Gets or sets impostor used for physic simulation
  69997. * @see https://doc.babylonjs.com/features/physics_engine
  69998. */
  69999. physicsImpostor: Nullable<PhysicsImpostor>;
  70000. /**
  70001. * Gets the current physics impostor
  70002. * @see https://doc.babylonjs.com/features/physics_engine
  70003. * @returns a physics impostor or null
  70004. */
  70005. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70006. /** Apply a physic impulse to the mesh
  70007. * @param force defines the force to apply
  70008. * @param contactPoint defines where to apply the force
  70009. * @returns the current mesh
  70010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70011. */
  70012. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70013. /**
  70014. * Creates a physic joint between two meshes
  70015. * @param otherMesh defines the other mesh to use
  70016. * @param pivot1 defines the pivot to use on this mesh
  70017. * @param pivot2 defines the pivot to use on the other mesh
  70018. * @param options defines additional options (can be plugin dependent)
  70019. * @returns the current mesh
  70020. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70021. */
  70022. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70023. /** @hidden */
  70024. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70025. }
  70026. /**
  70027. * Defines the physics engine scene component responsible to manage a physics engine
  70028. */
  70029. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70030. /**
  70031. * The component name helpful to identify the component in the list of scene components.
  70032. */
  70033. readonly name: string;
  70034. /**
  70035. * The scene the component belongs to.
  70036. */
  70037. scene: Scene;
  70038. /**
  70039. * Creates a new instance of the component for the given scene
  70040. * @param scene Defines the scene to register the component in
  70041. */
  70042. constructor(scene: Scene);
  70043. /**
  70044. * Registers the component in a given scene
  70045. */
  70046. register(): void;
  70047. /**
  70048. * Rebuilds the elements related to this component in case of
  70049. * context lost for instance.
  70050. */
  70051. rebuild(): void;
  70052. /**
  70053. * Disposes the component and the associated ressources
  70054. */
  70055. dispose(): void;
  70056. }
  70057. }
  70058. declare module BABYLON {
  70059. /**
  70060. * A helper for physics simulations
  70061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70062. */
  70063. export class PhysicsHelper {
  70064. private _scene;
  70065. private _physicsEngine;
  70066. /**
  70067. * Initializes the Physics helper
  70068. * @param scene Babylon.js scene
  70069. */
  70070. constructor(scene: Scene);
  70071. /**
  70072. * Applies a radial explosion impulse
  70073. * @param origin the origin of the explosion
  70074. * @param radiusOrEventOptions the radius or the options of radial explosion
  70075. * @param strength the explosion strength
  70076. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70077. * @returns A physics radial explosion event, or null
  70078. */
  70079. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70080. /**
  70081. * Applies a radial explosion force
  70082. * @param origin the origin of the explosion
  70083. * @param radiusOrEventOptions the radius or the options of radial explosion
  70084. * @param strength the explosion strength
  70085. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70086. * @returns A physics radial explosion event, or null
  70087. */
  70088. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70089. /**
  70090. * Creates a gravitational field
  70091. * @param origin the origin of the explosion
  70092. * @param radiusOrEventOptions the radius or the options of radial explosion
  70093. * @param strength the explosion strength
  70094. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70095. * @returns A physics gravitational field event, or null
  70096. */
  70097. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70098. /**
  70099. * Creates a physics updraft event
  70100. * @param origin the origin of the updraft
  70101. * @param radiusOrEventOptions the radius or the options of the updraft
  70102. * @param strength the strength of the updraft
  70103. * @param height the height of the updraft
  70104. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70105. * @returns A physics updraft event, or null
  70106. */
  70107. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70108. /**
  70109. * Creates a physics vortex event
  70110. * @param origin the of the vortex
  70111. * @param radiusOrEventOptions the radius or the options of the vortex
  70112. * @param strength the strength of the vortex
  70113. * @param height the height of the vortex
  70114. * @returns a Physics vortex event, or null
  70115. * A physics vortex event or null
  70116. */
  70117. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70118. }
  70119. /**
  70120. * Represents a physics radial explosion event
  70121. */
  70122. class PhysicsRadialExplosionEvent {
  70123. private _scene;
  70124. private _options;
  70125. private _sphere;
  70126. private _dataFetched;
  70127. /**
  70128. * Initializes a radial explosioin event
  70129. * @param _scene BabylonJS scene
  70130. * @param _options The options for the vortex event
  70131. */
  70132. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70133. /**
  70134. * Returns the data related to the radial explosion event (sphere).
  70135. * @returns The radial explosion event data
  70136. */
  70137. getData(): PhysicsRadialExplosionEventData;
  70138. /**
  70139. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70140. * @param impostor A physics imposter
  70141. * @param origin the origin of the explosion
  70142. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70143. */
  70144. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70145. /**
  70146. * Triggers affecterd impostors callbacks
  70147. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70148. */
  70149. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70150. /**
  70151. * Disposes the sphere.
  70152. * @param force Specifies if the sphere should be disposed by force
  70153. */
  70154. dispose(force?: boolean): void;
  70155. /*** Helpers ***/
  70156. private _prepareSphere;
  70157. private _intersectsWithSphere;
  70158. }
  70159. /**
  70160. * Represents a gravitational field event
  70161. */
  70162. class PhysicsGravitationalFieldEvent {
  70163. private _physicsHelper;
  70164. private _scene;
  70165. private _origin;
  70166. private _options;
  70167. private _tickCallback;
  70168. private _sphere;
  70169. private _dataFetched;
  70170. /**
  70171. * Initializes the physics gravitational field event
  70172. * @param _physicsHelper A physics helper
  70173. * @param _scene BabylonJS scene
  70174. * @param _origin The origin position of the gravitational field event
  70175. * @param _options The options for the vortex event
  70176. */
  70177. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70178. /**
  70179. * Returns the data related to the gravitational field event (sphere).
  70180. * @returns A gravitational field event
  70181. */
  70182. getData(): PhysicsGravitationalFieldEventData;
  70183. /**
  70184. * Enables the gravitational field.
  70185. */
  70186. enable(): void;
  70187. /**
  70188. * Disables the gravitational field.
  70189. */
  70190. disable(): void;
  70191. /**
  70192. * Disposes the sphere.
  70193. * @param force The force to dispose from the gravitational field event
  70194. */
  70195. dispose(force?: boolean): void;
  70196. private _tick;
  70197. }
  70198. /**
  70199. * Represents a physics updraft event
  70200. */
  70201. class PhysicsUpdraftEvent {
  70202. private _scene;
  70203. private _origin;
  70204. private _options;
  70205. private _physicsEngine;
  70206. private _originTop;
  70207. private _originDirection;
  70208. private _tickCallback;
  70209. private _cylinder;
  70210. private _cylinderPosition;
  70211. private _dataFetched;
  70212. /**
  70213. * Initializes the physics updraft event
  70214. * @param _scene BabylonJS scene
  70215. * @param _origin The origin position of the updraft
  70216. * @param _options The options for the updraft event
  70217. */
  70218. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70219. /**
  70220. * Returns the data related to the updraft event (cylinder).
  70221. * @returns A physics updraft event
  70222. */
  70223. getData(): PhysicsUpdraftEventData;
  70224. /**
  70225. * Enables the updraft.
  70226. */
  70227. enable(): void;
  70228. /**
  70229. * Disables the updraft.
  70230. */
  70231. disable(): void;
  70232. /**
  70233. * Disposes the cylinder.
  70234. * @param force Specifies if the updraft should be disposed by force
  70235. */
  70236. dispose(force?: boolean): void;
  70237. private getImpostorHitData;
  70238. private _tick;
  70239. /*** Helpers ***/
  70240. private _prepareCylinder;
  70241. private _intersectsWithCylinder;
  70242. }
  70243. /**
  70244. * Represents a physics vortex event
  70245. */
  70246. class PhysicsVortexEvent {
  70247. private _scene;
  70248. private _origin;
  70249. private _options;
  70250. private _physicsEngine;
  70251. private _originTop;
  70252. private _tickCallback;
  70253. private _cylinder;
  70254. private _cylinderPosition;
  70255. private _dataFetched;
  70256. /**
  70257. * Initializes the physics vortex event
  70258. * @param _scene The BabylonJS scene
  70259. * @param _origin The origin position of the vortex
  70260. * @param _options The options for the vortex event
  70261. */
  70262. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70263. /**
  70264. * Returns the data related to the vortex event (cylinder).
  70265. * @returns The physics vortex event data
  70266. */
  70267. getData(): PhysicsVortexEventData;
  70268. /**
  70269. * Enables the vortex.
  70270. */
  70271. enable(): void;
  70272. /**
  70273. * Disables the cortex.
  70274. */
  70275. disable(): void;
  70276. /**
  70277. * Disposes the sphere.
  70278. * @param force
  70279. */
  70280. dispose(force?: boolean): void;
  70281. private getImpostorHitData;
  70282. private _tick;
  70283. /*** Helpers ***/
  70284. private _prepareCylinder;
  70285. private _intersectsWithCylinder;
  70286. }
  70287. /**
  70288. * Options fot the radial explosion event
  70289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70290. */
  70291. export class PhysicsRadialExplosionEventOptions {
  70292. /**
  70293. * The radius of the sphere for the radial explosion.
  70294. */
  70295. radius: number;
  70296. /**
  70297. * The strenth of the explosion.
  70298. */
  70299. strength: number;
  70300. /**
  70301. * The strenght of the force in correspondence to the distance of the affected object
  70302. */
  70303. falloff: PhysicsRadialImpulseFalloff;
  70304. /**
  70305. * Sphere options for the radial explosion.
  70306. */
  70307. sphere: {
  70308. segments: number;
  70309. diameter: number;
  70310. };
  70311. /**
  70312. * Sphere options for the radial explosion.
  70313. */
  70314. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70315. }
  70316. /**
  70317. * Options fot the updraft event
  70318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70319. */
  70320. export class PhysicsUpdraftEventOptions {
  70321. /**
  70322. * The radius of the cylinder for the vortex
  70323. */
  70324. radius: number;
  70325. /**
  70326. * The strenth of the updraft.
  70327. */
  70328. strength: number;
  70329. /**
  70330. * The height of the cylinder for the updraft.
  70331. */
  70332. height: number;
  70333. /**
  70334. * The mode for the the updraft.
  70335. */
  70336. updraftMode: PhysicsUpdraftMode;
  70337. }
  70338. /**
  70339. * Options fot the vortex event
  70340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70341. */
  70342. export class PhysicsVortexEventOptions {
  70343. /**
  70344. * The radius of the cylinder for the vortex
  70345. */
  70346. radius: number;
  70347. /**
  70348. * The strenth of the vortex.
  70349. */
  70350. strength: number;
  70351. /**
  70352. * The height of the cylinder for the vortex.
  70353. */
  70354. height: number;
  70355. /**
  70356. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70357. */
  70358. centripetalForceThreshold: number;
  70359. /**
  70360. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70361. */
  70362. centripetalForceMultiplier: number;
  70363. /**
  70364. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70365. */
  70366. centrifugalForceMultiplier: number;
  70367. /**
  70368. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70369. */
  70370. updraftForceMultiplier: number;
  70371. }
  70372. /**
  70373. * The strenght of the force in correspondence to the distance of the affected object
  70374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70375. */
  70376. export enum PhysicsRadialImpulseFalloff {
  70377. /** Defines that impulse is constant in strength across it's whole radius */
  70378. Constant = 0,
  70379. /** Defines that impulse gets weaker if it's further from the origin */
  70380. Linear = 1
  70381. }
  70382. /**
  70383. * The strength of the force in correspondence to the distance of the affected object
  70384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70385. */
  70386. export enum PhysicsUpdraftMode {
  70387. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70388. Center = 0,
  70389. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70390. Perpendicular = 1
  70391. }
  70392. /**
  70393. * Interface for a physics hit data
  70394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70395. */
  70396. export interface PhysicsHitData {
  70397. /**
  70398. * The force applied at the contact point
  70399. */
  70400. force: Vector3;
  70401. /**
  70402. * The contact point
  70403. */
  70404. contactPoint: Vector3;
  70405. /**
  70406. * The distance from the origin to the contact point
  70407. */
  70408. distanceFromOrigin: number;
  70409. }
  70410. /**
  70411. * Interface for radial explosion event data
  70412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70413. */
  70414. export interface PhysicsRadialExplosionEventData {
  70415. /**
  70416. * A sphere used for the radial explosion event
  70417. */
  70418. sphere: Mesh;
  70419. }
  70420. /**
  70421. * Interface for gravitational field event data
  70422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70423. */
  70424. export interface PhysicsGravitationalFieldEventData {
  70425. /**
  70426. * A sphere mesh used for the gravitational field event
  70427. */
  70428. sphere: Mesh;
  70429. }
  70430. /**
  70431. * Interface for updraft event data
  70432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70433. */
  70434. export interface PhysicsUpdraftEventData {
  70435. /**
  70436. * A cylinder used for the updraft event
  70437. */
  70438. cylinder: Mesh;
  70439. }
  70440. /**
  70441. * Interface for vortex event data
  70442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70443. */
  70444. export interface PhysicsVortexEventData {
  70445. /**
  70446. * A cylinder used for the vortex event
  70447. */
  70448. cylinder: Mesh;
  70449. }
  70450. /**
  70451. * Interface for an affected physics impostor
  70452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70453. */
  70454. export interface PhysicsAffectedImpostorWithData {
  70455. /**
  70456. * The impostor affected by the effect
  70457. */
  70458. impostor: PhysicsImpostor;
  70459. /**
  70460. * The data about the hit/horce from the explosion
  70461. */
  70462. hitData: PhysicsHitData;
  70463. }
  70464. }
  70465. declare module BABYLON {
  70466. /** @hidden */
  70467. export var blackAndWhitePixelShader: {
  70468. name: string;
  70469. shader: string;
  70470. };
  70471. }
  70472. declare module BABYLON {
  70473. /**
  70474. * Post process used to render in black and white
  70475. */
  70476. export class BlackAndWhitePostProcess extends PostProcess {
  70477. /**
  70478. * Linear about to convert he result to black and white (default: 1)
  70479. */
  70480. degree: number;
  70481. /**
  70482. * Gets a string identifying the name of the class
  70483. * @returns "BlackAndWhitePostProcess" string
  70484. */
  70485. getClassName(): string;
  70486. /**
  70487. * Creates a black and white post process
  70488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70489. * @param name The name of the effect.
  70490. * @param options The required width/height ratio to downsize to before computing the render pass.
  70491. * @param camera The camera to apply the render pass to.
  70492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70493. * @param engine The engine which the post process will be applied. (default: current engine)
  70494. * @param reusable If the post process can be reused on the same frame. (default: false)
  70495. */
  70496. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70497. /** @hidden */
  70498. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70499. }
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * This represents a set of one or more post processes in Babylon.
  70504. * A post process can be used to apply a shader to a texture after it is rendered.
  70505. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70506. */
  70507. export class PostProcessRenderEffect {
  70508. private _postProcesses;
  70509. private _getPostProcesses;
  70510. private _singleInstance;
  70511. private _cameras;
  70512. private _indicesForCamera;
  70513. /**
  70514. * Name of the effect
  70515. * @hidden
  70516. */
  70517. _name: string;
  70518. /**
  70519. * Instantiates a post process render effect.
  70520. * A post process can be used to apply a shader to a texture after it is rendered.
  70521. * @param engine The engine the effect is tied to
  70522. * @param name The name of the effect
  70523. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70524. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70525. */
  70526. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70527. /**
  70528. * Checks if all the post processes in the effect are supported.
  70529. */
  70530. get isSupported(): boolean;
  70531. /**
  70532. * Updates the current state of the effect
  70533. * @hidden
  70534. */
  70535. _update(): void;
  70536. /**
  70537. * Attaches the effect on cameras
  70538. * @param cameras The camera to attach to.
  70539. * @hidden
  70540. */
  70541. _attachCameras(cameras: Camera): void;
  70542. /**
  70543. * Attaches the effect on cameras
  70544. * @param cameras The camera to attach to.
  70545. * @hidden
  70546. */
  70547. _attachCameras(cameras: Camera[]): void;
  70548. /**
  70549. * Detaches the effect on cameras
  70550. * @param cameras The camera to detatch from.
  70551. * @hidden
  70552. */
  70553. _detachCameras(cameras: Camera): void;
  70554. /**
  70555. * Detatches the effect on cameras
  70556. * @param cameras The camera to detatch from.
  70557. * @hidden
  70558. */
  70559. _detachCameras(cameras: Camera[]): void;
  70560. /**
  70561. * Enables the effect on given cameras
  70562. * @param cameras The camera to enable.
  70563. * @hidden
  70564. */
  70565. _enable(cameras: Camera): void;
  70566. /**
  70567. * Enables the effect on given cameras
  70568. * @param cameras The camera to enable.
  70569. * @hidden
  70570. */
  70571. _enable(cameras: Nullable<Camera[]>): void;
  70572. /**
  70573. * Disables the effect on the given cameras
  70574. * @param cameras The camera to disable.
  70575. * @hidden
  70576. */
  70577. _disable(cameras: Camera): void;
  70578. /**
  70579. * Disables the effect on the given cameras
  70580. * @param cameras The camera to disable.
  70581. * @hidden
  70582. */
  70583. _disable(cameras: Nullable<Camera[]>): void;
  70584. /**
  70585. * Gets a list of the post processes contained in the effect.
  70586. * @param camera The camera to get the post processes on.
  70587. * @returns The list of the post processes in the effect.
  70588. */
  70589. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /** @hidden */
  70594. export var extractHighlightsPixelShader: {
  70595. name: string;
  70596. shader: string;
  70597. };
  70598. }
  70599. declare module BABYLON {
  70600. /**
  70601. * 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.
  70602. */
  70603. export class ExtractHighlightsPostProcess extends PostProcess {
  70604. /**
  70605. * The luminance threshold, pixels below this value will be set to black.
  70606. */
  70607. threshold: number;
  70608. /** @hidden */
  70609. _exposure: number;
  70610. /**
  70611. * Post process which has the input texture to be used when performing highlight extraction
  70612. * @hidden
  70613. */
  70614. _inputPostProcess: Nullable<PostProcess>;
  70615. /**
  70616. * Gets a string identifying the name of the class
  70617. * @returns "ExtractHighlightsPostProcess" string
  70618. */
  70619. getClassName(): string;
  70620. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70621. }
  70622. }
  70623. declare module BABYLON {
  70624. /** @hidden */
  70625. export var bloomMergePixelShader: {
  70626. name: string;
  70627. shader: string;
  70628. };
  70629. }
  70630. declare module BABYLON {
  70631. /**
  70632. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70633. */
  70634. export class BloomMergePostProcess extends PostProcess {
  70635. /** Weight of the bloom to be added to the original input. */
  70636. weight: number;
  70637. /**
  70638. * Gets a string identifying the name of the class
  70639. * @returns "BloomMergePostProcess" string
  70640. */
  70641. getClassName(): string;
  70642. /**
  70643. * Creates a new instance of @see BloomMergePostProcess
  70644. * @param name The name of the effect.
  70645. * @param originalFromInput Post process which's input will be used for the merge.
  70646. * @param blurred Blurred highlights post process which's output will be used.
  70647. * @param weight Weight of the bloom to be added to the original input.
  70648. * @param options The required width/height ratio to downsize to before computing the render pass.
  70649. * @param camera The camera to apply the render pass to.
  70650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70651. * @param engine The engine which the post process will be applied. (default: current engine)
  70652. * @param reusable If the post process can be reused on the same frame. (default: false)
  70653. * @param textureType Type of textures used when performing the post process. (default: 0)
  70654. * @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)
  70655. */
  70656. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70657. /** Weight of the bloom to be added to the original input. */
  70658. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70659. }
  70660. }
  70661. declare module BABYLON {
  70662. /**
  70663. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70664. */
  70665. export class BloomEffect extends PostProcessRenderEffect {
  70666. private bloomScale;
  70667. /**
  70668. * @hidden Internal
  70669. */
  70670. _effects: Array<PostProcess>;
  70671. /**
  70672. * @hidden Internal
  70673. */
  70674. _downscale: ExtractHighlightsPostProcess;
  70675. private _blurX;
  70676. private _blurY;
  70677. private _merge;
  70678. /**
  70679. * The luminance threshold to find bright areas of the image to bloom.
  70680. */
  70681. get threshold(): number;
  70682. set threshold(value: number);
  70683. /**
  70684. * The strength of the bloom.
  70685. */
  70686. get weight(): number;
  70687. set weight(value: number);
  70688. /**
  70689. * Specifies the size of the bloom blur kernel, relative to the final output size
  70690. */
  70691. get kernel(): number;
  70692. set kernel(value: number);
  70693. /**
  70694. * Creates a new instance of @see BloomEffect
  70695. * @param scene The scene the effect belongs to.
  70696. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70697. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70698. * @param bloomWeight The the strength of bloom.
  70699. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70700. * @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)
  70701. */
  70702. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70703. /**
  70704. * Disposes each of the internal effects for a given camera.
  70705. * @param camera The camera to dispose the effect on.
  70706. */
  70707. disposeEffects(camera: Camera): void;
  70708. /**
  70709. * @hidden Internal
  70710. */
  70711. _updateEffects(): void;
  70712. /**
  70713. * Internal
  70714. * @returns if all the contained post processes are ready.
  70715. * @hidden
  70716. */
  70717. _isReady(): boolean;
  70718. }
  70719. }
  70720. declare module BABYLON {
  70721. /** @hidden */
  70722. export var chromaticAberrationPixelShader: {
  70723. name: string;
  70724. shader: string;
  70725. };
  70726. }
  70727. declare module BABYLON {
  70728. /**
  70729. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70730. */
  70731. export class ChromaticAberrationPostProcess extends PostProcess {
  70732. /**
  70733. * The amount of seperation of rgb channels (default: 30)
  70734. */
  70735. aberrationAmount: number;
  70736. /**
  70737. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70738. */
  70739. radialIntensity: number;
  70740. /**
  70741. * 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))
  70742. */
  70743. direction: Vector2;
  70744. /**
  70745. * 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))
  70746. */
  70747. centerPosition: Vector2;
  70748. /** The width of the screen to apply the effect on */
  70749. screenWidth: number;
  70750. /** The height of the screen to apply the effect on */
  70751. screenHeight: number;
  70752. /**
  70753. * Gets a string identifying the name of the class
  70754. * @returns "ChromaticAberrationPostProcess" string
  70755. */
  70756. getClassName(): string;
  70757. /**
  70758. * Creates a new instance ChromaticAberrationPostProcess
  70759. * @param name The name of the effect.
  70760. * @param screenWidth The width of the screen to apply the effect on.
  70761. * @param screenHeight The height of the screen to apply the effect on.
  70762. * @param options The required width/height ratio to downsize to before computing the render pass.
  70763. * @param camera The camera to apply the render pass to.
  70764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70765. * @param engine The engine which the post process will be applied. (default: current engine)
  70766. * @param reusable If the post process can be reused on the same frame. (default: false)
  70767. * @param textureType Type of textures used when performing the post process. (default: 0)
  70768. * @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)
  70769. */
  70770. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70771. /** @hidden */
  70772. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70773. }
  70774. }
  70775. declare module BABYLON {
  70776. /** @hidden */
  70777. export var circleOfConfusionPixelShader: {
  70778. name: string;
  70779. shader: string;
  70780. };
  70781. }
  70782. declare module BABYLON {
  70783. /**
  70784. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70785. */
  70786. export class CircleOfConfusionPostProcess extends PostProcess {
  70787. /**
  70788. * 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.
  70789. */
  70790. lensSize: number;
  70791. /**
  70792. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70793. */
  70794. fStop: number;
  70795. /**
  70796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70797. */
  70798. focusDistance: number;
  70799. /**
  70800. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70801. */
  70802. focalLength: number;
  70803. /**
  70804. * Gets a string identifying the name of the class
  70805. * @returns "CircleOfConfusionPostProcess" string
  70806. */
  70807. getClassName(): string;
  70808. private _depthTexture;
  70809. /**
  70810. * Creates a new instance CircleOfConfusionPostProcess
  70811. * @param name The name of the effect.
  70812. * @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.
  70813. * @param options The required width/height ratio to downsize to before computing the render pass.
  70814. * @param camera The camera to apply the render pass to.
  70815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70816. * @param engine The engine which the post process will be applied. (default: current engine)
  70817. * @param reusable If the post process can be reused on the same frame. (default: false)
  70818. * @param textureType Type of textures used when performing the post process. (default: 0)
  70819. * @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)
  70820. */
  70821. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70822. /**
  70823. * 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.
  70824. */
  70825. set depthTexture(value: RenderTargetTexture);
  70826. }
  70827. }
  70828. declare module BABYLON {
  70829. /** @hidden */
  70830. export var colorCorrectionPixelShader: {
  70831. name: string;
  70832. shader: string;
  70833. };
  70834. }
  70835. declare module BABYLON {
  70836. /**
  70837. *
  70838. * This post-process allows the modification of rendered colors by using
  70839. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70840. *
  70841. * The object needs to be provided an url to a texture containing the color
  70842. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70843. * Use an image editing software to tweak the LUT to match your needs.
  70844. *
  70845. * For an example of a color LUT, see here:
  70846. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70847. * For explanations on color grading, see here:
  70848. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70849. *
  70850. */
  70851. export class ColorCorrectionPostProcess extends PostProcess {
  70852. private _colorTableTexture;
  70853. /**
  70854. * Gets the color table url used to create the LUT texture
  70855. */
  70856. colorTableUrl: string;
  70857. /**
  70858. * Gets a string identifying the name of the class
  70859. * @returns "ColorCorrectionPostProcess" string
  70860. */
  70861. getClassName(): string;
  70862. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70863. /** @hidden */
  70864. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70865. }
  70866. }
  70867. declare module BABYLON {
  70868. /** @hidden */
  70869. export var convolutionPixelShader: {
  70870. name: string;
  70871. shader: string;
  70872. };
  70873. }
  70874. declare module BABYLON {
  70875. /**
  70876. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70877. * input texture to perform effects such as edge detection or sharpening
  70878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70879. */
  70880. export class ConvolutionPostProcess extends PostProcess {
  70881. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70882. kernel: number[];
  70883. /**
  70884. * Gets a string identifying the name of the class
  70885. * @returns "ConvolutionPostProcess" string
  70886. */
  70887. getClassName(): string;
  70888. /**
  70889. * Creates a new instance ConvolutionPostProcess
  70890. * @param name The name of the effect.
  70891. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70892. * @param options The required width/height ratio to downsize to before computing the render pass.
  70893. * @param camera The camera to apply the render pass to.
  70894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70895. * @param engine The engine which the post process will be applied. (default: current engine)
  70896. * @param reusable If the post process can be reused on the same frame. (default: false)
  70897. * @param textureType Type of textures used when performing the post process. (default: 0)
  70898. */
  70899. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70900. /** @hidden */
  70901. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70902. /**
  70903. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70904. */
  70905. static EdgeDetect0Kernel: number[];
  70906. /**
  70907. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70908. */
  70909. static EdgeDetect1Kernel: number[];
  70910. /**
  70911. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70912. */
  70913. static EdgeDetect2Kernel: number[];
  70914. /**
  70915. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70916. */
  70917. static SharpenKernel: number[];
  70918. /**
  70919. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70920. */
  70921. static EmbossKernel: number[];
  70922. /**
  70923. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70924. */
  70925. static GaussianKernel: number[];
  70926. }
  70927. }
  70928. declare module BABYLON {
  70929. /**
  70930. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70931. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70932. * based on samples that have a large difference in distance than the center pixel.
  70933. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70934. */
  70935. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70936. /**
  70937. * The direction the blur should be applied
  70938. */
  70939. direction: Vector2;
  70940. /**
  70941. * Gets a string identifying the name of the class
  70942. * @returns "DepthOfFieldBlurPostProcess" string
  70943. */
  70944. getClassName(): string;
  70945. /**
  70946. * Creates a new instance CircleOfConfusionPostProcess
  70947. * @param name The name of the effect.
  70948. * @param scene The scene the effect belongs to.
  70949. * @param direction The direction the blur should be applied.
  70950. * @param kernel The size of the kernel used to blur.
  70951. * @param options The required width/height ratio to downsize to before computing the render pass.
  70952. * @param camera The camera to apply the render pass to.
  70953. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70954. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70956. * @param engine The engine which the post process will be applied. (default: current engine)
  70957. * @param reusable If the post process can be reused on the same frame. (default: false)
  70958. * @param textureType Type of textures used when performing the post process. (default: 0)
  70959. * @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)
  70960. */
  70961. 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);
  70962. }
  70963. }
  70964. declare module BABYLON {
  70965. /** @hidden */
  70966. export var depthOfFieldMergePixelShader: {
  70967. name: string;
  70968. shader: string;
  70969. };
  70970. }
  70971. declare module BABYLON {
  70972. /**
  70973. * Options to be set when merging outputs from the default pipeline.
  70974. */
  70975. export class DepthOfFieldMergePostProcessOptions {
  70976. /**
  70977. * The original image to merge on top of
  70978. */
  70979. originalFromInput: PostProcess;
  70980. /**
  70981. * Parameters to perform the merge of the depth of field effect
  70982. */
  70983. depthOfField?: {
  70984. circleOfConfusion: PostProcess;
  70985. blurSteps: Array<PostProcess>;
  70986. };
  70987. /**
  70988. * Parameters to perform the merge of bloom effect
  70989. */
  70990. bloom?: {
  70991. blurred: PostProcess;
  70992. weight: number;
  70993. };
  70994. }
  70995. /**
  70996. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70997. */
  70998. export class DepthOfFieldMergePostProcess extends PostProcess {
  70999. private blurSteps;
  71000. /**
  71001. * Gets a string identifying the name of the class
  71002. * @returns "DepthOfFieldMergePostProcess" string
  71003. */
  71004. getClassName(): string;
  71005. /**
  71006. * Creates a new instance of DepthOfFieldMergePostProcess
  71007. * @param name The name of the effect.
  71008. * @param originalFromInput Post process which's input will be used for the merge.
  71009. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71010. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71011. * @param options The required width/height ratio to downsize to before computing the render pass.
  71012. * @param camera The camera to apply the render pass to.
  71013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71014. * @param engine The engine which the post process will be applied. (default: current engine)
  71015. * @param reusable If the post process can be reused on the same frame. (default: false)
  71016. * @param textureType Type of textures used when performing the post process. (default: 0)
  71017. * @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)
  71018. */
  71019. 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);
  71020. /**
  71021. * Updates the effect with the current post process compile time values and recompiles the shader.
  71022. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71023. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71024. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71025. * @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
  71026. * @param onCompiled Called when the shader has been compiled.
  71027. * @param onError Called if there is an error when compiling a shader.
  71028. */
  71029. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71030. }
  71031. }
  71032. declare module BABYLON {
  71033. /**
  71034. * Specifies the level of max blur that should be applied when using the depth of field effect
  71035. */
  71036. export enum DepthOfFieldEffectBlurLevel {
  71037. /**
  71038. * Subtle blur
  71039. */
  71040. Low = 0,
  71041. /**
  71042. * Medium blur
  71043. */
  71044. Medium = 1,
  71045. /**
  71046. * Large blur
  71047. */
  71048. High = 2
  71049. }
  71050. /**
  71051. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71052. */
  71053. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71054. private _circleOfConfusion;
  71055. /**
  71056. * @hidden Internal, blurs from high to low
  71057. */
  71058. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71059. private _depthOfFieldBlurY;
  71060. private _dofMerge;
  71061. /**
  71062. * @hidden Internal post processes in depth of field effect
  71063. */
  71064. _effects: Array<PostProcess>;
  71065. /**
  71066. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71067. */
  71068. set focalLength(value: number);
  71069. get focalLength(): number;
  71070. /**
  71071. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71072. */
  71073. set fStop(value: number);
  71074. get fStop(): number;
  71075. /**
  71076. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71077. */
  71078. set focusDistance(value: number);
  71079. get focusDistance(): number;
  71080. /**
  71081. * 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.
  71082. */
  71083. set lensSize(value: number);
  71084. get lensSize(): number;
  71085. /**
  71086. * Creates a new instance DepthOfFieldEffect
  71087. * @param scene The scene the effect belongs to.
  71088. * @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.
  71089. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71090. * @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)
  71091. */
  71092. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71093. /**
  71094. * Get the current class name of the current effet
  71095. * @returns "DepthOfFieldEffect"
  71096. */
  71097. getClassName(): string;
  71098. /**
  71099. * 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.
  71100. */
  71101. set depthTexture(value: RenderTargetTexture);
  71102. /**
  71103. * Disposes each of the internal effects for a given camera.
  71104. * @param camera The camera to dispose the effect on.
  71105. */
  71106. disposeEffects(camera: Camera): void;
  71107. /**
  71108. * @hidden Internal
  71109. */
  71110. _updateEffects(): void;
  71111. /**
  71112. * Internal
  71113. * @returns if all the contained post processes are ready.
  71114. * @hidden
  71115. */
  71116. _isReady(): boolean;
  71117. }
  71118. }
  71119. declare module BABYLON {
  71120. /** @hidden */
  71121. export var displayPassPixelShader: {
  71122. name: string;
  71123. shader: string;
  71124. };
  71125. }
  71126. declare module BABYLON {
  71127. /**
  71128. * DisplayPassPostProcess which produces an output the same as it's input
  71129. */
  71130. export class DisplayPassPostProcess extends PostProcess {
  71131. /**
  71132. * Gets a string identifying the name of the class
  71133. * @returns "DisplayPassPostProcess" string
  71134. */
  71135. getClassName(): string;
  71136. /**
  71137. * Creates the DisplayPassPostProcess
  71138. * @param name The name of the effect.
  71139. * @param options The required width/height ratio to downsize to before computing the render pass.
  71140. * @param camera The camera to apply the render pass to.
  71141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71142. * @param engine The engine which the post process will be applied. (default: current engine)
  71143. * @param reusable If the post process can be reused on the same frame. (default: false)
  71144. */
  71145. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71146. /** @hidden */
  71147. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71148. }
  71149. }
  71150. declare module BABYLON {
  71151. /** @hidden */
  71152. export var filterPixelShader: {
  71153. name: string;
  71154. shader: string;
  71155. };
  71156. }
  71157. declare module BABYLON {
  71158. /**
  71159. * Applies a kernel filter to the image
  71160. */
  71161. export class FilterPostProcess extends PostProcess {
  71162. /** The matrix to be applied to the image */
  71163. kernelMatrix: Matrix;
  71164. /**
  71165. * Gets a string identifying the name of the class
  71166. * @returns "FilterPostProcess" string
  71167. */
  71168. getClassName(): string;
  71169. /**
  71170. *
  71171. * @param name The name of the effect.
  71172. * @param kernelMatrix The matrix to be applied to the image
  71173. * @param options The required width/height ratio to downsize to before computing the render pass.
  71174. * @param camera The camera to apply the render pass to.
  71175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71176. * @param engine The engine which the post process will be applied. (default: current engine)
  71177. * @param reusable If the post process can be reused on the same frame. (default: false)
  71178. */
  71179. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71180. /** @hidden */
  71181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71182. }
  71183. }
  71184. declare module BABYLON {
  71185. /** @hidden */
  71186. export var fxaaPixelShader: {
  71187. name: string;
  71188. shader: string;
  71189. };
  71190. }
  71191. declare module BABYLON {
  71192. /** @hidden */
  71193. export var fxaaVertexShader: {
  71194. name: string;
  71195. shader: string;
  71196. };
  71197. }
  71198. declare module BABYLON {
  71199. /**
  71200. * Fxaa post process
  71201. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71202. */
  71203. export class FxaaPostProcess extends PostProcess {
  71204. /**
  71205. * Gets a string identifying the name of the class
  71206. * @returns "FxaaPostProcess" string
  71207. */
  71208. getClassName(): string;
  71209. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71210. private _getDefines;
  71211. /** @hidden */
  71212. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71213. }
  71214. }
  71215. declare module BABYLON {
  71216. /** @hidden */
  71217. export var grainPixelShader: {
  71218. name: string;
  71219. shader: string;
  71220. };
  71221. }
  71222. declare module BABYLON {
  71223. /**
  71224. * The GrainPostProcess adds noise to the image at mid luminance levels
  71225. */
  71226. export class GrainPostProcess extends PostProcess {
  71227. /**
  71228. * The intensity of the grain added (default: 30)
  71229. */
  71230. intensity: number;
  71231. /**
  71232. * If the grain should be randomized on every frame
  71233. */
  71234. animated: boolean;
  71235. /**
  71236. * Gets a string identifying the name of the class
  71237. * @returns "GrainPostProcess" string
  71238. */
  71239. getClassName(): string;
  71240. /**
  71241. * Creates a new instance of @see GrainPostProcess
  71242. * @param name The name of the effect.
  71243. * @param options The required width/height ratio to downsize to before computing the render pass.
  71244. * @param camera The camera to apply the render pass to.
  71245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71246. * @param engine The engine which the post process will be applied. (default: current engine)
  71247. * @param reusable If the post process can be reused on the same frame. (default: false)
  71248. * @param textureType Type of textures used when performing the post process. (default: 0)
  71249. * @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)
  71250. */
  71251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71252. /** @hidden */
  71253. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71254. }
  71255. }
  71256. declare module BABYLON {
  71257. /** @hidden */
  71258. export var highlightsPixelShader: {
  71259. name: string;
  71260. shader: string;
  71261. };
  71262. }
  71263. declare module BABYLON {
  71264. /**
  71265. * Extracts highlights from the image
  71266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71267. */
  71268. export class HighlightsPostProcess extends PostProcess {
  71269. /**
  71270. * Gets a string identifying the name of the class
  71271. * @returns "HighlightsPostProcess" string
  71272. */
  71273. getClassName(): string;
  71274. /**
  71275. * Extracts highlights from the image
  71276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71277. * @param name The name of the effect.
  71278. * @param options The required width/height ratio to downsize to before computing the render pass.
  71279. * @param camera The camera to apply the render pass to.
  71280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71281. * @param engine The engine which the post process will be applied. (default: current engine)
  71282. * @param reusable If the post process can be reused on the same frame. (default: false)
  71283. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71284. */
  71285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71286. }
  71287. }
  71288. declare module BABYLON {
  71289. /**
  71290. * Contains all parameters needed for the prepass to perform
  71291. * motion blur
  71292. */
  71293. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71294. /**
  71295. * Is motion blur enabled
  71296. */
  71297. enabled: boolean;
  71298. /**
  71299. * Name of the configuration
  71300. */
  71301. name: string;
  71302. /**
  71303. * Textures that should be present in the MRT for this effect to work
  71304. */
  71305. readonly texturesRequired: number[];
  71306. }
  71307. }
  71308. declare module BABYLON {
  71309. interface Scene {
  71310. /** @hidden (Backing field) */
  71311. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71312. /**
  71313. * Gets or Sets the current geometry buffer associated to the scene.
  71314. */
  71315. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71316. /**
  71317. * Enables a GeometryBufferRender and associates it with the scene
  71318. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71319. * @returns the GeometryBufferRenderer
  71320. */
  71321. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71322. /**
  71323. * Disables the GeometryBufferRender associated with the scene
  71324. */
  71325. disableGeometryBufferRenderer(): void;
  71326. }
  71327. /**
  71328. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71329. * in several rendering techniques.
  71330. */
  71331. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71332. /**
  71333. * The component name helpful to identify the component in the list of scene components.
  71334. */
  71335. readonly name: string;
  71336. /**
  71337. * The scene the component belongs to.
  71338. */
  71339. scene: Scene;
  71340. /**
  71341. * Creates a new instance of the component for the given scene
  71342. * @param scene Defines the scene to register the component in
  71343. */
  71344. constructor(scene: Scene);
  71345. /**
  71346. * Registers the component in a given scene
  71347. */
  71348. register(): void;
  71349. /**
  71350. * Rebuilds the elements related to this component in case of
  71351. * context lost for instance.
  71352. */
  71353. rebuild(): void;
  71354. /**
  71355. * Disposes the component and the associated ressources
  71356. */
  71357. dispose(): void;
  71358. private _gatherRenderTargets;
  71359. }
  71360. }
  71361. declare module BABYLON {
  71362. /** @hidden */
  71363. export var motionBlurPixelShader: {
  71364. name: string;
  71365. shader: string;
  71366. };
  71367. }
  71368. declare module BABYLON {
  71369. /**
  71370. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71371. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71372. * As an example, all you have to do is to create the post-process:
  71373. * var mb = new BABYLON.MotionBlurPostProcess(
  71374. * 'mb', // The name of the effect.
  71375. * scene, // The scene containing the objects to blur according to their velocity.
  71376. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71377. * camera // The camera to apply the render pass to.
  71378. * );
  71379. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71380. */
  71381. export class MotionBlurPostProcess extends PostProcess {
  71382. /**
  71383. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71384. */
  71385. motionStrength: number;
  71386. /**
  71387. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71388. */
  71389. get motionBlurSamples(): number;
  71390. /**
  71391. * Sets the number of iterations to be used for motion blur quality
  71392. */
  71393. set motionBlurSamples(samples: number);
  71394. private _motionBlurSamples;
  71395. /**
  71396. * Gets wether or not the motion blur post-process is in object based mode.
  71397. */
  71398. get isObjectBased(): boolean;
  71399. /**
  71400. * Sets wether or not the motion blur post-process is in object based mode.
  71401. */
  71402. set isObjectBased(value: boolean);
  71403. private _isObjectBased;
  71404. private _forceGeometryBuffer;
  71405. private _geometryBufferRenderer;
  71406. private _prePassRenderer;
  71407. private _invViewProjection;
  71408. private _previousViewProjection;
  71409. /**
  71410. * Gets a string identifying the name of the class
  71411. * @returns "MotionBlurPostProcess" string
  71412. */
  71413. getClassName(): string;
  71414. /**
  71415. * Creates a new instance MotionBlurPostProcess
  71416. * @param name The name of the effect.
  71417. * @param scene The scene containing the objects to blur according to their velocity.
  71418. * @param options The required width/height ratio to downsize to before computing the render pass.
  71419. * @param camera The camera to apply the render pass to.
  71420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71421. * @param engine The engine which the post process will be applied. (default: current engine)
  71422. * @param reusable If the post process can be reused on the same frame. (default: false)
  71423. * @param textureType Type of textures used when performing the post process. (default: 0)
  71424. * @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)
  71425. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71426. */
  71427. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71428. /**
  71429. * Excludes the given skinned mesh from computing bones velocities.
  71430. * 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.
  71431. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71432. */
  71433. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71434. /**
  71435. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71436. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71437. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71438. */
  71439. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71440. /**
  71441. * Disposes the post process.
  71442. * @param camera The camera to dispose the post process on.
  71443. */
  71444. dispose(camera?: Camera): void;
  71445. /**
  71446. * Called on the mode changed (object based or screen based).
  71447. */
  71448. private _applyMode;
  71449. /**
  71450. * Called on the effect is applied when the motion blur post-process is in object based mode.
  71451. */
  71452. private _onApplyObjectBased;
  71453. /**
  71454. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  71455. */
  71456. private _onApplyScreenBased;
  71457. /**
  71458. * Called on the effect must be updated (changed mode, samples count, etc.).
  71459. */
  71460. private _updateEffect;
  71461. /** @hidden */
  71462. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71463. }
  71464. }
  71465. declare module BABYLON {
  71466. /** @hidden */
  71467. export var refractionPixelShader: {
  71468. name: string;
  71469. shader: string;
  71470. };
  71471. }
  71472. declare module BABYLON {
  71473. /**
  71474. * Post process which applies a refractin texture
  71475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71476. */
  71477. export class RefractionPostProcess extends PostProcess {
  71478. private _refTexture;
  71479. private _ownRefractionTexture;
  71480. /** the base color of the refraction (used to taint the rendering) */
  71481. color: Color3;
  71482. /** simulated refraction depth */
  71483. depth: number;
  71484. /** the coefficient of the base color (0 to remove base color tainting) */
  71485. colorLevel: number;
  71486. /** Gets the url used to load the refraction texture */
  71487. refractionTextureUrl: string;
  71488. /**
  71489. * Gets or sets the refraction texture
  71490. * Please note that you are responsible for disposing the texture if you set it manually
  71491. */
  71492. get refractionTexture(): Texture;
  71493. set refractionTexture(value: Texture);
  71494. /**
  71495. * Gets a string identifying the name of the class
  71496. * @returns "RefractionPostProcess" string
  71497. */
  71498. getClassName(): string;
  71499. /**
  71500. * Initializes the RefractionPostProcess
  71501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71502. * @param name The name of the effect.
  71503. * @param refractionTextureUrl Url of the refraction texture to use
  71504. * @param color the base color of the refraction (used to taint the rendering)
  71505. * @param depth simulated refraction depth
  71506. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71507. * @param camera The camera to apply the render pass to.
  71508. * @param options The required width/height ratio to downsize to before computing the render pass.
  71509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71510. * @param engine The engine which the post process will be applied. (default: current engine)
  71511. * @param reusable If the post process can be reused on the same frame. (default: false)
  71512. */
  71513. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71514. /**
  71515. * Disposes of the post process
  71516. * @param camera Camera to dispose post process on
  71517. */
  71518. dispose(camera: Camera): void;
  71519. /** @hidden */
  71520. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71521. }
  71522. }
  71523. declare module BABYLON {
  71524. /** @hidden */
  71525. export var sharpenPixelShader: {
  71526. name: string;
  71527. shader: string;
  71528. };
  71529. }
  71530. declare module BABYLON {
  71531. /**
  71532. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71533. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71534. */
  71535. export class SharpenPostProcess extends PostProcess {
  71536. /**
  71537. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71538. */
  71539. colorAmount: number;
  71540. /**
  71541. * How much sharpness should be applied (default: 0.3)
  71542. */
  71543. edgeAmount: number;
  71544. /**
  71545. * Gets a string identifying the name of the class
  71546. * @returns "SharpenPostProcess" string
  71547. */
  71548. getClassName(): string;
  71549. /**
  71550. * Creates a new instance ConvolutionPostProcess
  71551. * @param name The name of the effect.
  71552. * @param options The required width/height ratio to downsize to before computing the render pass.
  71553. * @param camera The camera to apply the render pass to.
  71554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71555. * @param engine The engine which the post process will be applied. (default: current engine)
  71556. * @param reusable If the post process can be reused on the same frame. (default: false)
  71557. * @param textureType Type of textures used when performing the post process. (default: 0)
  71558. * @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)
  71559. */
  71560. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71561. /** @hidden */
  71562. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71563. }
  71564. }
  71565. declare module BABYLON {
  71566. /**
  71567. * PostProcessRenderPipeline
  71568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71569. */
  71570. export class PostProcessRenderPipeline {
  71571. private engine;
  71572. private _renderEffects;
  71573. private _renderEffectsForIsolatedPass;
  71574. /**
  71575. * List of inspectable custom properties (used by the Inspector)
  71576. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71577. */
  71578. inspectableCustomProperties: IInspectable[];
  71579. /**
  71580. * @hidden
  71581. */
  71582. protected _cameras: Camera[];
  71583. /** @hidden */
  71584. _name: string;
  71585. /**
  71586. * Gets pipeline name
  71587. */
  71588. get name(): string;
  71589. /** Gets the list of attached cameras */
  71590. get cameras(): Camera[];
  71591. /**
  71592. * Initializes a PostProcessRenderPipeline
  71593. * @param engine engine to add the pipeline to
  71594. * @param name name of the pipeline
  71595. */
  71596. constructor(engine: Engine, name: string);
  71597. /**
  71598. * Gets the class name
  71599. * @returns "PostProcessRenderPipeline"
  71600. */
  71601. getClassName(): string;
  71602. /**
  71603. * If all the render effects in the pipeline are supported
  71604. */
  71605. get isSupported(): boolean;
  71606. /**
  71607. * Adds an effect to the pipeline
  71608. * @param renderEffect the effect to add
  71609. */
  71610. addEffect(renderEffect: PostProcessRenderEffect): void;
  71611. /** @hidden */
  71612. _rebuild(): void;
  71613. /** @hidden */
  71614. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71615. /** @hidden */
  71616. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71617. /** @hidden */
  71618. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71619. /** @hidden */
  71620. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71621. /** @hidden */
  71622. _attachCameras(cameras: Camera, unique: boolean): void;
  71623. /** @hidden */
  71624. _attachCameras(cameras: Camera[], unique: boolean): void;
  71625. /** @hidden */
  71626. _detachCameras(cameras: Camera): void;
  71627. /** @hidden */
  71628. _detachCameras(cameras: Nullable<Camera[]>): void;
  71629. /** @hidden */
  71630. _update(): void;
  71631. /** @hidden */
  71632. _reset(): void;
  71633. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71634. /**
  71635. * Sets the required values to the prepass renderer.
  71636. * @param prePassRenderer defines the prepass renderer to setup.
  71637. * @returns true if the pre pass is needed.
  71638. */
  71639. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71640. /**
  71641. * Disposes of the pipeline
  71642. */
  71643. dispose(): void;
  71644. }
  71645. }
  71646. declare module BABYLON {
  71647. /**
  71648. * PostProcessRenderPipelineManager class
  71649. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71650. */
  71651. export class PostProcessRenderPipelineManager {
  71652. private _renderPipelines;
  71653. /**
  71654. * Initializes a PostProcessRenderPipelineManager
  71655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71656. */
  71657. constructor();
  71658. /**
  71659. * Gets the list of supported render pipelines
  71660. */
  71661. get supportedPipelines(): PostProcessRenderPipeline[];
  71662. /**
  71663. * Adds a pipeline to the manager
  71664. * @param renderPipeline The pipeline to add
  71665. */
  71666. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71667. /**
  71668. * Attaches a camera to the pipeline
  71669. * @param renderPipelineName The name of the pipeline to attach to
  71670. * @param cameras the camera to attach
  71671. * @param unique if the camera can be attached multiple times to the pipeline
  71672. */
  71673. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71674. /**
  71675. * Detaches a camera from the pipeline
  71676. * @param renderPipelineName The name of the pipeline to detach from
  71677. * @param cameras the camera to detach
  71678. */
  71679. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71680. /**
  71681. * Enables an effect by name on a pipeline
  71682. * @param renderPipelineName the name of the pipeline to enable the effect in
  71683. * @param renderEffectName the name of the effect to enable
  71684. * @param cameras the cameras that the effect should be enabled on
  71685. */
  71686. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71687. /**
  71688. * Disables an effect by name on a pipeline
  71689. * @param renderPipelineName the name of the pipeline to disable the effect in
  71690. * @param renderEffectName the name of the effect to disable
  71691. * @param cameras the cameras that the effect should be disabled on
  71692. */
  71693. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71694. /**
  71695. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71696. */
  71697. update(): void;
  71698. /** @hidden */
  71699. _rebuild(): void;
  71700. /**
  71701. * Disposes of the manager and pipelines
  71702. */
  71703. dispose(): void;
  71704. }
  71705. }
  71706. declare module BABYLON {
  71707. interface Scene {
  71708. /** @hidden (Backing field) */
  71709. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71710. /**
  71711. * Gets the postprocess render pipeline manager
  71712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71713. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71714. */
  71715. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71716. }
  71717. /**
  71718. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71719. */
  71720. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71721. /**
  71722. * The component name helpfull to identify the component in the list of scene components.
  71723. */
  71724. readonly name: string;
  71725. /**
  71726. * The scene the component belongs to.
  71727. */
  71728. scene: Scene;
  71729. /**
  71730. * Creates a new instance of the component for the given scene
  71731. * @param scene Defines the scene to register the component in
  71732. */
  71733. constructor(scene: Scene);
  71734. /**
  71735. * Registers the component in a given scene
  71736. */
  71737. register(): void;
  71738. /**
  71739. * Rebuilds the elements related to this component in case of
  71740. * context lost for instance.
  71741. */
  71742. rebuild(): void;
  71743. /**
  71744. * Disposes the component and the associated ressources
  71745. */
  71746. dispose(): void;
  71747. private _gatherRenderTargets;
  71748. }
  71749. }
  71750. declare module BABYLON {
  71751. /**
  71752. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71753. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71754. */
  71755. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71756. private _scene;
  71757. private _camerasToBeAttached;
  71758. /**
  71759. * ID of the sharpen post process,
  71760. */
  71761. private readonly SharpenPostProcessId;
  71762. /**
  71763. * @ignore
  71764. * ID of the image processing post process;
  71765. */
  71766. readonly ImageProcessingPostProcessId: string;
  71767. /**
  71768. * @ignore
  71769. * ID of the Fast Approximate Anti-Aliasing post process;
  71770. */
  71771. readonly FxaaPostProcessId: string;
  71772. /**
  71773. * ID of the chromatic aberration post process,
  71774. */
  71775. private readonly ChromaticAberrationPostProcessId;
  71776. /**
  71777. * ID of the grain post process
  71778. */
  71779. private readonly GrainPostProcessId;
  71780. /**
  71781. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71782. */
  71783. sharpen: SharpenPostProcess;
  71784. private _sharpenEffect;
  71785. private bloom;
  71786. /**
  71787. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71788. */
  71789. depthOfField: DepthOfFieldEffect;
  71790. /**
  71791. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71792. */
  71793. fxaa: FxaaPostProcess;
  71794. /**
  71795. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71796. */
  71797. imageProcessing: ImageProcessingPostProcess;
  71798. /**
  71799. * Chromatic aberration post process which will shift rgb colors in the image
  71800. */
  71801. chromaticAberration: ChromaticAberrationPostProcess;
  71802. private _chromaticAberrationEffect;
  71803. /**
  71804. * Grain post process which add noise to the image
  71805. */
  71806. grain: GrainPostProcess;
  71807. private _grainEffect;
  71808. /**
  71809. * Glow post process which adds a glow to emissive areas of the image
  71810. */
  71811. private _glowLayer;
  71812. /**
  71813. * Animations which can be used to tweak settings over a period of time
  71814. */
  71815. animations: Animation[];
  71816. private _imageProcessingConfigurationObserver;
  71817. private _sharpenEnabled;
  71818. private _bloomEnabled;
  71819. private _depthOfFieldEnabled;
  71820. private _depthOfFieldBlurLevel;
  71821. private _fxaaEnabled;
  71822. private _imageProcessingEnabled;
  71823. private _defaultPipelineTextureType;
  71824. private _bloomScale;
  71825. private _chromaticAberrationEnabled;
  71826. private _grainEnabled;
  71827. private _buildAllowed;
  71828. /**
  71829. * This is triggered each time the pipeline has been built.
  71830. */
  71831. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71832. /**
  71833. * Gets active scene
  71834. */
  71835. get scene(): Scene;
  71836. /**
  71837. * Enable or disable the sharpen process from the pipeline
  71838. */
  71839. set sharpenEnabled(enabled: boolean);
  71840. get sharpenEnabled(): boolean;
  71841. private _resizeObserver;
  71842. private _hardwareScaleLevel;
  71843. private _bloomKernel;
  71844. /**
  71845. * Specifies the size of the bloom blur kernel, relative to the final output size
  71846. */
  71847. get bloomKernel(): number;
  71848. set bloomKernel(value: number);
  71849. /**
  71850. * Specifies the weight of the bloom in the final rendering
  71851. */
  71852. private _bloomWeight;
  71853. /**
  71854. * Specifies the luma threshold for the area that will be blurred by the bloom
  71855. */
  71856. private _bloomThreshold;
  71857. private _hdr;
  71858. /**
  71859. * The strength of the bloom.
  71860. */
  71861. set bloomWeight(value: number);
  71862. get bloomWeight(): number;
  71863. /**
  71864. * The strength of the bloom.
  71865. */
  71866. set bloomThreshold(value: number);
  71867. get bloomThreshold(): number;
  71868. /**
  71869. * The scale of the bloom, lower value will provide better performance.
  71870. */
  71871. set bloomScale(value: number);
  71872. get bloomScale(): number;
  71873. /**
  71874. * Enable or disable the bloom from the pipeline
  71875. */
  71876. set bloomEnabled(enabled: boolean);
  71877. get bloomEnabled(): boolean;
  71878. private _rebuildBloom;
  71879. /**
  71880. * If the depth of field is enabled.
  71881. */
  71882. get depthOfFieldEnabled(): boolean;
  71883. set depthOfFieldEnabled(enabled: boolean);
  71884. /**
  71885. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71886. */
  71887. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71888. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71889. /**
  71890. * If the anti aliasing is enabled.
  71891. */
  71892. set fxaaEnabled(enabled: boolean);
  71893. get fxaaEnabled(): boolean;
  71894. private _samples;
  71895. /**
  71896. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71897. */
  71898. set samples(sampleCount: number);
  71899. get samples(): number;
  71900. /**
  71901. * If image processing is enabled.
  71902. */
  71903. set imageProcessingEnabled(enabled: boolean);
  71904. get imageProcessingEnabled(): boolean;
  71905. /**
  71906. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71907. */
  71908. set glowLayerEnabled(enabled: boolean);
  71909. get glowLayerEnabled(): boolean;
  71910. /**
  71911. * Gets the glow layer (or null if not defined)
  71912. */
  71913. get glowLayer(): Nullable<GlowLayer>;
  71914. /**
  71915. * Enable or disable the chromaticAberration process from the pipeline
  71916. */
  71917. set chromaticAberrationEnabled(enabled: boolean);
  71918. get chromaticAberrationEnabled(): boolean;
  71919. /**
  71920. * Enable or disable the grain process from the pipeline
  71921. */
  71922. set grainEnabled(enabled: boolean);
  71923. get grainEnabled(): boolean;
  71924. /**
  71925. * @constructor
  71926. * @param name - The rendering pipeline name (default: "")
  71927. * @param hdr - If high dynamic range textures should be used (default: true)
  71928. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71929. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71930. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71931. */
  71932. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71933. /**
  71934. * Get the class name
  71935. * @returns "DefaultRenderingPipeline"
  71936. */
  71937. getClassName(): string;
  71938. /**
  71939. * Force the compilation of the entire pipeline.
  71940. */
  71941. prepare(): void;
  71942. private _hasCleared;
  71943. private _prevPostProcess;
  71944. private _prevPrevPostProcess;
  71945. private _setAutoClearAndTextureSharing;
  71946. private _depthOfFieldSceneObserver;
  71947. private _buildPipeline;
  71948. private _disposePostProcesses;
  71949. /**
  71950. * Adds a camera to the pipeline
  71951. * @param camera the camera to be added
  71952. */
  71953. addCamera(camera: Camera): void;
  71954. /**
  71955. * Removes a camera from the pipeline
  71956. * @param camera the camera to remove
  71957. */
  71958. removeCamera(camera: Camera): void;
  71959. /**
  71960. * Dispose of the pipeline and stop all post processes
  71961. */
  71962. dispose(): void;
  71963. /**
  71964. * Serialize the rendering pipeline (Used when exporting)
  71965. * @returns the serialized object
  71966. */
  71967. serialize(): any;
  71968. /**
  71969. * Parse the serialized pipeline
  71970. * @param source Source pipeline.
  71971. * @param scene The scene to load the pipeline to.
  71972. * @param rootUrl The URL of the serialized pipeline.
  71973. * @returns An instantiated pipeline from the serialized object.
  71974. */
  71975. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71976. }
  71977. }
  71978. declare module BABYLON {
  71979. /** @hidden */
  71980. export var lensHighlightsPixelShader: {
  71981. name: string;
  71982. shader: string;
  71983. };
  71984. }
  71985. declare module BABYLON {
  71986. /** @hidden */
  71987. export var depthOfFieldPixelShader: {
  71988. name: string;
  71989. shader: string;
  71990. };
  71991. }
  71992. declare module BABYLON {
  71993. /**
  71994. * BABYLON.JS Chromatic Aberration GLSL Shader
  71995. * Author: Olivier Guyot
  71996. * Separates very slightly R, G and B colors on the edges of the screen
  71997. * Inspired by Francois Tarlier & Martins Upitis
  71998. */
  71999. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72000. /**
  72001. * @ignore
  72002. * The chromatic aberration PostProcess id in the pipeline
  72003. */
  72004. LensChromaticAberrationEffect: string;
  72005. /**
  72006. * @ignore
  72007. * The highlights enhancing PostProcess id in the pipeline
  72008. */
  72009. HighlightsEnhancingEffect: string;
  72010. /**
  72011. * @ignore
  72012. * The depth-of-field PostProcess id in the pipeline
  72013. */
  72014. LensDepthOfFieldEffect: string;
  72015. private _scene;
  72016. private _depthTexture;
  72017. private _grainTexture;
  72018. private _chromaticAberrationPostProcess;
  72019. private _highlightsPostProcess;
  72020. private _depthOfFieldPostProcess;
  72021. private _edgeBlur;
  72022. private _grainAmount;
  72023. private _chromaticAberration;
  72024. private _distortion;
  72025. private _highlightsGain;
  72026. private _highlightsThreshold;
  72027. private _dofDistance;
  72028. private _dofAperture;
  72029. private _dofDarken;
  72030. private _dofPentagon;
  72031. private _blurNoise;
  72032. /**
  72033. * @constructor
  72034. *
  72035. * Effect parameters are as follow:
  72036. * {
  72037. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72038. * edge_blur: number; // from 0 to x (1 for realism)
  72039. * distortion: number; // from 0 to x (1 for realism)
  72040. * grain_amount: number; // from 0 to 1
  72041. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72042. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72043. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72044. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72045. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72046. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72047. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72048. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72049. * }
  72050. * Note: if an effect parameter is unset, effect is disabled
  72051. *
  72052. * @param name The rendering pipeline name
  72053. * @param parameters - An object containing all parameters (see above)
  72054. * @param scene The scene linked to this pipeline
  72055. * @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)
  72056. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72057. */
  72058. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72059. /**
  72060. * Get the class name
  72061. * @returns "LensRenderingPipeline"
  72062. */
  72063. getClassName(): string;
  72064. /**
  72065. * Gets associated scene
  72066. */
  72067. get scene(): Scene;
  72068. /**
  72069. * Gets or sets the edge blur
  72070. */
  72071. get edgeBlur(): number;
  72072. set edgeBlur(value: number);
  72073. /**
  72074. * Gets or sets the grain amount
  72075. */
  72076. get grainAmount(): number;
  72077. set grainAmount(value: number);
  72078. /**
  72079. * Gets or sets the chromatic aberration amount
  72080. */
  72081. get chromaticAberration(): number;
  72082. set chromaticAberration(value: number);
  72083. /**
  72084. * Gets or sets the depth of field aperture
  72085. */
  72086. get dofAperture(): number;
  72087. set dofAperture(value: number);
  72088. /**
  72089. * Gets or sets the edge distortion
  72090. */
  72091. get edgeDistortion(): number;
  72092. set edgeDistortion(value: number);
  72093. /**
  72094. * Gets or sets the depth of field distortion
  72095. */
  72096. get dofDistortion(): number;
  72097. set dofDistortion(value: number);
  72098. /**
  72099. * Gets or sets the darken out of focus amount
  72100. */
  72101. get darkenOutOfFocus(): number;
  72102. set darkenOutOfFocus(value: number);
  72103. /**
  72104. * Gets or sets a boolean indicating if blur noise is enabled
  72105. */
  72106. get blurNoise(): boolean;
  72107. set blurNoise(value: boolean);
  72108. /**
  72109. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72110. */
  72111. get pentagonBokeh(): boolean;
  72112. set pentagonBokeh(value: boolean);
  72113. /**
  72114. * Gets or sets the highlight grain amount
  72115. */
  72116. get highlightsGain(): number;
  72117. set highlightsGain(value: number);
  72118. /**
  72119. * Gets or sets the highlight threshold
  72120. */
  72121. get highlightsThreshold(): number;
  72122. set highlightsThreshold(value: number);
  72123. /**
  72124. * Sets the amount of blur at the edges
  72125. * @param amount blur amount
  72126. */
  72127. setEdgeBlur(amount: number): void;
  72128. /**
  72129. * Sets edge blur to 0
  72130. */
  72131. disableEdgeBlur(): void;
  72132. /**
  72133. * Sets the amout of grain
  72134. * @param amount Amount of grain
  72135. */
  72136. setGrainAmount(amount: number): void;
  72137. /**
  72138. * Set grain amount to 0
  72139. */
  72140. disableGrain(): void;
  72141. /**
  72142. * Sets the chromatic aberration amount
  72143. * @param amount amount of chromatic aberration
  72144. */
  72145. setChromaticAberration(amount: number): void;
  72146. /**
  72147. * Sets chromatic aberration amount to 0
  72148. */
  72149. disableChromaticAberration(): void;
  72150. /**
  72151. * Sets the EdgeDistortion amount
  72152. * @param amount amount of EdgeDistortion
  72153. */
  72154. setEdgeDistortion(amount: number): void;
  72155. /**
  72156. * Sets edge distortion to 0
  72157. */
  72158. disableEdgeDistortion(): void;
  72159. /**
  72160. * Sets the FocusDistance amount
  72161. * @param amount amount of FocusDistance
  72162. */
  72163. setFocusDistance(amount: number): void;
  72164. /**
  72165. * Disables depth of field
  72166. */
  72167. disableDepthOfField(): void;
  72168. /**
  72169. * Sets the Aperture amount
  72170. * @param amount amount of Aperture
  72171. */
  72172. setAperture(amount: number): void;
  72173. /**
  72174. * Sets the DarkenOutOfFocus amount
  72175. * @param amount amount of DarkenOutOfFocus
  72176. */
  72177. setDarkenOutOfFocus(amount: number): void;
  72178. private _pentagonBokehIsEnabled;
  72179. /**
  72180. * Creates a pentagon bokeh effect
  72181. */
  72182. enablePentagonBokeh(): void;
  72183. /**
  72184. * Disables the pentagon bokeh effect
  72185. */
  72186. disablePentagonBokeh(): void;
  72187. /**
  72188. * Enables noise blur
  72189. */
  72190. enableNoiseBlur(): void;
  72191. /**
  72192. * Disables noise blur
  72193. */
  72194. disableNoiseBlur(): void;
  72195. /**
  72196. * Sets the HighlightsGain amount
  72197. * @param amount amount of HighlightsGain
  72198. */
  72199. setHighlightsGain(amount: number): void;
  72200. /**
  72201. * Sets the HighlightsThreshold amount
  72202. * @param amount amount of HighlightsThreshold
  72203. */
  72204. setHighlightsThreshold(amount: number): void;
  72205. /**
  72206. * Disables highlights
  72207. */
  72208. disableHighlights(): void;
  72209. /**
  72210. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72211. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72212. */
  72213. dispose(disableDepthRender?: boolean): void;
  72214. private _createChromaticAberrationPostProcess;
  72215. private _createHighlightsPostProcess;
  72216. private _createDepthOfFieldPostProcess;
  72217. private _createGrainTexture;
  72218. }
  72219. }
  72220. declare module BABYLON {
  72221. /**
  72222. * Contains all parameters needed for the prepass to perform
  72223. * screen space subsurface scattering
  72224. */
  72225. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72226. /**
  72227. * Is subsurface enabled
  72228. */
  72229. enabled: boolean;
  72230. /**
  72231. * Name of the configuration
  72232. */
  72233. name: string;
  72234. /**
  72235. * Textures that should be present in the MRT for this effect to work
  72236. */
  72237. readonly texturesRequired: number[];
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /** @hidden */
  72242. export var ssao2PixelShader: {
  72243. name: string;
  72244. shader: string;
  72245. };
  72246. }
  72247. declare module BABYLON {
  72248. /** @hidden */
  72249. export var ssaoCombinePixelShader: {
  72250. name: string;
  72251. shader: string;
  72252. };
  72253. }
  72254. declare module BABYLON {
  72255. /**
  72256. * Render pipeline to produce ssao effect
  72257. */
  72258. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72259. /**
  72260. * @ignore
  72261. * The PassPostProcess id in the pipeline that contains the original scene color
  72262. */
  72263. SSAOOriginalSceneColorEffect: string;
  72264. /**
  72265. * @ignore
  72266. * The SSAO PostProcess id in the pipeline
  72267. */
  72268. SSAORenderEffect: string;
  72269. /**
  72270. * @ignore
  72271. * The horizontal blur PostProcess id in the pipeline
  72272. */
  72273. SSAOBlurHRenderEffect: string;
  72274. /**
  72275. * @ignore
  72276. * The vertical blur PostProcess id in the pipeline
  72277. */
  72278. SSAOBlurVRenderEffect: string;
  72279. /**
  72280. * @ignore
  72281. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72282. */
  72283. SSAOCombineRenderEffect: string;
  72284. /**
  72285. * The output strength of the SSAO post-process. Default value is 1.0.
  72286. */
  72287. totalStrength: number;
  72288. /**
  72289. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72290. */
  72291. maxZ: number;
  72292. /**
  72293. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72294. */
  72295. minZAspect: number;
  72296. private _samples;
  72297. /**
  72298. * Number of samples used for the SSAO calculations. Default value is 8
  72299. */
  72300. set samples(n: number);
  72301. get samples(): number;
  72302. private _textureSamples;
  72303. /**
  72304. * Number of samples to use for antialiasing
  72305. */
  72306. set textureSamples(n: number);
  72307. get textureSamples(): number;
  72308. /**
  72309. * Force rendering the geometry through geometry buffer
  72310. */
  72311. private _forceGeometryBuffer;
  72312. /**
  72313. * Ratio object used for SSAO ratio and blur ratio
  72314. */
  72315. private _ratio;
  72316. /**
  72317. * Dynamically generated sphere sampler.
  72318. */
  72319. private _sampleSphere;
  72320. /**
  72321. * Blur filter offsets
  72322. */
  72323. private _samplerOffsets;
  72324. private _expensiveBlur;
  72325. /**
  72326. * If bilateral blur should be used
  72327. */
  72328. set expensiveBlur(b: boolean);
  72329. get expensiveBlur(): boolean;
  72330. /**
  72331. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72332. */
  72333. radius: number;
  72334. /**
  72335. * The base color of the SSAO post-process
  72336. * The final result is "base + ssao" between [0, 1]
  72337. */
  72338. base: number;
  72339. /**
  72340. * Support test.
  72341. */
  72342. static get IsSupported(): boolean;
  72343. private _scene;
  72344. private _randomTexture;
  72345. private _originalColorPostProcess;
  72346. private _ssaoPostProcess;
  72347. private _blurHPostProcess;
  72348. private _blurVPostProcess;
  72349. private _ssaoCombinePostProcess;
  72350. private _prePassRenderer;
  72351. /**
  72352. * Gets active scene
  72353. */
  72354. get scene(): Scene;
  72355. /**
  72356. * @constructor
  72357. * @param name The rendering pipeline name
  72358. * @param scene The scene linked to this pipeline
  72359. * @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 }
  72360. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72361. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72362. */
  72363. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72364. /**
  72365. * Get the class name
  72366. * @returns "SSAO2RenderingPipeline"
  72367. */
  72368. getClassName(): string;
  72369. /**
  72370. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72371. */
  72372. dispose(disableGeometryBufferRenderer?: boolean): void;
  72373. private _createBlurPostProcess;
  72374. /** @hidden */
  72375. _rebuild(): void;
  72376. private _bits;
  72377. private _radicalInverse_VdC;
  72378. private _hammersley;
  72379. private _hemisphereSample_uniform;
  72380. private _generateHemisphere;
  72381. private _getDefinesForSSAO;
  72382. private _createSSAOPostProcess;
  72383. private _createSSAOCombinePostProcess;
  72384. private _createRandomTexture;
  72385. /**
  72386. * Serialize the rendering pipeline (Used when exporting)
  72387. * @returns the serialized object
  72388. */
  72389. serialize(): any;
  72390. /**
  72391. * Parse the serialized pipeline
  72392. * @param source Source pipeline.
  72393. * @param scene The scene to load the pipeline to.
  72394. * @param rootUrl The URL of the serialized pipeline.
  72395. * @returns An instantiated pipeline from the serialized object.
  72396. */
  72397. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72398. }
  72399. }
  72400. declare module BABYLON {
  72401. /** @hidden */
  72402. export var ssaoPixelShader: {
  72403. name: string;
  72404. shader: string;
  72405. };
  72406. }
  72407. declare module BABYLON {
  72408. /**
  72409. * Render pipeline to produce ssao effect
  72410. */
  72411. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72412. /**
  72413. * @ignore
  72414. * The PassPostProcess id in the pipeline that contains the original scene color
  72415. */
  72416. SSAOOriginalSceneColorEffect: string;
  72417. /**
  72418. * @ignore
  72419. * The SSAO PostProcess id in the pipeline
  72420. */
  72421. SSAORenderEffect: string;
  72422. /**
  72423. * @ignore
  72424. * The horizontal blur PostProcess id in the pipeline
  72425. */
  72426. SSAOBlurHRenderEffect: string;
  72427. /**
  72428. * @ignore
  72429. * The vertical blur PostProcess id in the pipeline
  72430. */
  72431. SSAOBlurVRenderEffect: string;
  72432. /**
  72433. * @ignore
  72434. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72435. */
  72436. SSAOCombineRenderEffect: string;
  72437. /**
  72438. * The output strength of the SSAO post-process. Default value is 1.0.
  72439. */
  72440. totalStrength: number;
  72441. /**
  72442. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72443. */
  72444. radius: number;
  72445. /**
  72446. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72447. * Must not be equal to fallOff and superior to fallOff.
  72448. * Default value is 0.0075
  72449. */
  72450. area: number;
  72451. /**
  72452. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72453. * Must not be equal to area and inferior to area.
  72454. * Default value is 0.000001
  72455. */
  72456. fallOff: number;
  72457. /**
  72458. * The base color of the SSAO post-process
  72459. * The final result is "base + ssao" between [0, 1]
  72460. */
  72461. base: number;
  72462. private _scene;
  72463. private _depthTexture;
  72464. private _randomTexture;
  72465. private _originalColorPostProcess;
  72466. private _ssaoPostProcess;
  72467. private _blurHPostProcess;
  72468. private _blurVPostProcess;
  72469. private _ssaoCombinePostProcess;
  72470. private _firstUpdate;
  72471. /**
  72472. * Gets active scene
  72473. */
  72474. get scene(): Scene;
  72475. /**
  72476. * @constructor
  72477. * @param name - The rendering pipeline name
  72478. * @param scene - The scene linked to this pipeline
  72479. * @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 }
  72480. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72481. */
  72482. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72483. /**
  72484. * Get the class name
  72485. * @returns "SSAORenderingPipeline"
  72486. */
  72487. getClassName(): string;
  72488. /**
  72489. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72490. */
  72491. dispose(disableDepthRender?: boolean): void;
  72492. private _createBlurPostProcess;
  72493. /** @hidden */
  72494. _rebuild(): void;
  72495. private _createSSAOPostProcess;
  72496. private _createSSAOCombinePostProcess;
  72497. private _createRandomTexture;
  72498. }
  72499. }
  72500. declare module BABYLON {
  72501. /**
  72502. * Contains all parameters needed for the prepass to perform
  72503. * screen space reflections
  72504. */
  72505. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72506. /**
  72507. * Is ssr enabled
  72508. */
  72509. enabled: boolean;
  72510. /**
  72511. * Name of the configuration
  72512. */
  72513. name: string;
  72514. /**
  72515. * Textures that should be present in the MRT for this effect to work
  72516. */
  72517. readonly texturesRequired: number[];
  72518. }
  72519. }
  72520. declare module BABYLON {
  72521. /** @hidden */
  72522. export var screenSpaceReflectionPixelShader: {
  72523. name: string;
  72524. shader: string;
  72525. };
  72526. }
  72527. declare module BABYLON {
  72528. /**
  72529. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72530. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72531. */
  72532. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72533. /**
  72534. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72535. */
  72536. threshold: number;
  72537. /**
  72538. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72539. */
  72540. strength: number;
  72541. /**
  72542. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72543. */
  72544. reflectionSpecularFalloffExponent: number;
  72545. /**
  72546. * 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]
  72547. */
  72548. step: number;
  72549. /**
  72550. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72551. */
  72552. roughnessFactor: number;
  72553. private _forceGeometryBuffer;
  72554. private _geometryBufferRenderer;
  72555. private _prePassRenderer;
  72556. private _enableSmoothReflections;
  72557. private _reflectionSamples;
  72558. private _smoothSteps;
  72559. /**
  72560. * Gets a string identifying the name of the class
  72561. * @returns "ScreenSpaceReflectionPostProcess" string
  72562. */
  72563. getClassName(): string;
  72564. /**
  72565. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72566. * @param name The name of the effect.
  72567. * @param scene The scene containing the objects to calculate reflections.
  72568. * @param options The required width/height ratio to downsize to before computing the render pass.
  72569. * @param camera The camera to apply the render pass to.
  72570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72571. * @param engine The engine which the post process will be applied. (default: current engine)
  72572. * @param reusable If the post process can be reused on the same frame. (default: false)
  72573. * @param textureType Type of textures used when performing the post process. (default: 0)
  72574. * @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)
  72575. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72576. */
  72577. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72578. /**
  72579. * Gets wether or not smoothing reflections is enabled.
  72580. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72581. */
  72582. get enableSmoothReflections(): boolean;
  72583. /**
  72584. * Sets wether or not smoothing reflections is enabled.
  72585. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72586. */
  72587. set enableSmoothReflections(enabled: boolean);
  72588. /**
  72589. * Gets the number of samples taken while computing reflections. More samples count is high,
  72590. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72591. */
  72592. get reflectionSamples(): number;
  72593. /**
  72594. * Sets the number of samples taken while computing reflections. More samples count is high,
  72595. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72596. */
  72597. set reflectionSamples(samples: number);
  72598. /**
  72599. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72600. * more the post-process will require GPU power and can generate a drop in FPS.
  72601. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72602. */
  72603. get smoothSteps(): number;
  72604. set smoothSteps(steps: number);
  72605. private _updateEffectDefines;
  72606. /** @hidden */
  72607. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72608. }
  72609. }
  72610. declare module BABYLON {
  72611. /** @hidden */
  72612. export var standardPixelShader: {
  72613. name: string;
  72614. shader: string;
  72615. };
  72616. }
  72617. declare module BABYLON {
  72618. /**
  72619. * Standard rendering pipeline
  72620. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72621. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72622. */
  72623. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72624. /**
  72625. * Public members
  72626. */
  72627. /**
  72628. * Post-process which contains the original scene color before the pipeline applies all the effects
  72629. */
  72630. originalPostProcess: Nullable<PostProcess>;
  72631. /**
  72632. * Post-process used to down scale an image x4
  72633. */
  72634. downSampleX4PostProcess: Nullable<PostProcess>;
  72635. /**
  72636. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72637. */
  72638. brightPassPostProcess: Nullable<PostProcess>;
  72639. /**
  72640. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72641. */
  72642. blurHPostProcesses: PostProcess[];
  72643. /**
  72644. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72645. */
  72646. blurVPostProcesses: PostProcess[];
  72647. /**
  72648. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72649. */
  72650. textureAdderPostProcess: Nullable<PostProcess>;
  72651. /**
  72652. * Post-process used to create volumetric lighting effect
  72653. */
  72654. volumetricLightPostProcess: Nullable<PostProcess>;
  72655. /**
  72656. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72657. */
  72658. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72659. /**
  72660. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72661. */
  72662. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72663. /**
  72664. * Post-process used to merge the volumetric light effect and the real scene color
  72665. */
  72666. volumetricLightMergePostProces: Nullable<PostProcess>;
  72667. /**
  72668. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72669. */
  72670. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72671. /**
  72672. * Base post-process used to calculate the average luminance of the final image for HDR
  72673. */
  72674. luminancePostProcess: Nullable<PostProcess>;
  72675. /**
  72676. * Post-processes used to create down sample post-processes in order to get
  72677. * the average luminance of the final image for HDR
  72678. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72679. */
  72680. luminanceDownSamplePostProcesses: PostProcess[];
  72681. /**
  72682. * Post-process used to create a HDR effect (light adaptation)
  72683. */
  72684. hdrPostProcess: Nullable<PostProcess>;
  72685. /**
  72686. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72687. */
  72688. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72689. /**
  72690. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72691. */
  72692. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72693. /**
  72694. * Post-process used to merge the final HDR post-process and the real scene color
  72695. */
  72696. hdrFinalPostProcess: Nullable<PostProcess>;
  72697. /**
  72698. * Post-process used to create a lens flare effect
  72699. */
  72700. lensFlarePostProcess: Nullable<PostProcess>;
  72701. /**
  72702. * Post-process that merges the result of the lens flare post-process and the real scene color
  72703. */
  72704. lensFlareComposePostProcess: Nullable<PostProcess>;
  72705. /**
  72706. * Post-process used to create a motion blur effect
  72707. */
  72708. motionBlurPostProcess: Nullable<PostProcess>;
  72709. /**
  72710. * Post-process used to create a depth of field effect
  72711. */
  72712. depthOfFieldPostProcess: Nullable<PostProcess>;
  72713. /**
  72714. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72715. */
  72716. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72717. /**
  72718. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72719. */
  72720. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72721. /**
  72722. * Represents the brightness threshold in order to configure the illuminated surfaces
  72723. */
  72724. brightThreshold: number;
  72725. /**
  72726. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72727. */
  72728. blurWidth: number;
  72729. /**
  72730. * Sets if the blur for highlighted surfaces must be only horizontal
  72731. */
  72732. horizontalBlur: boolean;
  72733. /**
  72734. * Gets the overall exposure used by the pipeline
  72735. */
  72736. get exposure(): number;
  72737. /**
  72738. * Sets the overall exposure used by the pipeline
  72739. */
  72740. set exposure(value: number);
  72741. /**
  72742. * Texture used typically to simulate "dirty" on camera lens
  72743. */
  72744. lensTexture: Nullable<Texture>;
  72745. /**
  72746. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72747. */
  72748. volumetricLightCoefficient: number;
  72749. /**
  72750. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72751. */
  72752. volumetricLightPower: number;
  72753. /**
  72754. * Used the set the blur intensity to smooth the volumetric lights
  72755. */
  72756. volumetricLightBlurScale: number;
  72757. /**
  72758. * Light (spot or directional) used to generate the volumetric lights rays
  72759. * The source light must have a shadow generate so the pipeline can get its
  72760. * depth map
  72761. */
  72762. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72763. /**
  72764. * For eye adaptation, represents the minimum luminance the eye can see
  72765. */
  72766. hdrMinimumLuminance: number;
  72767. /**
  72768. * For eye adaptation, represents the decrease luminance speed
  72769. */
  72770. hdrDecreaseRate: number;
  72771. /**
  72772. * For eye adaptation, represents the increase luminance speed
  72773. */
  72774. hdrIncreaseRate: number;
  72775. /**
  72776. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72777. */
  72778. get hdrAutoExposure(): boolean;
  72779. /**
  72780. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72781. */
  72782. set hdrAutoExposure(value: boolean);
  72783. /**
  72784. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72785. */
  72786. lensColorTexture: Nullable<Texture>;
  72787. /**
  72788. * The overall strengh for the lens flare effect
  72789. */
  72790. lensFlareStrength: number;
  72791. /**
  72792. * Dispersion coefficient for lens flare ghosts
  72793. */
  72794. lensFlareGhostDispersal: number;
  72795. /**
  72796. * Main lens flare halo width
  72797. */
  72798. lensFlareHaloWidth: number;
  72799. /**
  72800. * Based on the lens distortion effect, defines how much the lens flare result
  72801. * is distorted
  72802. */
  72803. lensFlareDistortionStrength: number;
  72804. /**
  72805. * Configures the blur intensity used for for lens flare (halo)
  72806. */
  72807. lensFlareBlurWidth: number;
  72808. /**
  72809. * Lens star texture must be used to simulate rays on the flares and is available
  72810. * in the documentation
  72811. */
  72812. lensStarTexture: Nullable<Texture>;
  72813. /**
  72814. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72815. * flare effect by taking account of the dirt texture
  72816. */
  72817. lensFlareDirtTexture: Nullable<Texture>;
  72818. /**
  72819. * Represents the focal length for the depth of field effect
  72820. */
  72821. depthOfFieldDistance: number;
  72822. /**
  72823. * Represents the blur intensity for the blurred part of the depth of field effect
  72824. */
  72825. depthOfFieldBlurWidth: number;
  72826. /**
  72827. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72828. */
  72829. get motionStrength(): number;
  72830. /**
  72831. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72832. */
  72833. set motionStrength(strength: number);
  72834. /**
  72835. * Gets wether or not the motion blur post-process is object based or screen based.
  72836. */
  72837. get objectBasedMotionBlur(): boolean;
  72838. /**
  72839. * Sets wether or not the motion blur post-process should be object based or screen based
  72840. */
  72841. set objectBasedMotionBlur(value: boolean);
  72842. /**
  72843. * List of animations for the pipeline (IAnimatable implementation)
  72844. */
  72845. animations: Animation[];
  72846. /**
  72847. * Private members
  72848. */
  72849. private _scene;
  72850. private _currentDepthOfFieldSource;
  72851. private _basePostProcess;
  72852. private _fixedExposure;
  72853. private _currentExposure;
  72854. private _hdrAutoExposure;
  72855. private _hdrCurrentLuminance;
  72856. private _motionStrength;
  72857. private _isObjectBasedMotionBlur;
  72858. private _floatTextureType;
  72859. private _camerasToBeAttached;
  72860. private _ratio;
  72861. private _bloomEnabled;
  72862. private _depthOfFieldEnabled;
  72863. private _vlsEnabled;
  72864. private _lensFlareEnabled;
  72865. private _hdrEnabled;
  72866. private _motionBlurEnabled;
  72867. private _fxaaEnabled;
  72868. private _screenSpaceReflectionsEnabled;
  72869. private _motionBlurSamples;
  72870. private _volumetricLightStepsCount;
  72871. private _samples;
  72872. /**
  72873. * @ignore
  72874. * Specifies if the bloom pipeline is enabled
  72875. */
  72876. get BloomEnabled(): boolean;
  72877. set BloomEnabled(enabled: boolean);
  72878. /**
  72879. * @ignore
  72880. * Specifies if the depth of field pipeline is enabed
  72881. */
  72882. get DepthOfFieldEnabled(): boolean;
  72883. set DepthOfFieldEnabled(enabled: boolean);
  72884. /**
  72885. * @ignore
  72886. * Specifies if the lens flare pipeline is enabed
  72887. */
  72888. get LensFlareEnabled(): boolean;
  72889. set LensFlareEnabled(enabled: boolean);
  72890. /**
  72891. * @ignore
  72892. * Specifies if the HDR pipeline is enabled
  72893. */
  72894. get HDREnabled(): boolean;
  72895. set HDREnabled(enabled: boolean);
  72896. /**
  72897. * @ignore
  72898. * Specifies if the volumetric lights scattering effect is enabled
  72899. */
  72900. get VLSEnabled(): boolean;
  72901. set VLSEnabled(enabled: boolean);
  72902. /**
  72903. * @ignore
  72904. * Specifies if the motion blur effect is enabled
  72905. */
  72906. get MotionBlurEnabled(): boolean;
  72907. set MotionBlurEnabled(enabled: boolean);
  72908. /**
  72909. * Specifies if anti-aliasing is enabled
  72910. */
  72911. get fxaaEnabled(): boolean;
  72912. set fxaaEnabled(enabled: boolean);
  72913. /**
  72914. * Specifies if screen space reflections are enabled.
  72915. */
  72916. get screenSpaceReflectionsEnabled(): boolean;
  72917. set screenSpaceReflectionsEnabled(enabled: boolean);
  72918. /**
  72919. * Specifies the number of steps used to calculate the volumetric lights
  72920. * Typically in interval [50, 200]
  72921. */
  72922. get volumetricLightStepsCount(): number;
  72923. set volumetricLightStepsCount(count: number);
  72924. /**
  72925. * Specifies the number of samples used for the motion blur effect
  72926. * Typically in interval [16, 64]
  72927. */
  72928. get motionBlurSamples(): number;
  72929. set motionBlurSamples(samples: number);
  72930. /**
  72931. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72932. */
  72933. get samples(): number;
  72934. set samples(sampleCount: number);
  72935. /**
  72936. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72937. * @constructor
  72938. * @param name The rendering pipeline name
  72939. * @param scene The scene linked to this pipeline
  72940. * @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)
  72941. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72942. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72943. */
  72944. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72945. private _buildPipeline;
  72946. private _createDownSampleX4PostProcess;
  72947. private _createBrightPassPostProcess;
  72948. private _createBlurPostProcesses;
  72949. private _createTextureAdderPostProcess;
  72950. private _createVolumetricLightPostProcess;
  72951. private _createLuminancePostProcesses;
  72952. private _createHdrPostProcess;
  72953. private _createLensFlarePostProcess;
  72954. private _createDepthOfFieldPostProcess;
  72955. private _createMotionBlurPostProcess;
  72956. private _getDepthTexture;
  72957. private _disposePostProcesses;
  72958. /**
  72959. * Dispose of the pipeline and stop all post processes
  72960. */
  72961. dispose(): void;
  72962. /**
  72963. * Serialize the rendering pipeline (Used when exporting)
  72964. * @returns the serialized object
  72965. */
  72966. serialize(): any;
  72967. /**
  72968. * Parse the serialized pipeline
  72969. * @param source Source pipeline.
  72970. * @param scene The scene to load the pipeline to.
  72971. * @param rootUrl The URL of the serialized pipeline.
  72972. * @returns An instantiated pipeline from the serialized object.
  72973. */
  72974. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72975. /**
  72976. * Luminance steps
  72977. */
  72978. static LuminanceSteps: number;
  72979. }
  72980. }
  72981. declare module BABYLON {
  72982. /** @hidden */
  72983. export var stereoscopicInterlacePixelShader: {
  72984. name: string;
  72985. shader: string;
  72986. };
  72987. }
  72988. declare module BABYLON {
  72989. /**
  72990. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72991. */
  72992. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72993. private _stepSize;
  72994. private _passedProcess;
  72995. /**
  72996. * Gets a string identifying the name of the class
  72997. * @returns "StereoscopicInterlacePostProcessI" string
  72998. */
  72999. getClassName(): string;
  73000. /**
  73001. * Initializes a StereoscopicInterlacePostProcessI
  73002. * @param name The name of the effect.
  73003. * @param rigCameras The rig cameras to be appled to the post process
  73004. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73005. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73007. * @param engine The engine which the post process will be applied. (default: current engine)
  73008. * @param reusable If the post process can be reused on the same frame. (default: false)
  73009. */
  73010. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73011. }
  73012. /**
  73013. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73014. */
  73015. export class StereoscopicInterlacePostProcess extends PostProcess {
  73016. private _stepSize;
  73017. private _passedProcess;
  73018. /**
  73019. * Gets a string identifying the name of the class
  73020. * @returns "StereoscopicInterlacePostProcess" string
  73021. */
  73022. getClassName(): string;
  73023. /**
  73024. * Initializes a StereoscopicInterlacePostProcess
  73025. * @param name The name of the effect.
  73026. * @param rigCameras The rig cameras to be appled to the post process
  73027. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73029. * @param engine The engine which the post process will be applied. (default: current engine)
  73030. * @param reusable If the post process can be reused on the same frame. (default: false)
  73031. */
  73032. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73033. }
  73034. }
  73035. declare module BABYLON {
  73036. /** @hidden */
  73037. export var tonemapPixelShader: {
  73038. name: string;
  73039. shader: string;
  73040. };
  73041. }
  73042. declare module BABYLON {
  73043. /** Defines operator used for tonemapping */
  73044. export enum TonemappingOperator {
  73045. /** Hable */
  73046. Hable = 0,
  73047. /** Reinhard */
  73048. Reinhard = 1,
  73049. /** HejiDawson */
  73050. HejiDawson = 2,
  73051. /** Photographic */
  73052. Photographic = 3
  73053. }
  73054. /**
  73055. * Defines a post process to apply tone mapping
  73056. */
  73057. export class TonemapPostProcess extends PostProcess {
  73058. private _operator;
  73059. /** Defines the required exposure adjustement */
  73060. exposureAdjustment: number;
  73061. /**
  73062. * Gets a string identifying the name of the class
  73063. * @returns "TonemapPostProcess" string
  73064. */
  73065. getClassName(): string;
  73066. /**
  73067. * Creates a new TonemapPostProcess
  73068. * @param name defines the name of the postprocess
  73069. * @param _operator defines the operator to use
  73070. * @param exposureAdjustment defines the required exposure adjustement
  73071. * @param camera defines the camera to use (can be null)
  73072. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73073. * @param engine defines the hosting engine (can be ignore if camera is set)
  73074. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73075. */
  73076. constructor(name: string, _operator: TonemappingOperator,
  73077. /** Defines the required exposure adjustement */
  73078. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73079. }
  73080. }
  73081. declare module BABYLON {
  73082. /** @hidden */
  73083. export var volumetricLightScatteringPixelShader: {
  73084. name: string;
  73085. shader: string;
  73086. };
  73087. }
  73088. declare module BABYLON {
  73089. /** @hidden */
  73090. export var volumetricLightScatteringPassVertexShader: {
  73091. name: string;
  73092. shader: string;
  73093. };
  73094. }
  73095. declare module BABYLON {
  73096. /** @hidden */
  73097. export var volumetricLightScatteringPassPixelShader: {
  73098. name: string;
  73099. shader: string;
  73100. };
  73101. }
  73102. declare module BABYLON {
  73103. /**
  73104. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73105. */
  73106. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73107. private _volumetricLightScatteringPass;
  73108. private _volumetricLightScatteringRTT;
  73109. private _viewPort;
  73110. private _screenCoordinates;
  73111. private _cachedDefines;
  73112. /**
  73113. * If not undefined, the mesh position is computed from the attached node position
  73114. */
  73115. attachedNode: {
  73116. position: Vector3;
  73117. };
  73118. /**
  73119. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73120. */
  73121. customMeshPosition: Vector3;
  73122. /**
  73123. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73124. */
  73125. useCustomMeshPosition: boolean;
  73126. /**
  73127. * If the post-process should inverse the light scattering direction
  73128. */
  73129. invert: boolean;
  73130. /**
  73131. * The internal mesh used by the post-process
  73132. */
  73133. mesh: Mesh;
  73134. /**
  73135. * @hidden
  73136. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73137. */
  73138. get useDiffuseColor(): boolean;
  73139. set useDiffuseColor(useDiffuseColor: boolean);
  73140. /**
  73141. * Array containing the excluded meshes not rendered in the internal pass
  73142. */
  73143. excludedMeshes: AbstractMesh[];
  73144. /**
  73145. * Controls the overall intensity of the post-process
  73146. */
  73147. exposure: number;
  73148. /**
  73149. * Dissipates each sample's contribution in range [0, 1]
  73150. */
  73151. decay: number;
  73152. /**
  73153. * Controls the overall intensity of each sample
  73154. */
  73155. weight: number;
  73156. /**
  73157. * Controls the density of each sample
  73158. */
  73159. density: number;
  73160. /**
  73161. * @constructor
  73162. * @param name The post-process name
  73163. * @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)
  73164. * @param camera The camera that the post-process will be attached to
  73165. * @param mesh The mesh used to create the light scattering
  73166. * @param samples The post-process quality, default 100
  73167. * @param samplingModeThe post-process filtering mode
  73168. * @param engine The babylon engine
  73169. * @param reusable If the post-process is reusable
  73170. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73171. */
  73172. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73173. /**
  73174. * Returns the string "VolumetricLightScatteringPostProcess"
  73175. * @returns "VolumetricLightScatteringPostProcess"
  73176. */
  73177. getClassName(): string;
  73178. private _isReady;
  73179. /**
  73180. * Sets the new light position for light scattering effect
  73181. * @param position The new custom light position
  73182. */
  73183. setCustomMeshPosition(position: Vector3): void;
  73184. /**
  73185. * Returns the light position for light scattering effect
  73186. * @return Vector3 The custom light position
  73187. */
  73188. getCustomMeshPosition(): Vector3;
  73189. /**
  73190. * Disposes the internal assets and detaches the post-process from the camera
  73191. */
  73192. dispose(camera: Camera): void;
  73193. /**
  73194. * Returns the render target texture used by the post-process
  73195. * @return the render target texture used by the post-process
  73196. */
  73197. getPass(): RenderTargetTexture;
  73198. private _meshExcluded;
  73199. private _createPass;
  73200. private _updateMeshScreenCoordinates;
  73201. /**
  73202. * Creates a default mesh for the Volumeric Light Scattering post-process
  73203. * @param name The mesh name
  73204. * @param scene The scene where to create the mesh
  73205. * @return the default mesh
  73206. */
  73207. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73208. }
  73209. }
  73210. declare module BABYLON {
  73211. /** @hidden */
  73212. export var screenSpaceCurvaturePixelShader: {
  73213. name: string;
  73214. shader: string;
  73215. };
  73216. }
  73217. declare module BABYLON {
  73218. /**
  73219. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73220. */
  73221. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73222. /**
  73223. * Defines how much ridge the curvature effect displays.
  73224. */
  73225. ridge: number;
  73226. /**
  73227. * Defines how much valley the curvature effect displays.
  73228. */
  73229. valley: number;
  73230. private _geometryBufferRenderer;
  73231. /**
  73232. * Gets a string identifying the name of the class
  73233. * @returns "ScreenSpaceCurvaturePostProcess" string
  73234. */
  73235. getClassName(): string;
  73236. /**
  73237. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73238. * @param name The name of the effect.
  73239. * @param scene The scene containing the objects to blur according to their velocity.
  73240. * @param options The required width/height ratio to downsize to before computing the render pass.
  73241. * @param camera The camera to apply the render pass to.
  73242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73243. * @param engine The engine which the post process will be applied. (default: current engine)
  73244. * @param reusable If the post process can be reused on the same frame. (default: false)
  73245. * @param textureType Type of textures used when performing the post process. (default: 0)
  73246. * @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)
  73247. */
  73248. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73249. /**
  73250. * Support test.
  73251. */
  73252. static get IsSupported(): boolean;
  73253. /** @hidden */
  73254. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73255. }
  73256. }
  73257. declare module BABYLON {
  73258. interface Scene {
  73259. /** @hidden (Backing field) */
  73260. _boundingBoxRenderer: BoundingBoxRenderer;
  73261. /** @hidden (Backing field) */
  73262. _forceShowBoundingBoxes: boolean;
  73263. /**
  73264. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73265. */
  73266. forceShowBoundingBoxes: boolean;
  73267. /**
  73268. * Gets the bounding box renderer associated with the scene
  73269. * @returns a BoundingBoxRenderer
  73270. */
  73271. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73272. }
  73273. interface AbstractMesh {
  73274. /** @hidden (Backing field) */
  73275. _showBoundingBox: boolean;
  73276. /**
  73277. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73278. */
  73279. showBoundingBox: boolean;
  73280. }
  73281. /**
  73282. * Component responsible of rendering the bounding box of the meshes in a scene.
  73283. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73284. */
  73285. export class BoundingBoxRenderer implements ISceneComponent {
  73286. /**
  73287. * The component name helpfull to identify the component in the list of scene components.
  73288. */
  73289. readonly name: string;
  73290. /**
  73291. * The scene the component belongs to.
  73292. */
  73293. scene: Scene;
  73294. /**
  73295. * Color of the bounding box lines placed in front of an object
  73296. */
  73297. frontColor: Color3;
  73298. /**
  73299. * Color of the bounding box lines placed behind an object
  73300. */
  73301. backColor: Color3;
  73302. /**
  73303. * Defines if the renderer should show the back lines or not
  73304. */
  73305. showBackLines: boolean;
  73306. /**
  73307. * Observable raised before rendering a bounding box
  73308. */
  73309. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73310. /**
  73311. * Observable raised after rendering a bounding box
  73312. */
  73313. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73314. /**
  73315. * Observable raised after resources are created
  73316. */
  73317. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73318. /**
  73319. * When false, no bounding boxes will be rendered
  73320. */
  73321. enabled: boolean;
  73322. /**
  73323. * @hidden
  73324. */
  73325. renderList: SmartArray<BoundingBox>;
  73326. private _colorShader;
  73327. private _vertexBuffers;
  73328. private _indexBuffer;
  73329. private _fillIndexBuffer;
  73330. private _fillIndexData;
  73331. /**
  73332. * Instantiates a new bounding box renderer in a scene.
  73333. * @param scene the scene the renderer renders in
  73334. */
  73335. constructor(scene: Scene);
  73336. /**
  73337. * Registers the component in a given scene
  73338. */
  73339. register(): void;
  73340. private _evaluateSubMesh;
  73341. private _preActiveMesh;
  73342. private _prepareResources;
  73343. private _createIndexBuffer;
  73344. /**
  73345. * Rebuilds the elements related to this component in case of
  73346. * context lost for instance.
  73347. */
  73348. rebuild(): void;
  73349. /**
  73350. * @hidden
  73351. */
  73352. reset(): void;
  73353. /**
  73354. * Render the bounding boxes of a specific rendering group
  73355. * @param renderingGroupId defines the rendering group to render
  73356. */
  73357. render(renderingGroupId: number): void;
  73358. /**
  73359. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73360. * @param mesh Define the mesh to render the occlusion bounding box for
  73361. */
  73362. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73363. /**
  73364. * Dispose and release the resources attached to this renderer.
  73365. */
  73366. dispose(): void;
  73367. }
  73368. }
  73369. declare module BABYLON {
  73370. interface Scene {
  73371. /** @hidden (Backing field) */
  73372. _depthRenderer: {
  73373. [id: string]: DepthRenderer;
  73374. };
  73375. /**
  73376. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73377. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73378. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73379. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73380. * @returns the created depth renderer
  73381. */
  73382. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73383. /**
  73384. * Disables a depth renderer for a given camera
  73385. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73386. */
  73387. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73388. }
  73389. /**
  73390. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73391. * in several rendering techniques.
  73392. */
  73393. export class DepthRendererSceneComponent implements ISceneComponent {
  73394. /**
  73395. * The component name helpfull to identify the component in the list of scene components.
  73396. */
  73397. readonly name: string;
  73398. /**
  73399. * The scene the component belongs to.
  73400. */
  73401. scene: Scene;
  73402. /**
  73403. * Creates a new instance of the component for the given scene
  73404. * @param scene Defines the scene to register the component in
  73405. */
  73406. constructor(scene: Scene);
  73407. /**
  73408. * Registers the component in a given scene
  73409. */
  73410. register(): void;
  73411. /**
  73412. * Rebuilds the elements related to this component in case of
  73413. * context lost for instance.
  73414. */
  73415. rebuild(): void;
  73416. /**
  73417. * Disposes the component and the associated ressources
  73418. */
  73419. dispose(): void;
  73420. private _gatherRenderTargets;
  73421. private _gatherActiveCameraRenderTargets;
  73422. }
  73423. }
  73424. declare module BABYLON {
  73425. interface AbstractScene {
  73426. /** @hidden (Backing field) */
  73427. _prePassRenderer: Nullable<PrePassRenderer>;
  73428. /**
  73429. * Gets or Sets the current prepass renderer associated to the scene.
  73430. */
  73431. prePassRenderer: Nullable<PrePassRenderer>;
  73432. /**
  73433. * Enables the prepass and associates it with the scene
  73434. * @returns the PrePassRenderer
  73435. */
  73436. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73437. /**
  73438. * Disables the prepass associated with the scene
  73439. */
  73440. disablePrePassRenderer(): void;
  73441. }
  73442. /**
  73443. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73444. * in several rendering techniques.
  73445. */
  73446. export class PrePassRendererSceneComponent implements ISceneComponent {
  73447. /**
  73448. * The component name helpful to identify the component in the list of scene components.
  73449. */
  73450. readonly name: string;
  73451. /**
  73452. * The scene the component belongs to.
  73453. */
  73454. scene: Scene;
  73455. /**
  73456. * Creates a new instance of the component for the given scene
  73457. * @param scene Defines the scene to register the component in
  73458. */
  73459. constructor(scene: Scene);
  73460. /**
  73461. * Registers the component in a given scene
  73462. */
  73463. register(): void;
  73464. private _beforeCameraDraw;
  73465. private _afterCameraDraw;
  73466. private _beforeClearStage;
  73467. private _beforeRenderingMeshStage;
  73468. private _afterRenderingMeshStage;
  73469. /**
  73470. * Rebuilds the elements related to this component in case of
  73471. * context lost for instance.
  73472. */
  73473. rebuild(): void;
  73474. /**
  73475. * Disposes the component and the associated ressources
  73476. */
  73477. dispose(): void;
  73478. }
  73479. }
  73480. declare module BABYLON {
  73481. /** @hidden */
  73482. export var fibonacci: {
  73483. name: string;
  73484. shader: string;
  73485. };
  73486. }
  73487. declare module BABYLON {
  73488. /** @hidden */
  73489. export var diffusionProfile: {
  73490. name: string;
  73491. shader: string;
  73492. };
  73493. }
  73494. declare module BABYLON {
  73495. /** @hidden */
  73496. export var subSurfaceScatteringPixelShader: {
  73497. name: string;
  73498. shader: string;
  73499. };
  73500. }
  73501. declare module BABYLON {
  73502. /**
  73503. * Sub surface scattering post process
  73504. */
  73505. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73506. /**
  73507. * Gets a string identifying the name of the class
  73508. * @returns "SubSurfaceScatteringPostProcess" string
  73509. */
  73510. getClassName(): string;
  73511. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73512. }
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * Contains all parameters needed for the prepass to perform
  73517. * screen space subsurface scattering
  73518. */
  73519. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73520. /** @hidden */
  73521. static _SceneComponentInitialization: (scene: Scene) => void;
  73522. private _ssDiffusionS;
  73523. private _ssFilterRadii;
  73524. private _ssDiffusionD;
  73525. /**
  73526. * Post process to attach for screen space subsurface scattering
  73527. */
  73528. postProcess: SubSurfaceScatteringPostProcess;
  73529. /**
  73530. * Diffusion profile color for subsurface scattering
  73531. */
  73532. get ssDiffusionS(): number[];
  73533. /**
  73534. * Diffusion profile max color channel value for subsurface scattering
  73535. */
  73536. get ssDiffusionD(): number[];
  73537. /**
  73538. * Diffusion profile filter radius for subsurface scattering
  73539. */
  73540. get ssFilterRadii(): number[];
  73541. /**
  73542. * Is subsurface enabled
  73543. */
  73544. enabled: boolean;
  73545. /**
  73546. * Name of the configuration
  73547. */
  73548. name: string;
  73549. /**
  73550. * Diffusion profile colors for subsurface scattering
  73551. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73552. * See ...
  73553. * Note that you can only store up to 5 of them
  73554. */
  73555. ssDiffusionProfileColors: Color3[];
  73556. /**
  73557. * Defines the ratio real world => scene units.
  73558. * Used for subsurface scattering
  73559. */
  73560. metersPerUnit: number;
  73561. /**
  73562. * Textures that should be present in the MRT for this effect to work
  73563. */
  73564. readonly texturesRequired: number[];
  73565. private _scene;
  73566. /**
  73567. * Builds a subsurface configuration object
  73568. * @param scene The scene
  73569. */
  73570. constructor(scene: Scene);
  73571. /**
  73572. * Adds a new diffusion profile.
  73573. * Useful for more realistic subsurface scattering on diverse materials.
  73574. * @param color The color of the diffusion profile. Should be the average color of the material.
  73575. * @return The index of the diffusion profile for the material subsurface configuration
  73576. */
  73577. addDiffusionProfile(color: Color3): number;
  73578. /**
  73579. * Creates the sss post process
  73580. * @return The created post process
  73581. */
  73582. createPostProcess(): SubSurfaceScatteringPostProcess;
  73583. /**
  73584. * Deletes all diffusion profiles.
  73585. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73586. */
  73587. clearAllDiffusionProfiles(): void;
  73588. /**
  73589. * Disposes this object
  73590. */
  73591. dispose(): void;
  73592. /**
  73593. * @hidden
  73594. * https://zero-radiance.github.io/post/sampling-diffusion/
  73595. *
  73596. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73597. * ------------------------------------------------------------------------------------
  73598. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73599. * PDF[r, phi, s] = r * R[r, phi, s]
  73600. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73601. * ------------------------------------------------------------------------------------
  73602. * We importance sample the color channel with the widest scattering distance.
  73603. */
  73604. getDiffusionProfileParameters(color: Color3): number;
  73605. /**
  73606. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73607. * 'u' is the random number (the value of the CDF): [0, 1).
  73608. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73609. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73610. */
  73611. private _sampleBurleyDiffusionProfile;
  73612. }
  73613. }
  73614. declare module BABYLON {
  73615. interface AbstractScene {
  73616. /** @hidden (Backing field) */
  73617. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73618. /**
  73619. * Gets or Sets the current prepass renderer associated to the scene.
  73620. */
  73621. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73622. /**
  73623. * Enables the subsurface effect for prepass
  73624. * @returns the SubSurfaceConfiguration
  73625. */
  73626. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73627. /**
  73628. * Disables the subsurface effect for prepass
  73629. */
  73630. disableSubSurfaceForPrePass(): void;
  73631. }
  73632. /**
  73633. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73634. * in several rendering techniques.
  73635. */
  73636. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73637. /**
  73638. * The component name helpful to identify the component in the list of scene components.
  73639. */
  73640. readonly name: string;
  73641. /**
  73642. * The scene the component belongs to.
  73643. */
  73644. scene: Scene;
  73645. /**
  73646. * Creates a new instance of the component for the given scene
  73647. * @param scene Defines the scene to register the component in
  73648. */
  73649. constructor(scene: Scene);
  73650. /**
  73651. * Registers the component in a given scene
  73652. */
  73653. register(): void;
  73654. /**
  73655. * Serializes the component data to the specified json object
  73656. * @param serializationObject The object to serialize to
  73657. */
  73658. serialize(serializationObject: any): void;
  73659. /**
  73660. * Adds all the elements from the container to the scene
  73661. * @param container the container holding the elements
  73662. */
  73663. addFromContainer(container: AbstractScene): void;
  73664. /**
  73665. * Removes all the elements in the container from the scene
  73666. * @param container contains the elements to remove
  73667. * @param dispose if the removed element should be disposed (default: false)
  73668. */
  73669. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73670. /**
  73671. * Rebuilds the elements related to this component in case of
  73672. * context lost for instance.
  73673. */
  73674. rebuild(): void;
  73675. /**
  73676. * Disposes the component and the associated ressources
  73677. */
  73678. dispose(): void;
  73679. }
  73680. }
  73681. declare module BABYLON {
  73682. /** @hidden */
  73683. export var outlinePixelShader: {
  73684. name: string;
  73685. shader: string;
  73686. };
  73687. }
  73688. declare module BABYLON {
  73689. /** @hidden */
  73690. export var outlineVertexShader: {
  73691. name: string;
  73692. shader: string;
  73693. };
  73694. }
  73695. declare module BABYLON {
  73696. interface Scene {
  73697. /** @hidden */
  73698. _outlineRenderer: OutlineRenderer;
  73699. /**
  73700. * Gets the outline renderer associated with the scene
  73701. * @returns a OutlineRenderer
  73702. */
  73703. getOutlineRenderer(): OutlineRenderer;
  73704. }
  73705. interface AbstractMesh {
  73706. /** @hidden (Backing field) */
  73707. _renderOutline: boolean;
  73708. /**
  73709. * Gets or sets a boolean indicating if the outline must be rendered as well
  73710. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73711. */
  73712. renderOutline: boolean;
  73713. /** @hidden (Backing field) */
  73714. _renderOverlay: boolean;
  73715. /**
  73716. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73717. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73718. */
  73719. renderOverlay: boolean;
  73720. }
  73721. /**
  73722. * This class is responsible to draw bothe outline/overlay of meshes.
  73723. * It should not be used directly but through the available method on mesh.
  73724. */
  73725. export class OutlineRenderer implements ISceneComponent {
  73726. /**
  73727. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73728. */
  73729. private static _StencilReference;
  73730. /**
  73731. * The name of the component. Each component must have a unique name.
  73732. */
  73733. name: string;
  73734. /**
  73735. * The scene the component belongs to.
  73736. */
  73737. scene: Scene;
  73738. /**
  73739. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73740. */
  73741. zOffset: number;
  73742. private _engine;
  73743. private _effect;
  73744. private _cachedDefines;
  73745. private _savedDepthWrite;
  73746. /**
  73747. * Instantiates a new outline renderer. (There could be only one per scene).
  73748. * @param scene Defines the scene it belongs to
  73749. */
  73750. constructor(scene: Scene);
  73751. /**
  73752. * Register the component to one instance of a scene.
  73753. */
  73754. register(): void;
  73755. /**
  73756. * Rebuilds the elements related to this component in case of
  73757. * context lost for instance.
  73758. */
  73759. rebuild(): void;
  73760. /**
  73761. * Disposes the component and the associated ressources.
  73762. */
  73763. dispose(): void;
  73764. /**
  73765. * Renders the outline in the canvas.
  73766. * @param subMesh Defines the sumesh to render
  73767. * @param batch Defines the batch of meshes in case of instances
  73768. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73769. */
  73770. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73771. /**
  73772. * Returns whether or not the outline renderer is ready for a given submesh.
  73773. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73774. * @param subMesh Defines the submesh to check readyness for
  73775. * @param useInstances Defines wheter wee are trying to render instances or not
  73776. * @returns true if ready otherwise false
  73777. */
  73778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73779. private _beforeRenderingMesh;
  73780. private _afterRenderingMesh;
  73781. }
  73782. }
  73783. declare module BABYLON {
  73784. /**
  73785. * Defines the basic options interface of a Sprite Frame Source Size.
  73786. */
  73787. export interface ISpriteJSONSpriteSourceSize {
  73788. /**
  73789. * number of the original width of the Frame
  73790. */
  73791. w: number;
  73792. /**
  73793. * number of the original height of the Frame
  73794. */
  73795. h: number;
  73796. }
  73797. /**
  73798. * Defines the basic options interface of a Sprite Frame Data.
  73799. */
  73800. export interface ISpriteJSONSpriteFrameData {
  73801. /**
  73802. * number of the x offset of the Frame
  73803. */
  73804. x: number;
  73805. /**
  73806. * number of the y offset of the Frame
  73807. */
  73808. y: number;
  73809. /**
  73810. * number of the width of the Frame
  73811. */
  73812. w: number;
  73813. /**
  73814. * number of the height of the Frame
  73815. */
  73816. h: number;
  73817. }
  73818. /**
  73819. * Defines the basic options interface of a JSON Sprite.
  73820. */
  73821. export interface ISpriteJSONSprite {
  73822. /**
  73823. * string name of the Frame
  73824. */
  73825. filename: string;
  73826. /**
  73827. * ISpriteJSONSpriteFrame basic object of the frame data
  73828. */
  73829. frame: ISpriteJSONSpriteFrameData;
  73830. /**
  73831. * boolean to flag is the frame was rotated.
  73832. */
  73833. rotated: boolean;
  73834. /**
  73835. * boolean to flag is the frame was trimmed.
  73836. */
  73837. trimmed: boolean;
  73838. /**
  73839. * ISpriteJSONSpriteFrame basic object of the source data
  73840. */
  73841. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73842. /**
  73843. * ISpriteJSONSpriteFrame basic object of the source data
  73844. */
  73845. sourceSize: ISpriteJSONSpriteSourceSize;
  73846. }
  73847. /**
  73848. * Defines the basic options interface of a JSON atlas.
  73849. */
  73850. export interface ISpriteJSONAtlas {
  73851. /**
  73852. * Array of objects that contain the frame data.
  73853. */
  73854. frames: Array<ISpriteJSONSprite>;
  73855. /**
  73856. * object basic object containing the sprite meta data.
  73857. */
  73858. meta?: object;
  73859. }
  73860. }
  73861. declare module BABYLON {
  73862. /** @hidden */
  73863. export var spriteMapPixelShader: {
  73864. name: string;
  73865. shader: string;
  73866. };
  73867. }
  73868. declare module BABYLON {
  73869. /** @hidden */
  73870. export var spriteMapVertexShader: {
  73871. name: string;
  73872. shader: string;
  73873. };
  73874. }
  73875. declare module BABYLON {
  73876. /**
  73877. * Defines the basic options interface of a SpriteMap
  73878. */
  73879. export interface ISpriteMapOptions {
  73880. /**
  73881. * Vector2 of the number of cells in the grid.
  73882. */
  73883. stageSize?: Vector2;
  73884. /**
  73885. * Vector2 of the size of the output plane in World Units.
  73886. */
  73887. outputSize?: Vector2;
  73888. /**
  73889. * Vector3 of the position of the output plane in World Units.
  73890. */
  73891. outputPosition?: Vector3;
  73892. /**
  73893. * Vector3 of the rotation of the output plane.
  73894. */
  73895. outputRotation?: Vector3;
  73896. /**
  73897. * number of layers that the system will reserve in resources.
  73898. */
  73899. layerCount?: number;
  73900. /**
  73901. * number of max animation frames a single cell will reserve in resources.
  73902. */
  73903. maxAnimationFrames?: number;
  73904. /**
  73905. * number cell index of the base tile when the system compiles.
  73906. */
  73907. baseTile?: number;
  73908. /**
  73909. * boolean flip the sprite after its been repositioned by the framing data.
  73910. */
  73911. flipU?: boolean;
  73912. /**
  73913. * Vector3 scalar of the global RGB values of the SpriteMap.
  73914. */
  73915. colorMultiply?: Vector3;
  73916. }
  73917. /**
  73918. * Defines the IDisposable interface in order to be cleanable from resources.
  73919. */
  73920. export interface ISpriteMap extends IDisposable {
  73921. /**
  73922. * String name of the SpriteMap.
  73923. */
  73924. name: string;
  73925. /**
  73926. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73927. */
  73928. atlasJSON: ISpriteJSONAtlas;
  73929. /**
  73930. * Texture of the SpriteMap.
  73931. */
  73932. spriteSheet: Texture;
  73933. /**
  73934. * The parameters to initialize the SpriteMap with.
  73935. */
  73936. options: ISpriteMapOptions;
  73937. }
  73938. /**
  73939. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73940. */
  73941. export class SpriteMap implements ISpriteMap {
  73942. /** The Name of the spriteMap */
  73943. name: string;
  73944. /** The JSON file with the frame and meta data */
  73945. atlasJSON: ISpriteJSONAtlas;
  73946. /** The systems Sprite Sheet Texture */
  73947. spriteSheet: Texture;
  73948. /** Arguments passed with the Constructor */
  73949. options: ISpriteMapOptions;
  73950. /** Public Sprite Storage array, parsed from atlasJSON */
  73951. sprites: Array<ISpriteJSONSprite>;
  73952. /** Returns the Number of Sprites in the System */
  73953. get spriteCount(): number;
  73954. /** Returns the Position of Output Plane*/
  73955. get position(): Vector3;
  73956. /** Returns the Position of Output Plane*/
  73957. set position(v: Vector3);
  73958. /** Returns the Rotation of Output Plane*/
  73959. get rotation(): Vector3;
  73960. /** Returns the Rotation of Output Plane*/
  73961. set rotation(v: Vector3);
  73962. /** Sets the AnimationMap*/
  73963. get animationMap(): RawTexture;
  73964. /** Sets the AnimationMap*/
  73965. set animationMap(v: RawTexture);
  73966. /** Scene that the SpriteMap was created in */
  73967. private _scene;
  73968. /** Texture Buffer of Float32 that holds tile frame data*/
  73969. private _frameMap;
  73970. /** Texture Buffers of Float32 that holds tileMap data*/
  73971. private _tileMaps;
  73972. /** Texture Buffer of Float32 that holds Animation Data*/
  73973. private _animationMap;
  73974. /** Custom ShaderMaterial Central to the System*/
  73975. private _material;
  73976. /** Custom ShaderMaterial Central to the System*/
  73977. private _output;
  73978. /** Systems Time Ticker*/
  73979. private _time;
  73980. /**
  73981. * Creates a new SpriteMap
  73982. * @param name defines the SpriteMaps Name
  73983. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73984. * @param spriteSheet is the Texture that the Sprites are on.
  73985. * @param options a basic deployment configuration
  73986. * @param scene The Scene that the map is deployed on
  73987. */
  73988. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73989. /**
  73990. * Returns tileID location
  73991. * @returns Vector2 the cell position ID
  73992. */
  73993. getTileID(): Vector2;
  73994. /**
  73995. * Gets the UV location of the mouse over the SpriteMap.
  73996. * @returns Vector2 the UV position of the mouse interaction
  73997. */
  73998. getMousePosition(): Vector2;
  73999. /**
  74000. * Creates the "frame" texture Buffer
  74001. * -------------------------------------
  74002. * Structure of frames
  74003. * "filename": "Falling-Water-2.png",
  74004. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74005. * "rotated": true,
  74006. * "trimmed": true,
  74007. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74008. * "sourceSize": {"w":32,"h":32}
  74009. * @returns RawTexture of the frameMap
  74010. */
  74011. private _createFrameBuffer;
  74012. /**
  74013. * Creates the tileMap texture Buffer
  74014. * @param buffer normally and array of numbers, or a false to generate from scratch
  74015. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74016. * @returns RawTexture of the tileMap
  74017. */
  74018. private _createTileBuffer;
  74019. /**
  74020. * Modifies the data of the tileMaps
  74021. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74022. * @param pos is the iVector2 Coordinates of the Tile
  74023. * @param tile The SpriteIndex of the new Tile
  74024. */
  74025. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74026. /**
  74027. * Creates the animationMap texture Buffer
  74028. * @param buffer normally and array of numbers, or a false to generate from scratch
  74029. * @returns RawTexture of the animationMap
  74030. */
  74031. private _createTileAnimationBuffer;
  74032. /**
  74033. * Modifies the data of the animationMap
  74034. * @param cellID is the Index of the Sprite
  74035. * @param _frame is the target Animation frame
  74036. * @param toCell is the Target Index of the next frame of the animation
  74037. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74038. * @param speed is a global scalar of the time variable on the map.
  74039. */
  74040. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74041. /**
  74042. * Exports the .tilemaps file
  74043. */
  74044. saveTileMaps(): void;
  74045. /**
  74046. * Imports the .tilemaps file
  74047. * @param url of the .tilemaps file
  74048. */
  74049. loadTileMaps(url: string): void;
  74050. /**
  74051. * Release associated resources
  74052. */
  74053. dispose(): void;
  74054. }
  74055. }
  74056. declare module BABYLON {
  74057. /**
  74058. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74059. * @see https://doc.babylonjs.com/babylon101/sprites
  74060. */
  74061. export class SpritePackedManager extends SpriteManager {
  74062. /** defines the packed manager's name */
  74063. name: string;
  74064. /**
  74065. * Creates a new sprite manager from a packed sprite sheet
  74066. * @param name defines the manager's name
  74067. * @param imgUrl defines the sprite sheet url
  74068. * @param capacity defines the maximum allowed number of sprites
  74069. * @param scene defines the hosting scene
  74070. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74071. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74072. * @param samplingMode defines the smapling mode to use with spritesheet
  74073. * @param fromPacked set to true; do not alter
  74074. */
  74075. constructor(
  74076. /** defines the packed manager's name */
  74077. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74078. }
  74079. }
  74080. declare module BABYLON {
  74081. /**
  74082. * Defines the list of states available for a task inside a AssetsManager
  74083. */
  74084. export enum AssetTaskState {
  74085. /**
  74086. * Initialization
  74087. */
  74088. INIT = 0,
  74089. /**
  74090. * Running
  74091. */
  74092. RUNNING = 1,
  74093. /**
  74094. * Done
  74095. */
  74096. DONE = 2,
  74097. /**
  74098. * Error
  74099. */
  74100. ERROR = 3
  74101. }
  74102. /**
  74103. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74104. */
  74105. export abstract class AbstractAssetTask {
  74106. /**
  74107. * Task name
  74108. */ name: string;
  74109. /**
  74110. * Callback called when the task is successful
  74111. */
  74112. onSuccess: (task: any) => void;
  74113. /**
  74114. * Callback called when the task is not successful
  74115. */
  74116. onError: (task: any, message?: string, exception?: any) => void;
  74117. /**
  74118. * Creates a new AssetsManager
  74119. * @param name defines the name of the task
  74120. */
  74121. constructor(
  74122. /**
  74123. * Task name
  74124. */ name: string);
  74125. private _isCompleted;
  74126. private _taskState;
  74127. private _errorObject;
  74128. /**
  74129. * Get if the task is completed
  74130. */
  74131. get isCompleted(): boolean;
  74132. /**
  74133. * Gets the current state of the task
  74134. */
  74135. get taskState(): AssetTaskState;
  74136. /**
  74137. * Gets the current error object (if task is in error)
  74138. */
  74139. get errorObject(): {
  74140. message?: string;
  74141. exception?: any;
  74142. };
  74143. /**
  74144. * Internal only
  74145. * @hidden
  74146. */
  74147. _setErrorObject(message?: string, exception?: any): void;
  74148. /**
  74149. * Execute the current task
  74150. * @param scene defines the scene where you want your assets to be loaded
  74151. * @param onSuccess is a callback called when the task is successfully executed
  74152. * @param onError is a callback called if an error occurs
  74153. */
  74154. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74155. /**
  74156. * Execute the current task
  74157. * @param scene defines the scene where you want your assets to be loaded
  74158. * @param onSuccess is a callback called when the task is successfully executed
  74159. * @param onError is a callback called if an error occurs
  74160. */
  74161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74162. /**
  74163. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74164. * This can be used with failed tasks that have the reason for failure fixed.
  74165. */
  74166. reset(): void;
  74167. private onErrorCallback;
  74168. private onDoneCallback;
  74169. }
  74170. /**
  74171. * Define the interface used by progress events raised during assets loading
  74172. */
  74173. export interface IAssetsProgressEvent {
  74174. /**
  74175. * Defines the number of remaining tasks to process
  74176. */
  74177. remainingCount: number;
  74178. /**
  74179. * Defines the total number of tasks
  74180. */
  74181. totalCount: number;
  74182. /**
  74183. * Defines the task that was just processed
  74184. */
  74185. task: AbstractAssetTask;
  74186. }
  74187. /**
  74188. * Class used to share progress information about assets loading
  74189. */
  74190. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74191. /**
  74192. * Defines the number of remaining tasks to process
  74193. */
  74194. remainingCount: number;
  74195. /**
  74196. * Defines the total number of tasks
  74197. */
  74198. totalCount: number;
  74199. /**
  74200. * Defines the task that was just processed
  74201. */
  74202. task: AbstractAssetTask;
  74203. /**
  74204. * Creates a AssetsProgressEvent
  74205. * @param remainingCount defines the number of remaining tasks to process
  74206. * @param totalCount defines the total number of tasks
  74207. * @param task defines the task that was just processed
  74208. */
  74209. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74210. }
  74211. /**
  74212. * Define a task used by AssetsManager to load assets into a container
  74213. */
  74214. export class ContainerAssetTask extends AbstractAssetTask {
  74215. /**
  74216. * Defines the name of the task
  74217. */
  74218. name: string;
  74219. /**
  74220. * Defines the list of mesh's names you want to load
  74221. */
  74222. meshesNames: any;
  74223. /**
  74224. * Defines the root url to use as a base to load your meshes and associated resources
  74225. */
  74226. rootUrl: string;
  74227. /**
  74228. * Defines the filename or File of the scene to load from
  74229. */
  74230. sceneFilename: string | File;
  74231. /**
  74232. * Get the loaded asset container
  74233. */
  74234. loadedContainer: AssetContainer;
  74235. /**
  74236. * Gets the list of loaded meshes
  74237. */
  74238. loadedMeshes: Array<AbstractMesh>;
  74239. /**
  74240. * Gets the list of loaded particle systems
  74241. */
  74242. loadedParticleSystems: Array<IParticleSystem>;
  74243. /**
  74244. * Gets the list of loaded skeletons
  74245. */
  74246. loadedSkeletons: Array<Skeleton>;
  74247. /**
  74248. * Gets the list of loaded animation groups
  74249. */
  74250. loadedAnimationGroups: Array<AnimationGroup>;
  74251. /**
  74252. * Callback called when the task is successful
  74253. */
  74254. onSuccess: (task: ContainerAssetTask) => void;
  74255. /**
  74256. * Callback called when the task is successful
  74257. */
  74258. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74259. /**
  74260. * Creates a new ContainerAssetTask
  74261. * @param name defines the name of the task
  74262. * @param meshesNames defines the list of mesh's names you want to load
  74263. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74264. * @param sceneFilename defines the filename or File of the scene to load from
  74265. */
  74266. constructor(
  74267. /**
  74268. * Defines the name of the task
  74269. */
  74270. name: string,
  74271. /**
  74272. * Defines the list of mesh's names you want to load
  74273. */
  74274. meshesNames: any,
  74275. /**
  74276. * Defines the root url to use as a base to load your meshes and associated resources
  74277. */
  74278. rootUrl: string,
  74279. /**
  74280. * Defines the filename or File of the scene to load from
  74281. */
  74282. sceneFilename: string | File);
  74283. /**
  74284. * Execute the current task
  74285. * @param scene defines the scene where you want your assets to be loaded
  74286. * @param onSuccess is a callback called when the task is successfully executed
  74287. * @param onError is a callback called if an error occurs
  74288. */
  74289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74290. }
  74291. /**
  74292. * Define a task used by AssetsManager to load meshes
  74293. */
  74294. export class MeshAssetTask extends AbstractAssetTask {
  74295. /**
  74296. * Defines the name of the task
  74297. */
  74298. name: string;
  74299. /**
  74300. * Defines the list of mesh's names you want to load
  74301. */
  74302. meshesNames: any;
  74303. /**
  74304. * Defines the root url to use as a base to load your meshes and associated resources
  74305. */
  74306. rootUrl: string;
  74307. /**
  74308. * Defines the filename or File of the scene to load from
  74309. */
  74310. sceneFilename: string | File;
  74311. /**
  74312. * Gets the list of loaded meshes
  74313. */
  74314. loadedMeshes: Array<AbstractMesh>;
  74315. /**
  74316. * Gets the list of loaded particle systems
  74317. */
  74318. loadedParticleSystems: Array<IParticleSystem>;
  74319. /**
  74320. * Gets the list of loaded skeletons
  74321. */
  74322. loadedSkeletons: Array<Skeleton>;
  74323. /**
  74324. * Gets the list of loaded animation groups
  74325. */
  74326. loadedAnimationGroups: Array<AnimationGroup>;
  74327. /**
  74328. * Callback called when the task is successful
  74329. */
  74330. onSuccess: (task: MeshAssetTask) => void;
  74331. /**
  74332. * Callback called when the task is successful
  74333. */
  74334. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74335. /**
  74336. * Creates a new MeshAssetTask
  74337. * @param name defines the name of the task
  74338. * @param meshesNames defines the list of mesh's names you want to load
  74339. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74340. * @param sceneFilename defines the filename or File of the scene to load from
  74341. */
  74342. constructor(
  74343. /**
  74344. * Defines the name of the task
  74345. */
  74346. name: string,
  74347. /**
  74348. * Defines the list of mesh's names you want to load
  74349. */
  74350. meshesNames: any,
  74351. /**
  74352. * Defines the root url to use as a base to load your meshes and associated resources
  74353. */
  74354. rootUrl: string,
  74355. /**
  74356. * Defines the filename or File of the scene to load from
  74357. */
  74358. sceneFilename: string | File);
  74359. /**
  74360. * Execute the current task
  74361. * @param scene defines the scene where you want your assets to be loaded
  74362. * @param onSuccess is a callback called when the task is successfully executed
  74363. * @param onError is a callback called if an error occurs
  74364. */
  74365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74366. }
  74367. /**
  74368. * Define a task used by AssetsManager to load text content
  74369. */
  74370. export class TextFileAssetTask extends AbstractAssetTask {
  74371. /**
  74372. * Defines the name of the task
  74373. */
  74374. name: string;
  74375. /**
  74376. * Defines the location of the file to load
  74377. */
  74378. url: string;
  74379. /**
  74380. * Gets the loaded text string
  74381. */
  74382. text: string;
  74383. /**
  74384. * Callback called when the task is successful
  74385. */
  74386. onSuccess: (task: TextFileAssetTask) => void;
  74387. /**
  74388. * Callback called when the task is successful
  74389. */
  74390. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74391. /**
  74392. * Creates a new TextFileAssetTask object
  74393. * @param name defines the name of the task
  74394. * @param url defines the location of the file to load
  74395. */
  74396. constructor(
  74397. /**
  74398. * Defines the name of the task
  74399. */
  74400. name: string,
  74401. /**
  74402. * Defines the location of the file to load
  74403. */
  74404. url: string);
  74405. /**
  74406. * Execute the current task
  74407. * @param scene defines the scene where you want your assets to be loaded
  74408. * @param onSuccess is a callback called when the task is successfully executed
  74409. * @param onError is a callback called if an error occurs
  74410. */
  74411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74412. }
  74413. /**
  74414. * Define a task used by AssetsManager to load binary data
  74415. */
  74416. export class BinaryFileAssetTask extends AbstractAssetTask {
  74417. /**
  74418. * Defines the name of the task
  74419. */
  74420. name: string;
  74421. /**
  74422. * Defines the location of the file to load
  74423. */
  74424. url: string;
  74425. /**
  74426. * Gets the lodaded data (as an array buffer)
  74427. */
  74428. data: ArrayBuffer;
  74429. /**
  74430. * Callback called when the task is successful
  74431. */
  74432. onSuccess: (task: BinaryFileAssetTask) => void;
  74433. /**
  74434. * Callback called when the task is successful
  74435. */
  74436. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74437. /**
  74438. * Creates a new BinaryFileAssetTask object
  74439. * @param name defines the name of the new task
  74440. * @param url defines the location of the file to load
  74441. */
  74442. constructor(
  74443. /**
  74444. * Defines the name of the task
  74445. */
  74446. name: string,
  74447. /**
  74448. * Defines the location of the file to load
  74449. */
  74450. url: string);
  74451. /**
  74452. * Execute the current task
  74453. * @param scene defines the scene where you want your assets to be loaded
  74454. * @param onSuccess is a callback called when the task is successfully executed
  74455. * @param onError is a callback called if an error occurs
  74456. */
  74457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74458. }
  74459. /**
  74460. * Define a task used by AssetsManager to load images
  74461. */
  74462. export class ImageAssetTask extends AbstractAssetTask {
  74463. /**
  74464. * Defines the name of the task
  74465. */
  74466. name: string;
  74467. /**
  74468. * Defines the location of the image to load
  74469. */
  74470. url: string;
  74471. /**
  74472. * Gets the loaded images
  74473. */
  74474. image: HTMLImageElement;
  74475. /**
  74476. * Callback called when the task is successful
  74477. */
  74478. onSuccess: (task: ImageAssetTask) => void;
  74479. /**
  74480. * Callback called when the task is successful
  74481. */
  74482. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74483. /**
  74484. * Creates a new ImageAssetTask
  74485. * @param name defines the name of the task
  74486. * @param url defines the location of the image to load
  74487. */
  74488. constructor(
  74489. /**
  74490. * Defines the name of the task
  74491. */
  74492. name: string,
  74493. /**
  74494. * Defines the location of the image to load
  74495. */
  74496. url: string);
  74497. /**
  74498. * Execute the current task
  74499. * @param scene defines the scene where you want your assets to be loaded
  74500. * @param onSuccess is a callback called when the task is successfully executed
  74501. * @param onError is a callback called if an error occurs
  74502. */
  74503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74504. }
  74505. /**
  74506. * Defines the interface used by texture loading tasks
  74507. */
  74508. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74509. /**
  74510. * Gets the loaded texture
  74511. */
  74512. texture: TEX;
  74513. }
  74514. /**
  74515. * Define a task used by AssetsManager to load 2D textures
  74516. */
  74517. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74518. /**
  74519. * Defines the name of the task
  74520. */
  74521. name: string;
  74522. /**
  74523. * Defines the location of the file to load
  74524. */
  74525. url: string;
  74526. /**
  74527. * Defines if mipmap should not be generated (default is false)
  74528. */
  74529. noMipmap?: boolean | undefined;
  74530. /**
  74531. * Defines if texture must be inverted on Y axis (default is true)
  74532. */
  74533. invertY: boolean;
  74534. /**
  74535. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74536. */
  74537. samplingMode: number;
  74538. /**
  74539. * Gets the loaded texture
  74540. */
  74541. texture: Texture;
  74542. /**
  74543. * Callback called when the task is successful
  74544. */
  74545. onSuccess: (task: TextureAssetTask) => void;
  74546. /**
  74547. * Callback called when the task is successful
  74548. */
  74549. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74550. /**
  74551. * Creates a new TextureAssetTask object
  74552. * @param name defines the name of the task
  74553. * @param url defines the location of the file to load
  74554. * @param noMipmap defines if mipmap should not be generated (default is false)
  74555. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74556. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74557. */
  74558. constructor(
  74559. /**
  74560. * Defines the name of the task
  74561. */
  74562. name: string,
  74563. /**
  74564. * Defines the location of the file to load
  74565. */
  74566. url: string,
  74567. /**
  74568. * Defines if mipmap should not be generated (default is false)
  74569. */
  74570. noMipmap?: boolean | undefined,
  74571. /**
  74572. * Defines if texture must be inverted on Y axis (default is true)
  74573. */
  74574. invertY?: boolean,
  74575. /**
  74576. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74577. */
  74578. samplingMode?: number);
  74579. /**
  74580. * Execute the current task
  74581. * @param scene defines the scene where you want your assets to be loaded
  74582. * @param onSuccess is a callback called when the task is successfully executed
  74583. * @param onError is a callback called if an error occurs
  74584. */
  74585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74586. }
  74587. /**
  74588. * Define a task used by AssetsManager to load cube textures
  74589. */
  74590. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74591. /**
  74592. * Defines the name of the task
  74593. */
  74594. name: string;
  74595. /**
  74596. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74597. */
  74598. url: string;
  74599. /**
  74600. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74601. */
  74602. extensions?: string[] | undefined;
  74603. /**
  74604. * Defines if mipmaps should not be generated (default is false)
  74605. */
  74606. noMipmap?: boolean | undefined;
  74607. /**
  74608. * Defines the explicit list of files (undefined by default)
  74609. */
  74610. files?: string[] | undefined;
  74611. /**
  74612. * Gets the loaded texture
  74613. */
  74614. texture: CubeTexture;
  74615. /**
  74616. * Callback called when the task is successful
  74617. */
  74618. onSuccess: (task: CubeTextureAssetTask) => void;
  74619. /**
  74620. * Callback called when the task is successful
  74621. */
  74622. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74623. /**
  74624. * Creates a new CubeTextureAssetTask
  74625. * @param name defines the name of the task
  74626. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74627. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74628. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74629. * @param files defines the explicit list of files (undefined by default)
  74630. */
  74631. constructor(
  74632. /**
  74633. * Defines the name of the task
  74634. */
  74635. name: string,
  74636. /**
  74637. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74638. */
  74639. url: string,
  74640. /**
  74641. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74642. */
  74643. extensions?: string[] | undefined,
  74644. /**
  74645. * Defines if mipmaps should not be generated (default is false)
  74646. */
  74647. noMipmap?: boolean | undefined,
  74648. /**
  74649. * Defines the explicit list of files (undefined by default)
  74650. */
  74651. files?: string[] | undefined);
  74652. /**
  74653. * Execute the current task
  74654. * @param scene defines the scene where you want your assets to be loaded
  74655. * @param onSuccess is a callback called when the task is successfully executed
  74656. * @param onError is a callback called if an error occurs
  74657. */
  74658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74659. }
  74660. /**
  74661. * Define a task used by AssetsManager to load HDR cube textures
  74662. */
  74663. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74664. /**
  74665. * Defines the name of the task
  74666. */
  74667. name: string;
  74668. /**
  74669. * Defines the location of the file to load
  74670. */
  74671. url: string;
  74672. /**
  74673. * Defines the desired size (the more it increases the longer the generation will be)
  74674. */
  74675. size: number;
  74676. /**
  74677. * Defines if mipmaps should not be generated (default is false)
  74678. */
  74679. noMipmap: boolean;
  74680. /**
  74681. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74682. */
  74683. generateHarmonics: boolean;
  74684. /**
  74685. * 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)
  74686. */
  74687. gammaSpace: boolean;
  74688. /**
  74689. * Internal Use Only
  74690. */
  74691. reserved: boolean;
  74692. /**
  74693. * Gets the loaded texture
  74694. */
  74695. texture: HDRCubeTexture;
  74696. /**
  74697. * Callback called when the task is successful
  74698. */
  74699. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74700. /**
  74701. * Callback called when the task is successful
  74702. */
  74703. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74704. /**
  74705. * Creates a new HDRCubeTextureAssetTask object
  74706. * @param name defines the name of the task
  74707. * @param url defines the location of the file to load
  74708. * @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.
  74709. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74710. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74711. * @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)
  74712. * @param reserved Internal use only
  74713. */
  74714. constructor(
  74715. /**
  74716. * Defines the name of the task
  74717. */
  74718. name: string,
  74719. /**
  74720. * Defines the location of the file to load
  74721. */
  74722. url: string,
  74723. /**
  74724. * Defines the desired size (the more it increases the longer the generation will be)
  74725. */
  74726. size: number,
  74727. /**
  74728. * Defines if mipmaps should not be generated (default is false)
  74729. */
  74730. noMipmap?: boolean,
  74731. /**
  74732. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74733. */
  74734. generateHarmonics?: boolean,
  74735. /**
  74736. * 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)
  74737. */
  74738. gammaSpace?: boolean,
  74739. /**
  74740. * Internal Use Only
  74741. */
  74742. reserved?: boolean);
  74743. /**
  74744. * Execute the current task
  74745. * @param scene defines the scene where you want your assets to be loaded
  74746. * @param onSuccess is a callback called when the task is successfully executed
  74747. * @param onError is a callback called if an error occurs
  74748. */
  74749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74750. }
  74751. /**
  74752. * Define a task used by AssetsManager to load Equirectangular cube textures
  74753. */
  74754. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74755. /**
  74756. * Defines the name of the task
  74757. */
  74758. name: string;
  74759. /**
  74760. * Defines the location of the file to load
  74761. */
  74762. url: string;
  74763. /**
  74764. * Defines the desired size (the more it increases the longer the generation will be)
  74765. */
  74766. size: number;
  74767. /**
  74768. * Defines if mipmaps should not be generated (default is false)
  74769. */
  74770. noMipmap: boolean;
  74771. /**
  74772. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74773. * but the standard material would require them in Gamma space) (default is true)
  74774. */
  74775. gammaSpace: boolean;
  74776. /**
  74777. * Gets the loaded texture
  74778. */
  74779. texture: EquiRectangularCubeTexture;
  74780. /**
  74781. * Callback called when the task is successful
  74782. */
  74783. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74784. /**
  74785. * Callback called when the task is successful
  74786. */
  74787. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74788. /**
  74789. * Creates a new EquiRectangularCubeTextureAssetTask object
  74790. * @param name defines the name of the task
  74791. * @param url defines the location of the file to load
  74792. * @param size defines the desired size (the more it increases the longer the generation will be)
  74793. * If the size is omitted this implies you are using a preprocessed cubemap.
  74794. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74795. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74796. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74797. * (default is true)
  74798. */
  74799. constructor(
  74800. /**
  74801. * Defines the name of the task
  74802. */
  74803. name: string,
  74804. /**
  74805. * Defines the location of the file to load
  74806. */
  74807. url: string,
  74808. /**
  74809. * Defines the desired size (the more it increases the longer the generation will be)
  74810. */
  74811. size: number,
  74812. /**
  74813. * Defines if mipmaps should not be generated (default is false)
  74814. */
  74815. noMipmap?: boolean,
  74816. /**
  74817. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74818. * but the standard material would require them in Gamma space) (default is true)
  74819. */
  74820. gammaSpace?: boolean);
  74821. /**
  74822. * Execute the current task
  74823. * @param scene defines the scene where you want your assets to be loaded
  74824. * @param onSuccess is a callback called when the task is successfully executed
  74825. * @param onError is a callback called if an error occurs
  74826. */
  74827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74828. }
  74829. /**
  74830. * This class can be used to easily import assets into a scene
  74831. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74832. */
  74833. export class AssetsManager {
  74834. private _scene;
  74835. private _isLoading;
  74836. protected _tasks: AbstractAssetTask[];
  74837. protected _waitingTasksCount: number;
  74838. protected _totalTasksCount: number;
  74839. /**
  74840. * Callback called when all tasks are processed
  74841. */
  74842. onFinish: (tasks: AbstractAssetTask[]) => void;
  74843. /**
  74844. * Callback called when a task is successful
  74845. */
  74846. onTaskSuccess: (task: AbstractAssetTask) => void;
  74847. /**
  74848. * Callback called when a task had an error
  74849. */
  74850. onTaskError: (task: AbstractAssetTask) => void;
  74851. /**
  74852. * Callback called when a task is done (whatever the result is)
  74853. */
  74854. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74855. /**
  74856. * Observable called when all tasks are processed
  74857. */
  74858. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74859. /**
  74860. * Observable called when a task had an error
  74861. */
  74862. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74863. /**
  74864. * Observable called when all tasks were executed
  74865. */
  74866. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74867. /**
  74868. * Observable called when a task is done (whatever the result is)
  74869. */
  74870. onProgressObservable: Observable<IAssetsProgressEvent>;
  74871. /**
  74872. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74873. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74874. */
  74875. useDefaultLoadingScreen: boolean;
  74876. /**
  74877. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74878. * when all assets have been downloaded.
  74879. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74880. */
  74881. autoHideLoadingUI: boolean;
  74882. /**
  74883. * Creates a new AssetsManager
  74884. * @param scene defines the scene to work on
  74885. */
  74886. constructor(scene: Scene);
  74887. /**
  74888. * Add a ContainerAssetTask to the list of active tasks
  74889. * @param taskName defines the name of the new task
  74890. * @param meshesNames defines the name of meshes to load
  74891. * @param rootUrl defines the root url to use to locate files
  74892. * @param sceneFilename defines the filename of the scene file
  74893. * @returns a new ContainerAssetTask object
  74894. */
  74895. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74896. /**
  74897. * Add a MeshAssetTask to the list of active tasks
  74898. * @param taskName defines the name of the new task
  74899. * @param meshesNames defines the name of meshes to load
  74900. * @param rootUrl defines the root url to use to locate files
  74901. * @param sceneFilename defines the filename of the scene file
  74902. * @returns a new MeshAssetTask object
  74903. */
  74904. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74905. /**
  74906. * Add a TextFileAssetTask to the list of active tasks
  74907. * @param taskName defines the name of the new task
  74908. * @param url defines the url of the file to load
  74909. * @returns a new TextFileAssetTask object
  74910. */
  74911. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74912. /**
  74913. * Add a BinaryFileAssetTask to the list of active tasks
  74914. * @param taskName defines the name of the new task
  74915. * @param url defines the url of the file to load
  74916. * @returns a new BinaryFileAssetTask object
  74917. */
  74918. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74919. /**
  74920. * Add a ImageAssetTask to the list of active tasks
  74921. * @param taskName defines the name of the new task
  74922. * @param url defines the url of the file to load
  74923. * @returns a new ImageAssetTask object
  74924. */
  74925. addImageTask(taskName: string, url: string): ImageAssetTask;
  74926. /**
  74927. * Add a TextureAssetTask to the list of active tasks
  74928. * @param taskName defines the name of the new task
  74929. * @param url defines the url of the file to load
  74930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74931. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74932. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74933. * @returns a new TextureAssetTask object
  74934. */
  74935. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74936. /**
  74937. * Add a CubeTextureAssetTask to the list of active tasks
  74938. * @param taskName defines the name of the new task
  74939. * @param url defines the url of the file to load
  74940. * @param extensions defines the extension to use to load the cube map (can be null)
  74941. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74942. * @param files defines the list of files to load (can be null)
  74943. * @returns a new CubeTextureAssetTask object
  74944. */
  74945. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74946. /**
  74947. *
  74948. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74949. * @param taskName defines the name of the new task
  74950. * @param url defines the url of the file to load
  74951. * @param size defines the size you want for the cubemap (can be null)
  74952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74953. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74954. * @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)
  74955. * @param reserved Internal use only
  74956. * @returns a new HDRCubeTextureAssetTask object
  74957. */
  74958. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74959. /**
  74960. *
  74961. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74962. * @param taskName defines the name of the new task
  74963. * @param url defines the url of the file to load
  74964. * @param size defines the size you want for the cubemap (can be null)
  74965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74966. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74967. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74968. * @returns a new EquiRectangularCubeTextureAssetTask object
  74969. */
  74970. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74971. /**
  74972. * Remove a task from the assets manager.
  74973. * @param task the task to remove
  74974. */
  74975. removeTask(task: AbstractAssetTask): void;
  74976. private _decreaseWaitingTasksCount;
  74977. private _runTask;
  74978. /**
  74979. * Reset the AssetsManager and remove all tasks
  74980. * @return the current instance of the AssetsManager
  74981. */
  74982. reset(): AssetsManager;
  74983. /**
  74984. * Start the loading process
  74985. * @return the current instance of the AssetsManager
  74986. */
  74987. load(): AssetsManager;
  74988. /**
  74989. * Start the loading process as an async operation
  74990. * @return a promise returning the list of failed tasks
  74991. */
  74992. loadAsync(): Promise<void>;
  74993. }
  74994. }
  74995. declare module BABYLON {
  74996. /**
  74997. * Wrapper class for promise with external resolve and reject.
  74998. */
  74999. export class Deferred<T> {
  75000. /**
  75001. * The promise associated with this deferred object.
  75002. */
  75003. readonly promise: Promise<T>;
  75004. private _resolve;
  75005. private _reject;
  75006. /**
  75007. * The resolve method of the promise associated with this deferred object.
  75008. */
  75009. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75010. /**
  75011. * The reject method of the promise associated with this deferred object.
  75012. */
  75013. get reject(): (reason?: any) => void;
  75014. /**
  75015. * Constructor for this deferred object.
  75016. */
  75017. constructor();
  75018. }
  75019. }
  75020. declare module BABYLON {
  75021. /**
  75022. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75023. */
  75024. export class MeshExploder {
  75025. private _centerMesh;
  75026. private _meshes;
  75027. private _meshesOrigins;
  75028. private _toCenterVectors;
  75029. private _scaledDirection;
  75030. private _newPosition;
  75031. private _centerPosition;
  75032. /**
  75033. * Explodes meshes from a center mesh.
  75034. * @param meshes The meshes to explode.
  75035. * @param centerMesh The mesh to be center of explosion.
  75036. */
  75037. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75038. private _setCenterMesh;
  75039. /**
  75040. * Get class name
  75041. * @returns "MeshExploder"
  75042. */
  75043. getClassName(): string;
  75044. /**
  75045. * "Exploded meshes"
  75046. * @returns Array of meshes with the centerMesh at index 0.
  75047. */
  75048. getMeshes(): Array<Mesh>;
  75049. /**
  75050. * Explodes meshes giving a specific direction
  75051. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75052. */
  75053. explode(direction?: number): void;
  75054. }
  75055. }
  75056. declare module BABYLON {
  75057. /**
  75058. * Class used to help managing file picking and drag'n'drop
  75059. */
  75060. export class FilesInput {
  75061. /**
  75062. * List of files ready to be loaded
  75063. */
  75064. static get FilesToLoad(): {
  75065. [key: string]: File;
  75066. };
  75067. /**
  75068. * Callback called when a file is processed
  75069. */
  75070. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  75071. private _engine;
  75072. private _currentScene;
  75073. private _sceneLoadedCallback;
  75074. private _progressCallback;
  75075. private _additionalRenderLoopLogicCallback;
  75076. private _textureLoadingCallback;
  75077. private _startingProcessingFilesCallback;
  75078. private _onReloadCallback;
  75079. private _errorCallback;
  75080. private _elementToMonitor;
  75081. private _sceneFileToLoad;
  75082. private _filesToLoad;
  75083. /**
  75084. * Creates a new FilesInput
  75085. * @param engine defines the rendering engine
  75086. * @param scene defines the hosting scene
  75087. * @param sceneLoadedCallback callback called when scene is loaded
  75088. * @param progressCallback callback called to track progress
  75089. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75090. * @param textureLoadingCallback callback called when a texture is loading
  75091. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75092. * @param onReloadCallback callback called when a reload is requested
  75093. * @param errorCallback callback call if an error occurs
  75094. */
  75095. 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>);
  75096. private _dragEnterHandler;
  75097. private _dragOverHandler;
  75098. private _dropHandler;
  75099. /**
  75100. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75101. * @param elementToMonitor defines the DOM element to track
  75102. */
  75103. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75104. /** Gets the current list of files to load */
  75105. get filesToLoad(): File[];
  75106. /**
  75107. * Release all associated resources
  75108. */
  75109. dispose(): void;
  75110. private renderFunction;
  75111. private drag;
  75112. private drop;
  75113. private _traverseFolder;
  75114. private _processFiles;
  75115. /**
  75116. * Load files from a drop event
  75117. * @param event defines the drop event to use as source
  75118. */
  75119. loadFiles(event: any): void;
  75120. private _processReload;
  75121. /**
  75122. * Reload the current scene from the loaded files
  75123. */
  75124. reload(): void;
  75125. }
  75126. }
  75127. declare module BABYLON {
  75128. /**
  75129. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75130. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75131. */
  75132. export class SceneOptimization {
  75133. /**
  75134. * Defines the priority of this optimization (0 by default which means first in the list)
  75135. */
  75136. priority: number;
  75137. /**
  75138. * Gets a string describing the action executed by the current optimization
  75139. * @returns description string
  75140. */
  75141. getDescription(): string;
  75142. /**
  75143. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75144. * @param scene defines the current scene where to apply this optimization
  75145. * @param optimizer defines the current optimizer
  75146. * @returns true if everything that can be done was applied
  75147. */
  75148. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75149. /**
  75150. * Creates the SceneOptimization object
  75151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75152. * @param desc defines the description associated with the optimization
  75153. */
  75154. constructor(
  75155. /**
  75156. * Defines the priority of this optimization (0 by default which means first in the list)
  75157. */
  75158. priority?: number);
  75159. }
  75160. /**
  75161. * Defines an optimization used to reduce the size of render target textures
  75162. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75163. */
  75164. export class TextureOptimization extends SceneOptimization {
  75165. /**
  75166. * Defines the priority of this optimization (0 by default which means first in the list)
  75167. */
  75168. priority: number;
  75169. /**
  75170. * 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
  75171. */
  75172. maximumSize: number;
  75173. /**
  75174. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75175. */
  75176. step: number;
  75177. /**
  75178. * Gets a string describing the action executed by the current optimization
  75179. * @returns description string
  75180. */
  75181. getDescription(): string;
  75182. /**
  75183. * Creates the TextureOptimization object
  75184. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75185. * @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
  75186. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75187. */
  75188. constructor(
  75189. /**
  75190. * Defines the priority of this optimization (0 by default which means first in the list)
  75191. */
  75192. priority?: number,
  75193. /**
  75194. * 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
  75195. */
  75196. maximumSize?: number,
  75197. /**
  75198. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75199. */
  75200. step?: number);
  75201. /**
  75202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75203. * @param scene defines the current scene where to apply this optimization
  75204. * @param optimizer defines the current optimizer
  75205. * @returns true if everything that can be done was applied
  75206. */
  75207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75208. }
  75209. /**
  75210. * Defines an optimization used to increase or decrease the rendering resolution
  75211. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75212. */
  75213. export class HardwareScalingOptimization extends SceneOptimization {
  75214. /**
  75215. * Defines the priority of this optimization (0 by default which means first in the list)
  75216. */
  75217. priority: number;
  75218. /**
  75219. * Defines the maximum scale to use (2 by default)
  75220. */
  75221. maximumScale: number;
  75222. /**
  75223. * Defines the step to use between two passes (0.5 by default)
  75224. */
  75225. step: number;
  75226. private _currentScale;
  75227. private _directionOffset;
  75228. /**
  75229. * Gets a string describing the action executed by the current optimization
  75230. * @return description string
  75231. */
  75232. getDescription(): string;
  75233. /**
  75234. * Creates the HardwareScalingOptimization object
  75235. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75236. * @param maximumScale defines the maximum scale to use (2 by default)
  75237. * @param step defines the step to use between two passes (0.5 by default)
  75238. */
  75239. constructor(
  75240. /**
  75241. * Defines the priority of this optimization (0 by default which means first in the list)
  75242. */
  75243. priority?: number,
  75244. /**
  75245. * Defines the maximum scale to use (2 by default)
  75246. */
  75247. maximumScale?: number,
  75248. /**
  75249. * Defines the step to use between two passes (0.5 by default)
  75250. */
  75251. step?: number);
  75252. /**
  75253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75254. * @param scene defines the current scene where to apply this optimization
  75255. * @param optimizer defines the current optimizer
  75256. * @returns true if everything that can be done was applied
  75257. */
  75258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75259. }
  75260. /**
  75261. * Defines an optimization used to remove shadows
  75262. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75263. */
  75264. export class ShadowsOptimization extends SceneOptimization {
  75265. /**
  75266. * Gets a string describing the action executed by the current optimization
  75267. * @return description string
  75268. */
  75269. getDescription(): string;
  75270. /**
  75271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75272. * @param scene defines the current scene where to apply this optimization
  75273. * @param optimizer defines the current optimizer
  75274. * @returns true if everything that can be done was applied
  75275. */
  75276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75277. }
  75278. /**
  75279. * Defines an optimization used to turn post-processes off
  75280. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75281. */
  75282. export class PostProcessesOptimization extends SceneOptimization {
  75283. /**
  75284. * Gets a string describing the action executed by the current optimization
  75285. * @return description string
  75286. */
  75287. getDescription(): string;
  75288. /**
  75289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75290. * @param scene defines the current scene where to apply this optimization
  75291. * @param optimizer defines the current optimizer
  75292. * @returns true if everything that can be done was applied
  75293. */
  75294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75295. }
  75296. /**
  75297. * Defines an optimization used to turn lens flares off
  75298. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75299. */
  75300. export class LensFlaresOptimization extends SceneOptimization {
  75301. /**
  75302. * Gets a string describing the action executed by the current optimization
  75303. * @return description string
  75304. */
  75305. getDescription(): string;
  75306. /**
  75307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75308. * @param scene defines the current scene where to apply this optimization
  75309. * @param optimizer defines the current optimizer
  75310. * @returns true if everything that can be done was applied
  75311. */
  75312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75313. }
  75314. /**
  75315. * Defines an optimization based on user defined callback.
  75316. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75317. */
  75318. export class CustomOptimization extends SceneOptimization {
  75319. /**
  75320. * Callback called to apply the custom optimization.
  75321. */
  75322. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75323. /**
  75324. * Callback called to get custom description
  75325. */
  75326. onGetDescription: () => string;
  75327. /**
  75328. * Gets a string describing the action executed by the current optimization
  75329. * @returns description string
  75330. */
  75331. getDescription(): string;
  75332. /**
  75333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75334. * @param scene defines the current scene where to apply this optimization
  75335. * @param optimizer defines the current optimizer
  75336. * @returns true if everything that can be done was applied
  75337. */
  75338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75339. }
  75340. /**
  75341. * Defines an optimization used to turn particles off
  75342. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75343. */
  75344. export class ParticlesOptimization extends SceneOptimization {
  75345. /**
  75346. * Gets a string describing the action executed by the current optimization
  75347. * @return description string
  75348. */
  75349. getDescription(): string;
  75350. /**
  75351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75352. * @param scene defines the current scene where to apply this optimization
  75353. * @param optimizer defines the current optimizer
  75354. * @returns true if everything that can be done was applied
  75355. */
  75356. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75357. }
  75358. /**
  75359. * Defines an optimization used to turn render targets off
  75360. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75361. */
  75362. export class RenderTargetsOptimization extends SceneOptimization {
  75363. /**
  75364. * Gets a string describing the action executed by the current optimization
  75365. * @return description string
  75366. */
  75367. getDescription(): string;
  75368. /**
  75369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75370. * @param scene defines the current scene where to apply this optimization
  75371. * @param optimizer defines the current optimizer
  75372. * @returns true if everything that can be done was applied
  75373. */
  75374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75375. }
  75376. /**
  75377. * Defines an optimization used to merge meshes with compatible materials
  75378. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75379. */
  75380. export class MergeMeshesOptimization extends SceneOptimization {
  75381. private static _UpdateSelectionTree;
  75382. /**
  75383. * Gets or sets a boolean which defines if optimization octree has to be updated
  75384. */
  75385. static get UpdateSelectionTree(): boolean;
  75386. /**
  75387. * Gets or sets a boolean which defines if optimization octree has to be updated
  75388. */
  75389. static set UpdateSelectionTree(value: boolean);
  75390. /**
  75391. * Gets a string describing the action executed by the current optimization
  75392. * @return description string
  75393. */
  75394. getDescription(): string;
  75395. private _canBeMerged;
  75396. /**
  75397. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75398. * @param scene defines the current scene where to apply this optimization
  75399. * @param optimizer defines the current optimizer
  75400. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75401. * @returns true if everything that can be done was applied
  75402. */
  75403. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75404. }
  75405. /**
  75406. * Defines a list of options used by SceneOptimizer
  75407. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75408. */
  75409. export class SceneOptimizerOptions {
  75410. /**
  75411. * Defines the target frame rate to reach (60 by default)
  75412. */
  75413. targetFrameRate: number;
  75414. /**
  75415. * Defines the interval between two checkes (2000ms by default)
  75416. */
  75417. trackerDuration: number;
  75418. /**
  75419. * Gets the list of optimizations to apply
  75420. */
  75421. optimizations: SceneOptimization[];
  75422. /**
  75423. * Creates a new list of options used by SceneOptimizer
  75424. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75425. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75426. */
  75427. constructor(
  75428. /**
  75429. * Defines the target frame rate to reach (60 by default)
  75430. */
  75431. targetFrameRate?: number,
  75432. /**
  75433. * Defines the interval between two checkes (2000ms by default)
  75434. */
  75435. trackerDuration?: number);
  75436. /**
  75437. * Add a new optimization
  75438. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75439. * @returns the current SceneOptimizerOptions
  75440. */
  75441. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75442. /**
  75443. * Add a new custom optimization
  75444. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75445. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75446. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75447. * @returns the current SceneOptimizerOptions
  75448. */
  75449. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75450. /**
  75451. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75452. * @param targetFrameRate defines the target frame rate (60 by default)
  75453. * @returns a SceneOptimizerOptions object
  75454. */
  75455. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75456. /**
  75457. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75458. * @param targetFrameRate defines the target frame rate (60 by default)
  75459. * @returns a SceneOptimizerOptions object
  75460. */
  75461. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75462. /**
  75463. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75464. * @param targetFrameRate defines the target frame rate (60 by default)
  75465. * @returns a SceneOptimizerOptions object
  75466. */
  75467. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75468. }
  75469. /**
  75470. * Class used to run optimizations in order to reach a target frame rate
  75471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75472. */
  75473. export class SceneOptimizer implements IDisposable {
  75474. private _isRunning;
  75475. private _options;
  75476. private _scene;
  75477. private _currentPriorityLevel;
  75478. private _targetFrameRate;
  75479. private _trackerDuration;
  75480. private _currentFrameRate;
  75481. private _sceneDisposeObserver;
  75482. private _improvementMode;
  75483. /**
  75484. * Defines an observable called when the optimizer reaches the target frame rate
  75485. */
  75486. onSuccessObservable: Observable<SceneOptimizer>;
  75487. /**
  75488. * Defines an observable called when the optimizer enables an optimization
  75489. */
  75490. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75491. /**
  75492. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75493. */
  75494. onFailureObservable: Observable<SceneOptimizer>;
  75495. /**
  75496. * Gets a boolean indicating if the optimizer is in improvement mode
  75497. */
  75498. get isInImprovementMode(): boolean;
  75499. /**
  75500. * Gets the current priority level (0 at start)
  75501. */
  75502. get currentPriorityLevel(): number;
  75503. /**
  75504. * Gets the current frame rate checked by the SceneOptimizer
  75505. */
  75506. get currentFrameRate(): number;
  75507. /**
  75508. * Gets or sets the current target frame rate (60 by default)
  75509. */
  75510. get targetFrameRate(): number;
  75511. /**
  75512. * Gets or sets the current target frame rate (60 by default)
  75513. */
  75514. set targetFrameRate(value: number);
  75515. /**
  75516. * Gets or sets the current interval between two checks (every 2000ms by default)
  75517. */
  75518. get trackerDuration(): number;
  75519. /**
  75520. * Gets or sets the current interval between two checks (every 2000ms by default)
  75521. */
  75522. set trackerDuration(value: number);
  75523. /**
  75524. * Gets the list of active optimizations
  75525. */
  75526. get optimizations(): SceneOptimization[];
  75527. /**
  75528. * Creates a new SceneOptimizer
  75529. * @param scene defines the scene to work on
  75530. * @param options defines the options to use with the SceneOptimizer
  75531. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75532. * @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)
  75533. */
  75534. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75535. /**
  75536. * Stops the current optimizer
  75537. */
  75538. stop(): void;
  75539. /**
  75540. * Reset the optimizer to initial step (current priority level = 0)
  75541. */
  75542. reset(): void;
  75543. /**
  75544. * Start the optimizer. By default it will try to reach a specific framerate
  75545. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75546. */
  75547. start(): void;
  75548. private _checkCurrentState;
  75549. /**
  75550. * Release all resources
  75551. */
  75552. dispose(): void;
  75553. /**
  75554. * Helper function to create a SceneOptimizer with one single line of code
  75555. * @param scene defines the scene to work on
  75556. * @param options defines the options to use with the SceneOptimizer
  75557. * @param onSuccess defines a callback to call on success
  75558. * @param onFailure defines a callback to call on failure
  75559. * @returns the new SceneOptimizer object
  75560. */
  75561. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75562. }
  75563. }
  75564. declare module BABYLON {
  75565. /**
  75566. * Class used to serialize a scene into a string
  75567. */
  75568. export class SceneSerializer {
  75569. /**
  75570. * Clear cache used by a previous serialization
  75571. */
  75572. static ClearCache(): void;
  75573. /**
  75574. * Serialize a scene into a JSON compatible object
  75575. * @param scene defines the scene to serialize
  75576. * @returns a JSON compatible object
  75577. */
  75578. static Serialize(scene: Scene): any;
  75579. /**
  75580. * Serialize a mesh into a JSON compatible object
  75581. * @param toSerialize defines the mesh to serialize
  75582. * @param withParents defines if parents must be serialized as well
  75583. * @param withChildren defines if children must be serialized as well
  75584. * @returns a JSON compatible object
  75585. */
  75586. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75587. }
  75588. }
  75589. declare module BABYLON {
  75590. /**
  75591. * Class used to host texture specific utilities
  75592. */
  75593. export class TextureTools {
  75594. /**
  75595. * Uses the GPU to create a copy texture rescaled at a given size
  75596. * @param texture Texture to copy from
  75597. * @param width defines the desired width
  75598. * @param height defines the desired height
  75599. * @param useBilinearMode defines if bilinear mode has to be used
  75600. * @return the generated texture
  75601. */
  75602. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75603. }
  75604. }
  75605. declare module BABYLON {
  75606. /**
  75607. * This represents the different options available for the video capture.
  75608. */
  75609. export interface VideoRecorderOptions {
  75610. /** Defines the mime type of the video. */
  75611. mimeType: string;
  75612. /** Defines the FPS the video should be recorded at. */
  75613. fps: number;
  75614. /** Defines the chunk size for the recording data. */
  75615. recordChunckSize: number;
  75616. /** The audio tracks to attach to the recording. */
  75617. audioTracks?: MediaStreamTrack[];
  75618. }
  75619. /**
  75620. * This can help with recording videos from BabylonJS.
  75621. * This is based on the available WebRTC functionalities of the browser.
  75622. *
  75623. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75624. */
  75625. export class VideoRecorder {
  75626. private static readonly _defaultOptions;
  75627. /**
  75628. * Returns whether or not the VideoRecorder is available in your browser.
  75629. * @param engine Defines the Babylon Engine.
  75630. * @returns true if supported otherwise false.
  75631. */
  75632. static IsSupported(engine: Engine): boolean;
  75633. private readonly _options;
  75634. private _canvas;
  75635. private _mediaRecorder;
  75636. private _recordedChunks;
  75637. private _fileName;
  75638. private _resolve;
  75639. private _reject;
  75640. /**
  75641. * True when a recording is already in progress.
  75642. */
  75643. get isRecording(): boolean;
  75644. /**
  75645. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75646. * @param engine Defines the BabylonJS Engine you wish to record.
  75647. * @param options Defines options that can be used to customize the capture.
  75648. */
  75649. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75650. /**
  75651. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75652. */
  75653. stopRecording(): void;
  75654. /**
  75655. * Starts recording the canvas for a max duration specified in parameters.
  75656. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75657. * If null no automatic download will start and you can rely on the promise to get the data back.
  75658. * @param maxDuration Defines the maximum recording time in seconds.
  75659. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75660. * @return A promise callback at the end of the recording with the video data in Blob.
  75661. */
  75662. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75663. /**
  75664. * Releases internal resources used during the recording.
  75665. */
  75666. dispose(): void;
  75667. private _handleDataAvailable;
  75668. private _handleError;
  75669. private _handleStop;
  75670. }
  75671. }
  75672. declare module BABYLON {
  75673. /**
  75674. * Class containing a set of static utilities functions for screenshots
  75675. */
  75676. export class ScreenshotTools {
  75677. /**
  75678. * Captures a screenshot of the current rendering
  75679. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75680. * @param engine defines the rendering engine
  75681. * @param camera defines the source camera
  75682. * @param size This parameter can be set to a single number or to an object with the
  75683. * following (optional) properties: precision, width, height. If a single number is passed,
  75684. * it will be used for both width and height. If an object is passed, the screenshot size
  75685. * will be derived from the parameters. The precision property is a multiplier allowing
  75686. * rendering at a higher or lower resolution
  75687. * @param successCallback defines the callback receives a single parameter which contains the
  75688. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75689. * src parameter of an <img> to display it
  75690. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75691. * Check your browser for supported MIME types
  75692. */
  75693. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75694. /**
  75695. * Captures a screenshot of the current rendering
  75696. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75697. * @param engine defines the rendering engine
  75698. * @param camera defines the source camera
  75699. * @param size This parameter can be set to a single number or to an object with the
  75700. * following (optional) properties: precision, width, height. If a single number is passed,
  75701. * it will be used for both width and height. If an object is passed, the screenshot size
  75702. * will be derived from the parameters. The precision property is a multiplier allowing
  75703. * rendering at a higher or lower resolution
  75704. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75705. * Check your browser for supported MIME types
  75706. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75707. * to the src parameter of an <img> to display it
  75708. */
  75709. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75710. /**
  75711. * Generates an image screenshot from the specified camera.
  75712. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75713. * @param engine The engine to use for rendering
  75714. * @param camera The camera to use for rendering
  75715. * @param size This parameter can be set to a single number or to an object with the
  75716. * following (optional) properties: precision, width, height. If a single number is passed,
  75717. * it will be used for both width and height. If an object is passed, the screenshot size
  75718. * will be derived from the parameters. The precision property is a multiplier allowing
  75719. * rendering at a higher or lower resolution
  75720. * @param successCallback The callback receives a single parameter which contains the
  75721. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75722. * src parameter of an <img> to display it
  75723. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75724. * Check your browser for supported MIME types
  75725. * @param samples Texture samples (default: 1)
  75726. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75727. * @param fileName A name for for the downloaded file.
  75728. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75729. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75730. */
  75731. 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;
  75732. /**
  75733. * Generates an image screenshot from the specified camera.
  75734. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75735. * @param engine The engine to use for rendering
  75736. * @param camera The camera to use for rendering
  75737. * @param size This parameter can be set to a single number or to an object with the
  75738. * following (optional) properties: precision, width, height. If a single number is passed,
  75739. * it will be used for both width and height. If an object is passed, the screenshot size
  75740. * will be derived from the parameters. The precision property is a multiplier allowing
  75741. * rendering at a higher or lower resolution
  75742. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75743. * Check your browser for supported MIME types
  75744. * @param samples Texture samples (default: 1)
  75745. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75746. * @param fileName A name for for the downloaded file.
  75747. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75748. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75749. * to the src parameter of an <img> to display it
  75750. */
  75751. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75752. /**
  75753. * Gets height and width for screenshot size
  75754. * @private
  75755. */
  75756. private static _getScreenshotSize;
  75757. }
  75758. }
  75759. declare module BABYLON {
  75760. /**
  75761. * Interface for a data buffer
  75762. */
  75763. export interface IDataBuffer {
  75764. /**
  75765. * Reads bytes from the data buffer.
  75766. * @param byteOffset The byte offset to read
  75767. * @param byteLength The byte length to read
  75768. * @returns A promise that resolves when the bytes are read
  75769. */
  75770. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75771. /**
  75772. * The byte length of the buffer.
  75773. */
  75774. readonly byteLength: number;
  75775. }
  75776. /**
  75777. * Utility class for reading from a data buffer
  75778. */
  75779. export class DataReader {
  75780. /**
  75781. * The data buffer associated with this data reader.
  75782. */
  75783. readonly buffer: IDataBuffer;
  75784. /**
  75785. * The current byte offset from the beginning of the data buffer.
  75786. */
  75787. byteOffset: number;
  75788. private _dataView;
  75789. private _dataByteOffset;
  75790. /**
  75791. * Constructor
  75792. * @param buffer The buffer to read
  75793. */
  75794. constructor(buffer: IDataBuffer);
  75795. /**
  75796. * Loads the given byte length.
  75797. * @param byteLength The byte length to load
  75798. * @returns A promise that resolves when the load is complete
  75799. */
  75800. loadAsync(byteLength: number): Promise<void>;
  75801. /**
  75802. * Read a unsigned 32-bit integer from the currently loaded data range.
  75803. * @returns The 32-bit integer read
  75804. */
  75805. readUint32(): number;
  75806. /**
  75807. * Read a byte array from the currently loaded data range.
  75808. * @param byteLength The byte length to read
  75809. * @returns The byte array read
  75810. */
  75811. readUint8Array(byteLength: number): Uint8Array;
  75812. /**
  75813. * Read a string from the currently loaded data range.
  75814. * @param byteLength The byte length to read
  75815. * @returns The string read
  75816. */
  75817. readString(byteLength: number): string;
  75818. /**
  75819. * Skips the given byte length the currently loaded data range.
  75820. * @param byteLength The byte length to skip
  75821. */
  75822. skipBytes(byteLength: number): void;
  75823. }
  75824. }
  75825. declare module BABYLON {
  75826. /**
  75827. * Class for storing data to local storage if available or in-memory storage otherwise
  75828. */
  75829. export class DataStorage {
  75830. private static _Storage;
  75831. private static _GetStorage;
  75832. /**
  75833. * Reads a string from the data storage
  75834. * @param key The key to read
  75835. * @param defaultValue The value if the key doesn't exist
  75836. * @returns The string value
  75837. */
  75838. static ReadString(key: string, defaultValue: string): string;
  75839. /**
  75840. * Writes a string to the data storage
  75841. * @param key The key to write
  75842. * @param value The value to write
  75843. */
  75844. static WriteString(key: string, value: string): void;
  75845. /**
  75846. * Reads a boolean from the data storage
  75847. * @param key The key to read
  75848. * @param defaultValue The value if the key doesn't exist
  75849. * @returns The boolean value
  75850. */
  75851. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75852. /**
  75853. * Writes a boolean to the data storage
  75854. * @param key The key to write
  75855. * @param value The value to write
  75856. */
  75857. static WriteBoolean(key: string, value: boolean): void;
  75858. /**
  75859. * Reads a number from the data storage
  75860. * @param key The key to read
  75861. * @param defaultValue The value if the key doesn't exist
  75862. * @returns The number value
  75863. */
  75864. static ReadNumber(key: string, defaultValue: number): number;
  75865. /**
  75866. * Writes a number to the data storage
  75867. * @param key The key to write
  75868. * @param value The value to write
  75869. */
  75870. static WriteNumber(key: string, value: number): void;
  75871. }
  75872. }
  75873. declare module BABYLON {
  75874. /**
  75875. * Class used to record delta files between 2 scene states
  75876. */
  75877. export class SceneRecorder {
  75878. private _trackedScene;
  75879. private _savedJSON;
  75880. /**
  75881. * Track a given scene. This means the current scene state will be considered the original state
  75882. * @param scene defines the scene to track
  75883. */
  75884. track(scene: Scene): void;
  75885. /**
  75886. * Get the delta between current state and original state
  75887. * @returns a string containing the delta
  75888. */
  75889. getDelta(): any;
  75890. private _compareArray;
  75891. private _compareObjects;
  75892. private _compareCollections;
  75893. private static GetShadowGeneratorById;
  75894. /**
  75895. * Apply a given delta to a given scene
  75896. * @param deltaJSON defines the JSON containing the delta
  75897. * @param scene defines the scene to apply the delta to
  75898. */
  75899. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75900. private static _ApplyPropertiesToEntity;
  75901. private static _ApplyDeltaForEntity;
  75902. }
  75903. }
  75904. declare module BABYLON {
  75905. /**
  75906. * A 3D trajectory consisting of an order list of vectors describing a
  75907. * path of motion through 3D space.
  75908. */
  75909. export class Trajectory {
  75910. private _points;
  75911. private readonly _segmentLength;
  75912. /**
  75913. * Serialize to JSON.
  75914. * @returns serialized JSON string
  75915. */
  75916. serialize(): string;
  75917. /**
  75918. * Deserialize from JSON.
  75919. * @param json serialized JSON string
  75920. * @returns deserialized Trajectory
  75921. */
  75922. static Deserialize(json: string): Trajectory;
  75923. /**
  75924. * Create a new empty Trajectory.
  75925. * @param segmentLength radius of discretization for Trajectory points
  75926. */
  75927. constructor(segmentLength?: number);
  75928. /**
  75929. * Get the length of the Trajectory.
  75930. * @returns length of the Trajectory
  75931. */
  75932. getLength(): number;
  75933. /**
  75934. * Append a new point to the Trajectory.
  75935. * NOTE: This implementation has many allocations.
  75936. * @param point point to append to the Trajectory
  75937. */
  75938. add(point: DeepImmutable<Vector3>): void;
  75939. /**
  75940. * Create a new Trajectory with a segment length chosen to make it
  75941. * probable that the new Trajectory will have a specified number of
  75942. * segments. This operation is imprecise.
  75943. * @param targetResolution number of segments desired
  75944. * @returns new Trajectory with approximately the requested number of segments
  75945. */
  75946. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75947. /**
  75948. * Convert Trajectory segments into tokenized representation. This
  75949. * representation is an array of numbers where each nth number is the
  75950. * index of the token which is most similar to the nth segment of the
  75951. * Trajectory.
  75952. * @param tokens list of vectors which serve as discrete tokens
  75953. * @returns list of indices of most similar token per segment
  75954. */
  75955. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75956. private static _forwardDir;
  75957. private static _inverseFromVec;
  75958. private static _upDir;
  75959. private static _fromToVec;
  75960. private static _lookMatrix;
  75961. /**
  75962. * Transform the rotation (i.e., direction) of a segment to isolate
  75963. * the relative transformation represented by the segment. This operation
  75964. * may or may not succeed due to singularities in the equations that define
  75965. * motion relativity in this context.
  75966. * @param priorVec the origin of the prior segment
  75967. * @param fromVec the origin of the current segment
  75968. * @param toVec the destination of the current segment
  75969. * @param result reference to output variable
  75970. * @returns whether or not transformation was successful
  75971. */
  75972. private static _transformSegmentDirToRef;
  75973. private static _bestMatch;
  75974. private static _score;
  75975. private static _bestScore;
  75976. /**
  75977. * Determine which token vector is most similar to the
  75978. * segment vector.
  75979. * @param segment segment vector
  75980. * @param tokens token vector list
  75981. * @returns index of the most similar token to the segment
  75982. */
  75983. private static _tokenizeSegment;
  75984. }
  75985. /**
  75986. * Class representing a set of known, named trajectories to which Trajectories can be
  75987. * added and using which Trajectories can be recognized.
  75988. */
  75989. export class TrajectoryClassifier {
  75990. private _maximumAllowableMatchCost;
  75991. private _vector3Alphabet;
  75992. private _levenshteinAlphabet;
  75993. private _nameToDescribedTrajectory;
  75994. /**
  75995. * Serialize to JSON.
  75996. * @returns JSON serialization
  75997. */
  75998. serialize(): string;
  75999. /**
  76000. * Deserialize from JSON.
  76001. * @param json JSON serialization
  76002. * @returns deserialized TrajectorySet
  76003. */
  76004. static Deserialize(json: string): TrajectoryClassifier;
  76005. /**
  76006. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  76007. * VERY naive, need to be generating these things from known
  76008. * sets. Better version later, probably eliminating this one.
  76009. * @returns auto-generated TrajectorySet
  76010. */
  76011. static Generate(): TrajectoryClassifier;
  76012. private constructor();
  76013. /**
  76014. * Add a new Trajectory to the set with a given name.
  76015. * @param trajectory new Trajectory to be added
  76016. * @param classification name to which to add the Trajectory
  76017. */
  76018. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  76019. /**
  76020. * Remove a known named trajectory and all Trajectories associated with it.
  76021. * @param classification name to remove
  76022. * @returns whether anything was removed
  76023. */
  76024. deleteClassification(classification: string): boolean;
  76025. /**
  76026. * Attempt to recognize a Trajectory from among all the classifications
  76027. * already known to the classifier.
  76028. * @param trajectory Trajectory to be recognized
  76029. * @returns classification of Trajectory if recognized, null otherwise
  76030. */
  76031. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  76032. }
  76033. }
  76034. declare module BABYLON {
  76035. /**
  76036. * An interface for all Hit test features
  76037. */
  76038. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76039. /**
  76040. * Triggered when new babylon (transformed) hit test results are available
  76041. */
  76042. onHitTestResultObservable: Observable<T[]>;
  76043. }
  76044. /**
  76045. * Options used for hit testing
  76046. */
  76047. export interface IWebXRLegacyHitTestOptions {
  76048. /**
  76049. * Only test when user interacted with the scene. Default - hit test every frame
  76050. */
  76051. testOnPointerDownOnly?: boolean;
  76052. /**
  76053. * The node to use to transform the local results to world coordinates
  76054. */
  76055. worldParentNode?: TransformNode;
  76056. }
  76057. /**
  76058. * Interface defining the babylon result of raycasting/hit-test
  76059. */
  76060. export interface IWebXRLegacyHitResult {
  76061. /**
  76062. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76063. */
  76064. transformationMatrix: Matrix;
  76065. /**
  76066. * The native hit test result
  76067. */
  76068. xrHitResult: XRHitResult | XRHitTestResult;
  76069. }
  76070. /**
  76071. * The currently-working hit-test module.
  76072. * Hit test (or Ray-casting) is used to interact with the real world.
  76073. * For further information read here - https://github.com/immersive-web/hit-test
  76074. */
  76075. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76076. /**
  76077. * options to use when constructing this feature
  76078. */
  76079. readonly options: IWebXRLegacyHitTestOptions;
  76080. private _direction;
  76081. private _mat;
  76082. private _onSelectEnabled;
  76083. private _origin;
  76084. /**
  76085. * The module's name
  76086. */
  76087. static readonly Name: string;
  76088. /**
  76089. * The (Babylon) version of this module.
  76090. * This is an integer representing the implementation version.
  76091. * This number does not correspond to the WebXR specs version
  76092. */
  76093. static readonly Version: number;
  76094. /**
  76095. * Populated with the last native XR Hit Results
  76096. */
  76097. lastNativeXRHitResults: XRHitResult[];
  76098. /**
  76099. * Triggered when new babylon (transformed) hit test results are available
  76100. */
  76101. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76102. /**
  76103. * Creates a new instance of the (legacy version) hit test feature
  76104. * @param _xrSessionManager an instance of WebXRSessionManager
  76105. * @param options options to use when constructing this feature
  76106. */
  76107. constructor(_xrSessionManager: WebXRSessionManager,
  76108. /**
  76109. * options to use when constructing this feature
  76110. */
  76111. options?: IWebXRLegacyHitTestOptions);
  76112. /**
  76113. * execute a hit test with an XR Ray
  76114. *
  76115. * @param xrSession a native xrSession that will execute this hit test
  76116. * @param xrRay the ray (position and direction) to use for ray-casting
  76117. * @param referenceSpace native XR reference space to use for the hit-test
  76118. * @param filter filter function that will filter the results
  76119. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76120. */
  76121. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76122. /**
  76123. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76124. * @param event the (select) event to use to select with
  76125. * @param referenceSpace the reference space to use for this hit test
  76126. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76127. */
  76128. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76129. /**
  76130. * attach this feature
  76131. * Will usually be called by the features manager
  76132. *
  76133. * @returns true if successful.
  76134. */
  76135. attach(): boolean;
  76136. /**
  76137. * detach this feature.
  76138. * Will usually be called by the features manager
  76139. *
  76140. * @returns true if successful.
  76141. */
  76142. detach(): boolean;
  76143. /**
  76144. * Dispose this feature and all of the resources attached
  76145. */
  76146. dispose(): void;
  76147. protected _onXRFrame(frame: XRFrame): void;
  76148. private _onHitTestResults;
  76149. private _onSelect;
  76150. }
  76151. }
  76152. declare module BABYLON {
  76153. /**
  76154. * Options used for hit testing (version 2)
  76155. */
  76156. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76157. /**
  76158. * Do not create a permanent hit test. Will usually be used when only
  76159. * transient inputs are needed.
  76160. */
  76161. disablePermanentHitTest?: boolean;
  76162. /**
  76163. * Enable transient (for example touch-based) hit test inspections
  76164. */
  76165. enableTransientHitTest?: boolean;
  76166. /**
  76167. * Offset ray for the permanent hit test
  76168. */
  76169. offsetRay?: Vector3;
  76170. /**
  76171. * Offset ray for the transient hit test
  76172. */
  76173. transientOffsetRay?: Vector3;
  76174. /**
  76175. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76176. */
  76177. useReferenceSpace?: boolean;
  76178. /**
  76179. * Override the default entity type(s) of the hit-test result
  76180. */
  76181. entityTypes?: XRHitTestTrackableType[];
  76182. }
  76183. /**
  76184. * Interface defining the babylon result of hit-test
  76185. */
  76186. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76187. /**
  76188. * The input source that generated this hit test (if transient)
  76189. */
  76190. inputSource?: XRInputSource;
  76191. /**
  76192. * Is this a transient hit test
  76193. */
  76194. isTransient?: boolean;
  76195. /**
  76196. * Position of the hit test result
  76197. */
  76198. position: Vector3;
  76199. /**
  76200. * Rotation of the hit test result
  76201. */
  76202. rotationQuaternion: Quaternion;
  76203. /**
  76204. * The native hit test result
  76205. */
  76206. xrHitResult: XRHitTestResult;
  76207. }
  76208. /**
  76209. * The currently-working hit-test module.
  76210. * Hit test (or Ray-casting) is used to interact with the real world.
  76211. * For further information read here - https://github.com/immersive-web/hit-test
  76212. *
  76213. * Tested on chrome (mobile) 80.
  76214. */
  76215. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76216. /**
  76217. * options to use when constructing this feature
  76218. */
  76219. readonly options: IWebXRHitTestOptions;
  76220. private _tmpMat;
  76221. private _tmpPos;
  76222. private _tmpQuat;
  76223. private _transientXrHitTestSource;
  76224. private _xrHitTestSource;
  76225. private initHitTestSource;
  76226. /**
  76227. * The module's name
  76228. */
  76229. static readonly Name: string;
  76230. /**
  76231. * The (Babylon) version of this module.
  76232. * This is an integer representing the implementation version.
  76233. * This number does not correspond to the WebXR specs version
  76234. */
  76235. static readonly Version: number;
  76236. /**
  76237. * When set to true, each hit test will have its own position/rotation objects
  76238. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76239. * the developers will clone them or copy them as they see fit.
  76240. */
  76241. autoCloneTransformation: boolean;
  76242. /**
  76243. * Triggered when new babylon (transformed) hit test results are available
  76244. * Note - this will be called when results come back from the device. It can be an empty array!!
  76245. */
  76246. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76247. /**
  76248. * Use this to temporarily pause hit test checks.
  76249. */
  76250. paused: boolean;
  76251. /**
  76252. * Creates a new instance of the hit test feature
  76253. * @param _xrSessionManager an instance of WebXRSessionManager
  76254. * @param options options to use when constructing this feature
  76255. */
  76256. constructor(_xrSessionManager: WebXRSessionManager,
  76257. /**
  76258. * options to use when constructing this feature
  76259. */
  76260. options?: IWebXRHitTestOptions);
  76261. /**
  76262. * attach this feature
  76263. * Will usually be called by the features manager
  76264. *
  76265. * @returns true if successful.
  76266. */
  76267. attach(): boolean;
  76268. /**
  76269. * detach this feature.
  76270. * Will usually be called by the features manager
  76271. *
  76272. * @returns true if successful.
  76273. */
  76274. detach(): boolean;
  76275. /**
  76276. * Dispose this feature and all of the resources attached
  76277. */
  76278. dispose(): void;
  76279. protected _onXRFrame(frame: XRFrame): void;
  76280. private _processWebXRHitTestResult;
  76281. }
  76282. }
  76283. declare module BABYLON {
  76284. /**
  76285. * Configuration options of the anchor system
  76286. */
  76287. export interface IWebXRAnchorSystemOptions {
  76288. /**
  76289. * a node that will be used to convert local to world coordinates
  76290. */
  76291. worldParentNode?: TransformNode;
  76292. /**
  76293. * If set to true a reference of the created anchors will be kept until the next session starts
  76294. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76295. */
  76296. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76297. }
  76298. /**
  76299. * A babylon container for an XR Anchor
  76300. */
  76301. export interface IWebXRAnchor {
  76302. /**
  76303. * A babylon-assigned ID for this anchor
  76304. */
  76305. id: number;
  76306. /**
  76307. * Transformation matrix to apply to an object attached to this anchor
  76308. */
  76309. transformationMatrix: Matrix;
  76310. /**
  76311. * The native anchor object
  76312. */
  76313. xrAnchor: XRAnchor;
  76314. /**
  76315. * if defined, this object will be constantly updated by the anchor's position and rotation
  76316. */
  76317. attachedNode?: TransformNode;
  76318. /**
  76319. * Remove this anchor from the scene
  76320. */
  76321. remove(): void;
  76322. }
  76323. /**
  76324. * An implementation of the anchor system for WebXR.
  76325. * For further information see https://github.com/immersive-web/anchors/
  76326. */
  76327. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76328. private _options;
  76329. private _lastFrameDetected;
  76330. private _trackedAnchors;
  76331. private _referenceSpaceForFrameAnchors;
  76332. private _futureAnchors;
  76333. /**
  76334. * The module's name
  76335. */
  76336. static readonly Name: string;
  76337. /**
  76338. * The (Babylon) version of this module.
  76339. * This is an integer representing the implementation version.
  76340. * This number does not correspond to the WebXR specs version
  76341. */
  76342. static readonly Version: number;
  76343. /**
  76344. * Observers registered here will be executed when a new anchor was added to the session
  76345. */
  76346. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76347. /**
  76348. * Observers registered here will be executed when an anchor was removed from the session
  76349. */
  76350. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76351. /**
  76352. * Observers registered here will be executed when an existing anchor updates
  76353. * This can execute N times every frame
  76354. */
  76355. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76356. /**
  76357. * Set the reference space to use for anchor creation, when not using a hit test.
  76358. * Will default to the session's reference space if not defined
  76359. */
  76360. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76361. /**
  76362. * constructs a new anchor system
  76363. * @param _xrSessionManager an instance of WebXRSessionManager
  76364. * @param _options configuration object for this feature
  76365. */
  76366. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76367. private _tmpVector;
  76368. private _tmpQuaternion;
  76369. private _populateTmpTransformation;
  76370. /**
  76371. * Create a new anchor point using a hit test result at a specific point in the scene
  76372. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76373. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76374. *
  76375. * @param hitTestResult The hit test result to use for this anchor creation
  76376. * @param position an optional position offset for this anchor
  76377. * @param rotationQuaternion an optional rotation offset for this anchor
  76378. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76379. */
  76380. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76381. /**
  76382. * Add a new anchor at a specific position and rotation
  76383. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76384. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76385. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76386. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76387. *
  76388. * @param position the position in which to add an anchor
  76389. * @param rotationQuaternion an optional rotation for the anchor transformation
  76390. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76391. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76392. */
  76393. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76394. /**
  76395. * Get the list of anchors currently being tracked by the system
  76396. */
  76397. get anchors(): IWebXRAnchor[];
  76398. /**
  76399. * detach this feature.
  76400. * Will usually be called by the features manager
  76401. *
  76402. * @returns true if successful.
  76403. */
  76404. detach(): boolean;
  76405. /**
  76406. * Dispose this feature and all of the resources attached
  76407. */
  76408. dispose(): void;
  76409. protected _onXRFrame(frame: XRFrame): void;
  76410. /**
  76411. * avoiding using Array.find for global support.
  76412. * @param xrAnchor the plane to find in the array
  76413. */
  76414. private _findIndexInAnchorArray;
  76415. private _updateAnchorWithXRFrame;
  76416. private _createAnchorAtTransformation;
  76417. }
  76418. }
  76419. declare module BABYLON {
  76420. /**
  76421. * Options used in the plane detector module
  76422. */
  76423. export interface IWebXRPlaneDetectorOptions {
  76424. /**
  76425. * The node to use to transform the local results to world coordinates
  76426. */
  76427. worldParentNode?: TransformNode;
  76428. /**
  76429. * If set to true a reference of the created planes will be kept until the next session starts
  76430. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76431. */
  76432. doNotRemovePlanesOnSessionEnded?: boolean;
  76433. }
  76434. /**
  76435. * A babylon interface for a WebXR plane.
  76436. * A Plane is actually a polygon, built from N points in space
  76437. *
  76438. * Supported in chrome 79, not supported in canary 81 ATM
  76439. */
  76440. export interface IWebXRPlane {
  76441. /**
  76442. * a babylon-assigned ID for this polygon
  76443. */
  76444. id: number;
  76445. /**
  76446. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76447. */
  76448. polygonDefinition: Array<Vector3>;
  76449. /**
  76450. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76451. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76452. */
  76453. transformationMatrix: Matrix;
  76454. /**
  76455. * the native xr-plane object
  76456. */
  76457. xrPlane: XRPlane;
  76458. }
  76459. /**
  76460. * The plane detector is used to detect planes in the real world when in AR
  76461. * For more information see https://github.com/immersive-web/real-world-geometry/
  76462. */
  76463. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76464. private _options;
  76465. private _detectedPlanes;
  76466. private _enabled;
  76467. private _lastFrameDetected;
  76468. /**
  76469. * The module's name
  76470. */
  76471. static readonly Name: string;
  76472. /**
  76473. * The (Babylon) version of this module.
  76474. * This is an integer representing the implementation version.
  76475. * This number does not correspond to the WebXR specs version
  76476. */
  76477. static readonly Version: number;
  76478. /**
  76479. * Observers registered here will be executed when a new plane was added to the session
  76480. */
  76481. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76482. /**
  76483. * Observers registered here will be executed when a plane is no longer detected in the session
  76484. */
  76485. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76486. /**
  76487. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76488. * This can execute N times every frame
  76489. */
  76490. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76491. /**
  76492. * construct a new Plane Detector
  76493. * @param _xrSessionManager an instance of xr Session manager
  76494. * @param _options configuration to use when constructing this feature
  76495. */
  76496. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76497. /**
  76498. * detach this feature.
  76499. * Will usually be called by the features manager
  76500. *
  76501. * @returns true if successful.
  76502. */
  76503. detach(): boolean;
  76504. /**
  76505. * Dispose this feature and all of the resources attached
  76506. */
  76507. dispose(): void;
  76508. /**
  76509. * Check if the needed objects are defined.
  76510. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76511. */
  76512. isCompatible(): boolean;
  76513. protected _onXRFrame(frame: XRFrame): void;
  76514. private _init;
  76515. private _updatePlaneWithXRPlane;
  76516. /**
  76517. * avoiding using Array.find for global support.
  76518. * @param xrPlane the plane to find in the array
  76519. */
  76520. private findIndexInPlaneArray;
  76521. }
  76522. }
  76523. declare module BABYLON {
  76524. /**
  76525. * Options interface for the background remover plugin
  76526. */
  76527. export interface IWebXRBackgroundRemoverOptions {
  76528. /**
  76529. * Further background meshes to disable when entering AR
  76530. */
  76531. backgroundMeshes?: AbstractMesh[];
  76532. /**
  76533. * flags to configure the removal of the environment helper.
  76534. * If not set, the entire background will be removed. If set, flags should be set as well.
  76535. */
  76536. environmentHelperRemovalFlags?: {
  76537. /**
  76538. * Should the skybox be removed (default false)
  76539. */
  76540. skyBox?: boolean;
  76541. /**
  76542. * Should the ground be removed (default false)
  76543. */
  76544. ground?: boolean;
  76545. };
  76546. /**
  76547. * don't disable the environment helper
  76548. */
  76549. ignoreEnvironmentHelper?: boolean;
  76550. }
  76551. /**
  76552. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76553. */
  76554. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76555. /**
  76556. * read-only options to be used in this module
  76557. */
  76558. readonly options: IWebXRBackgroundRemoverOptions;
  76559. /**
  76560. * The module's name
  76561. */
  76562. static readonly Name: string;
  76563. /**
  76564. * The (Babylon) version of this module.
  76565. * This is an integer representing the implementation version.
  76566. * This number does not correspond to the WebXR specs version
  76567. */
  76568. static readonly Version: number;
  76569. /**
  76570. * registered observers will be triggered when the background state changes
  76571. */
  76572. onBackgroundStateChangedObservable: Observable<boolean>;
  76573. /**
  76574. * constructs a new background remover module
  76575. * @param _xrSessionManager the session manager for this module
  76576. * @param options read-only options to be used in this module
  76577. */
  76578. constructor(_xrSessionManager: WebXRSessionManager,
  76579. /**
  76580. * read-only options to be used in this module
  76581. */
  76582. options?: IWebXRBackgroundRemoverOptions);
  76583. /**
  76584. * attach this feature
  76585. * Will usually be called by the features manager
  76586. *
  76587. * @returns true if successful.
  76588. */
  76589. attach(): boolean;
  76590. /**
  76591. * detach this feature.
  76592. * Will usually be called by the features manager
  76593. *
  76594. * @returns true if successful.
  76595. */
  76596. detach(): boolean;
  76597. /**
  76598. * Dispose this feature and all of the resources attached
  76599. */
  76600. dispose(): void;
  76601. protected _onXRFrame(_xrFrame: XRFrame): void;
  76602. private _setBackgroundState;
  76603. }
  76604. }
  76605. declare module BABYLON {
  76606. /**
  76607. * Options for the controller physics feature
  76608. */
  76609. export class IWebXRControllerPhysicsOptions {
  76610. /**
  76611. * Should the headset get its own impostor
  76612. */
  76613. enableHeadsetImpostor?: boolean;
  76614. /**
  76615. * Optional parameters for the headset impostor
  76616. */
  76617. headsetImpostorParams?: {
  76618. /**
  76619. * The type of impostor to create. Default is sphere
  76620. */
  76621. impostorType: number;
  76622. /**
  76623. * the size of the impostor. Defaults to 10cm
  76624. */
  76625. impostorSize?: number | {
  76626. width: number;
  76627. height: number;
  76628. depth: number;
  76629. };
  76630. /**
  76631. * Friction definitions
  76632. */
  76633. friction?: number;
  76634. /**
  76635. * Restitution
  76636. */
  76637. restitution?: number;
  76638. };
  76639. /**
  76640. * The physics properties of the future impostors
  76641. */
  76642. physicsProperties?: {
  76643. /**
  76644. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76645. * Note that this requires a physics engine that supports mesh impostors!
  76646. */
  76647. useControllerMesh?: boolean;
  76648. /**
  76649. * The type of impostor to create. Default is sphere
  76650. */
  76651. impostorType?: number;
  76652. /**
  76653. * the size of the impostor. Defaults to 10cm
  76654. */
  76655. impostorSize?: number | {
  76656. width: number;
  76657. height: number;
  76658. depth: number;
  76659. };
  76660. /**
  76661. * Friction definitions
  76662. */
  76663. friction?: number;
  76664. /**
  76665. * Restitution
  76666. */
  76667. restitution?: number;
  76668. };
  76669. /**
  76670. * the xr input to use with this pointer selection
  76671. */
  76672. xrInput: WebXRInput;
  76673. }
  76674. /**
  76675. * Add physics impostor to your webxr controllers,
  76676. * including naive calculation of their linear and angular velocity
  76677. */
  76678. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76679. private readonly _options;
  76680. private _attachController;
  76681. private _controllers;
  76682. private _debugMode;
  76683. private _delta;
  76684. private _headsetImpostor?;
  76685. private _headsetMesh?;
  76686. private _lastTimestamp;
  76687. private _tmpQuaternion;
  76688. private _tmpVector;
  76689. /**
  76690. * The module's name
  76691. */
  76692. static readonly Name: string;
  76693. /**
  76694. * The (Babylon) version of this module.
  76695. * This is an integer representing the implementation version.
  76696. * This number does not correspond to the webxr specs version
  76697. */
  76698. static readonly Version: number;
  76699. /**
  76700. * Construct a new Controller Physics Feature
  76701. * @param _xrSessionManager the corresponding xr session manager
  76702. * @param _options options to create this feature with
  76703. */
  76704. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76705. /**
  76706. * @hidden
  76707. * enable debugging - will show console outputs and the impostor mesh
  76708. */
  76709. _enablePhysicsDebug(): void;
  76710. /**
  76711. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76712. * @param xrController the controller to add
  76713. */
  76714. addController(xrController: WebXRInputSource): void;
  76715. /**
  76716. * attach this feature
  76717. * Will usually be called by the features manager
  76718. *
  76719. * @returns true if successful.
  76720. */
  76721. attach(): boolean;
  76722. /**
  76723. * detach this feature.
  76724. * Will usually be called by the features manager
  76725. *
  76726. * @returns true if successful.
  76727. */
  76728. detach(): boolean;
  76729. /**
  76730. * Get the headset impostor, if enabled
  76731. * @returns the impostor
  76732. */
  76733. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76734. /**
  76735. * Get the physics impostor of a specific controller.
  76736. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76737. * @param controller the controller or the controller id of which to get the impostor
  76738. * @returns the impostor or null
  76739. */
  76740. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76741. /**
  76742. * Update the physics properties provided in the constructor
  76743. * @param newProperties the new properties object
  76744. */
  76745. setPhysicsProperties(newProperties: {
  76746. impostorType?: number;
  76747. impostorSize?: number | {
  76748. width: number;
  76749. height: number;
  76750. depth: number;
  76751. };
  76752. friction?: number;
  76753. restitution?: number;
  76754. }): void;
  76755. protected _onXRFrame(_xrFrame: any): void;
  76756. private _detachController;
  76757. }
  76758. }
  76759. declare module BABYLON {
  76760. /**
  76761. * A babylon interface for a "WebXR" feature point.
  76762. * Represents the position and confidence value of a given feature point.
  76763. */
  76764. export interface IWebXRFeaturePoint {
  76765. /**
  76766. * Represents the position of the feature point in world space.
  76767. */
  76768. position: Vector3;
  76769. /**
  76770. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76771. */
  76772. confidenceValue: number;
  76773. }
  76774. /**
  76775. * The feature point system is used to detect feature points from real world geometry.
  76776. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76777. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76778. */
  76779. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76780. private _enabled;
  76781. private _featurePointCloud;
  76782. /**
  76783. * The module's name
  76784. */
  76785. static readonly Name: string;
  76786. /**
  76787. * The (Babylon) version of this module.
  76788. * This is an integer representing the implementation version.
  76789. * This number does not correspond to the WebXR specs version
  76790. */
  76791. static readonly Version: number;
  76792. /**
  76793. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76794. * Will notify the observers about which feature points have been added.
  76795. */
  76796. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76797. /**
  76798. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76799. * Will notify the observers about which feature points have been updated.
  76800. */
  76801. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76802. /**
  76803. * The current feature point cloud maintained across frames.
  76804. */
  76805. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76806. /**
  76807. * construct the feature point system
  76808. * @param _xrSessionManager an instance of xr Session manager
  76809. */
  76810. constructor(_xrSessionManager: WebXRSessionManager);
  76811. /**
  76812. * Detach this feature.
  76813. * Will usually be called by the features manager
  76814. *
  76815. * @returns true if successful.
  76816. */
  76817. detach(): boolean;
  76818. /**
  76819. * Dispose this feature and all of the resources attached
  76820. */
  76821. dispose(): void;
  76822. /**
  76823. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76824. */
  76825. protected _onXRFrame(frame: XRFrame): void;
  76826. /**
  76827. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76828. */
  76829. private _init;
  76830. }
  76831. }
  76832. declare module BABYLON {
  76833. /**
  76834. * Configuration interface for the hand tracking feature
  76835. */
  76836. export interface IWebXRHandTrackingOptions {
  76837. /**
  76838. * The xrInput that will be used as source for new hands
  76839. */
  76840. xrInput: WebXRInput;
  76841. /**
  76842. * Configuration object for the joint meshes
  76843. */
  76844. jointMeshes?: {
  76845. /**
  76846. * Should the meshes created be invisible (defaults to false)
  76847. */
  76848. invisible?: boolean;
  76849. /**
  76850. * A source mesh to be used to create instances. Defaults to a sphere.
  76851. * This mesh will be the source for all other (25) meshes.
  76852. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76853. */
  76854. sourceMesh?: Mesh;
  76855. /**
  76856. * This function will be called after a mesh was created for a specific joint.
  76857. * Using this function you can either manipulate the instance or return a new mesh.
  76858. * When returning a new mesh the instance created before will be disposed
  76859. */
  76860. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76861. /**
  76862. * Should the source mesh stay visible. Defaults to false
  76863. */
  76864. keepOriginalVisible?: boolean;
  76865. /**
  76866. * Scale factor for all instances (defaults to 2)
  76867. */
  76868. scaleFactor?: number;
  76869. /**
  76870. * Should each instance have its own physics impostor
  76871. */
  76872. enablePhysics?: boolean;
  76873. /**
  76874. * If enabled, override default physics properties
  76875. */
  76876. physicsProps?: {
  76877. friction?: number;
  76878. restitution?: number;
  76879. impostorType?: number;
  76880. };
  76881. /**
  76882. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  76883. */
  76884. disableDefaultHandMesh?: boolean;
  76885. /**
  76886. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  76887. */
  76888. handMeshes?: {
  76889. right: AbstractMesh;
  76890. left: AbstractMesh;
  76891. };
  76892. /**
  76893. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  76894. */
  76895. rigMapping?: {
  76896. right: string[];
  76897. left: string[];
  76898. };
  76899. };
  76900. }
  76901. /**
  76902. * Parts of the hands divided to writs and finger names
  76903. */
  76904. export const enum HandPart {
  76905. /**
  76906. * HandPart - Wrist
  76907. */
  76908. WRIST = "wrist",
  76909. /**
  76910. * HandPart - The THumb
  76911. */
  76912. THUMB = "thumb",
  76913. /**
  76914. * HandPart - Index finger
  76915. */
  76916. INDEX = "index",
  76917. /**
  76918. * HandPart - Middle finger
  76919. */
  76920. MIDDLE = "middle",
  76921. /**
  76922. * HandPart - Ring finger
  76923. */
  76924. RING = "ring",
  76925. /**
  76926. * HandPart - Little finger
  76927. */
  76928. LITTLE = "little"
  76929. }
  76930. /**
  76931. * Representing a single hand (with its corresponding native XRHand object)
  76932. */
  76933. export class WebXRHand implements IDisposable {
  76934. /** the controller to which the hand correlates */
  76935. readonly xrController: WebXRInputSource;
  76936. /** the meshes to be used to track the hand joints */
  76937. readonly trackedMeshes: AbstractMesh[];
  76938. private _handMesh?;
  76939. private _rigMapping?;
  76940. private _scene;
  76941. private _defaultHandMesh;
  76942. private _transformNodeMapping;
  76943. /**
  76944. * Hand-parts definition (key is HandPart)
  76945. */
  76946. handPartsDefinition: {
  76947. [key: string]: number[];
  76948. };
  76949. /**
  76950. * Populate the HandPartsDefinition object.
  76951. * This is called as a side effect since certain browsers don't have XRHand defined.
  76952. */
  76953. private generateHandPartsDefinition;
  76954. /**
  76955. * Construct a new hand object
  76956. * @param xrController the controller to which the hand correlates
  76957. * @param trackedMeshes the meshes to be used to track the hand joints
  76958. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  76959. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  76960. * @param disableDefaultHandMesh should the default mesh creation be disabled
  76961. */
  76962. constructor(
  76963. /** the controller to which the hand correlates */
  76964. xrController: WebXRInputSource,
  76965. /** the meshes to be used to track the hand joints */
  76966. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  76967. /**
  76968. * Update this hand from the latest xr frame
  76969. * @param xrFrame xrFrame to update from
  76970. * @param referenceSpace The current viewer reference space
  76971. * @param scaleFactor optional scale factor for the meshes
  76972. */
  76973. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76974. /**
  76975. * Get meshes of part of the hand
  76976. * @param part the part of hand to get
  76977. * @returns An array of meshes that correlate to the hand part requested
  76978. */
  76979. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76980. /**
  76981. * Dispose this Hand object
  76982. */
  76983. dispose(): void;
  76984. private _generateDefaultHandMesh;
  76985. }
  76986. /**
  76987. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76988. */
  76989. export class WebXRHandTracking extends WebXRAbstractFeature {
  76990. /**
  76991. * options to use when constructing this feature
  76992. */
  76993. readonly options: IWebXRHandTrackingOptions;
  76994. private static _idCounter;
  76995. /**
  76996. * The module's name
  76997. */
  76998. static readonly Name: string;
  76999. /**
  77000. * The (Babylon) version of this module.
  77001. * This is an integer representing the implementation version.
  77002. * This number does not correspond to the WebXR specs version
  77003. */
  77004. static readonly Version: number;
  77005. /**
  77006. * This observable will notify registered observers when a new hand object was added and initialized
  77007. */
  77008. onHandAddedObservable: Observable<WebXRHand>;
  77009. /**
  77010. * This observable will notify its observers right before the hand object is disposed
  77011. */
  77012. onHandRemovedObservable: Observable<WebXRHand>;
  77013. private _hands;
  77014. /**
  77015. * Creates a new instance of the hit test feature
  77016. * @param _xrSessionManager an instance of WebXRSessionManager
  77017. * @param options options to use when constructing this feature
  77018. */
  77019. constructor(_xrSessionManager: WebXRSessionManager,
  77020. /**
  77021. * options to use when constructing this feature
  77022. */
  77023. options: IWebXRHandTrackingOptions);
  77024. /**
  77025. * Check if the needed objects are defined.
  77026. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  77027. */
  77028. isCompatible(): boolean;
  77029. /**
  77030. * attach this feature
  77031. * Will usually be called by the features manager
  77032. *
  77033. * @returns true if successful.
  77034. */
  77035. attach(): boolean;
  77036. /**
  77037. * detach this feature.
  77038. * Will usually be called by the features manager
  77039. *
  77040. * @returns true if successful.
  77041. */
  77042. detach(): boolean;
  77043. /**
  77044. * Dispose this feature and all of the resources attached
  77045. */
  77046. dispose(): void;
  77047. /**
  77048. * Get the hand object according to the controller id
  77049. * @param controllerId the controller id to which we want to get the hand
  77050. * @returns null if not found or the WebXRHand object if found
  77051. */
  77052. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  77053. /**
  77054. * Get a hand object according to the requested handedness
  77055. * @param handedness the handedness to request
  77056. * @returns null if not found or the WebXRHand object if found
  77057. */
  77058. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  77059. protected _onXRFrame(_xrFrame: XRFrame): void;
  77060. private _attachHand;
  77061. private _detachHand;
  77062. }
  77063. }
  77064. declare module BABYLON {
  77065. /**
  77066. * The motion controller class for all microsoft mixed reality controllers
  77067. */
  77068. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77069. protected readonly _mapping: {
  77070. defaultButton: {
  77071. valueNodeName: string;
  77072. unpressedNodeName: string;
  77073. pressedNodeName: string;
  77074. };
  77075. defaultAxis: {
  77076. valueNodeName: string;
  77077. minNodeName: string;
  77078. maxNodeName: string;
  77079. };
  77080. buttons: {
  77081. "xr-standard-trigger": {
  77082. rootNodeName: string;
  77083. componentProperty: string;
  77084. states: string[];
  77085. };
  77086. "xr-standard-squeeze": {
  77087. rootNodeName: string;
  77088. componentProperty: string;
  77089. states: string[];
  77090. };
  77091. "xr-standard-touchpad": {
  77092. rootNodeName: string;
  77093. labelAnchorNodeName: string;
  77094. touchPointNodeName: string;
  77095. };
  77096. "xr-standard-thumbstick": {
  77097. rootNodeName: string;
  77098. componentProperty: string;
  77099. states: string[];
  77100. };
  77101. };
  77102. axes: {
  77103. "xr-standard-touchpad": {
  77104. "x-axis": {
  77105. rootNodeName: string;
  77106. };
  77107. "y-axis": {
  77108. rootNodeName: string;
  77109. };
  77110. };
  77111. "xr-standard-thumbstick": {
  77112. "x-axis": {
  77113. rootNodeName: string;
  77114. };
  77115. "y-axis": {
  77116. rootNodeName: string;
  77117. };
  77118. };
  77119. };
  77120. };
  77121. /**
  77122. * The base url used to load the left and right controller models
  77123. */
  77124. static MODEL_BASE_URL: string;
  77125. /**
  77126. * The name of the left controller model file
  77127. */
  77128. static MODEL_LEFT_FILENAME: string;
  77129. /**
  77130. * The name of the right controller model file
  77131. */
  77132. static MODEL_RIGHT_FILENAME: string;
  77133. profileId: string;
  77134. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77135. protected _getFilenameAndPath(): {
  77136. filename: string;
  77137. path: string;
  77138. };
  77139. protected _getModelLoadingConstraints(): boolean;
  77140. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77141. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77142. protected _updateModel(): void;
  77143. }
  77144. }
  77145. declare module BABYLON {
  77146. /**
  77147. * The motion controller class for oculus touch (quest, rift).
  77148. * This class supports legacy mapping as well the standard xr mapping
  77149. */
  77150. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77151. private _forceLegacyControllers;
  77152. private _modelRootNode;
  77153. /**
  77154. * The base url used to load the left and right controller models
  77155. */
  77156. static MODEL_BASE_URL: string;
  77157. /**
  77158. * The name of the left controller model file
  77159. */
  77160. static MODEL_LEFT_FILENAME: string;
  77161. /**
  77162. * The name of the right controller model file
  77163. */
  77164. static MODEL_RIGHT_FILENAME: string;
  77165. /**
  77166. * Base Url for the Quest controller model.
  77167. */
  77168. static QUEST_MODEL_BASE_URL: string;
  77169. profileId: string;
  77170. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77171. protected _getFilenameAndPath(): {
  77172. filename: string;
  77173. path: string;
  77174. };
  77175. protected _getModelLoadingConstraints(): boolean;
  77176. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77177. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77178. protected _updateModel(): void;
  77179. /**
  77180. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77181. * between the touch and touch 2.
  77182. */
  77183. private _isQuest;
  77184. }
  77185. }
  77186. declare module BABYLON {
  77187. /**
  77188. * The motion controller class for the standard HTC-Vive controllers
  77189. */
  77190. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77191. private _modelRootNode;
  77192. /**
  77193. * The base url used to load the left and right controller models
  77194. */
  77195. static MODEL_BASE_URL: string;
  77196. /**
  77197. * File name for the controller model.
  77198. */
  77199. static MODEL_FILENAME: string;
  77200. profileId: string;
  77201. /**
  77202. * Create a new Vive motion controller object
  77203. * @param scene the scene to use to create this controller
  77204. * @param gamepadObject the corresponding gamepad object
  77205. * @param handedness the handedness of the controller
  77206. */
  77207. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77208. protected _getFilenameAndPath(): {
  77209. filename: string;
  77210. path: string;
  77211. };
  77212. protected _getModelLoadingConstraints(): boolean;
  77213. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77214. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77215. protected _updateModel(): void;
  77216. }
  77217. }
  77218. declare module BABYLON {
  77219. /**
  77220. * A cursor which tracks a point on a path
  77221. */
  77222. export class PathCursor {
  77223. private path;
  77224. /**
  77225. * Stores path cursor callbacks for when an onchange event is triggered
  77226. */
  77227. private _onchange;
  77228. /**
  77229. * The value of the path cursor
  77230. */
  77231. value: number;
  77232. /**
  77233. * The animation array of the path cursor
  77234. */
  77235. animations: Animation[];
  77236. /**
  77237. * Initializes the path cursor
  77238. * @param path The path to track
  77239. */
  77240. constructor(path: Path2);
  77241. /**
  77242. * Gets the cursor point on the path
  77243. * @returns A point on the path cursor at the cursor location
  77244. */
  77245. getPoint(): Vector3;
  77246. /**
  77247. * Moves the cursor ahead by the step amount
  77248. * @param step The amount to move the cursor forward
  77249. * @returns This path cursor
  77250. */
  77251. moveAhead(step?: number): PathCursor;
  77252. /**
  77253. * Moves the cursor behind by the step amount
  77254. * @param step The amount to move the cursor back
  77255. * @returns This path cursor
  77256. */
  77257. moveBack(step?: number): PathCursor;
  77258. /**
  77259. * Moves the cursor by the step amount
  77260. * If the step amount is greater than one, an exception is thrown
  77261. * @param step The amount to move the cursor
  77262. * @returns This path cursor
  77263. */
  77264. move(step: number): PathCursor;
  77265. /**
  77266. * Ensures that the value is limited between zero and one
  77267. * @returns This path cursor
  77268. */
  77269. private ensureLimits;
  77270. /**
  77271. * Runs onchange callbacks on change (used by the animation engine)
  77272. * @returns This path cursor
  77273. */
  77274. private raiseOnChange;
  77275. /**
  77276. * Executes a function on change
  77277. * @param f A path cursor onchange callback
  77278. * @returns This path cursor
  77279. */
  77280. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77281. }
  77282. }
  77283. declare module BABYLON {
  77284. /** @hidden */
  77285. export var blurPixelShader: {
  77286. name: string;
  77287. shader: string;
  77288. };
  77289. }
  77290. declare module BABYLON {
  77291. /** @hidden */
  77292. export var pointCloudVertexDeclaration: {
  77293. name: string;
  77294. shader: string;
  77295. };
  77296. }
  77297. // Mixins
  77298. interface Window {
  77299. mozIndexedDB: IDBFactory;
  77300. webkitIndexedDB: IDBFactory;
  77301. msIndexedDB: IDBFactory;
  77302. webkitURL: typeof URL;
  77303. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77304. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77305. WebGLRenderingContext: WebGLRenderingContext;
  77306. MSGesture: MSGesture;
  77307. CANNON: any;
  77308. AudioContext: AudioContext;
  77309. webkitAudioContext: AudioContext;
  77310. PointerEvent: any;
  77311. Math: Math;
  77312. Uint8Array: Uint8ArrayConstructor;
  77313. Float32Array: Float32ArrayConstructor;
  77314. mozURL: typeof URL;
  77315. msURL: typeof URL;
  77316. VRFrameData: any; // WebVR, from specs 1.1
  77317. DracoDecoderModule: any;
  77318. setImmediate(handler: (...args: any[]) => void): number;
  77319. }
  77320. interface HTMLCanvasElement {
  77321. requestPointerLock(): void;
  77322. msRequestPointerLock?(): void;
  77323. mozRequestPointerLock?(): void;
  77324. webkitRequestPointerLock?(): void;
  77325. /** Track wether a record is in progress */
  77326. isRecording: boolean;
  77327. /** Capture Stream method defined by some browsers */
  77328. captureStream(fps?: number): MediaStream;
  77329. }
  77330. interface CanvasRenderingContext2D {
  77331. msImageSmoothingEnabled: boolean;
  77332. }
  77333. interface MouseEvent {
  77334. mozMovementX: number;
  77335. mozMovementY: number;
  77336. webkitMovementX: number;
  77337. webkitMovementY: number;
  77338. msMovementX: number;
  77339. msMovementY: number;
  77340. }
  77341. interface Navigator {
  77342. mozGetVRDevices: (any: any) => any;
  77343. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77344. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77345. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77346. webkitGetGamepads(): Gamepad[];
  77347. msGetGamepads(): Gamepad[];
  77348. webkitGamepads(): Gamepad[];
  77349. }
  77350. interface HTMLVideoElement {
  77351. mozSrcObject: any;
  77352. }
  77353. interface Math {
  77354. fround(x: number): number;
  77355. imul(a: number, b: number): number;
  77356. }
  77357. interface WebGLRenderingContext {
  77358. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77359. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77360. vertexAttribDivisor(index: number, divisor: number): void;
  77361. createVertexArray(): any;
  77362. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77363. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77364. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77365. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77366. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77367. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77368. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77369. // Queries
  77370. createQuery(): WebGLQuery;
  77371. deleteQuery(query: WebGLQuery): void;
  77372. beginQuery(target: number, query: WebGLQuery): void;
  77373. endQuery(target: number): void;
  77374. getQueryParameter(query: WebGLQuery, pname: number): any;
  77375. getQuery(target: number, pname: number): any;
  77376. MAX_SAMPLES: number;
  77377. RGBA8: number;
  77378. READ_FRAMEBUFFER: number;
  77379. DRAW_FRAMEBUFFER: number;
  77380. UNIFORM_BUFFER: number;
  77381. HALF_FLOAT_OES: number;
  77382. RGBA16F: number;
  77383. RGBA32F: number;
  77384. R32F: number;
  77385. RG32F: number;
  77386. RGB32F: number;
  77387. R16F: number;
  77388. RG16F: number;
  77389. RGB16F: number;
  77390. RED: number;
  77391. RG: number;
  77392. R8: number;
  77393. RG8: number;
  77394. UNSIGNED_INT_24_8: number;
  77395. DEPTH24_STENCIL8: number;
  77396. MIN: number;
  77397. MAX: number;
  77398. /* Multiple Render Targets */
  77399. drawBuffers(buffers: number[]): void;
  77400. readBuffer(src: number): void;
  77401. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77402. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77403. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77404. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77405. // Occlusion Query
  77406. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77407. ANY_SAMPLES_PASSED: number;
  77408. QUERY_RESULT_AVAILABLE: number;
  77409. QUERY_RESULT: number;
  77410. }
  77411. interface WebGLProgram {
  77412. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77413. }
  77414. interface EXT_disjoint_timer_query {
  77415. QUERY_COUNTER_BITS_EXT: number;
  77416. TIME_ELAPSED_EXT: number;
  77417. TIMESTAMP_EXT: number;
  77418. GPU_DISJOINT_EXT: number;
  77419. QUERY_RESULT_EXT: number;
  77420. QUERY_RESULT_AVAILABLE_EXT: number;
  77421. queryCounterEXT(query: WebGLQuery, target: number): void;
  77422. createQueryEXT(): WebGLQuery;
  77423. beginQueryEXT(target: number, query: WebGLQuery): void;
  77424. endQueryEXT(target: number): void;
  77425. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77426. deleteQueryEXT(query: WebGLQuery): void;
  77427. }
  77428. interface WebGLUniformLocation {
  77429. _currentState: any;
  77430. }
  77431. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77432. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77433. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77434. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77435. interface WebGLRenderingContext {
  77436. readonly RASTERIZER_DISCARD: number;
  77437. readonly DEPTH_COMPONENT24: number;
  77438. readonly TEXTURE_3D: number;
  77439. readonly TEXTURE_2D_ARRAY: number;
  77440. readonly TEXTURE_COMPARE_FUNC: number;
  77441. readonly TEXTURE_COMPARE_MODE: number;
  77442. readonly COMPARE_REF_TO_TEXTURE: number;
  77443. readonly TEXTURE_WRAP_R: number;
  77444. readonly HALF_FLOAT: number;
  77445. readonly RGB8: number;
  77446. readonly RED_INTEGER: number;
  77447. readonly RG_INTEGER: number;
  77448. readonly RGB_INTEGER: number;
  77449. readonly RGBA_INTEGER: number;
  77450. readonly R8_SNORM: number;
  77451. readonly RG8_SNORM: number;
  77452. readonly RGB8_SNORM: number;
  77453. readonly RGBA8_SNORM: number;
  77454. readonly R8I: number;
  77455. readonly RG8I: number;
  77456. readonly RGB8I: number;
  77457. readonly RGBA8I: number;
  77458. readonly R8UI: number;
  77459. readonly RG8UI: number;
  77460. readonly RGB8UI: number;
  77461. readonly RGBA8UI: number;
  77462. readonly R16I: number;
  77463. readonly RG16I: number;
  77464. readonly RGB16I: number;
  77465. readonly RGBA16I: number;
  77466. readonly R16UI: number;
  77467. readonly RG16UI: number;
  77468. readonly RGB16UI: number;
  77469. readonly RGBA16UI: number;
  77470. readonly R32I: number;
  77471. readonly RG32I: number;
  77472. readonly RGB32I: number;
  77473. readonly RGBA32I: number;
  77474. readonly R32UI: number;
  77475. readonly RG32UI: number;
  77476. readonly RGB32UI: number;
  77477. readonly RGBA32UI: number;
  77478. readonly RGB10_A2UI: number;
  77479. readonly R11F_G11F_B10F: number;
  77480. readonly RGB9_E5: number;
  77481. readonly RGB10_A2: number;
  77482. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77483. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77484. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77485. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77486. readonly DEPTH_COMPONENT32F: number;
  77487. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77488. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77489. 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;
  77490. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77491. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77492. readonly TRANSFORM_FEEDBACK: number;
  77493. readonly INTERLEAVED_ATTRIBS: number;
  77494. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77495. createTransformFeedback(): WebGLTransformFeedback;
  77496. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77497. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77498. beginTransformFeedback(primitiveMode: number): void;
  77499. endTransformFeedback(): void;
  77500. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77501. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77502. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77503. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77504. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77505. }
  77506. interface ImageBitmap {
  77507. readonly width: number;
  77508. readonly height: number;
  77509. close(): void;
  77510. }
  77511. interface WebGLQuery extends WebGLObject {
  77512. }
  77513. declare var WebGLQuery: {
  77514. prototype: WebGLQuery;
  77515. new(): WebGLQuery;
  77516. };
  77517. interface WebGLSampler extends WebGLObject {
  77518. }
  77519. declare var WebGLSampler: {
  77520. prototype: WebGLSampler;
  77521. new(): WebGLSampler;
  77522. };
  77523. interface WebGLSync extends WebGLObject {
  77524. }
  77525. declare var WebGLSync: {
  77526. prototype: WebGLSync;
  77527. new(): WebGLSync;
  77528. };
  77529. interface WebGLTransformFeedback extends WebGLObject {
  77530. }
  77531. declare var WebGLTransformFeedback: {
  77532. prototype: WebGLTransformFeedback;
  77533. new(): WebGLTransformFeedback;
  77534. };
  77535. interface WebGLVertexArrayObject extends WebGLObject {
  77536. }
  77537. declare var WebGLVertexArrayObject: {
  77538. prototype: WebGLVertexArrayObject;
  77539. new(): WebGLVertexArrayObject;
  77540. };
  77541. // Type definitions for WebVR API
  77542. // Project: https://w3c.github.io/webvr/
  77543. // Definitions by: six a <https://github.com/lostfictions>
  77544. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77545. interface VRDisplay extends EventTarget {
  77546. /**
  77547. * Dictionary of capabilities describing the VRDisplay.
  77548. */
  77549. readonly capabilities: VRDisplayCapabilities;
  77550. /**
  77551. * z-depth defining the far plane of the eye view frustum
  77552. * enables mapping of values in the render target depth
  77553. * attachment to scene coordinates. Initially set to 10000.0.
  77554. */
  77555. depthFar: number;
  77556. /**
  77557. * z-depth defining the near plane of the eye view frustum
  77558. * enables mapping of values in the render target depth
  77559. * attachment to scene coordinates. Initially set to 0.01.
  77560. */
  77561. depthNear: number;
  77562. /**
  77563. * An identifier for this distinct VRDisplay. Used as an
  77564. * association point in the Gamepad API.
  77565. */
  77566. readonly displayId: number;
  77567. /**
  77568. * A display name, a user-readable name identifying it.
  77569. */
  77570. readonly displayName: string;
  77571. readonly isConnected: boolean;
  77572. readonly isPresenting: boolean;
  77573. /**
  77574. * If this VRDisplay supports room-scale experiences, the optional
  77575. * stage attribute contains details on the room-scale parameters.
  77576. */
  77577. readonly stageParameters: VRStageParameters | null;
  77578. /**
  77579. * Passing the value returned by `requestAnimationFrame` to
  77580. * `cancelAnimationFrame` will unregister the callback.
  77581. * @param handle Define the hanle of the request to cancel
  77582. */
  77583. cancelAnimationFrame(handle: number): void;
  77584. /**
  77585. * Stops presenting to the VRDisplay.
  77586. * @returns a promise to know when it stopped
  77587. */
  77588. exitPresent(): Promise<void>;
  77589. /**
  77590. * Return the current VREyeParameters for the given eye.
  77591. * @param whichEye Define the eye we want the parameter for
  77592. * @returns the eye parameters
  77593. */
  77594. getEyeParameters(whichEye: string): VREyeParameters;
  77595. /**
  77596. * Populates the passed VRFrameData with the information required to render
  77597. * the current frame.
  77598. * @param frameData Define the data structure to populate
  77599. * @returns true if ok otherwise false
  77600. */
  77601. getFrameData(frameData: VRFrameData): boolean;
  77602. /**
  77603. * Get the layers currently being presented.
  77604. * @returns the list of VR layers
  77605. */
  77606. getLayers(): VRLayer[];
  77607. /**
  77608. * Return a VRPose containing the future predicted pose of the VRDisplay
  77609. * when the current frame will be presented. The value returned will not
  77610. * change until JavaScript has returned control to the browser.
  77611. *
  77612. * The VRPose will contain the position, orientation, velocity,
  77613. * and acceleration of each of these properties.
  77614. * @returns the pose object
  77615. */
  77616. getPose(): VRPose;
  77617. /**
  77618. * Return the current instantaneous pose of the VRDisplay, with no
  77619. * prediction applied.
  77620. * @returns the current instantaneous pose
  77621. */
  77622. getImmediatePose(): VRPose;
  77623. /**
  77624. * The callback passed to `requestAnimationFrame` will be called
  77625. * any time a new frame should be rendered. When the VRDisplay is
  77626. * presenting the callback will be called at the native refresh
  77627. * rate of the HMD. When not presenting this function acts
  77628. * identically to how window.requestAnimationFrame acts. Content should
  77629. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77630. * asynchronously from other displays and at differing refresh rates.
  77631. * @param callback Define the eaction to run next frame
  77632. * @returns the request handle it
  77633. */
  77634. requestAnimationFrame(callback: FrameRequestCallback): number;
  77635. /**
  77636. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77637. * Repeat calls while already presenting will update the VRLayers being displayed.
  77638. * @param layers Define the list of layer to present
  77639. * @returns a promise to know when the request has been fulfilled
  77640. */
  77641. requestPresent(layers: VRLayer[]): Promise<void>;
  77642. /**
  77643. * Reset the pose for this display, treating its current position and
  77644. * orientation as the "origin/zero" values. VRPose.position,
  77645. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77646. * updated when calling resetPose(). This should be called in only
  77647. * sitting-space experiences.
  77648. */
  77649. resetPose(): void;
  77650. /**
  77651. * The VRLayer provided to the VRDisplay will be captured and presented
  77652. * in the HMD. Calling this function has the same effect on the source
  77653. * canvas as any other operation that uses its source image, and canvases
  77654. * created without preserveDrawingBuffer set to true will be cleared.
  77655. * @param pose Define the pose to submit
  77656. */
  77657. submitFrame(pose?: VRPose): void;
  77658. }
  77659. declare var VRDisplay: {
  77660. prototype: VRDisplay;
  77661. new(): VRDisplay;
  77662. };
  77663. interface VRLayer {
  77664. leftBounds?: number[] | Float32Array | null;
  77665. rightBounds?: number[] | Float32Array | null;
  77666. source?: HTMLCanvasElement | null;
  77667. }
  77668. interface VRDisplayCapabilities {
  77669. readonly canPresent: boolean;
  77670. readonly hasExternalDisplay: boolean;
  77671. readonly hasOrientation: boolean;
  77672. readonly hasPosition: boolean;
  77673. readonly maxLayers: number;
  77674. }
  77675. interface VREyeParameters {
  77676. /** @deprecated */
  77677. readonly fieldOfView: VRFieldOfView;
  77678. readonly offset: Float32Array;
  77679. readonly renderHeight: number;
  77680. readonly renderWidth: number;
  77681. }
  77682. interface VRFieldOfView {
  77683. readonly downDegrees: number;
  77684. readonly leftDegrees: number;
  77685. readonly rightDegrees: number;
  77686. readonly upDegrees: number;
  77687. }
  77688. interface VRFrameData {
  77689. readonly leftProjectionMatrix: Float32Array;
  77690. readonly leftViewMatrix: Float32Array;
  77691. readonly pose: VRPose;
  77692. readonly rightProjectionMatrix: Float32Array;
  77693. readonly rightViewMatrix: Float32Array;
  77694. readonly timestamp: number;
  77695. }
  77696. interface VRPose {
  77697. readonly angularAcceleration: Float32Array | null;
  77698. readonly angularVelocity: Float32Array | null;
  77699. readonly linearAcceleration: Float32Array | null;
  77700. readonly linearVelocity: Float32Array | null;
  77701. readonly orientation: Float32Array | null;
  77702. readonly position: Float32Array | null;
  77703. readonly timestamp: number;
  77704. }
  77705. interface VRStageParameters {
  77706. sittingToStandingTransform?: Float32Array;
  77707. sizeX?: number;
  77708. sizeY?: number;
  77709. }
  77710. interface Navigator {
  77711. getVRDisplays(): Promise<VRDisplay[]>;
  77712. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77713. }
  77714. interface Window {
  77715. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77716. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77717. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77718. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77719. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77720. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77721. }
  77722. interface Gamepad {
  77723. readonly displayId: number;
  77724. }
  77725. /**
  77726. * Available session modes
  77727. */
  77728. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77729. /**
  77730. * Reference space types
  77731. */
  77732. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77733. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77734. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77735. /**
  77736. * Handedness types
  77737. */
  77738. type XRHandedness = "none" | "left" | "right";
  77739. /**
  77740. * InputSource target ray modes
  77741. */
  77742. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77743. /**
  77744. * Eye types
  77745. */
  77746. type XREye = "none" | "left" | "right";
  77747. /**
  77748. * Type of XR events available
  77749. */
  77750. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77751. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77752. type XRPlaneSet = Set<XRPlane>;
  77753. type XRAnchorSet = Set<XRAnchor>;
  77754. type XREventHandler = (callback: any) => void;
  77755. interface XRLayer extends EventTarget {}
  77756. interface XRSessionInit {
  77757. optionalFeatures?: string[];
  77758. requiredFeatures?: string[];
  77759. }
  77760. interface XRSessionEvent extends Event {
  77761. readonly session: XRSession;
  77762. }
  77763. interface XRSystem {
  77764. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77765. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77766. }
  77767. interface XRViewport {
  77768. readonly x: number;
  77769. readonly y: number;
  77770. readonly width: number;
  77771. readonly height: number;
  77772. }
  77773. interface XRWebGLLayerInit {
  77774. antialias?: boolean;
  77775. depth?: boolean;
  77776. stencil?: boolean;
  77777. alpha?: boolean;
  77778. multiview?: boolean;
  77779. framebufferScaleFactor?: number;
  77780. }
  77781. declare class XRWebGLLayer {
  77782. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77783. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77784. readonly antialias: boolean;
  77785. readonly framebuffer: WebGLFramebuffer;
  77786. readonly framebufferWidth: number;
  77787. readonly framebufferHeight: number;
  77788. readonly ignoreDepthValues: boolean;
  77789. getViewport: (view: XRView) => XRViewport;
  77790. }
  77791. // tslint:disable-next-line no-empty-interface
  77792. interface XRSpace extends EventTarget {}
  77793. interface XRRenderState {
  77794. readonly baseLayer?: XRWebGLLayer;
  77795. readonly depthFar: number;
  77796. readonly depthNear: number;
  77797. readonly inlineVerticalFieldOfView?: number;
  77798. }
  77799. interface XRRenderStateInit extends XRRenderState {
  77800. baseLayer: XRWebGLLayer;
  77801. depthFar: number;
  77802. depthNear: number;
  77803. inlineVerticalFieldOfView?: number;
  77804. layers?: XRLayer[];
  77805. }
  77806. interface XRReferenceSpace extends XRSpace {
  77807. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77808. onreset: XREventHandler;
  77809. }
  77810. interface XRBoundedReferenceSpace extends XRSpace {
  77811. readonly boundsGeometry: DOMPointReadOnly[];
  77812. }
  77813. interface XRInputSource {
  77814. readonly handedness: XRHandedness;
  77815. readonly targetRayMode: XRTargetRayMode;
  77816. readonly targetRaySpace: XRSpace;
  77817. readonly gripSpace?: XRSpace;
  77818. readonly gamepad?: Gamepad;
  77819. readonly profiles: Array<string>;
  77820. readonly hand?: XRHand;
  77821. }
  77822. interface XRPose {
  77823. readonly transform: XRRigidTransform;
  77824. readonly emulatedPosition: boolean;
  77825. }
  77826. interface XRFrame {
  77827. readonly session: XRSession;
  77828. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77829. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77830. // AR
  77831. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77832. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77833. // Anchors
  77834. trackedAnchors?: XRAnchorSet;
  77835. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77836. // Planes
  77837. worldInformation?: {
  77838. detectedPlanes?: XRPlaneSet;
  77839. };
  77840. // Hand tracking
  77841. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77842. }
  77843. interface XRInputSourceEvent extends Event {
  77844. readonly frame: XRFrame;
  77845. readonly inputSource: XRInputSource;
  77846. }
  77847. type XRInputSourceArray = XRInputSource[];
  77848. interface XRSession {
  77849. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77850. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77851. /**
  77852. * Returns a list of this session's XRInputSources, each representing an input device
  77853. * used to control the camera and/or scene.
  77854. */
  77855. readonly inputSources: Array<XRInputSource>;
  77856. /**
  77857. * object which contains options affecting how the imagery is rendered.
  77858. * This includes things such as the near and far clipping planes
  77859. */
  77860. readonly renderState: XRRenderState;
  77861. readonly visibilityState: XRVisibilityState;
  77862. /**
  77863. * Removes a callback from the animation frame painting callback from
  77864. * XRSession's set of animation frame rendering callbacks, given the
  77865. * identifying handle returned by a previous call to requestAnimationFrame().
  77866. */
  77867. cancelAnimationFrame: (handle: number) => void;
  77868. /**
  77869. * Ends the WebXR session. Returns a promise which resolves when the
  77870. * session has been shut down.
  77871. */
  77872. end(): Promise<void>;
  77873. /**
  77874. * Schedules the specified method to be called the next time the user agent
  77875. * is working on rendering an animation frame for the WebXR device. Returns an
  77876. * integer value which can be used to identify the request for the purposes of
  77877. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77878. * to the Window.requestAnimationFrame() method.
  77879. */
  77880. requestAnimationFrame: XRFrameRequestCallback;
  77881. /**
  77882. * Requests that a new XRReferenceSpace of the specified type be created.
  77883. * Returns a promise which resolves with the XRReferenceSpace or
  77884. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77885. * the requested space type isn't supported by the device.
  77886. */
  77887. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77888. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77889. onend: XREventHandler;
  77890. oninputsourceschange: XREventHandler;
  77891. onselect: XREventHandler;
  77892. onselectstart: XREventHandler;
  77893. onselectend: XREventHandler;
  77894. onsqueeze: XREventHandler;
  77895. onsqueezestart: XREventHandler;
  77896. onsqueezeend: XREventHandler;
  77897. onvisibilitychange: XREventHandler;
  77898. // hit test
  77899. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77900. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77901. // legacy AR hit test
  77902. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77903. // legacy plane detection
  77904. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77905. }
  77906. interface XRViewerPose extends XRPose {
  77907. readonly views: Array<XRView>;
  77908. }
  77909. declare class XRRigidTransform {
  77910. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77911. position: DOMPointReadOnly;
  77912. orientation: DOMPointReadOnly;
  77913. matrix: Float32Array;
  77914. inverse: XRRigidTransform;
  77915. }
  77916. interface XRView {
  77917. readonly eye: XREye;
  77918. readonly projectionMatrix: Float32Array;
  77919. readonly transform: XRRigidTransform;
  77920. readonly recommendedViewportScale?: number;
  77921. requestViewportScale(scale: number): void;
  77922. }
  77923. interface XRInputSourceChangeEvent extends Event {
  77924. session: XRSession;
  77925. removed: Array<XRInputSource>;
  77926. added: Array<XRInputSource>;
  77927. }
  77928. // Experimental/Draft features
  77929. declare class XRRay {
  77930. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77931. origin: DOMPointReadOnly;
  77932. direction: DOMPointReadOnly;
  77933. matrix: Float32Array;
  77934. }
  77935. declare enum XRHitTestTrackableType {
  77936. "point",
  77937. "plane",
  77938. "mesh",
  77939. }
  77940. interface XRHitResult {
  77941. hitMatrix: Float32Array;
  77942. }
  77943. interface XRTransientInputHitTestResult {
  77944. readonly inputSource: XRInputSource;
  77945. readonly results: Array<XRHitTestResult>;
  77946. }
  77947. interface XRHitTestResult {
  77948. getPose(baseSpace: XRSpace): XRPose | undefined;
  77949. // When anchor system is enabled
  77950. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77951. }
  77952. interface XRHitTestSource {
  77953. cancel(): void;
  77954. }
  77955. interface XRTransientInputHitTestSource {
  77956. cancel(): void;
  77957. }
  77958. interface XRHitTestOptionsInit {
  77959. space: XRSpace;
  77960. entityTypes?: Array<XRHitTestTrackableType>;
  77961. offsetRay?: XRRay;
  77962. }
  77963. interface XRTransientInputHitTestOptionsInit {
  77964. profile: string;
  77965. entityTypes?: Array<XRHitTestTrackableType>;
  77966. offsetRay?: XRRay;
  77967. }
  77968. interface XRAnchor {
  77969. anchorSpace: XRSpace;
  77970. delete(): void;
  77971. }
  77972. interface XRPlane {
  77973. orientation: "Horizontal" | "Vertical";
  77974. planeSpace: XRSpace;
  77975. polygon: Array<DOMPointReadOnly>;
  77976. lastChangedTime: number;
  77977. }
  77978. interface XRJointSpace extends XRSpace {}
  77979. interface XRJointPose extends XRPose {
  77980. radius: number | undefined;
  77981. }
  77982. interface XRHand extends Iterable<XRJointSpace> {
  77983. readonly length: number;
  77984. [index: number]: XRJointSpace;
  77985. readonly WRIST: number;
  77986. readonly THUMB_METACARPAL: number;
  77987. readonly THUMB_PHALANX_PROXIMAL: number;
  77988. readonly THUMB_PHALANX_DISTAL: number;
  77989. readonly THUMB_PHALANX_TIP: number;
  77990. readonly INDEX_METACARPAL: number;
  77991. readonly INDEX_PHALANX_PROXIMAL: number;
  77992. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77993. readonly INDEX_PHALANX_DISTAL: number;
  77994. readonly INDEX_PHALANX_TIP: number;
  77995. readonly MIDDLE_METACARPAL: number;
  77996. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77997. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77998. readonly MIDDLE_PHALANX_DISTAL: number;
  77999. readonly MIDDLE_PHALANX_TIP: number;
  78000. readonly RING_METACARPAL: number;
  78001. readonly RING_PHALANX_PROXIMAL: number;
  78002. readonly RING_PHALANX_INTERMEDIATE: number;
  78003. readonly RING_PHALANX_DISTAL: number;
  78004. readonly RING_PHALANX_TIP: number;
  78005. readonly LITTLE_METACARPAL: number;
  78006. readonly LITTLE_PHALANX_PROXIMAL: number;
  78007. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  78008. readonly LITTLE_PHALANX_DISTAL: number;
  78009. readonly LITTLE_PHALANX_TIP: number;
  78010. }
  78011. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  78012. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  78013. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  78014. interface XRSession {
  78015. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  78016. }
  78017. interface XRFrame {
  78018. featurePointCloud? : Array<number>;
  78019. }
  78020. /**
  78021. * @ignore
  78022. */
  78023. declare module BABYLON.GLTF2.Exporter {
  78024. }
  78025. /**
  78026. * @ignore
  78027. */
  78028. declare module BABYLON.GLTF1 {
  78029. }
  78030. declare module BABYLON.GUI {
  78031. /**
  78032. * Class used to specific a value and its associated unit
  78033. */
  78034. export class ValueAndUnit {
  78035. /** defines the unit to store */
  78036. unit: number;
  78037. /** defines a boolean indicating if the value can be negative */
  78038. negativeValueAllowed: boolean;
  78039. private _value;
  78040. private _originalUnit;
  78041. /**
  78042. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  78043. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78044. */
  78045. ignoreAdaptiveScaling: boolean;
  78046. /**
  78047. * Creates a new ValueAndUnit
  78048. * @param value defines the value to store
  78049. * @param unit defines the unit to store
  78050. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  78051. */
  78052. constructor(value: number,
  78053. /** defines the unit to store */
  78054. unit?: number,
  78055. /** defines a boolean indicating if the value can be negative */
  78056. negativeValueAllowed?: boolean);
  78057. /** Gets a boolean indicating if the value is a percentage */
  78058. get isPercentage(): boolean;
  78059. /** Gets a boolean indicating if the value is store as pixel */
  78060. get isPixel(): boolean;
  78061. /** Gets direct internal value */
  78062. get internalValue(): number;
  78063. /**
  78064. * Gets value as pixel
  78065. * @param host defines the root host
  78066. * @param refValue defines the reference value for percentages
  78067. * @returns the value as pixel
  78068. */
  78069. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  78070. /**
  78071. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  78072. * @param value defines the value to store
  78073. * @param unit defines the unit to store
  78074. * @returns the current ValueAndUnit
  78075. */
  78076. updateInPlace(value: number, unit?: number): ValueAndUnit;
  78077. /**
  78078. * Gets the value accordingly to its unit
  78079. * @param host defines the root host
  78080. * @returns the value
  78081. */
  78082. getValue(host: AdvancedDynamicTexture): number;
  78083. /**
  78084. * Gets a string representation of the value
  78085. * @param host defines the root host
  78086. * @param decimals defines an optional number of decimals to display
  78087. * @returns a string
  78088. */
  78089. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  78090. /**
  78091. * Store a value parsed from a string
  78092. * @param source defines the source string
  78093. * @returns true if the value was successfully parsed
  78094. */
  78095. fromString(source: string | number): boolean;
  78096. private static _Regex;
  78097. private static _UNITMODE_PERCENTAGE;
  78098. private static _UNITMODE_PIXEL;
  78099. /** UNITMODE_PERCENTAGE */
  78100. static get UNITMODE_PERCENTAGE(): number;
  78101. /** UNITMODE_PIXEL */
  78102. static get UNITMODE_PIXEL(): number;
  78103. }
  78104. }
  78105. declare module BABYLON.GUI {
  78106. /**
  78107. * Define a style used by control to automatically setup properties based on a template.
  78108. * Only support font related properties so far
  78109. */
  78110. export class Style implements BABYLON.IDisposable {
  78111. private _fontFamily;
  78112. private _fontStyle;
  78113. private _fontWeight;
  78114. /** @hidden */
  78115. _host: AdvancedDynamicTexture;
  78116. /** @hidden */
  78117. _fontSize: ValueAndUnit;
  78118. /**
  78119. * BABYLON.Observable raised when the style values are changed
  78120. */
  78121. onChangedObservable: BABYLON.Observable<Style>;
  78122. /**
  78123. * Creates a new style object
  78124. * @param host defines the AdvancedDynamicTexture which hosts this style
  78125. */
  78126. constructor(host: AdvancedDynamicTexture);
  78127. /**
  78128. * Gets or sets the font size
  78129. */
  78130. get fontSize(): string | number;
  78131. set fontSize(value: string | number);
  78132. /**
  78133. * Gets or sets the font family
  78134. */
  78135. get fontFamily(): string;
  78136. set fontFamily(value: string);
  78137. /**
  78138. * Gets or sets the font style
  78139. */
  78140. get fontStyle(): string;
  78141. set fontStyle(value: string);
  78142. /** Gets or sets font weight */
  78143. get fontWeight(): string;
  78144. set fontWeight(value: string);
  78145. /** Dispose all associated resources */
  78146. dispose(): void;
  78147. }
  78148. }
  78149. declare module BABYLON.GUI {
  78150. /**
  78151. * Class used to transport BABYLON.Vector2 information for pointer events
  78152. */
  78153. export class Vector2WithInfo extends BABYLON.Vector2 {
  78154. /** defines the current mouse button index */
  78155. buttonIndex: number;
  78156. /**
  78157. * Creates a new Vector2WithInfo
  78158. * @param source defines the vector2 data to transport
  78159. * @param buttonIndex defines the current mouse button index
  78160. */
  78161. constructor(source: BABYLON.Vector2,
  78162. /** defines the current mouse button index */
  78163. buttonIndex?: number);
  78164. }
  78165. /** Class used to provide 2D matrix features */
  78166. export class Matrix2D {
  78167. /** Gets the internal array of 6 floats used to store matrix data */
  78168. m: Float32Array;
  78169. /**
  78170. * Creates a new matrix
  78171. * @param m00 defines value for (0, 0)
  78172. * @param m01 defines value for (0, 1)
  78173. * @param m10 defines value for (1, 0)
  78174. * @param m11 defines value for (1, 1)
  78175. * @param m20 defines value for (2, 0)
  78176. * @param m21 defines value for (2, 1)
  78177. */
  78178. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78179. /**
  78180. * Fills the matrix from direct values
  78181. * @param m00 defines value for (0, 0)
  78182. * @param m01 defines value for (0, 1)
  78183. * @param m10 defines value for (1, 0)
  78184. * @param m11 defines value for (1, 1)
  78185. * @param m20 defines value for (2, 0)
  78186. * @param m21 defines value for (2, 1)
  78187. * @returns the current modified matrix
  78188. */
  78189. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78190. /**
  78191. * Gets matrix determinant
  78192. * @returns the determinant
  78193. */
  78194. determinant(): number;
  78195. /**
  78196. * Inverses the matrix and stores it in a target matrix
  78197. * @param result defines the target matrix
  78198. * @returns the current matrix
  78199. */
  78200. invertToRef(result: Matrix2D): Matrix2D;
  78201. /**
  78202. * Multiplies the current matrix with another one
  78203. * @param other defines the second operand
  78204. * @param result defines the target matrix
  78205. * @returns the current matrix
  78206. */
  78207. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78208. /**
  78209. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78210. * @param x defines the x coordinate to transform
  78211. * @param y defines the x coordinate to transform
  78212. * @param result defines the target vector2
  78213. * @returns the current matrix
  78214. */
  78215. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78216. /**
  78217. * Creates an identity matrix
  78218. * @returns a new matrix
  78219. */
  78220. static Identity(): Matrix2D;
  78221. /**
  78222. * Creates a translation matrix and stores it in a target matrix
  78223. * @param x defines the x coordinate of the translation
  78224. * @param y defines the y coordinate of the translation
  78225. * @param result defines the target matrix
  78226. */
  78227. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78228. /**
  78229. * Creates a scaling matrix and stores it in a target matrix
  78230. * @param x defines the x coordinate of the scaling
  78231. * @param y defines the y coordinate of the scaling
  78232. * @param result defines the target matrix
  78233. */
  78234. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78235. /**
  78236. * Creates a rotation matrix and stores it in a target matrix
  78237. * @param angle defines the rotation angle
  78238. * @param result defines the target matrix
  78239. */
  78240. static RotationToRef(angle: number, result: Matrix2D): void;
  78241. private static _TempPreTranslationMatrix;
  78242. private static _TempPostTranslationMatrix;
  78243. private static _TempRotationMatrix;
  78244. private static _TempScalingMatrix;
  78245. private static _TempCompose0;
  78246. private static _TempCompose1;
  78247. private static _TempCompose2;
  78248. /**
  78249. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78250. * @param tx defines the x coordinate of the translation
  78251. * @param ty defines the y coordinate of the translation
  78252. * @param angle defines the rotation angle
  78253. * @param scaleX defines the x coordinate of the scaling
  78254. * @param scaleY defines the y coordinate of the scaling
  78255. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78256. * @param result defines the target matrix
  78257. */
  78258. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78259. }
  78260. }
  78261. declare module BABYLON.GUI {
  78262. /**
  78263. * Class used to store 2D control sizes
  78264. */
  78265. export class Measure {
  78266. /** defines left coordinate */
  78267. left: number;
  78268. /** defines top coordinate */
  78269. top: number;
  78270. /** defines width dimension */
  78271. width: number;
  78272. /** defines height dimension */
  78273. height: number;
  78274. /**
  78275. * Creates a new measure
  78276. * @param left defines left coordinate
  78277. * @param top defines top coordinate
  78278. * @param width defines width dimension
  78279. * @param height defines height dimension
  78280. */
  78281. constructor(
  78282. /** defines left coordinate */
  78283. left: number,
  78284. /** defines top coordinate */
  78285. top: number,
  78286. /** defines width dimension */
  78287. width: number,
  78288. /** defines height dimension */
  78289. height: number);
  78290. /**
  78291. * Copy from another measure
  78292. * @param other defines the other measure to copy from
  78293. */
  78294. copyFrom(other: Measure): void;
  78295. /**
  78296. * Copy from a group of 4 floats
  78297. * @param left defines left coordinate
  78298. * @param top defines top coordinate
  78299. * @param width defines width dimension
  78300. * @param height defines height dimension
  78301. */
  78302. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78303. /**
  78304. * Computes the axis aligned bounding box measure for two given measures
  78305. * @param a Input measure
  78306. * @param b Input measure
  78307. * @param result the resulting bounding measure
  78308. */
  78309. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78310. /**
  78311. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78312. * @param transform the matrix to transform the measure before computing the AABB
  78313. * @param addX number to add to left
  78314. * @param addY number to add to top
  78315. * @param addWidth number to add to width
  78316. * @param addHeight number to add to height
  78317. * @param result the resulting AABB
  78318. */
  78319. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78320. /**
  78321. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78322. * @param transform the matrix to transform the measure before computing the AABB
  78323. * @param result the resulting AABB
  78324. */
  78325. transformToRef(transform: Matrix2D, result: Measure): void;
  78326. /**
  78327. * Check equality between this measure and another one
  78328. * @param other defines the other measures
  78329. * @returns true if both measures are equals
  78330. */
  78331. isEqualsTo(other: Measure): boolean;
  78332. /**
  78333. * Creates an empty measure
  78334. * @returns a new measure
  78335. */
  78336. static Empty(): Measure;
  78337. }
  78338. }
  78339. declare module BABYLON.GUI {
  78340. /**
  78341. * Interface used to define a control that can receive focus
  78342. */
  78343. export interface IFocusableControl {
  78344. /**
  78345. * Function called when the control receives the focus
  78346. */
  78347. onFocus(): void;
  78348. /**
  78349. * Function called when the control loses the focus
  78350. */
  78351. onBlur(): void;
  78352. /**
  78353. * Function called to let the control handle keyboard events
  78354. * @param evt defines the current keyboard event
  78355. */
  78356. processKeyboard(evt: KeyboardEvent): void;
  78357. /**
  78358. * Function called to get the list of controls that should not steal the focus from this control
  78359. * @returns an array of controls
  78360. */
  78361. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78362. }
  78363. /**
  78364. * Class used to create texture to support 2D GUI elements
  78365. * @see https://doc.babylonjs.com/how_to/gui
  78366. */
  78367. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78368. private _isDirty;
  78369. private _renderObserver;
  78370. private _resizeObserver;
  78371. private _preKeyboardObserver;
  78372. private _pointerMoveObserver;
  78373. private _pointerObserver;
  78374. private _canvasPointerOutObserver;
  78375. private _canvasBlurObserver;
  78376. private _background;
  78377. /** @hidden */
  78378. _rootContainer: Container;
  78379. /** @hidden */
  78380. _lastPickedControl: Control;
  78381. /** @hidden */
  78382. _lastControlOver: {
  78383. [pointerId: number]: Control;
  78384. };
  78385. /** @hidden */
  78386. _lastControlDown: {
  78387. [pointerId: number]: Control;
  78388. };
  78389. /** @hidden */
  78390. _capturingControl: {
  78391. [pointerId: number]: Control;
  78392. };
  78393. /** @hidden */
  78394. _shouldBlockPointer: boolean;
  78395. /** @hidden */
  78396. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78397. /** @hidden */
  78398. _linkedControls: Control[];
  78399. private _isFullscreen;
  78400. private _fullscreenViewport;
  78401. private _idealWidth;
  78402. private _idealHeight;
  78403. private _useSmallestIdeal;
  78404. private _renderAtIdealSize;
  78405. private _focusedControl;
  78406. private _blockNextFocusCheck;
  78407. private _renderScale;
  78408. private _rootElement;
  78409. private _cursorChanged;
  78410. private _defaultMousePointerId;
  78411. /** @hidden */
  78412. _numLayoutCalls: number;
  78413. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78414. get numLayoutCalls(): number;
  78415. /** @hidden */
  78416. _numRenderCalls: number;
  78417. /** Gets the number of render calls made the last time the ADT has been rendered */
  78418. get numRenderCalls(): number;
  78419. /**
  78420. * Define type to string to ensure compatibility across browsers
  78421. * Safari doesn't support DataTransfer constructor
  78422. */
  78423. private _clipboardData;
  78424. /**
  78425. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78426. */
  78427. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78428. /**
  78429. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78430. */
  78431. onControlPickedObservable: BABYLON.Observable<Control>;
  78432. /**
  78433. * BABYLON.Observable event triggered before layout is evaluated
  78434. */
  78435. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78436. /**
  78437. * BABYLON.Observable event triggered after the layout was evaluated
  78438. */
  78439. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78440. /**
  78441. * BABYLON.Observable event triggered before the texture is rendered
  78442. */
  78443. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78444. /**
  78445. * BABYLON.Observable event triggered after the texture was rendered
  78446. */
  78447. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78448. /**
  78449. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78450. */
  78451. premulAlpha: boolean;
  78452. /**
  78453. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78454. */
  78455. applyYInversionOnUpdate: boolean;
  78456. /**
  78457. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78458. * Useful when you want more antialiasing
  78459. */
  78460. get renderScale(): number;
  78461. set renderScale(value: number);
  78462. /** Gets or sets the background color */
  78463. get background(): string;
  78464. set background(value: string);
  78465. /**
  78466. * Gets or sets the ideal width used to design controls.
  78467. * The GUI will then rescale everything accordingly
  78468. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78469. */
  78470. get idealWidth(): number;
  78471. set idealWidth(value: number);
  78472. /**
  78473. * Gets or sets the ideal height used to design controls.
  78474. * The GUI will then rescale everything accordingly
  78475. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78476. */
  78477. get idealHeight(): number;
  78478. set idealHeight(value: number);
  78479. /**
  78480. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78481. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78482. */
  78483. get useSmallestIdeal(): boolean;
  78484. set useSmallestIdeal(value: boolean);
  78485. /**
  78486. * Gets or sets a boolean indicating if adaptive scaling must be used
  78487. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78488. */
  78489. get renderAtIdealSize(): boolean;
  78490. set renderAtIdealSize(value: boolean);
  78491. /**
  78492. * Gets the ratio used when in "ideal mode"
  78493. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78494. * */
  78495. get idealRatio(): number;
  78496. /**
  78497. * Gets the underlying layer used to render the texture when in fullscreen mode
  78498. */
  78499. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78500. /**
  78501. * Gets the root container control
  78502. */
  78503. get rootContainer(): Container;
  78504. /**
  78505. * Returns an array containing the root container.
  78506. * This is mostly used to let the Inspector introspects the ADT
  78507. * @returns an array containing the rootContainer
  78508. */
  78509. getChildren(): Array<Container>;
  78510. /**
  78511. * Will return all controls that are inside this texture
  78512. * @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
  78513. * @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
  78514. * @return all child controls
  78515. */
  78516. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78517. /**
  78518. * Gets or sets the current focused control
  78519. */
  78520. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78521. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78522. /**
  78523. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78524. */
  78525. get isForeground(): boolean;
  78526. set isForeground(value: boolean);
  78527. /**
  78528. * Gets or set information about clipboardData
  78529. */
  78530. get clipboardData(): string;
  78531. set clipboardData(value: string);
  78532. /**
  78533. * Creates a new AdvancedDynamicTexture
  78534. * @param name defines the name of the texture
  78535. * @param width defines the width of the texture
  78536. * @param height defines the height of the texture
  78537. * @param scene defines the hosting scene
  78538. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78539. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78540. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78541. */
  78542. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78543. /**
  78544. * Get the current class name of the texture useful for serialization or dynamic coding.
  78545. * @returns "AdvancedDynamicTexture"
  78546. */
  78547. getClassName(): string;
  78548. /**
  78549. * Function used to execute a function on all controls
  78550. * @param func defines the function to execute
  78551. * @param container defines the container where controls belong. If null the root container will be used
  78552. */
  78553. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78554. private _useInvalidateRectOptimization;
  78555. /**
  78556. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78557. */
  78558. get useInvalidateRectOptimization(): boolean;
  78559. set useInvalidateRectOptimization(value: boolean);
  78560. private _invalidatedRectangle;
  78561. /**
  78562. * Invalidates a rectangle area on the gui texture
  78563. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78564. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78565. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78566. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78567. */
  78568. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78569. /**
  78570. * Marks the texture as dirty forcing a complete update
  78571. */
  78572. markAsDirty(): void;
  78573. /**
  78574. * Helper function used to create a new style
  78575. * @returns a new style
  78576. * @see https://doc.babylonjs.com/how_to/gui#styles
  78577. */
  78578. createStyle(): Style;
  78579. /**
  78580. * Adds a new control to the root container
  78581. * @param control defines the control to add
  78582. * @returns the current texture
  78583. */
  78584. addControl(control: Control): AdvancedDynamicTexture;
  78585. /**
  78586. * Removes a control from the root container
  78587. * @param control defines the control to remove
  78588. * @returns the current texture
  78589. */
  78590. removeControl(control: Control): AdvancedDynamicTexture;
  78591. /**
  78592. * Release all resources
  78593. */
  78594. dispose(): void;
  78595. private _onResize;
  78596. /** @hidden */
  78597. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78598. /**
  78599. * Get screen coordinates for a vector3
  78600. * @param position defines the position to project
  78601. * @param worldMatrix defines the world matrix to use
  78602. * @returns the projected position
  78603. */
  78604. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78605. /**
  78606. * Get screen coordinates for a vector3
  78607. * @param position defines the position to project
  78608. * @param worldMatrix defines the world matrix to use
  78609. * @returns the projected position with Z
  78610. */
  78611. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78612. private _checkUpdate;
  78613. private _clearMeasure;
  78614. private _render;
  78615. /** @hidden */
  78616. _changeCursor(cursor: string): void;
  78617. /** @hidden */
  78618. _registerLastControlDown(control: Control, pointerId: number): void;
  78619. private _doPicking;
  78620. /** @hidden */
  78621. _cleanControlAfterRemovalFromList(list: {
  78622. [pointerId: number]: Control;
  78623. }, control: Control): void;
  78624. /** @hidden */
  78625. _cleanControlAfterRemoval(control: Control): void;
  78626. /** Attach to all scene events required to support pointer events */
  78627. attach(): void;
  78628. /** @hidden */
  78629. private onClipboardCopy;
  78630. /** @hidden */
  78631. private onClipboardCut;
  78632. /** @hidden */
  78633. private onClipboardPaste;
  78634. /**
  78635. * Register the clipboard Events onto the canvas
  78636. */
  78637. registerClipboardEvents(): void;
  78638. /**
  78639. * Unregister the clipboard Events from the canvas
  78640. */
  78641. unRegisterClipboardEvents(): void;
  78642. /**
  78643. * Connect the texture to a hosting mesh to enable interactions
  78644. * @param mesh defines the mesh to attach to
  78645. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78646. */
  78647. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78648. /**
  78649. * Move the focus to a specific control
  78650. * @param control defines the control which will receive the focus
  78651. */
  78652. moveFocusToControl(control: IFocusableControl): void;
  78653. private _manageFocus;
  78654. private _attachToOnPointerOut;
  78655. private _attachToOnBlur;
  78656. /**
  78657. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78658. * @param mesh defines the mesh which will receive the texture
  78659. * @param width defines the texture width (1024 by default)
  78660. * @param height defines the texture height (1024 by default)
  78661. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78662. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78663. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78664. * @returns a new AdvancedDynamicTexture
  78665. */
  78666. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78667. /**
  78668. * 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
  78669. * @param mesh defines the mesh which will receive the texture
  78670. * @param width defines the texture width (1024 by default)
  78671. * @param height defines the texture height (1024 by default)
  78672. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78673. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78674. * @returns a new AdvancedDynamicTexture
  78675. */
  78676. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78677. /**
  78678. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78679. * In this mode the texture will rely on a layer for its rendering.
  78680. * This allows it to be treated like any other layer.
  78681. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78682. * LayerMask is set through advancedTexture.layer.layerMask
  78683. * @param name defines name for the texture
  78684. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78685. * @param scene defines the hsoting scene
  78686. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78687. * @returns a new AdvancedDynamicTexture
  78688. */
  78689. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78690. }
  78691. }
  78692. declare module BABYLON.GUI {
  78693. /**
  78694. * Root class used for all 2D controls
  78695. * @see https://doc.babylonjs.com/how_to/gui#controls
  78696. */
  78697. export class Control {
  78698. /** defines the name of the control */
  78699. name?: string | undefined;
  78700. /**
  78701. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78702. */
  78703. static AllowAlphaInheritance: boolean;
  78704. private _alpha;
  78705. private _alphaSet;
  78706. private _zIndex;
  78707. /** @hidden */
  78708. _host: AdvancedDynamicTexture;
  78709. /** Gets or sets the control parent */
  78710. parent: BABYLON.Nullable<Container>;
  78711. /** @hidden */
  78712. _currentMeasure: Measure;
  78713. private _fontFamily;
  78714. private _fontStyle;
  78715. private _fontWeight;
  78716. private _fontSize;
  78717. private _font;
  78718. /** @hidden */
  78719. _width: ValueAndUnit;
  78720. /** @hidden */
  78721. _height: ValueAndUnit;
  78722. /** @hidden */
  78723. protected _fontOffset: {
  78724. ascent: number;
  78725. height: number;
  78726. descent: number;
  78727. };
  78728. private _color;
  78729. private _style;
  78730. private _styleObserver;
  78731. /** @hidden */
  78732. protected _horizontalAlignment: number;
  78733. /** @hidden */
  78734. protected _verticalAlignment: number;
  78735. /** @hidden */
  78736. protected _isDirty: boolean;
  78737. /** @hidden */
  78738. protected _wasDirty: boolean;
  78739. /** @hidden */
  78740. _tempParentMeasure: Measure;
  78741. /** @hidden */
  78742. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78743. /** @hidden */
  78744. protected _cachedParentMeasure: Measure;
  78745. private _paddingLeft;
  78746. private _paddingRight;
  78747. private _paddingTop;
  78748. private _paddingBottom;
  78749. /** @hidden */
  78750. _left: ValueAndUnit;
  78751. /** @hidden */
  78752. _top: ValueAndUnit;
  78753. private _scaleX;
  78754. private _scaleY;
  78755. private _rotation;
  78756. private _transformCenterX;
  78757. private _transformCenterY;
  78758. /** @hidden */
  78759. _transformMatrix: Matrix2D;
  78760. /** @hidden */
  78761. protected _invertTransformMatrix: Matrix2D;
  78762. /** @hidden */
  78763. protected _transformedPosition: BABYLON.Vector2;
  78764. private _isMatrixDirty;
  78765. private _cachedOffsetX;
  78766. private _cachedOffsetY;
  78767. private _isVisible;
  78768. private _isHighlighted;
  78769. /** @hidden */
  78770. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78771. private _fontSet;
  78772. private _dummyVector2;
  78773. private _downCount;
  78774. private _enterCount;
  78775. private _doNotRender;
  78776. private _downPointerIds;
  78777. protected _isEnabled: boolean;
  78778. protected _disabledColor: string;
  78779. protected _disabledColorItem: string;
  78780. /** @hidden */
  78781. protected _rebuildLayout: boolean;
  78782. /** @hidden */
  78783. _customData: any;
  78784. /** @hidden */
  78785. _isClipped: boolean;
  78786. /** @hidden */
  78787. _automaticSize: boolean;
  78788. /** @hidden */
  78789. _tag: any;
  78790. /**
  78791. * 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
  78792. */
  78793. uniqueId: number;
  78794. /**
  78795. * Gets or sets an object used to store user defined information for the node
  78796. */
  78797. metadata: any;
  78798. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78799. isHitTestVisible: boolean;
  78800. /** Gets or sets a boolean indicating if the control can block pointer events */
  78801. isPointerBlocker: boolean;
  78802. /** Gets or sets a boolean indicating if the control can be focusable */
  78803. isFocusInvisible: boolean;
  78804. /**
  78805. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78806. * 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
  78807. */
  78808. clipChildren: boolean;
  78809. /**
  78810. * Gets or sets a boolean indicating that control content must be clipped
  78811. * 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
  78812. */
  78813. clipContent: boolean;
  78814. /**
  78815. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78816. */
  78817. useBitmapCache: boolean;
  78818. private _cacheData;
  78819. private _shadowOffsetX;
  78820. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78821. get shadowOffsetX(): number;
  78822. set shadowOffsetX(value: number);
  78823. private _shadowOffsetY;
  78824. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78825. get shadowOffsetY(): number;
  78826. set shadowOffsetY(value: number);
  78827. private _shadowBlur;
  78828. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78829. get shadowBlur(): number;
  78830. set shadowBlur(value: number);
  78831. private _shadowColor;
  78832. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78833. get shadowColor(): string;
  78834. set shadowColor(value: string);
  78835. /** Gets or sets the cursor to use when the control is hovered */
  78836. hoverCursor: string;
  78837. /** @hidden */
  78838. protected _linkOffsetX: ValueAndUnit;
  78839. /** @hidden */
  78840. protected _linkOffsetY: ValueAndUnit;
  78841. /** Gets the control type name */
  78842. get typeName(): string;
  78843. /**
  78844. * Get the current class name of the control.
  78845. * @returns current class name
  78846. */
  78847. getClassName(): string;
  78848. /**
  78849. * An event triggered when pointer wheel is scrolled
  78850. */
  78851. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78852. /**
  78853. * An event triggered when the pointer move over the control.
  78854. */
  78855. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78856. /**
  78857. * An event triggered when the pointer move out of the control.
  78858. */
  78859. onPointerOutObservable: BABYLON.Observable<Control>;
  78860. /**
  78861. * An event triggered when the pointer taps the control
  78862. */
  78863. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78864. /**
  78865. * An event triggered when pointer up
  78866. */
  78867. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78868. /**
  78869. * An event triggered when a control is clicked on
  78870. */
  78871. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78872. /**
  78873. * An event triggered when pointer enters the control
  78874. */
  78875. onPointerEnterObservable: BABYLON.Observable<Control>;
  78876. /**
  78877. * An event triggered when the control is marked as dirty
  78878. */
  78879. onDirtyObservable: BABYLON.Observable<Control>;
  78880. /**
  78881. * An event triggered before drawing the control
  78882. */
  78883. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78884. /**
  78885. * An event triggered after the control was drawn
  78886. */
  78887. onAfterDrawObservable: BABYLON.Observable<Control>;
  78888. /**
  78889. * An event triggered when the control has been disposed
  78890. */
  78891. onDisposeObservable: BABYLON.Observable<Control>;
  78892. /**
  78893. * Get the hosting AdvancedDynamicTexture
  78894. */
  78895. get host(): AdvancedDynamicTexture;
  78896. /** Gets or set information about font offsets (used to render and align text) */
  78897. get fontOffset(): {
  78898. ascent: number;
  78899. height: number;
  78900. descent: number;
  78901. };
  78902. set fontOffset(offset: {
  78903. ascent: number;
  78904. height: number;
  78905. descent: number;
  78906. });
  78907. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78908. get alpha(): number;
  78909. set alpha(value: number);
  78910. /**
  78911. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78912. */
  78913. get isHighlighted(): boolean;
  78914. set isHighlighted(value: boolean);
  78915. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78916. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78917. */
  78918. get scaleX(): number;
  78919. set scaleX(value: number);
  78920. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78921. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78922. */
  78923. get scaleY(): number;
  78924. set scaleY(value: number);
  78925. /** Gets or sets the rotation angle (0 by default)
  78926. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78927. */
  78928. get rotation(): number;
  78929. set rotation(value: number);
  78930. /** Gets or sets the transformation center on Y axis (0 by default)
  78931. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78932. */
  78933. get transformCenterY(): number;
  78934. set transformCenterY(value: number);
  78935. /** Gets or sets the transformation center on X axis (0 by default)
  78936. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78937. */
  78938. get transformCenterX(): number;
  78939. set transformCenterX(value: number);
  78940. /**
  78941. * Gets or sets the horizontal alignment
  78942. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78943. */
  78944. get horizontalAlignment(): number;
  78945. set horizontalAlignment(value: number);
  78946. /**
  78947. * Gets or sets the vertical alignment
  78948. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78949. */
  78950. get verticalAlignment(): number;
  78951. set verticalAlignment(value: number);
  78952. /**
  78953. * Gets or sets a fixed ratio for this control.
  78954. * When different from 0, the ratio is used to compute the "second" dimension.
  78955. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78956. * second dimension is computed as first dimension * fixedRatio
  78957. */
  78958. fixedRatio: number;
  78959. private _fixedRatioMasterIsWidth;
  78960. /**
  78961. * Gets or sets control width
  78962. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78963. */
  78964. get width(): string | number;
  78965. set width(value: string | number);
  78966. /**
  78967. * Gets or sets the control width in pixel
  78968. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78969. */
  78970. get widthInPixels(): number;
  78971. set widthInPixels(value: number);
  78972. /**
  78973. * Gets or sets control height
  78974. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78975. */
  78976. get height(): string | number;
  78977. set height(value: string | number);
  78978. /**
  78979. * Gets or sets control height in pixel
  78980. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78981. */
  78982. get heightInPixels(): number;
  78983. set heightInPixels(value: number);
  78984. /** Gets or set font family */
  78985. get fontFamily(): string;
  78986. set fontFamily(value: string);
  78987. /** Gets or sets font style */
  78988. get fontStyle(): string;
  78989. set fontStyle(value: string);
  78990. /** Gets or sets font weight */
  78991. get fontWeight(): string;
  78992. set fontWeight(value: string);
  78993. /**
  78994. * Gets or sets style
  78995. * @see https://doc.babylonjs.com/how_to/gui#styles
  78996. */
  78997. get style(): BABYLON.Nullable<Style>;
  78998. set style(value: BABYLON.Nullable<Style>);
  78999. /** @hidden */
  79000. get _isFontSizeInPercentage(): boolean;
  79001. /** Gets or sets font size in pixels */
  79002. get fontSizeInPixels(): number;
  79003. set fontSizeInPixels(value: number);
  79004. /** Gets or sets font size */
  79005. get fontSize(): string | number;
  79006. set fontSize(value: string | number);
  79007. /** Gets or sets foreground color */
  79008. get color(): string;
  79009. set color(value: string);
  79010. /** Gets or sets z index which is used to reorder controls on the z axis */
  79011. get zIndex(): number;
  79012. set zIndex(value: number);
  79013. /** Gets or sets a boolean indicating if the control can be rendered */
  79014. get notRenderable(): boolean;
  79015. set notRenderable(value: boolean);
  79016. /** Gets or sets a boolean indicating if the control is visible */
  79017. get isVisible(): boolean;
  79018. set isVisible(value: boolean);
  79019. /** Gets a boolean indicating that the control needs to update its rendering */
  79020. get isDirty(): boolean;
  79021. /**
  79022. * Gets the current linked mesh (or null if none)
  79023. */
  79024. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  79025. /**
  79026. * Gets or sets a value indicating the padding to use on the left of the control
  79027. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79028. */
  79029. get paddingLeft(): string | number;
  79030. set paddingLeft(value: string | number);
  79031. /**
  79032. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  79033. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79034. */
  79035. get paddingLeftInPixels(): number;
  79036. set paddingLeftInPixels(value: number);
  79037. /**
  79038. * Gets or sets a value indicating the padding to use on the right of the control
  79039. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79040. */
  79041. get paddingRight(): string | number;
  79042. set paddingRight(value: string | number);
  79043. /**
  79044. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  79045. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79046. */
  79047. get paddingRightInPixels(): number;
  79048. set paddingRightInPixels(value: number);
  79049. /**
  79050. * Gets or sets a value indicating the padding to use on the top of the control
  79051. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79052. */
  79053. get paddingTop(): string | number;
  79054. set paddingTop(value: string | number);
  79055. /**
  79056. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  79057. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79058. */
  79059. get paddingTopInPixels(): number;
  79060. set paddingTopInPixels(value: number);
  79061. /**
  79062. * Gets or sets a value indicating the padding to use on the bottom of the control
  79063. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79064. */
  79065. get paddingBottom(): string | number;
  79066. set paddingBottom(value: string | number);
  79067. /**
  79068. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  79069. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79070. */
  79071. get paddingBottomInPixels(): number;
  79072. set paddingBottomInPixels(value: number);
  79073. /**
  79074. * Gets or sets a value indicating the left coordinate of the control
  79075. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79076. */
  79077. get left(): string | number;
  79078. set left(value: string | number);
  79079. /**
  79080. * Gets or sets a value indicating the left coordinate in pixels of the control
  79081. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79082. */
  79083. get leftInPixels(): number;
  79084. set leftInPixels(value: number);
  79085. /**
  79086. * Gets or sets a value indicating the top coordinate of the control
  79087. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79088. */
  79089. get top(): string | number;
  79090. set top(value: string | number);
  79091. /**
  79092. * Gets or sets a value indicating the top coordinate in pixels of the control
  79093. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79094. */
  79095. get topInPixels(): number;
  79096. set topInPixels(value: number);
  79097. /**
  79098. * Gets or sets a value indicating the offset on X axis to the linked mesh
  79099. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79100. */
  79101. get linkOffsetX(): string | number;
  79102. set linkOffsetX(value: string | number);
  79103. /**
  79104. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  79105. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79106. */
  79107. get linkOffsetXInPixels(): number;
  79108. set linkOffsetXInPixels(value: number);
  79109. /**
  79110. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  79111. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79112. */
  79113. get linkOffsetY(): string | number;
  79114. set linkOffsetY(value: string | number);
  79115. /**
  79116. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  79117. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79118. */
  79119. get linkOffsetYInPixels(): number;
  79120. set linkOffsetYInPixels(value: number);
  79121. /** Gets the center coordinate on X axis */
  79122. get centerX(): number;
  79123. /** Gets the center coordinate on Y axis */
  79124. get centerY(): number;
  79125. /** Gets or sets if control is Enabled*/
  79126. get isEnabled(): boolean;
  79127. set isEnabled(value: boolean);
  79128. /** Gets or sets background color of control if it's disabled*/
  79129. get disabledColor(): string;
  79130. set disabledColor(value: string);
  79131. /** Gets or sets front color of control if it's disabled*/
  79132. get disabledColorItem(): string;
  79133. set disabledColorItem(value: string);
  79134. /**
  79135. * Creates a new control
  79136. * @param name defines the name of the control
  79137. */
  79138. constructor(
  79139. /** defines the name of the control */
  79140. name?: string | undefined);
  79141. /** @hidden */
  79142. protected _getTypeName(): string;
  79143. /**
  79144. * Gets the first ascendant in the hierarchy of the given type
  79145. * @param className defines the required type
  79146. * @returns the ascendant or null if not found
  79147. */
  79148. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  79149. /** @hidden */
  79150. _resetFontCache(): void;
  79151. /**
  79152. * Determines if a container is an ascendant of the current control
  79153. * @param container defines the container to look for
  79154. * @returns true if the container is one of the ascendant of the control
  79155. */
  79156. isAscendant(container: Control): boolean;
  79157. /**
  79158. * Gets coordinates in local control space
  79159. * @param globalCoordinates defines the coordinates to transform
  79160. * @returns the new coordinates in local space
  79161. */
  79162. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79163. /**
  79164. * Gets coordinates in local control space
  79165. * @param globalCoordinates defines the coordinates to transform
  79166. * @param result defines the target vector2 where to store the result
  79167. * @returns the current control
  79168. */
  79169. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79170. /**
  79171. * Gets coordinates in parent local control space
  79172. * @param globalCoordinates defines the coordinates to transform
  79173. * @returns the new coordinates in parent local space
  79174. */
  79175. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79176. /**
  79177. * Move the current control to a vector3 position projected onto the screen.
  79178. * @param position defines the target position
  79179. * @param scene defines the hosting scene
  79180. */
  79181. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79182. /**
  79183. * Will store all controls that have this control as ascendant in a given array
  79184. * @param results defines the array where to store the descendants
  79185. * @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
  79186. * @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
  79187. */
  79188. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79189. /**
  79190. * Will return all controls that have this control as ascendant
  79191. * @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
  79192. * @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
  79193. * @return all child controls
  79194. */
  79195. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79196. /**
  79197. * Link current control with a target mesh
  79198. * @param mesh defines the mesh to link with
  79199. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79200. */
  79201. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79202. /** @hidden */
  79203. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79204. /** @hidden */
  79205. _offsetLeft(offset: number): void;
  79206. /** @hidden */
  79207. _offsetTop(offset: number): void;
  79208. /** @hidden */
  79209. _markMatrixAsDirty(): void;
  79210. /** @hidden */
  79211. _flagDescendantsAsMatrixDirty(): void;
  79212. /** @hidden */
  79213. _intersectsRect(rect: Measure): boolean;
  79214. /** @hidden */
  79215. protected invalidateRect(): void;
  79216. /** @hidden */
  79217. _markAsDirty(force?: boolean): void;
  79218. /** @hidden */
  79219. _markAllAsDirty(): void;
  79220. /** @hidden */
  79221. _link(host: AdvancedDynamicTexture): void;
  79222. /** @hidden */
  79223. protected _transform(context?: CanvasRenderingContext2D): void;
  79224. /** @hidden */
  79225. _renderHighlight(context: CanvasRenderingContext2D): void;
  79226. /** @hidden */
  79227. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79228. /** @hidden */
  79229. protected _applyStates(context: CanvasRenderingContext2D): void;
  79230. /** @hidden */
  79231. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79232. /** @hidden */
  79233. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79234. protected _evaluateClippingState(parentMeasure: Measure): void;
  79235. /** @hidden */
  79236. _measure(): void;
  79237. /** @hidden */
  79238. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79239. /** @hidden */
  79240. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79241. /** @hidden */
  79242. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79243. /** @hidden */
  79244. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79245. private static _ClipMeasure;
  79246. private _tmpMeasureA;
  79247. private _clip;
  79248. /** @hidden */
  79249. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79250. /** @hidden */
  79251. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79252. /**
  79253. * Tests if a given coordinates belong to the current control
  79254. * @param x defines x coordinate to test
  79255. * @param y defines y coordinate to test
  79256. * @returns true if the coordinates are inside the control
  79257. */
  79258. contains(x: number, y: number): boolean;
  79259. /** @hidden */
  79260. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79261. /** @hidden */
  79262. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79263. /** @hidden */
  79264. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79265. /** @hidden */
  79266. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79267. /** @hidden */
  79268. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79269. /** @hidden */
  79270. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79271. /** @hidden */
  79272. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79273. /** @hidden */
  79274. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79275. /** @hidden */
  79276. _onCanvasBlur(): void;
  79277. /** @hidden */
  79278. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79279. private _prepareFont;
  79280. /** Releases associated resources */
  79281. dispose(): void;
  79282. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79283. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79284. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79285. private static _VERTICAL_ALIGNMENT_TOP;
  79286. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79287. private static _VERTICAL_ALIGNMENT_CENTER;
  79288. /** HORIZONTAL_ALIGNMENT_LEFT */
  79289. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79290. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79291. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79292. /** HORIZONTAL_ALIGNMENT_CENTER */
  79293. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79294. /** VERTICAL_ALIGNMENT_TOP */
  79295. static get VERTICAL_ALIGNMENT_TOP(): number;
  79296. /** VERTICAL_ALIGNMENT_BOTTOM */
  79297. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79298. /** VERTICAL_ALIGNMENT_CENTER */
  79299. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79300. private static _FontHeightSizes;
  79301. /** @hidden */
  79302. static _GetFontOffset(font: string): {
  79303. ascent: number;
  79304. height: number;
  79305. descent: number;
  79306. };
  79307. /**
  79308. * Creates a stack panel that can be used to render headers
  79309. * @param control defines the control to associate with the header
  79310. * @param text defines the text of the header
  79311. * @param size defines the size of the header
  79312. * @param options defines options used to configure the header
  79313. * @returns a new StackPanel
  79314. * @ignore
  79315. * @hidden
  79316. */
  79317. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79318. isHorizontal: boolean;
  79319. controlFirst: boolean;
  79320. }) => any;
  79321. /** @hidden */
  79322. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79323. }
  79324. }
  79325. declare module BABYLON.GUI {
  79326. /**
  79327. * Root class for 2D containers
  79328. * @see https://doc.babylonjs.com/how_to/gui#containers
  79329. */
  79330. export class Container extends Control {
  79331. name?: string | undefined;
  79332. /** @hidden */
  79333. _children: Control[];
  79334. /** @hidden */
  79335. protected _measureForChildren: Measure;
  79336. /** @hidden */
  79337. protected _background: string;
  79338. /** @hidden */
  79339. protected _adaptWidthToChildren: boolean;
  79340. /** @hidden */
  79341. protected _adaptHeightToChildren: boolean;
  79342. /**
  79343. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79344. */
  79345. logLayoutCycleErrors: boolean;
  79346. /**
  79347. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79348. */
  79349. maxLayoutCycle: number;
  79350. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79351. get adaptHeightToChildren(): boolean;
  79352. set adaptHeightToChildren(value: boolean);
  79353. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79354. get adaptWidthToChildren(): boolean;
  79355. set adaptWidthToChildren(value: boolean);
  79356. /** Gets or sets background color */
  79357. get background(): string;
  79358. set background(value: string);
  79359. /** Gets the list of children */
  79360. get children(): Control[];
  79361. /**
  79362. * Creates a new Container
  79363. * @param name defines the name of the container
  79364. */
  79365. constructor(name?: string | undefined);
  79366. protected _getTypeName(): string;
  79367. _flagDescendantsAsMatrixDirty(): void;
  79368. /**
  79369. * Gets a child using its name
  79370. * @param name defines the child name to look for
  79371. * @returns the child control if found
  79372. */
  79373. getChildByName(name: string): BABYLON.Nullable<Control>;
  79374. /**
  79375. * Gets a child using its type and its name
  79376. * @param name defines the child name to look for
  79377. * @param type defines the child type to look for
  79378. * @returns the child control if found
  79379. */
  79380. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79381. /**
  79382. * Search for a specific control in children
  79383. * @param control defines the control to look for
  79384. * @returns true if the control is in child list
  79385. */
  79386. containsControl(control: Control): boolean;
  79387. /**
  79388. * Adds a new control to the current container
  79389. * @param control defines the control to add
  79390. * @returns the current container
  79391. */
  79392. addControl(control: BABYLON.Nullable<Control>): Container;
  79393. /**
  79394. * Removes all controls from the current container
  79395. * @returns the current container
  79396. */
  79397. clearControls(): Container;
  79398. /**
  79399. * Removes a control from the current container
  79400. * @param control defines the control to remove
  79401. * @returns the current container
  79402. */
  79403. removeControl(control: Control): Container;
  79404. /** @hidden */
  79405. _reOrderControl(control: Control): void;
  79406. /** @hidden */
  79407. _offsetLeft(offset: number): void;
  79408. /** @hidden */
  79409. _offsetTop(offset: number): void;
  79410. /** @hidden */
  79411. _markAllAsDirty(): void;
  79412. /** @hidden */
  79413. protected _localDraw(context: CanvasRenderingContext2D): void;
  79414. /** @hidden */
  79415. _link(host: AdvancedDynamicTexture): void;
  79416. /** @hidden */
  79417. protected _beforeLayout(): void;
  79418. /** @hidden */
  79419. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79420. /** @hidden */
  79421. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79422. protected _postMeasure(): void;
  79423. /** @hidden */
  79424. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79425. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79426. /** @hidden */
  79427. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79428. /** @hidden */
  79429. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79430. /** Releases associated resources */
  79431. dispose(): void;
  79432. }
  79433. }
  79434. declare module BABYLON.GUI {
  79435. /** Class used to create rectangle container */
  79436. export class Rectangle extends Container {
  79437. name?: string | undefined;
  79438. private _thickness;
  79439. private _cornerRadius;
  79440. /** Gets or sets border thickness */
  79441. get thickness(): number;
  79442. set thickness(value: number);
  79443. /** Gets or sets the corner radius angle */
  79444. get cornerRadius(): number;
  79445. set cornerRadius(value: number);
  79446. /**
  79447. * Creates a new Rectangle
  79448. * @param name defines the control name
  79449. */
  79450. constructor(name?: string | undefined);
  79451. protected _getTypeName(): string;
  79452. protected _localDraw(context: CanvasRenderingContext2D): void;
  79453. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79454. private _drawRoundedRect;
  79455. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79456. }
  79457. }
  79458. declare module BABYLON.GUI {
  79459. /**
  79460. * Enum that determines the text-wrapping mode to use.
  79461. */
  79462. export enum TextWrapping {
  79463. /**
  79464. * Clip the text when it's larger than Control.width; this is the default mode.
  79465. */
  79466. Clip = 0,
  79467. /**
  79468. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79469. */
  79470. WordWrap = 1,
  79471. /**
  79472. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79473. */
  79474. Ellipsis = 2
  79475. }
  79476. /**
  79477. * Class used to create text block control
  79478. */
  79479. export class TextBlock extends Control {
  79480. /**
  79481. * Defines the name of the control
  79482. */
  79483. name?: string | undefined;
  79484. private _text;
  79485. private _textWrapping;
  79486. private _textHorizontalAlignment;
  79487. private _textVerticalAlignment;
  79488. private _lines;
  79489. private _resizeToFit;
  79490. private _lineSpacing;
  79491. private _outlineWidth;
  79492. private _outlineColor;
  79493. private _underline;
  79494. private _lineThrough;
  79495. /**
  79496. * An event triggered after the text is changed
  79497. */
  79498. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79499. /**
  79500. * An event triggered after the text was broken up into lines
  79501. */
  79502. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79503. /**
  79504. * Function used to split a string into words. By default, a string is split at each space character found
  79505. */
  79506. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79507. /**
  79508. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79509. */
  79510. get lines(): any[];
  79511. /**
  79512. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79513. */
  79514. get resizeToFit(): boolean;
  79515. /**
  79516. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79517. */
  79518. set resizeToFit(value: boolean);
  79519. /**
  79520. * Gets or sets a boolean indicating if text must be wrapped
  79521. */
  79522. get textWrapping(): TextWrapping | boolean;
  79523. /**
  79524. * Gets or sets a boolean indicating if text must be wrapped
  79525. */
  79526. set textWrapping(value: TextWrapping | boolean);
  79527. /**
  79528. * Gets or sets text to display
  79529. */
  79530. get text(): string;
  79531. /**
  79532. * Gets or sets text to display
  79533. */
  79534. set text(value: string);
  79535. /**
  79536. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79537. */
  79538. get textHorizontalAlignment(): number;
  79539. /**
  79540. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79541. */
  79542. set textHorizontalAlignment(value: number);
  79543. /**
  79544. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79545. */
  79546. get textVerticalAlignment(): number;
  79547. /**
  79548. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79549. */
  79550. set textVerticalAlignment(value: number);
  79551. /**
  79552. * Gets or sets line spacing value
  79553. */
  79554. set lineSpacing(value: string | number);
  79555. /**
  79556. * Gets or sets line spacing value
  79557. */
  79558. get lineSpacing(): string | number;
  79559. /**
  79560. * Gets or sets outlineWidth of the text to display
  79561. */
  79562. get outlineWidth(): number;
  79563. /**
  79564. * Gets or sets outlineWidth of the text to display
  79565. */
  79566. set outlineWidth(value: number);
  79567. /**
  79568. * Gets or sets a boolean indicating that text must have underline
  79569. */
  79570. get underline(): boolean;
  79571. /**
  79572. * Gets or sets a boolean indicating that text must have underline
  79573. */
  79574. set underline(value: boolean);
  79575. /**
  79576. * Gets or sets an boolean indicating that text must be crossed out
  79577. */
  79578. get lineThrough(): boolean;
  79579. /**
  79580. * Gets or sets an boolean indicating that text must be crossed out
  79581. */
  79582. set lineThrough(value: boolean);
  79583. /**
  79584. * Gets or sets outlineColor of the text to display
  79585. */
  79586. get outlineColor(): string;
  79587. /**
  79588. * Gets or sets outlineColor of the text to display
  79589. */
  79590. set outlineColor(value: string);
  79591. /**
  79592. * Creates a new TextBlock object
  79593. * @param name defines the name of the control
  79594. * @param text defines the text to display (emptry string by default)
  79595. */
  79596. constructor(
  79597. /**
  79598. * Defines the name of the control
  79599. */
  79600. name?: string | undefined, text?: string);
  79601. protected _getTypeName(): string;
  79602. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79603. private _drawText;
  79604. /** @hidden */
  79605. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79606. protected _applyStates(context: CanvasRenderingContext2D): void;
  79607. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79608. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79609. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79610. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79611. protected _renderLines(context: CanvasRenderingContext2D): void;
  79612. /**
  79613. * Given a width constraint applied on the text block, find the expected height
  79614. * @returns expected height
  79615. */
  79616. computeExpectedHeight(): number;
  79617. dispose(): void;
  79618. }
  79619. }
  79620. declare module BABYLON.GUI {
  79621. /**
  79622. * Class used to create 2D images
  79623. */
  79624. export class Image extends Control {
  79625. name?: string | undefined;
  79626. private _workingCanvas;
  79627. private _domImage;
  79628. private _imageWidth;
  79629. private _imageHeight;
  79630. private _loaded;
  79631. private _stretch;
  79632. private _source;
  79633. private _autoScale;
  79634. private _sourceLeft;
  79635. private _sourceTop;
  79636. private _sourceWidth;
  79637. private _sourceHeight;
  79638. private _svgAttributesComputationCompleted;
  79639. private _isSVG;
  79640. private _cellWidth;
  79641. private _cellHeight;
  79642. private _cellId;
  79643. private _populateNinePatchSlicesFromImage;
  79644. private _sliceLeft;
  79645. private _sliceRight;
  79646. private _sliceTop;
  79647. private _sliceBottom;
  79648. private _detectPointerOnOpaqueOnly;
  79649. private _imageDataCache;
  79650. /**
  79651. * BABYLON.Observable notified when the content is loaded
  79652. */
  79653. onImageLoadedObservable: BABYLON.Observable<Image>;
  79654. /**
  79655. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79656. */
  79657. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79658. /**
  79659. * Gets a boolean indicating that the content is loaded
  79660. */
  79661. get isLoaded(): boolean;
  79662. /**
  79663. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79664. */
  79665. get populateNinePatchSlicesFromImage(): boolean;
  79666. set populateNinePatchSlicesFromImage(value: boolean);
  79667. /**
  79668. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79669. * Beware using this as this will comsume more memory as the image has to be stored twice
  79670. */
  79671. get detectPointerOnOpaqueOnly(): boolean;
  79672. set detectPointerOnOpaqueOnly(value: boolean);
  79673. /**
  79674. * Gets or sets the left value for slicing (9-patch)
  79675. */
  79676. get sliceLeft(): number;
  79677. set sliceLeft(value: number);
  79678. /**
  79679. * Gets or sets the right value for slicing (9-patch)
  79680. */
  79681. get sliceRight(): number;
  79682. set sliceRight(value: number);
  79683. /**
  79684. * Gets or sets the top value for slicing (9-patch)
  79685. */
  79686. get sliceTop(): number;
  79687. set sliceTop(value: number);
  79688. /**
  79689. * Gets or sets the bottom value for slicing (9-patch)
  79690. */
  79691. get sliceBottom(): number;
  79692. set sliceBottom(value: number);
  79693. /**
  79694. * Gets or sets the left coordinate in the source image
  79695. */
  79696. get sourceLeft(): number;
  79697. set sourceLeft(value: number);
  79698. /**
  79699. * Gets or sets the top coordinate in the source image
  79700. */
  79701. get sourceTop(): number;
  79702. set sourceTop(value: number);
  79703. /**
  79704. * Gets or sets the width to capture in the source image
  79705. */
  79706. get sourceWidth(): number;
  79707. set sourceWidth(value: number);
  79708. /**
  79709. * Gets or sets the height to capture in the source image
  79710. */
  79711. get sourceHeight(): number;
  79712. set sourceHeight(value: number);
  79713. /** Indicates if the format of the image is SVG */
  79714. get isSVG(): boolean;
  79715. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79716. get svgAttributesComputationCompleted(): boolean;
  79717. /**
  79718. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79719. * @see https://doc.babylonjs.com/how_to/gui#image
  79720. */
  79721. get autoScale(): boolean;
  79722. set autoScale(value: boolean);
  79723. /** Gets or sets the streching mode used by the image */
  79724. get stretch(): number;
  79725. set stretch(value: number);
  79726. /** @hidden */
  79727. _rotate90(n: number, preserveProperties?: boolean): Image;
  79728. private _handleRotationForSVGImage;
  79729. private _rotate90SourceProperties;
  79730. /**
  79731. * Gets or sets the internal DOM image used to render the control
  79732. */
  79733. set domImage(value: HTMLImageElement);
  79734. get domImage(): HTMLImageElement;
  79735. private _onImageLoaded;
  79736. private _extractNinePatchSliceDataFromImage;
  79737. /**
  79738. * Gets or sets image source url
  79739. */
  79740. set source(value: BABYLON.Nullable<string>);
  79741. /**
  79742. * Checks for svg document with icon id present
  79743. */
  79744. private _svgCheck;
  79745. /**
  79746. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79747. * given external svg file and icon id
  79748. */
  79749. private _getSVGAttribs;
  79750. /**
  79751. * Gets or sets the cell width to use when animation sheet is enabled
  79752. * @see https://doc.babylonjs.com/how_to/gui#image
  79753. */
  79754. get cellWidth(): number;
  79755. set cellWidth(value: number);
  79756. /**
  79757. * Gets or sets the cell height to use when animation sheet is enabled
  79758. * @see https://doc.babylonjs.com/how_to/gui#image
  79759. */
  79760. get cellHeight(): number;
  79761. set cellHeight(value: number);
  79762. /**
  79763. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79764. * @see https://doc.babylonjs.com/how_to/gui#image
  79765. */
  79766. get cellId(): number;
  79767. set cellId(value: number);
  79768. /**
  79769. * Creates a new Image
  79770. * @param name defines the control name
  79771. * @param url defines the image url
  79772. */
  79773. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79774. /**
  79775. * Tests if a given coordinates belong to the current control
  79776. * @param x defines x coordinate to test
  79777. * @param y defines y coordinate to test
  79778. * @returns true if the coordinates are inside the control
  79779. */
  79780. contains(x: number, y: number): boolean;
  79781. protected _getTypeName(): string;
  79782. /** Force the control to synchronize with its content */
  79783. synchronizeSizeWithContent(): void;
  79784. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79785. private _prepareWorkingCanvasForOpaqueDetection;
  79786. private _drawImage;
  79787. _draw(context: CanvasRenderingContext2D): void;
  79788. private _renderCornerPatch;
  79789. private _renderNinePatch;
  79790. dispose(): void;
  79791. /** STRETCH_NONE */
  79792. static readonly STRETCH_NONE: number;
  79793. /** STRETCH_FILL */
  79794. static readonly STRETCH_FILL: number;
  79795. /** STRETCH_UNIFORM */
  79796. static readonly STRETCH_UNIFORM: number;
  79797. /** STRETCH_EXTEND */
  79798. static readonly STRETCH_EXTEND: number;
  79799. /** NINE_PATCH */
  79800. static readonly STRETCH_NINE_PATCH: number;
  79801. }
  79802. }
  79803. declare module BABYLON.GUI {
  79804. /**
  79805. * Class used to create 2D buttons
  79806. */
  79807. export class Button extends Rectangle {
  79808. name?: string | undefined;
  79809. /**
  79810. * Function called to generate a pointer enter animation
  79811. */
  79812. pointerEnterAnimation: () => void;
  79813. /**
  79814. * Function called to generate a pointer out animation
  79815. */
  79816. pointerOutAnimation: () => void;
  79817. /**
  79818. * Function called to generate a pointer down animation
  79819. */
  79820. pointerDownAnimation: () => void;
  79821. /**
  79822. * Function called to generate a pointer up animation
  79823. */
  79824. pointerUpAnimation: () => void;
  79825. /**
  79826. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79827. */
  79828. delegatePickingToChildren: boolean;
  79829. private _image;
  79830. /**
  79831. * Returns the image part of the button (if any)
  79832. */
  79833. get image(): BABYLON.Nullable<Image>;
  79834. private _textBlock;
  79835. /**
  79836. * Returns the image part of the button (if any)
  79837. */
  79838. get textBlock(): BABYLON.Nullable<TextBlock>;
  79839. /**
  79840. * Creates a new Button
  79841. * @param name defines the name of the button
  79842. */
  79843. constructor(name?: string | undefined);
  79844. protected _getTypeName(): string;
  79845. /** @hidden */
  79846. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79847. /** @hidden */
  79848. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79849. /** @hidden */
  79850. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79851. /** @hidden */
  79852. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79853. /** @hidden */
  79854. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79855. /**
  79856. * Creates a new button made with an image and a text
  79857. * @param name defines the name of the button
  79858. * @param text defines the text of the button
  79859. * @param imageUrl defines the url of the image
  79860. * @returns a new Button
  79861. */
  79862. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79863. /**
  79864. * Creates a new button made with an image
  79865. * @param name defines the name of the button
  79866. * @param imageUrl defines the url of the image
  79867. * @returns a new Button
  79868. */
  79869. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79870. /**
  79871. * Creates a new button made with a text
  79872. * @param name defines the name of the button
  79873. * @param text defines the text of the button
  79874. * @returns a new Button
  79875. */
  79876. static CreateSimpleButton(name: string, text: string): Button;
  79877. /**
  79878. * Creates a new button made with an image and a centered text
  79879. * @param name defines the name of the button
  79880. * @param text defines the text of the button
  79881. * @param imageUrl defines the url of the image
  79882. * @returns a new Button
  79883. */
  79884. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79885. }
  79886. }
  79887. declare module BABYLON.GUI {
  79888. /**
  79889. * Class used to create a 2D stack panel container
  79890. */
  79891. export class StackPanel extends Container {
  79892. name?: string | undefined;
  79893. private _isVertical;
  79894. private _manualWidth;
  79895. private _manualHeight;
  79896. private _doNotTrackManualChanges;
  79897. /**
  79898. * Gets or sets a boolean indicating that layou warnings should be ignored
  79899. */
  79900. ignoreLayoutWarnings: boolean;
  79901. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79902. get isVertical(): boolean;
  79903. set isVertical(value: boolean);
  79904. /**
  79905. * Gets or sets panel width.
  79906. * This value should not be set when in horizontal mode as it will be computed automatically
  79907. */
  79908. set width(value: string | number);
  79909. get width(): string | number;
  79910. /**
  79911. * Gets or sets panel height.
  79912. * This value should not be set when in vertical mode as it will be computed automatically
  79913. */
  79914. set height(value: string | number);
  79915. get height(): string | number;
  79916. /**
  79917. * Creates a new StackPanel
  79918. * @param name defines control name
  79919. */
  79920. constructor(name?: string | undefined);
  79921. protected _getTypeName(): string;
  79922. /** @hidden */
  79923. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79924. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79925. protected _postMeasure(): void;
  79926. }
  79927. }
  79928. declare module BABYLON.GUI {
  79929. /**
  79930. * Class used to represent a 2D checkbox
  79931. */
  79932. export class Checkbox extends Control {
  79933. name?: string | undefined;
  79934. private _isChecked;
  79935. private _background;
  79936. private _checkSizeRatio;
  79937. private _thickness;
  79938. /** Gets or sets border thickness */
  79939. get thickness(): number;
  79940. set thickness(value: number);
  79941. /**
  79942. * BABYLON.Observable raised when isChecked property changes
  79943. */
  79944. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79945. /** Gets or sets a value indicating the ratio between overall size and check size */
  79946. get checkSizeRatio(): number;
  79947. set checkSizeRatio(value: number);
  79948. /** Gets or sets background color */
  79949. get background(): string;
  79950. set background(value: string);
  79951. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79952. get isChecked(): boolean;
  79953. set isChecked(value: boolean);
  79954. /**
  79955. * Creates a new CheckBox
  79956. * @param name defines the control name
  79957. */
  79958. constructor(name?: string | undefined);
  79959. protected _getTypeName(): string;
  79960. /** @hidden */
  79961. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79962. /** @hidden */
  79963. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79964. /**
  79965. * Utility function to easily create a checkbox with a header
  79966. * @param title defines the label to use for the header
  79967. * @param onValueChanged defines the callback to call when value changes
  79968. * @returns a StackPanel containing the checkbox and a textBlock
  79969. */
  79970. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79971. }
  79972. }
  79973. declare module BABYLON.GUI {
  79974. /**
  79975. * Class used to store key control properties
  79976. */
  79977. export class KeyPropertySet {
  79978. /** Width */
  79979. width?: string;
  79980. /** Height */
  79981. height?: string;
  79982. /** Left padding */
  79983. paddingLeft?: string;
  79984. /** Right padding */
  79985. paddingRight?: string;
  79986. /** Top padding */
  79987. paddingTop?: string;
  79988. /** Bottom padding */
  79989. paddingBottom?: string;
  79990. /** Foreground color */
  79991. color?: string;
  79992. /** Background color */
  79993. background?: string;
  79994. }
  79995. /**
  79996. * Class used to create virtual keyboard
  79997. */
  79998. export class VirtualKeyboard extends StackPanel {
  79999. /** BABYLON.Observable raised when a key is pressed */
  80000. onKeyPressObservable: BABYLON.Observable<string>;
  80001. /** Gets or sets default key button width */
  80002. defaultButtonWidth: string;
  80003. /** Gets or sets default key button height */
  80004. defaultButtonHeight: string;
  80005. /** Gets or sets default key button left padding */
  80006. defaultButtonPaddingLeft: string;
  80007. /** Gets or sets default key button right padding */
  80008. defaultButtonPaddingRight: string;
  80009. /** Gets or sets default key button top padding */
  80010. defaultButtonPaddingTop: string;
  80011. /** Gets or sets default key button bottom padding */
  80012. defaultButtonPaddingBottom: string;
  80013. /** Gets or sets default key button foreground color */
  80014. defaultButtonColor: string;
  80015. /** Gets or sets default key button background color */
  80016. defaultButtonBackground: string;
  80017. /** Gets or sets shift button foreground color */
  80018. shiftButtonColor: string;
  80019. /** Gets or sets shift button thickness*/
  80020. selectedShiftThickness: number;
  80021. /** Gets shift key state */
  80022. shiftState: number;
  80023. protected _getTypeName(): string;
  80024. private _createKey;
  80025. /**
  80026. * Adds a new row of keys
  80027. * @param keys defines the list of keys to add
  80028. * @param propertySets defines the associated property sets
  80029. */
  80030. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  80031. /**
  80032. * Set the shift key to a specific state
  80033. * @param shiftState defines the new shift state
  80034. */
  80035. applyShiftState(shiftState: number): void;
  80036. private _currentlyConnectedInputText;
  80037. private _connectedInputTexts;
  80038. private _onKeyPressObserver;
  80039. /** Gets the input text control currently attached to the keyboard */
  80040. get connectedInputText(): BABYLON.Nullable<InputText>;
  80041. /**
  80042. * Connects the keyboard with an input text control
  80043. *
  80044. * @param input defines the target control
  80045. */
  80046. connect(input: InputText): void;
  80047. /**
  80048. * Disconnects the keyboard from connected InputText controls
  80049. *
  80050. * @param input optionally defines a target control, otherwise all are disconnected
  80051. */
  80052. disconnect(input?: InputText): void;
  80053. private _removeConnectedInputObservables;
  80054. /**
  80055. * Release all resources
  80056. */
  80057. dispose(): void;
  80058. /**
  80059. * Creates a new keyboard using a default layout
  80060. *
  80061. * @param name defines control name
  80062. * @returns a new VirtualKeyboard
  80063. */
  80064. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  80065. }
  80066. }
  80067. declare module BABYLON.GUI {
  80068. /** @hidden */
  80069. export class TextWrapper {
  80070. private _text;
  80071. private _characters;
  80072. get text(): string;
  80073. set text(txt: string);
  80074. get length(): number;
  80075. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  80076. charAt(idx: number): string;
  80077. substr(from: number, length?: number): string;
  80078. substring(from: number, to?: number): string;
  80079. isWord(index: number): boolean;
  80080. }
  80081. }
  80082. declare module BABYLON.GUI {
  80083. /**
  80084. * Class used to create input text control
  80085. */
  80086. export class InputText extends Control implements IFocusableControl {
  80087. name?: string | undefined;
  80088. private _textWrapper;
  80089. private _placeholderText;
  80090. private _background;
  80091. private _focusedBackground;
  80092. private _focusedColor;
  80093. private _placeholderColor;
  80094. private _thickness;
  80095. private _margin;
  80096. private _autoStretchWidth;
  80097. private _maxWidth;
  80098. private _isFocused;
  80099. private _blinkTimeout;
  80100. private _blinkIsEven;
  80101. private _cursorOffset;
  80102. private _scrollLeft;
  80103. private _textWidth;
  80104. private _clickedCoordinate;
  80105. private _deadKey;
  80106. private _addKey;
  80107. private _currentKey;
  80108. private _isTextHighlightOn;
  80109. private _textHighlightColor;
  80110. private _highligherOpacity;
  80111. private _highlightedText;
  80112. private _startHighlightIndex;
  80113. private _endHighlightIndex;
  80114. private _cursorIndex;
  80115. private _onFocusSelectAll;
  80116. private _isPointerDown;
  80117. private _onClipboardObserver;
  80118. private _onPointerDblTapObserver;
  80119. /** @hidden */
  80120. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  80121. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  80122. promptMessage: string;
  80123. /** Force disable prompt on mobile device */
  80124. disableMobilePrompt: boolean;
  80125. /** BABYLON.Observable raised when the text changes */
  80126. onTextChangedObservable: BABYLON.Observable<InputText>;
  80127. /** BABYLON.Observable raised just before an entered character is to be added */
  80128. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  80129. /** BABYLON.Observable raised when the control gets the focus */
  80130. onFocusObservable: BABYLON.Observable<InputText>;
  80131. /** BABYLON.Observable raised when the control loses the focus */
  80132. onBlurObservable: BABYLON.Observable<InputText>;
  80133. /**Observable raised when the text is highlighted */
  80134. onTextHighlightObservable: BABYLON.Observable<InputText>;
  80135. /**Observable raised when copy event is triggered */
  80136. onTextCopyObservable: BABYLON.Observable<InputText>;
  80137. /** BABYLON.Observable raised when cut event is triggered */
  80138. onTextCutObservable: BABYLON.Observable<InputText>;
  80139. /** BABYLON.Observable raised when paste event is triggered */
  80140. onTextPasteObservable: BABYLON.Observable<InputText>;
  80141. /** BABYLON.Observable raised when a key event was processed */
  80142. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80143. /** Gets or sets the maximum width allowed by the control */
  80144. get maxWidth(): string | number;
  80145. /** Gets the maximum width allowed by the control in pixels */
  80146. get maxWidthInPixels(): number;
  80147. set maxWidth(value: string | number);
  80148. /** Gets or sets the text highlighter transparency; default: 0.4 */
  80149. get highligherOpacity(): number;
  80150. set highligherOpacity(value: number);
  80151. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  80152. get onFocusSelectAll(): boolean;
  80153. set onFocusSelectAll(value: boolean);
  80154. /** Gets or sets the text hightlight color */
  80155. get textHighlightColor(): string;
  80156. set textHighlightColor(value: string);
  80157. /** Gets or sets control margin */
  80158. get margin(): string;
  80159. /** Gets control margin in pixels */
  80160. get marginInPixels(): number;
  80161. set margin(value: string);
  80162. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80163. get autoStretchWidth(): boolean;
  80164. set autoStretchWidth(value: boolean);
  80165. /** Gets or sets border thickness */
  80166. get thickness(): number;
  80167. set thickness(value: number);
  80168. /** Gets or sets the background color when focused */
  80169. get focusedBackground(): string;
  80170. set focusedBackground(value: string);
  80171. /** Gets or sets the background color when focused */
  80172. get focusedColor(): string;
  80173. set focusedColor(value: string);
  80174. /** Gets or sets the background color */
  80175. get background(): string;
  80176. set background(value: string);
  80177. /** Gets or sets the placeholder color */
  80178. get placeholderColor(): string;
  80179. set placeholderColor(value: string);
  80180. /** Gets or sets the text displayed when the control is empty */
  80181. get placeholderText(): string;
  80182. set placeholderText(value: string);
  80183. /** Gets or sets the dead key flag */
  80184. get deadKey(): boolean;
  80185. set deadKey(flag: boolean);
  80186. /** Gets or sets the highlight text */
  80187. get highlightedText(): string;
  80188. set highlightedText(text: string);
  80189. /** Gets or sets if the current key should be added */
  80190. get addKey(): boolean;
  80191. set addKey(flag: boolean);
  80192. /** Gets or sets the value of the current key being entered */
  80193. get currentKey(): string;
  80194. set currentKey(key: string);
  80195. /** Gets or sets the text displayed in the control */
  80196. get text(): string;
  80197. set text(value: string);
  80198. private _textHasChanged;
  80199. /** Gets or sets control width */
  80200. get width(): string | number;
  80201. set width(value: string | number);
  80202. /**
  80203. * Creates a new InputText
  80204. * @param name defines the control name
  80205. * @param text defines the text of the control
  80206. */
  80207. constructor(name?: string | undefined, text?: string);
  80208. /** @hidden */
  80209. onBlur(): void;
  80210. /** @hidden */
  80211. onFocus(): void;
  80212. protected _getTypeName(): string;
  80213. /**
  80214. * Function called to get the list of controls that should not steal the focus from this control
  80215. * @returns an array of controls
  80216. */
  80217. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80218. /** @hidden */
  80219. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80220. /** @hidden */
  80221. private _updateValueFromCursorIndex;
  80222. /** @hidden */
  80223. private _processDblClick;
  80224. /** @hidden */
  80225. private _selectAllText;
  80226. /**
  80227. * Handles the keyboard event
  80228. * @param evt Defines the KeyboardEvent
  80229. */
  80230. processKeyboard(evt: KeyboardEvent): void;
  80231. /** @hidden */
  80232. private _onCopyText;
  80233. /** @hidden */
  80234. private _onCutText;
  80235. /** @hidden */
  80236. private _onPasteText;
  80237. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80238. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80239. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80240. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80241. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80242. dispose(): void;
  80243. }
  80244. }
  80245. declare module BABYLON.GUI {
  80246. /**
  80247. * Class used to create a 2D grid container
  80248. */
  80249. export class Grid extends Container {
  80250. name?: string | undefined;
  80251. private _rowDefinitions;
  80252. private _columnDefinitions;
  80253. private _cells;
  80254. private _childControls;
  80255. /**
  80256. * Gets the number of columns
  80257. */
  80258. get columnCount(): number;
  80259. /**
  80260. * Gets the number of rows
  80261. */
  80262. get rowCount(): number;
  80263. /** Gets the list of children */
  80264. get children(): Control[];
  80265. /** Gets the list of cells (e.g. the containers) */
  80266. get cells(): {
  80267. [key: string]: Container;
  80268. };
  80269. /**
  80270. * Gets the definition of a specific row
  80271. * @param index defines the index of the row
  80272. * @returns the row definition
  80273. */
  80274. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80275. /**
  80276. * Gets the definition of a specific column
  80277. * @param index defines the index of the column
  80278. * @returns the column definition
  80279. */
  80280. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80281. /**
  80282. * Adds a new row to the grid
  80283. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80284. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80285. * @returns the current grid
  80286. */
  80287. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80288. /**
  80289. * Adds a new column to the grid
  80290. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80291. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80292. * @returns the current grid
  80293. */
  80294. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80295. /**
  80296. * Update a row definition
  80297. * @param index defines the index of the row to update
  80298. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80299. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80300. * @returns the current grid
  80301. */
  80302. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80303. /**
  80304. * Update a column definition
  80305. * @param index defines the index of the column to update
  80306. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80307. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80308. * @returns the current grid
  80309. */
  80310. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80311. /**
  80312. * Gets the list of children stored in a specific cell
  80313. * @param row defines the row to check
  80314. * @param column defines the column to check
  80315. * @returns the list of controls
  80316. */
  80317. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80318. /**
  80319. * Gets a string representing the child cell info (row x column)
  80320. * @param child defines the control to get info from
  80321. * @returns a string containing the child cell info (row x column)
  80322. */
  80323. getChildCellInfo(child: Control): string;
  80324. private _removeCell;
  80325. private _offsetCell;
  80326. /**
  80327. * Remove a column definition at specified index
  80328. * @param index defines the index of the column to remove
  80329. * @returns the current grid
  80330. */
  80331. removeColumnDefinition(index: number): Grid;
  80332. /**
  80333. * Remove a row definition at specified index
  80334. * @param index defines the index of the row to remove
  80335. * @returns the current grid
  80336. */
  80337. removeRowDefinition(index: number): Grid;
  80338. /**
  80339. * Adds a new control to the current grid
  80340. * @param control defines the control to add
  80341. * @param row defines the row where to add the control (0 by default)
  80342. * @param column defines the column where to add the control (0 by default)
  80343. * @returns the current grid
  80344. */
  80345. addControl(control: Control, row?: number, column?: number): Grid;
  80346. /**
  80347. * Removes a control from the current container
  80348. * @param control defines the control to remove
  80349. * @returns the current container
  80350. */
  80351. removeControl(control: Control): Container;
  80352. /**
  80353. * Creates a new Grid
  80354. * @param name defines control name
  80355. */
  80356. constructor(name?: string | undefined);
  80357. protected _getTypeName(): string;
  80358. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80359. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80360. _flagDescendantsAsMatrixDirty(): void;
  80361. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80362. /** Releases associated resources */
  80363. dispose(): void;
  80364. }
  80365. }
  80366. declare module BABYLON.GUI {
  80367. /** Class used to create color pickers */
  80368. export class ColorPicker extends Control {
  80369. name?: string | undefined;
  80370. private static _Epsilon;
  80371. private _colorWheelCanvas;
  80372. private _value;
  80373. private _tmpColor;
  80374. private _pointerStartedOnSquare;
  80375. private _pointerStartedOnWheel;
  80376. private _squareLeft;
  80377. private _squareTop;
  80378. private _squareSize;
  80379. private _h;
  80380. private _s;
  80381. private _v;
  80382. private _lastPointerDownID;
  80383. /**
  80384. * BABYLON.Observable raised when the value changes
  80385. */
  80386. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80387. /** Gets or sets the color of the color picker */
  80388. get value(): BABYLON.Color3;
  80389. set value(value: BABYLON.Color3);
  80390. /**
  80391. * Gets or sets control width
  80392. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80393. */
  80394. get width(): string | number;
  80395. set width(value: string | number);
  80396. /**
  80397. * Gets or sets control height
  80398. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80399. */
  80400. get height(): string | number;
  80401. /** Gets or sets control height */
  80402. set height(value: string | number);
  80403. /** Gets or sets control size */
  80404. get size(): string | number;
  80405. set size(value: string | number);
  80406. /**
  80407. * Creates a new ColorPicker
  80408. * @param name defines the control name
  80409. */
  80410. constructor(name?: string | undefined);
  80411. protected _getTypeName(): string;
  80412. /** @hidden */
  80413. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80414. private _updateSquareProps;
  80415. private _drawGradientSquare;
  80416. private _drawCircle;
  80417. private _createColorWheelCanvas;
  80418. /** @hidden */
  80419. _draw(context: CanvasRenderingContext2D): void;
  80420. private _pointerIsDown;
  80421. private _updateValueFromPointer;
  80422. private _isPointOnSquare;
  80423. private _isPointOnWheel;
  80424. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80425. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80426. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80427. _onCanvasBlur(): void;
  80428. /**
  80429. * This function expands the color picker by creating a color picker dialog with manual
  80430. * color value input and the ability to save colors into an array to be used later in
  80431. * subsequent launches of the dialogue.
  80432. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80433. * @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.
  80434. * @returns picked color as a hex string and the saved colors array as hex strings.
  80435. */
  80436. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80437. pickerWidth?: string;
  80438. pickerHeight?: string;
  80439. headerHeight?: string;
  80440. lastColor?: string;
  80441. swatchLimit?: number;
  80442. numSwatchesPerLine?: number;
  80443. savedColors?: Array<string>;
  80444. }): Promise<{
  80445. savedColors?: string[];
  80446. pickedColor: string;
  80447. }>;
  80448. }
  80449. }
  80450. declare module BABYLON.GUI {
  80451. /** Class used to create 2D ellipse containers */
  80452. export class Ellipse extends Container {
  80453. name?: string | undefined;
  80454. private _thickness;
  80455. /** Gets or sets border thickness */
  80456. get thickness(): number;
  80457. set thickness(value: number);
  80458. /**
  80459. * Creates a new Ellipse
  80460. * @param name defines the control name
  80461. */
  80462. constructor(name?: string | undefined);
  80463. protected _getTypeName(): string;
  80464. protected _localDraw(context: CanvasRenderingContext2D): void;
  80465. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80466. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80467. }
  80468. }
  80469. declare module BABYLON.GUI {
  80470. /**
  80471. * Class used to create a password control
  80472. */
  80473. export class InputPassword extends InputText {
  80474. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80475. }
  80476. }
  80477. declare module BABYLON.GUI {
  80478. /** Class used to render 2D lines */
  80479. export class Line extends Control {
  80480. name?: string | undefined;
  80481. private _lineWidth;
  80482. private _x1;
  80483. private _y1;
  80484. private _x2;
  80485. private _y2;
  80486. private _dash;
  80487. private _connectedControl;
  80488. private _connectedControlDirtyObserver;
  80489. /** Gets or sets the dash pattern */
  80490. get dash(): Array<number>;
  80491. set dash(value: Array<number>);
  80492. /** Gets or sets the control connected with the line end */
  80493. get connectedControl(): Control;
  80494. set connectedControl(value: Control);
  80495. /** Gets or sets start coordinates on X axis */
  80496. get x1(): string | number;
  80497. set x1(value: string | number);
  80498. /** Gets or sets start coordinates on Y axis */
  80499. get y1(): string | number;
  80500. set y1(value: string | number);
  80501. /** Gets or sets end coordinates on X axis */
  80502. get x2(): string | number;
  80503. set x2(value: string | number);
  80504. /** Gets or sets end coordinates on Y axis */
  80505. get y2(): string | number;
  80506. set y2(value: string | number);
  80507. /** Gets or sets line width */
  80508. get lineWidth(): number;
  80509. set lineWidth(value: number);
  80510. /** Gets or sets horizontal alignment */
  80511. set horizontalAlignment(value: number);
  80512. /** Gets or sets vertical alignment */
  80513. set verticalAlignment(value: number);
  80514. private get _effectiveX2();
  80515. private get _effectiveY2();
  80516. /**
  80517. * Creates a new Line
  80518. * @param name defines the control name
  80519. */
  80520. constructor(name?: string | undefined);
  80521. protected _getTypeName(): string;
  80522. _draw(context: CanvasRenderingContext2D): void;
  80523. _measure(): void;
  80524. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80525. /**
  80526. * Move one end of the line given 3D cartesian coordinates.
  80527. * @param position Targeted world position
  80528. * @param scene BABYLON.Scene
  80529. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80530. */
  80531. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80532. /**
  80533. * Move one end of the line to a position in screen absolute space.
  80534. * @param projectedPosition Position in screen absolute space (X, Y)
  80535. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80536. */
  80537. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80538. }
  80539. }
  80540. declare module BABYLON.GUI {
  80541. /**
  80542. * Class used to store a point for a MultiLine object.
  80543. * The point can be pure 2D coordinates, a mesh or a control
  80544. */
  80545. export class MultiLinePoint {
  80546. private _multiLine;
  80547. private _x;
  80548. private _y;
  80549. private _control;
  80550. private _mesh;
  80551. private _controlObserver;
  80552. private _meshObserver;
  80553. /** @hidden */
  80554. _point: BABYLON.Vector3;
  80555. /**
  80556. * Creates a new MultiLinePoint
  80557. * @param multiLine defines the source MultiLine object
  80558. */
  80559. constructor(multiLine: MultiLine);
  80560. /** Gets or sets x coordinate */
  80561. get x(): string | number;
  80562. set x(value: string | number);
  80563. /** Gets or sets y coordinate */
  80564. get y(): string | number;
  80565. set y(value: string | number);
  80566. /** Gets or sets the control associated with this point */
  80567. get control(): BABYLON.Nullable<Control>;
  80568. set control(value: BABYLON.Nullable<Control>);
  80569. /** Gets or sets the mesh associated with this point */
  80570. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80571. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80572. /** Resets links */
  80573. resetLinks(): void;
  80574. /**
  80575. * Gets a translation vector with Z component
  80576. * @returns the translation vector
  80577. */
  80578. translate(): BABYLON.Vector3;
  80579. private _translatePoint;
  80580. /** Release associated resources */
  80581. dispose(): void;
  80582. }
  80583. }
  80584. declare module BABYLON.GUI {
  80585. /**
  80586. * Class used to create multi line control
  80587. */
  80588. export class MultiLine extends Control {
  80589. name?: string | undefined;
  80590. private _lineWidth;
  80591. private _dash;
  80592. private _points;
  80593. private _minX;
  80594. private _minY;
  80595. private _maxX;
  80596. private _maxY;
  80597. /**
  80598. * Creates a new MultiLine
  80599. * @param name defines the control name
  80600. */
  80601. constructor(name?: string | undefined);
  80602. /** Gets or sets dash pattern */
  80603. get dash(): Array<number>;
  80604. set dash(value: Array<number>);
  80605. /**
  80606. * Gets point stored at specified index
  80607. * @param index defines the index to look for
  80608. * @returns the requested point if found
  80609. */
  80610. getAt(index: number): MultiLinePoint;
  80611. /** Function called when a point is updated */
  80612. onPointUpdate: () => void;
  80613. /**
  80614. * Adds new points to the point collection
  80615. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80616. * @returns the list of created MultiLinePoint
  80617. */
  80618. add(...items: (AbstractMesh | Control | {
  80619. x: string | number;
  80620. y: string | number;
  80621. })[]): MultiLinePoint[];
  80622. /**
  80623. * Adds a new point to the point collection
  80624. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80625. * @returns the created MultiLinePoint
  80626. */
  80627. push(item?: (AbstractMesh | Control | {
  80628. x: string | number;
  80629. y: string | number;
  80630. })): MultiLinePoint;
  80631. /**
  80632. * Remove a specific value or point from the active point collection
  80633. * @param value defines the value or point to remove
  80634. */
  80635. remove(value: number | MultiLinePoint): void;
  80636. /**
  80637. * Resets this object to initial state (no point)
  80638. */
  80639. reset(): void;
  80640. /**
  80641. * Resets all links
  80642. */
  80643. resetLinks(): void;
  80644. /** Gets or sets line width */
  80645. get lineWidth(): number;
  80646. set lineWidth(value: number);
  80647. set horizontalAlignment(value: number);
  80648. set verticalAlignment(value: number);
  80649. protected _getTypeName(): string;
  80650. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80651. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80652. _measure(): void;
  80653. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80654. dispose(): void;
  80655. }
  80656. }
  80657. declare module BABYLON.GUI {
  80658. /**
  80659. * Class used to create radio button controls
  80660. */
  80661. export class RadioButton extends Control {
  80662. name?: string | undefined;
  80663. private _isChecked;
  80664. private _background;
  80665. private _checkSizeRatio;
  80666. private _thickness;
  80667. /** Gets or sets border thickness */
  80668. get thickness(): number;
  80669. set thickness(value: number);
  80670. /** Gets or sets group name */
  80671. group: string;
  80672. /** BABYLON.Observable raised when isChecked is changed */
  80673. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80674. /** Gets or sets a value indicating the ratio between overall size and check size */
  80675. get checkSizeRatio(): number;
  80676. set checkSizeRatio(value: number);
  80677. /** Gets or sets background color */
  80678. get background(): string;
  80679. set background(value: string);
  80680. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80681. get isChecked(): boolean;
  80682. set isChecked(value: boolean);
  80683. /**
  80684. * Creates a new RadioButton
  80685. * @param name defines the control name
  80686. */
  80687. constructor(name?: string | undefined);
  80688. protected _getTypeName(): string;
  80689. _draw(context: CanvasRenderingContext2D): void;
  80690. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80691. /**
  80692. * Utility function to easily create a radio button with a header
  80693. * @param title defines the label to use for the header
  80694. * @param group defines the group to use for the radio button
  80695. * @param isChecked defines the initial state of the radio button
  80696. * @param onValueChanged defines the callback to call when value changes
  80697. * @returns a StackPanel containing the radio button and a textBlock
  80698. */
  80699. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80700. }
  80701. }
  80702. declare module BABYLON.GUI {
  80703. /**
  80704. * Class used to create slider controls
  80705. */
  80706. export class BaseSlider extends Control {
  80707. name?: string | undefined;
  80708. protected _thumbWidth: ValueAndUnit;
  80709. private _minimum;
  80710. private _maximum;
  80711. private _value;
  80712. private _isVertical;
  80713. protected _barOffset: ValueAndUnit;
  80714. private _isThumbClamped;
  80715. protected _displayThumb: boolean;
  80716. private _step;
  80717. private _lastPointerDownID;
  80718. protected _effectiveBarOffset: number;
  80719. protected _renderLeft: number;
  80720. protected _renderTop: number;
  80721. protected _renderWidth: number;
  80722. protected _renderHeight: number;
  80723. protected _backgroundBoxLength: number;
  80724. protected _backgroundBoxThickness: number;
  80725. protected _effectiveThumbThickness: number;
  80726. /** BABYLON.Observable raised when the sldier value changes */
  80727. onValueChangedObservable: BABYLON.Observable<number>;
  80728. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80729. get displayThumb(): boolean;
  80730. set displayThumb(value: boolean);
  80731. /** Gets or sets a step to apply to values (0 by default) */
  80732. get step(): number;
  80733. set step(value: number);
  80734. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80735. get barOffset(): string | number;
  80736. /** Gets main bar offset in pixels*/
  80737. get barOffsetInPixels(): number;
  80738. set barOffset(value: string | number);
  80739. /** Gets or sets thumb width */
  80740. get thumbWidth(): string | number;
  80741. /** Gets thumb width in pixels */
  80742. get thumbWidthInPixels(): number;
  80743. set thumbWidth(value: string | number);
  80744. /** Gets or sets minimum value */
  80745. get minimum(): number;
  80746. set minimum(value: number);
  80747. /** Gets or sets maximum value */
  80748. get maximum(): number;
  80749. set maximum(value: number);
  80750. /** Gets or sets current value */
  80751. get value(): number;
  80752. set value(value: number);
  80753. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80754. get isVertical(): boolean;
  80755. set isVertical(value: boolean);
  80756. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80757. get isThumbClamped(): boolean;
  80758. set isThumbClamped(value: boolean);
  80759. /**
  80760. * Creates a new BaseSlider
  80761. * @param name defines the control name
  80762. */
  80763. constructor(name?: string | undefined);
  80764. protected _getTypeName(): string;
  80765. protected _getThumbPosition(): number;
  80766. protected _getThumbThickness(type: string): number;
  80767. protected _prepareRenderingData(type: string): void;
  80768. private _pointerIsDown;
  80769. /** @hidden */
  80770. protected _updateValueFromPointer(x: number, y: number): void;
  80771. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80772. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80773. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80774. _onCanvasBlur(): void;
  80775. }
  80776. }
  80777. declare module BABYLON.GUI {
  80778. /**
  80779. * Class used to create slider controls
  80780. */
  80781. export class Slider extends BaseSlider {
  80782. name?: string | undefined;
  80783. private _background;
  80784. private _borderColor;
  80785. private _thumbColor;
  80786. private _isThumbCircle;
  80787. protected _displayValueBar: boolean;
  80788. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80789. get displayValueBar(): boolean;
  80790. set displayValueBar(value: boolean);
  80791. /** Gets or sets border color */
  80792. get borderColor(): string;
  80793. set borderColor(value: string);
  80794. /** Gets or sets background color */
  80795. get background(): string;
  80796. set background(value: string);
  80797. /** Gets or sets thumb's color */
  80798. get thumbColor(): string;
  80799. set thumbColor(value: string);
  80800. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80801. get isThumbCircle(): boolean;
  80802. set isThumbCircle(value: boolean);
  80803. /**
  80804. * Creates a new Slider
  80805. * @param name defines the control name
  80806. */
  80807. constructor(name?: string | undefined);
  80808. protected _getTypeName(): string;
  80809. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80810. }
  80811. }
  80812. declare module BABYLON.GUI {
  80813. /** Class used to create a RadioGroup
  80814. * which contains groups of radio buttons
  80815. */
  80816. export class SelectorGroup {
  80817. /** name of SelectorGroup */
  80818. name: string;
  80819. private _groupPanel;
  80820. private _selectors;
  80821. private _groupHeader;
  80822. /**
  80823. * Creates a new SelectorGroup
  80824. * @param name of group, used as a group heading
  80825. */
  80826. constructor(
  80827. /** name of SelectorGroup */
  80828. name: string);
  80829. /** Gets the groupPanel of the SelectorGroup */
  80830. get groupPanel(): StackPanel;
  80831. /** Gets the selectors array */
  80832. get selectors(): StackPanel[];
  80833. /** Gets and sets the group header */
  80834. get header(): string;
  80835. set header(label: string);
  80836. /** @hidden */
  80837. private _addGroupHeader;
  80838. /** @hidden*/
  80839. _getSelector(selectorNb: number): StackPanel | undefined;
  80840. /** Removes the selector at the given position
  80841. * @param selectorNb the position of the selector within the group
  80842. */
  80843. removeSelector(selectorNb: number): void;
  80844. }
  80845. /** Class used to create a CheckboxGroup
  80846. * which contains groups of checkbox buttons
  80847. */
  80848. export class CheckboxGroup extends SelectorGroup {
  80849. /** Adds a checkbox as a control
  80850. * @param text is the label for the selector
  80851. * @param func is the function called when the Selector is checked
  80852. * @param checked is true when Selector is checked
  80853. */
  80854. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80855. /** @hidden */
  80856. _setSelectorLabel(selectorNb: number, label: string): void;
  80857. /** @hidden */
  80858. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80859. /** @hidden */
  80860. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80861. /** @hidden */
  80862. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80863. }
  80864. /** Class used to create a RadioGroup
  80865. * which contains groups of radio buttons
  80866. */
  80867. export class RadioGroup extends SelectorGroup {
  80868. private _selectNb;
  80869. /** Adds a radio button as a control
  80870. * @param label is the label for the selector
  80871. * @param func is the function called when the Selector is checked
  80872. * @param checked is true when Selector is checked
  80873. */
  80874. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80875. /** @hidden */
  80876. _setSelectorLabel(selectorNb: number, label: string): void;
  80877. /** @hidden */
  80878. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80879. /** @hidden */
  80880. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80881. /** @hidden */
  80882. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80883. }
  80884. /** Class used to create a SliderGroup
  80885. * which contains groups of slider buttons
  80886. */
  80887. export class SliderGroup extends SelectorGroup {
  80888. /**
  80889. * Adds a slider to the SelectorGroup
  80890. * @param label is the label for the SliderBar
  80891. * @param func is the function called when the Slider moves
  80892. * @param unit is a string describing the units used, eg degrees or metres
  80893. * @param min is the minimum value for the Slider
  80894. * @param max is the maximum value for the Slider
  80895. * @param value is the start value for the Slider between min and max
  80896. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80897. */
  80898. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80899. /** @hidden */
  80900. _setSelectorLabel(selectorNb: number, label: string): void;
  80901. /** @hidden */
  80902. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80903. /** @hidden */
  80904. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80905. /** @hidden */
  80906. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80907. }
  80908. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80909. * @see https://doc.babylonjs.com/how_to/selector
  80910. */
  80911. export class SelectionPanel extends Rectangle {
  80912. /** name of SelectionPanel */
  80913. name: string;
  80914. /** an array of SelectionGroups */
  80915. groups: SelectorGroup[];
  80916. private _panel;
  80917. private _buttonColor;
  80918. private _buttonBackground;
  80919. private _headerColor;
  80920. private _barColor;
  80921. private _barHeight;
  80922. private _spacerHeight;
  80923. private _labelColor;
  80924. private _groups;
  80925. private _bars;
  80926. /**
  80927. * Creates a new SelectionPanel
  80928. * @param name of SelectionPanel
  80929. * @param groups is an array of SelectionGroups
  80930. */
  80931. constructor(
  80932. /** name of SelectionPanel */
  80933. name: string,
  80934. /** an array of SelectionGroups */
  80935. groups?: SelectorGroup[]);
  80936. protected _getTypeName(): string;
  80937. /** Gets the (stack) panel of the SelectionPanel */
  80938. get panel(): StackPanel;
  80939. /** Gets or sets the headerColor */
  80940. get headerColor(): string;
  80941. set headerColor(color: string);
  80942. private _setHeaderColor;
  80943. /** Gets or sets the button color */
  80944. get buttonColor(): string;
  80945. set buttonColor(color: string);
  80946. private _setbuttonColor;
  80947. /** Gets or sets the label color */
  80948. get labelColor(): string;
  80949. set labelColor(color: string);
  80950. private _setLabelColor;
  80951. /** Gets or sets the button background */
  80952. get buttonBackground(): string;
  80953. set buttonBackground(color: string);
  80954. private _setButtonBackground;
  80955. /** Gets or sets the color of separator bar */
  80956. get barColor(): string;
  80957. set barColor(color: string);
  80958. private _setBarColor;
  80959. /** Gets or sets the height of separator bar */
  80960. get barHeight(): string;
  80961. set barHeight(value: string);
  80962. private _setBarHeight;
  80963. /** Gets or sets the height of spacers*/
  80964. get spacerHeight(): string;
  80965. set spacerHeight(value: string);
  80966. private _setSpacerHeight;
  80967. /** Adds a bar between groups */
  80968. private _addSpacer;
  80969. /** Add a group to the selection panel
  80970. * @param group is the selector group to add
  80971. */
  80972. addGroup(group: SelectorGroup): void;
  80973. /** Remove the group from the given position
  80974. * @param groupNb is the position of the group in the list
  80975. */
  80976. removeGroup(groupNb: number): void;
  80977. /** Change a group header label
  80978. * @param label is the new group header label
  80979. * @param groupNb is the number of the group to relabel
  80980. * */
  80981. setHeaderName(label: string, groupNb: number): void;
  80982. /** Change selector label to the one given
  80983. * @param label is the new selector label
  80984. * @param groupNb is the number of the groupcontaining the selector
  80985. * @param selectorNb is the number of the selector within a group to relabel
  80986. * */
  80987. relabel(label: string, groupNb: number, selectorNb: number): void;
  80988. /** For a given group position remove the selector at the given position
  80989. * @param groupNb is the number of the group to remove the selector from
  80990. * @param selectorNb is the number of the selector within the group
  80991. */
  80992. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80993. /** For a given group position of correct type add a checkbox button
  80994. * @param groupNb is the number of the group to remove the selector from
  80995. * @param label is the label for the selector
  80996. * @param func is the function called when the Selector is checked
  80997. * @param checked is true when Selector is checked
  80998. */
  80999. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81000. /** For a given group position of correct type add a radio button
  81001. * @param groupNb is the number of the group to remove the selector from
  81002. * @param label is the label for the selector
  81003. * @param func is the function called when the Selector is checked
  81004. * @param checked is true when Selector is checked
  81005. */
  81006. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81007. /**
  81008. * For a given slider group add a slider
  81009. * @param groupNb is the number of the group to add the slider to
  81010. * @param label is the label for the Slider
  81011. * @param func is the function called when the Slider moves
  81012. * @param unit is a string describing the units used, eg degrees or metres
  81013. * @param min is the minimum value for the Slider
  81014. * @param max is the maximum value for the Slider
  81015. * @param value is the start value for the Slider between min and max
  81016. * @param onVal is the function used to format the value displayed, eg radians to degrees
  81017. */
  81018. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  81019. }
  81020. }
  81021. declare module BABYLON.GUI {
  81022. /**
  81023. * Class used to hold a the container for ScrollViewer
  81024. * @hidden
  81025. */
  81026. export class _ScrollViewerWindow extends Container {
  81027. parentClientWidth: number;
  81028. parentClientHeight: number;
  81029. private _freezeControls;
  81030. private _parentMeasure;
  81031. private _oldLeft;
  81032. private _oldTop;
  81033. get freezeControls(): boolean;
  81034. set freezeControls(value: boolean);
  81035. private _bucketWidth;
  81036. private _bucketHeight;
  81037. private _buckets;
  81038. private _bucketLen;
  81039. get bucketWidth(): number;
  81040. get bucketHeight(): number;
  81041. setBucketSizes(width: number, height: number): void;
  81042. private _useBuckets;
  81043. private _makeBuckets;
  81044. private _dispatchInBuckets;
  81045. private _updateMeasures;
  81046. private _updateChildrenMeasures;
  81047. private _restoreMeasures;
  81048. /**
  81049. * Creates a new ScrollViewerWindow
  81050. * @param name of ScrollViewerWindow
  81051. */
  81052. constructor(name?: string);
  81053. protected _getTypeName(): string;
  81054. /** @hidden */
  81055. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81056. /** @hidden */
  81057. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  81058. private _scrollChildren;
  81059. private _scrollChildrenWithBuckets;
  81060. /** @hidden */
  81061. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  81062. protected _postMeasure(): void;
  81063. }
  81064. }
  81065. declare module BABYLON.GUI {
  81066. /**
  81067. * Class used to create slider controls
  81068. */
  81069. export class ScrollBar extends BaseSlider {
  81070. name?: string | undefined;
  81071. private _background;
  81072. private _borderColor;
  81073. private _tempMeasure;
  81074. /** Gets or sets border color */
  81075. get borderColor(): string;
  81076. set borderColor(value: string);
  81077. /** Gets or sets background color */
  81078. get background(): string;
  81079. set background(value: string);
  81080. /**
  81081. * Creates a new Slider
  81082. * @param name defines the control name
  81083. */
  81084. constructor(name?: string | undefined);
  81085. protected _getTypeName(): string;
  81086. protected _getThumbThickness(): number;
  81087. _draw(context: CanvasRenderingContext2D): void;
  81088. private _first;
  81089. private _originX;
  81090. private _originY;
  81091. /** @hidden */
  81092. protected _updateValueFromPointer(x: number, y: number): void;
  81093. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81094. }
  81095. }
  81096. declare module BABYLON.GUI {
  81097. /**
  81098. * Class used to create slider controls
  81099. */
  81100. export class ImageScrollBar extends BaseSlider {
  81101. name?: string | undefined;
  81102. private _backgroundBaseImage;
  81103. private _backgroundImage;
  81104. private _thumbImage;
  81105. private _thumbBaseImage;
  81106. private _thumbLength;
  81107. private _thumbHeight;
  81108. private _barImageHeight;
  81109. private _tempMeasure;
  81110. /** Number of 90° rotation to apply on the images when in vertical mode */
  81111. num90RotationInVerticalMode: number;
  81112. /**
  81113. * Gets or sets the image used to render the background for horizontal bar
  81114. */
  81115. get backgroundImage(): Image;
  81116. set backgroundImage(value: Image);
  81117. /**
  81118. * Gets or sets the image used to render the thumb
  81119. */
  81120. get thumbImage(): Image;
  81121. set thumbImage(value: Image);
  81122. /**
  81123. * Gets or sets the length of the thumb
  81124. */
  81125. get thumbLength(): number;
  81126. set thumbLength(value: number);
  81127. /**
  81128. * Gets or sets the height of the thumb
  81129. */
  81130. get thumbHeight(): number;
  81131. set thumbHeight(value: number);
  81132. /**
  81133. * Gets or sets the height of the bar image
  81134. */
  81135. get barImageHeight(): number;
  81136. set barImageHeight(value: number);
  81137. /**
  81138. * Creates a new ImageScrollBar
  81139. * @param name defines the control name
  81140. */
  81141. constructor(name?: string | undefined);
  81142. protected _getTypeName(): string;
  81143. protected _getThumbThickness(): number;
  81144. _draw(context: CanvasRenderingContext2D): void;
  81145. private _first;
  81146. private _originX;
  81147. private _originY;
  81148. /** @hidden */
  81149. protected _updateValueFromPointer(x: number, y: number): void;
  81150. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81151. }
  81152. }
  81153. declare module BABYLON.GUI {
  81154. /**
  81155. * Class used to hold a viewer window and sliders in a grid
  81156. */
  81157. export class ScrollViewer extends Rectangle {
  81158. private _grid;
  81159. private _horizontalBarSpace;
  81160. private _verticalBarSpace;
  81161. private _dragSpace;
  81162. private _horizontalBar;
  81163. private _verticalBar;
  81164. private _barColor;
  81165. private _barBackground;
  81166. private _barImage;
  81167. private _horizontalBarImage;
  81168. private _verticalBarImage;
  81169. private _barBackgroundImage;
  81170. private _horizontalBarBackgroundImage;
  81171. private _verticalBarBackgroundImage;
  81172. private _barSize;
  81173. private _window;
  81174. private _pointerIsOver;
  81175. private _wheelPrecision;
  81176. private _onWheelObserver;
  81177. private _clientWidth;
  81178. private _clientHeight;
  81179. private _useImageBar;
  81180. private _thumbLength;
  81181. private _thumbHeight;
  81182. private _barImageHeight;
  81183. private _horizontalBarImageHeight;
  81184. private _verticalBarImageHeight;
  81185. private _oldWindowContentsWidth;
  81186. private _oldWindowContentsHeight;
  81187. /**
  81188. * Gets the horizontal scrollbar
  81189. */
  81190. get horizontalBar(): ScrollBar | ImageScrollBar;
  81191. /**
  81192. * Gets the vertical scrollbar
  81193. */
  81194. get verticalBar(): ScrollBar | ImageScrollBar;
  81195. /**
  81196. * Adds a new control to the current container
  81197. * @param control defines the control to add
  81198. * @returns the current container
  81199. */
  81200. addControl(control: BABYLON.Nullable<Control>): Container;
  81201. /**
  81202. * Removes a control from the current container
  81203. * @param control defines the control to remove
  81204. * @returns the current container
  81205. */
  81206. removeControl(control: Control): Container;
  81207. /** Gets the list of children */
  81208. get children(): Control[];
  81209. _flagDescendantsAsMatrixDirty(): void;
  81210. /**
  81211. * Freezes or unfreezes the controls in the window.
  81212. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81213. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81214. */
  81215. get freezeControls(): boolean;
  81216. set freezeControls(value: boolean);
  81217. /** Gets the bucket width */
  81218. get bucketWidth(): number;
  81219. /** Gets the bucket height */
  81220. get bucketHeight(): number;
  81221. /**
  81222. * Sets the bucket sizes.
  81223. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81224. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81225. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81226. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81227. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81228. * used), that's why it is not enabled by default.
  81229. * @param width width of the bucket
  81230. * @param height height of the bucket
  81231. */
  81232. setBucketSizes(width: number, height: number): void;
  81233. private _forceHorizontalBar;
  81234. private _forceVerticalBar;
  81235. /**
  81236. * Forces the horizontal scroll bar to be displayed
  81237. */
  81238. get forceHorizontalBar(): boolean;
  81239. set forceHorizontalBar(value: boolean);
  81240. /**
  81241. * Forces the vertical scroll bar to be displayed
  81242. */
  81243. get forceVerticalBar(): boolean;
  81244. set forceVerticalBar(value: boolean);
  81245. /**
  81246. * Creates a new ScrollViewer
  81247. * @param name of ScrollViewer
  81248. */
  81249. constructor(name?: string, isImageBased?: boolean);
  81250. /** Reset the scroll viewer window to initial size */
  81251. resetWindow(): void;
  81252. protected _getTypeName(): string;
  81253. private _buildClientSizes;
  81254. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81255. protected _postMeasure(): void;
  81256. /**
  81257. * Gets or sets the mouse wheel precision
  81258. * from 0 to 1 with a default value of 0.05
  81259. * */
  81260. get wheelPrecision(): number;
  81261. set wheelPrecision(value: number);
  81262. /** Gets or sets the scroll bar container background color */
  81263. get scrollBackground(): string;
  81264. set scrollBackground(color: string);
  81265. /** Gets or sets the bar color */
  81266. get barColor(): string;
  81267. set barColor(color: string);
  81268. /** Gets or sets the bar image */
  81269. get thumbImage(): Image;
  81270. set thumbImage(value: Image);
  81271. /** Gets or sets the horizontal bar image */
  81272. get horizontalThumbImage(): Image;
  81273. set horizontalThumbImage(value: Image);
  81274. /** Gets or sets the vertical bar image */
  81275. get verticalThumbImage(): Image;
  81276. set verticalThumbImage(value: Image);
  81277. /** Gets or sets the size of the bar */
  81278. get barSize(): number;
  81279. set barSize(value: number);
  81280. /** Gets or sets the length of the thumb */
  81281. get thumbLength(): number;
  81282. set thumbLength(value: number);
  81283. /** Gets or sets the height of the thumb */
  81284. get thumbHeight(): number;
  81285. set thumbHeight(value: number);
  81286. /** Gets or sets the height of the bar image */
  81287. get barImageHeight(): number;
  81288. set barImageHeight(value: number);
  81289. /** Gets or sets the height of the horizontal bar image */
  81290. get horizontalBarImageHeight(): number;
  81291. set horizontalBarImageHeight(value: number);
  81292. /** Gets or sets the height of the vertical bar image */
  81293. get verticalBarImageHeight(): number;
  81294. set verticalBarImageHeight(value: number);
  81295. /** Gets or sets the bar background */
  81296. get barBackground(): string;
  81297. set barBackground(color: string);
  81298. /** Gets or sets the bar background image */
  81299. get barImage(): Image;
  81300. set barImage(value: Image);
  81301. /** Gets or sets the horizontal bar background image */
  81302. get horizontalBarImage(): Image;
  81303. set horizontalBarImage(value: Image);
  81304. /** Gets or sets the vertical bar background image */
  81305. get verticalBarImage(): Image;
  81306. set verticalBarImage(value: Image);
  81307. private _setWindowPosition;
  81308. /** @hidden */
  81309. private _updateScroller;
  81310. _link(host: AdvancedDynamicTexture): void;
  81311. /** @hidden */
  81312. private _addBar;
  81313. /** @hidden */
  81314. private _attachWheel;
  81315. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81316. /** Releases associated resources */
  81317. dispose(): void;
  81318. }
  81319. }
  81320. declare module BABYLON.GUI {
  81321. /** Class used to render a grid */
  81322. export class DisplayGrid extends Control {
  81323. name?: string | undefined;
  81324. private _cellWidth;
  81325. private _cellHeight;
  81326. private _minorLineTickness;
  81327. private _minorLineColor;
  81328. private _majorLineTickness;
  81329. private _majorLineColor;
  81330. private _majorLineFrequency;
  81331. private _background;
  81332. private _displayMajorLines;
  81333. private _displayMinorLines;
  81334. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81335. get displayMinorLines(): boolean;
  81336. set displayMinorLines(value: boolean);
  81337. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81338. get displayMajorLines(): boolean;
  81339. set displayMajorLines(value: boolean);
  81340. /** Gets or sets background color (Black by default) */
  81341. get background(): string;
  81342. set background(value: string);
  81343. /** Gets or sets the width of each cell (20 by default) */
  81344. get cellWidth(): number;
  81345. set cellWidth(value: number);
  81346. /** Gets or sets the height of each cell (20 by default) */
  81347. get cellHeight(): number;
  81348. set cellHeight(value: number);
  81349. /** Gets or sets the tickness of minor lines (1 by default) */
  81350. get minorLineTickness(): number;
  81351. set minorLineTickness(value: number);
  81352. /** Gets or sets the color of minor lines (DarkGray by default) */
  81353. get minorLineColor(): string;
  81354. set minorLineColor(value: string);
  81355. /** Gets or sets the tickness of major lines (2 by default) */
  81356. get majorLineTickness(): number;
  81357. set majorLineTickness(value: number);
  81358. /** Gets or sets the color of major lines (White by default) */
  81359. get majorLineColor(): string;
  81360. set majorLineColor(value: string);
  81361. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81362. get majorLineFrequency(): number;
  81363. set majorLineFrequency(value: number);
  81364. /**
  81365. * Creates a new GridDisplayRectangle
  81366. * @param name defines the control name
  81367. */
  81368. constructor(name?: string | undefined);
  81369. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81370. protected _getTypeName(): string;
  81371. }
  81372. }
  81373. declare module BABYLON.GUI {
  81374. /**
  81375. * Class used to create slider controls based on images
  81376. */
  81377. export class ImageBasedSlider extends BaseSlider {
  81378. name?: string | undefined;
  81379. private _backgroundImage;
  81380. private _thumbImage;
  81381. private _valueBarImage;
  81382. private _tempMeasure;
  81383. get displayThumb(): boolean;
  81384. set displayThumb(value: boolean);
  81385. /**
  81386. * Gets or sets the image used to render the background
  81387. */
  81388. get backgroundImage(): Image;
  81389. set backgroundImage(value: Image);
  81390. /**
  81391. * Gets or sets the image used to render the value bar
  81392. */
  81393. get valueBarImage(): Image;
  81394. set valueBarImage(value: Image);
  81395. /**
  81396. * Gets or sets the image used to render the thumb
  81397. */
  81398. get thumbImage(): Image;
  81399. set thumbImage(value: Image);
  81400. /**
  81401. * Creates a new ImageBasedSlider
  81402. * @param name defines the control name
  81403. */
  81404. constructor(name?: string | undefined);
  81405. protected _getTypeName(): string;
  81406. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81407. }
  81408. }
  81409. declare module BABYLON.GUI {
  81410. /**
  81411. * Forcing an export so that this code will execute
  81412. * @hidden
  81413. */
  81414. const name = "Statics";
  81415. }
  81416. declare module BABYLON.GUI {
  81417. /**
  81418. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81419. */
  81420. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81421. /**
  81422. * Define the instrumented AdvancedDynamicTexture.
  81423. */
  81424. texture: AdvancedDynamicTexture;
  81425. private _captureRenderTime;
  81426. private _renderTime;
  81427. private _captureLayoutTime;
  81428. private _layoutTime;
  81429. private _onBeginRenderObserver;
  81430. private _onEndRenderObserver;
  81431. private _onBeginLayoutObserver;
  81432. private _onEndLayoutObserver;
  81433. /**
  81434. * Gets the perf counter used to capture render time
  81435. */
  81436. get renderTimeCounter(): BABYLON.PerfCounter;
  81437. /**
  81438. * Gets the perf counter used to capture layout time
  81439. */
  81440. get layoutTimeCounter(): BABYLON.PerfCounter;
  81441. /**
  81442. * Enable or disable the render time capture
  81443. */
  81444. get captureRenderTime(): boolean;
  81445. set captureRenderTime(value: boolean);
  81446. /**
  81447. * Enable or disable the layout time capture
  81448. */
  81449. get captureLayoutTime(): boolean;
  81450. set captureLayoutTime(value: boolean);
  81451. /**
  81452. * Instantiates a new advanced dynamic texture instrumentation.
  81453. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81454. * @param texture Defines the AdvancedDynamicTexture to instrument
  81455. */
  81456. constructor(
  81457. /**
  81458. * Define the instrumented AdvancedDynamicTexture.
  81459. */
  81460. texture: AdvancedDynamicTexture);
  81461. /**
  81462. * Dispose and release associated resources.
  81463. */
  81464. dispose(): void;
  81465. }
  81466. }
  81467. declare module BABYLON.GUI {
  81468. /**
  81469. * Class used to load GUI via XML.
  81470. */
  81471. export class XmlLoader {
  81472. private _nodes;
  81473. private _nodeTypes;
  81474. private _isLoaded;
  81475. private _objectAttributes;
  81476. private _parentClass;
  81477. /**
  81478. * Create a new xml loader
  81479. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81480. */
  81481. constructor(parentClass?: null);
  81482. private _getChainElement;
  81483. private _getClassAttribute;
  81484. private _createGuiElement;
  81485. private _parseGrid;
  81486. private _parseElement;
  81487. private _prepareSourceElement;
  81488. private _parseElementsFromSource;
  81489. private _parseXml;
  81490. /**
  81491. * Gets if the loading has finished.
  81492. * @returns whether the loading has finished or not
  81493. */
  81494. isLoaded(): boolean;
  81495. /**
  81496. * Gets a loaded node / control by id.
  81497. * @param id the Controls id set in the xml
  81498. * @returns element of type Control
  81499. */
  81500. getNodeById(id: string): any;
  81501. /**
  81502. * Gets all loaded nodes / controls
  81503. * @returns Array of controls
  81504. */
  81505. getNodes(): any;
  81506. /**
  81507. * Initiates the xml layout loading
  81508. * @param xmlFile defines the xml layout to load
  81509. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81510. * @param callback defines the callback called on layout load.
  81511. */
  81512. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81513. }
  81514. }
  81515. declare module BABYLON.GUI {
  81516. /**
  81517. * Class used to create containers for controls
  81518. */
  81519. export class Container3D extends Control3D {
  81520. private _blockLayout;
  81521. /**
  81522. * Gets the list of child controls
  81523. */
  81524. protected _children: Control3D[];
  81525. /**
  81526. * Gets the list of child controls
  81527. */
  81528. get children(): Array<Control3D>;
  81529. /**
  81530. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81531. * This is helpful to optimize layout operation when adding multiple children in a row
  81532. */
  81533. get blockLayout(): boolean;
  81534. set blockLayout(value: boolean);
  81535. /**
  81536. * Creates a new container
  81537. * @param name defines the container name
  81538. */
  81539. constructor(name?: string);
  81540. /**
  81541. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81542. * @returns the current container
  81543. */
  81544. updateLayout(): Container3D;
  81545. /**
  81546. * Gets a boolean indicating if the given control is in the children of this control
  81547. * @param control defines the control to check
  81548. * @returns true if the control is in the child list
  81549. */
  81550. containsControl(control: Control3D): boolean;
  81551. /**
  81552. * Adds a control to the children of this control
  81553. * @param control defines the control to add
  81554. * @returns the current container
  81555. */
  81556. addControl(control: Control3D): Container3D;
  81557. /**
  81558. * This function will be called everytime a new control is added
  81559. */
  81560. protected _arrangeChildren(): void;
  81561. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81562. /**
  81563. * Removes a control from the children of this control
  81564. * @param control defines the control to remove
  81565. * @returns the current container
  81566. */
  81567. removeControl(control: Control3D): Container3D;
  81568. protected _getTypeName(): string;
  81569. /**
  81570. * Releases all associated resources
  81571. */
  81572. dispose(): void;
  81573. /** Control rotation will remain unchanged */
  81574. static readonly UNSET_ORIENTATION: number;
  81575. /** Control will rotate to make it look at sphere central axis */
  81576. static readonly FACEORIGIN_ORIENTATION: number;
  81577. /** Control will rotate to make it look back at sphere central axis */
  81578. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81579. /** Control will rotate to look at z axis (0, 0, 1) */
  81580. static readonly FACEFORWARD_ORIENTATION: number;
  81581. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81582. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81583. }
  81584. }
  81585. declare module BABYLON.GUI {
  81586. /**
  81587. * Class used to manage 3D user interface
  81588. * @see https://doc.babylonjs.com/how_to/gui3d
  81589. */
  81590. export class GUI3DManager implements BABYLON.IDisposable {
  81591. private _scene;
  81592. private _sceneDisposeObserver;
  81593. private _utilityLayer;
  81594. private _rootContainer;
  81595. private _pointerObserver;
  81596. private _pointerOutObserver;
  81597. /** @hidden */
  81598. _lastPickedControl: Control3D;
  81599. /** @hidden */
  81600. _lastControlOver: {
  81601. [pointerId: number]: Control3D;
  81602. };
  81603. /** @hidden */
  81604. _lastControlDown: {
  81605. [pointerId: number]: Control3D;
  81606. };
  81607. /**
  81608. * BABYLON.Observable raised when the point picked by the pointer events changed
  81609. */
  81610. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81611. /** @hidden */
  81612. _sharedMaterials: {
  81613. [key: string]: BABYLON.Material;
  81614. };
  81615. /** Gets the hosting scene */
  81616. get scene(): BABYLON.Scene;
  81617. /** Gets associated utility layer */
  81618. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81619. /**
  81620. * Creates a new GUI3DManager
  81621. * @param scene
  81622. */
  81623. constructor(scene?: BABYLON.Scene);
  81624. private _handlePointerOut;
  81625. private _doPicking;
  81626. /**
  81627. * Gets the root container
  81628. */
  81629. get rootContainer(): Container3D;
  81630. /**
  81631. * Gets a boolean indicating if the given control is in the root child list
  81632. * @param control defines the control to check
  81633. * @returns true if the control is in the root child list
  81634. */
  81635. containsControl(control: Control3D): boolean;
  81636. /**
  81637. * Adds a control to the root child list
  81638. * @param control defines the control to add
  81639. * @returns the current manager
  81640. */
  81641. addControl(control: Control3D): GUI3DManager;
  81642. /**
  81643. * Removes a control from the root child list
  81644. * @param control defines the control to remove
  81645. * @returns the current container
  81646. */
  81647. removeControl(control: Control3D): GUI3DManager;
  81648. /**
  81649. * Releases all associated resources
  81650. */
  81651. dispose(): void;
  81652. }
  81653. }
  81654. declare module BABYLON.GUI {
  81655. /**
  81656. * Class used to transport BABYLON.Vector3 information for pointer events
  81657. */
  81658. export class Vector3WithInfo extends BABYLON.Vector3 {
  81659. /** defines the current mouse button index */
  81660. buttonIndex: number;
  81661. /**
  81662. * Creates a new Vector3WithInfo
  81663. * @param source defines the vector3 data to transport
  81664. * @param buttonIndex defines the current mouse button index
  81665. */
  81666. constructor(source: BABYLON.Vector3,
  81667. /** defines the current mouse button index */
  81668. buttonIndex?: number);
  81669. }
  81670. }
  81671. declare module BABYLON.GUI {
  81672. /**
  81673. * Class used as base class for controls
  81674. */
  81675. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81676. /** Defines the control name */
  81677. name?: string | undefined;
  81678. /** @hidden */
  81679. _host: GUI3DManager;
  81680. private _node;
  81681. private _downCount;
  81682. private _enterCount;
  81683. private _downPointerIds;
  81684. private _isVisible;
  81685. /** Gets or sets the control position in world space */
  81686. get position(): BABYLON.Vector3;
  81687. set position(value: BABYLON.Vector3);
  81688. /** Gets or sets the control scaling in world space */
  81689. get scaling(): BABYLON.Vector3;
  81690. set scaling(value: BABYLON.Vector3);
  81691. /** Callback used to start pointer enter animation */
  81692. pointerEnterAnimation: () => void;
  81693. /** Callback used to start pointer out animation */
  81694. pointerOutAnimation: () => void;
  81695. /** Callback used to start pointer down animation */
  81696. pointerDownAnimation: () => void;
  81697. /** Callback used to start pointer up animation */
  81698. pointerUpAnimation: () => void;
  81699. /**
  81700. * An event triggered when the pointer move over the control
  81701. */
  81702. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81703. /**
  81704. * An event triggered when the pointer move out of the control
  81705. */
  81706. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81707. /**
  81708. * An event triggered when the pointer taps the control
  81709. */
  81710. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81711. /**
  81712. * An event triggered when pointer is up
  81713. */
  81714. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81715. /**
  81716. * An event triggered when a control is clicked on (with a mouse)
  81717. */
  81718. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81719. /**
  81720. * An event triggered when pointer enters the control
  81721. */
  81722. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81723. /**
  81724. * Gets or sets the parent container
  81725. */
  81726. parent: BABYLON.Nullable<Container3D>;
  81727. private _behaviors;
  81728. /**
  81729. * Gets the list of attached behaviors
  81730. * @see https://doc.babylonjs.com/features/behaviour
  81731. */
  81732. get behaviors(): BABYLON.Behavior<Control3D>[];
  81733. /**
  81734. * Attach a behavior to the control
  81735. * @see https://doc.babylonjs.com/features/behaviour
  81736. * @param behavior defines the behavior to attach
  81737. * @returns the current control
  81738. */
  81739. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81740. /**
  81741. * Remove an attached behavior
  81742. * @see https://doc.babylonjs.com/features/behaviour
  81743. * @param behavior defines the behavior to attach
  81744. * @returns the current control
  81745. */
  81746. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81747. /**
  81748. * Gets an attached behavior by name
  81749. * @param name defines the name of the behavior to look for
  81750. * @see https://doc.babylonjs.com/features/behaviour
  81751. * @returns null if behavior was not found else the requested behavior
  81752. */
  81753. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81754. /** Gets or sets a boolean indicating if the control is visible */
  81755. get isVisible(): boolean;
  81756. set isVisible(value: boolean);
  81757. /**
  81758. * Creates a new control
  81759. * @param name defines the control name
  81760. */
  81761. constructor(
  81762. /** Defines the control name */
  81763. name?: string | undefined);
  81764. /**
  81765. * Gets a string representing the class name
  81766. */
  81767. get typeName(): string;
  81768. /**
  81769. * Get the current class name of the control.
  81770. * @returns current class name
  81771. */
  81772. getClassName(): string;
  81773. protected _getTypeName(): string;
  81774. /**
  81775. * Gets the transform node used by this control
  81776. */
  81777. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81778. /**
  81779. * Gets the mesh used to render this control
  81780. */
  81781. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81782. /**
  81783. * Link the control as child of the given node
  81784. * @param node defines the node to link to. Use null to unlink the control
  81785. * @returns the current control
  81786. */
  81787. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81788. /** @hidden **/
  81789. _prepareNode(scene: BABYLON.Scene): void;
  81790. /**
  81791. * Node creation.
  81792. * Can be overriden by children
  81793. * @param scene defines the scene where the node must be attached
  81794. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81795. */
  81796. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81797. /**
  81798. * Affect a material to the given mesh
  81799. * @param mesh defines the mesh which will represent the control
  81800. */
  81801. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81802. /** @hidden */
  81803. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81804. /** @hidden */
  81805. _onPointerEnter(target: Control3D): boolean;
  81806. /** @hidden */
  81807. _onPointerOut(target: Control3D): void;
  81808. /** @hidden */
  81809. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81810. /** @hidden */
  81811. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81812. /** @hidden */
  81813. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81814. /** @hidden */
  81815. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81816. /** @hidden */
  81817. _disposeNode(): void;
  81818. /**
  81819. * Releases all associated resources
  81820. */
  81821. dispose(): void;
  81822. }
  81823. }
  81824. declare module BABYLON.GUI {
  81825. /**
  81826. * Class used as a root to all buttons
  81827. */
  81828. export class AbstractButton3D extends Control3D {
  81829. /**
  81830. * Creates a new button
  81831. * @param name defines the control name
  81832. */
  81833. constructor(name?: string);
  81834. protected _getTypeName(): string;
  81835. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81836. }
  81837. }
  81838. declare module BABYLON.GUI {
  81839. /**
  81840. * Class used to create a button in 3D
  81841. */
  81842. export class Button3D extends AbstractButton3D {
  81843. /** @hidden */
  81844. protected _currentMaterial: BABYLON.Material;
  81845. private _facadeTexture;
  81846. private _content;
  81847. private _contentResolution;
  81848. private _contentScaleRatio;
  81849. /**
  81850. * Gets or sets the texture resolution used to render content (512 by default)
  81851. */
  81852. get contentResolution(): BABYLON.int;
  81853. set contentResolution(value: BABYLON.int);
  81854. /**
  81855. * Gets or sets the texture scale ratio used to render content (2 by default)
  81856. */
  81857. get contentScaleRatio(): number;
  81858. set contentScaleRatio(value: number);
  81859. protected _disposeFacadeTexture(): void;
  81860. protected _resetContent(): void;
  81861. /**
  81862. * Creates a new button
  81863. * @param name defines the control name
  81864. */
  81865. constructor(name?: string);
  81866. /**
  81867. * Gets or sets the GUI 2D content used to display the button's facade
  81868. */
  81869. get content(): Control;
  81870. set content(value: Control);
  81871. /**
  81872. * Apply the facade texture (created from the content property).
  81873. * This function can be overloaded by child classes
  81874. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81875. */
  81876. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81877. protected _getTypeName(): string;
  81878. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81879. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81880. /**
  81881. * Releases all associated resources
  81882. */
  81883. dispose(): void;
  81884. }
  81885. }
  81886. declare module BABYLON.GUI {
  81887. /**
  81888. * Abstract class used to create a container panel deployed on the surface of a volume
  81889. */
  81890. export abstract class VolumeBasedPanel extends Container3D {
  81891. private _columns;
  81892. private _rows;
  81893. private _rowThenColum;
  81894. private _orientation;
  81895. protected _cellWidth: number;
  81896. protected _cellHeight: number;
  81897. /**
  81898. * Gets or sets the distance between elements
  81899. */
  81900. margin: number;
  81901. /**
  81902. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81903. * | Value | Type | Description |
  81904. * | ----- | ----------------------------------- | ----------- |
  81905. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81906. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81907. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81908. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81909. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81910. */
  81911. get orientation(): number;
  81912. set orientation(value: number);
  81913. /**
  81914. * Gets or sets the number of columns requested (10 by default).
  81915. * The panel will automatically compute the number of rows based on number of child controls.
  81916. */
  81917. get columns(): BABYLON.int;
  81918. set columns(value: BABYLON.int);
  81919. /**
  81920. * Gets or sets a the number of rows requested.
  81921. * The panel will automatically compute the number of columns based on number of child controls.
  81922. */
  81923. get rows(): BABYLON.int;
  81924. set rows(value: BABYLON.int);
  81925. /**
  81926. * Creates new VolumeBasedPanel
  81927. */
  81928. constructor();
  81929. protected _arrangeChildren(): void;
  81930. /** Child classes must implement this function to provide correct control positioning */
  81931. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81932. /** Child classes can implement this function to provide additional processing */
  81933. protected _finalProcessing(): void;
  81934. }
  81935. }
  81936. declare module BABYLON.GUI {
  81937. /**
  81938. * Class used to create a container panel deployed on the surface of a cylinder
  81939. */
  81940. export class CylinderPanel extends VolumeBasedPanel {
  81941. private _radius;
  81942. /**
  81943. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81944. */
  81945. get radius(): BABYLON.float;
  81946. set radius(value: BABYLON.float);
  81947. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81948. private _cylindricalMapping;
  81949. }
  81950. }
  81951. declare module BABYLON.GUI {
  81952. /** @hidden */
  81953. export var fluentVertexShader: {
  81954. name: string;
  81955. shader: string;
  81956. };
  81957. }
  81958. declare module BABYLON.GUI {
  81959. /** @hidden */
  81960. export var fluentPixelShader: {
  81961. name: string;
  81962. shader: string;
  81963. };
  81964. }
  81965. declare module BABYLON.GUI {
  81966. /** @hidden */
  81967. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81968. INNERGLOW: boolean;
  81969. BORDER: boolean;
  81970. HOVERLIGHT: boolean;
  81971. TEXTURE: boolean;
  81972. constructor();
  81973. }
  81974. /**
  81975. * Class used to render controls with fluent desgin
  81976. */
  81977. export class FluentMaterial extends BABYLON.PushMaterial {
  81978. /**
  81979. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81980. */
  81981. innerGlowColorIntensity: number;
  81982. /**
  81983. * Gets or sets the inner glow color (white by default)
  81984. */
  81985. innerGlowColor: BABYLON.Color3;
  81986. /**
  81987. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81988. */
  81989. albedoColor: BABYLON.Color3;
  81990. /**
  81991. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81992. */
  81993. renderBorders: boolean;
  81994. /**
  81995. * Gets or sets border width (default is 0.5)
  81996. */
  81997. borderWidth: number;
  81998. /**
  81999. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  82000. */
  82001. edgeSmoothingValue: number;
  82002. /**
  82003. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  82004. */
  82005. borderMinValue: number;
  82006. /**
  82007. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  82008. */
  82009. renderHoverLight: boolean;
  82010. /**
  82011. * Gets or sets the radius used to render the hover light (default is 1.0)
  82012. */
  82013. hoverRadius: number;
  82014. /**
  82015. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  82016. */
  82017. hoverColor: BABYLON.Color4;
  82018. /**
  82019. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  82020. */
  82021. hoverPosition: BABYLON.Vector3;
  82022. private _albedoTexture;
  82023. /** Gets or sets the texture to use for albedo color */
  82024. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82025. /**
  82026. * Creates a new Fluent material
  82027. * @param name defines the name of the material
  82028. * @param scene defines the hosting scene
  82029. */
  82030. constructor(name: string, scene: BABYLON.Scene);
  82031. needAlphaBlending(): boolean;
  82032. needAlphaTesting(): boolean;
  82033. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82036. getActiveTextures(): BABYLON.BaseTexture[];
  82037. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82038. dispose(forceDisposeEffect?: boolean): void;
  82039. clone(name: string): FluentMaterial;
  82040. serialize(): any;
  82041. getClassName(): string;
  82042. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  82043. }
  82044. }
  82045. declare module BABYLON.GUI {
  82046. /**
  82047. * Class used to create a holographic button in 3D
  82048. */
  82049. export class HolographicButton extends Button3D {
  82050. private _backPlate;
  82051. private _textPlate;
  82052. private _frontPlate;
  82053. private _text;
  82054. private _imageUrl;
  82055. private _shareMaterials;
  82056. private _frontMaterial;
  82057. private _backMaterial;
  82058. private _plateMaterial;
  82059. private _pickedPointObserver;
  82060. private _tooltipFade;
  82061. private _tooltipTextBlock;
  82062. private _tooltipTexture;
  82063. private _tooltipMesh;
  82064. private _tooltipHoverObserver;
  82065. private _tooltipOutObserver;
  82066. private _disposeTooltip;
  82067. /**
  82068. * Rendering ground id of all the mesh in the button
  82069. */
  82070. set renderingGroupId(id: number);
  82071. get renderingGroupId(): number;
  82072. /**
  82073. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  82074. */
  82075. set tooltipText(text: BABYLON.Nullable<string>);
  82076. get tooltipText(): BABYLON.Nullable<string>;
  82077. /**
  82078. * Gets or sets text for the button
  82079. */
  82080. get text(): string;
  82081. set text(value: string);
  82082. /**
  82083. * Gets or sets the image url for the button
  82084. */
  82085. get imageUrl(): string;
  82086. set imageUrl(value: string);
  82087. /**
  82088. * Gets the back material used by this button
  82089. */
  82090. get backMaterial(): FluentMaterial;
  82091. /**
  82092. * Gets the front material used by this button
  82093. */
  82094. get frontMaterial(): FluentMaterial;
  82095. /**
  82096. * Gets the plate material used by this button
  82097. */
  82098. get plateMaterial(): BABYLON.StandardMaterial;
  82099. /**
  82100. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  82101. */
  82102. get shareMaterials(): boolean;
  82103. /**
  82104. * Creates a new button
  82105. * @param name defines the control name
  82106. */
  82107. constructor(name?: string, shareMaterials?: boolean);
  82108. protected _getTypeName(): string;
  82109. private _rebuildContent;
  82110. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82111. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  82112. private _createBackMaterial;
  82113. private _createFrontMaterial;
  82114. private _createPlateMaterial;
  82115. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  82116. /**
  82117. * Releases all associated resources
  82118. */
  82119. dispose(): void;
  82120. }
  82121. }
  82122. declare module BABYLON.GUI {
  82123. /**
  82124. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  82125. */
  82126. export class MeshButton3D extends Button3D {
  82127. /** @hidden */
  82128. protected _currentMesh: BABYLON.Mesh;
  82129. /**
  82130. * Creates a new 3D button based on a mesh
  82131. * @param mesh mesh to become a 3D button
  82132. * @param name defines the control name
  82133. */
  82134. constructor(mesh: BABYLON.Mesh, name?: string);
  82135. protected _getTypeName(): string;
  82136. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82137. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  82138. }
  82139. }
  82140. declare module BABYLON.GUI {
  82141. /**
  82142. * Class used to create a container panel deployed on the surface of a plane
  82143. */
  82144. export class PlanePanel extends VolumeBasedPanel {
  82145. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82146. }
  82147. }
  82148. declare module BABYLON.GUI {
  82149. /**
  82150. * Class used to create a container panel where items get randomized planar mapping
  82151. */
  82152. export class ScatterPanel extends VolumeBasedPanel {
  82153. private _iteration;
  82154. /**
  82155. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82156. */
  82157. get iteration(): BABYLON.float;
  82158. set iteration(value: BABYLON.float);
  82159. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82160. private _scatterMapping;
  82161. protected _finalProcessing(): void;
  82162. }
  82163. }
  82164. declare module BABYLON.GUI {
  82165. /**
  82166. * Class used to create a container panel deployed on the surface of a sphere
  82167. */
  82168. export class SpherePanel extends VolumeBasedPanel {
  82169. private _radius;
  82170. /**
  82171. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82172. */
  82173. get radius(): BABYLON.float;
  82174. set radius(value: BABYLON.float);
  82175. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82176. private _sphericalMapping;
  82177. }
  82178. }
  82179. declare module BABYLON.GUI {
  82180. /**
  82181. * Class used to create a stack panel in 3D on XY plane
  82182. */
  82183. export class StackPanel3D extends Container3D {
  82184. private _isVertical;
  82185. /**
  82186. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82187. */
  82188. get isVertical(): boolean;
  82189. set isVertical(value: boolean);
  82190. /**
  82191. * Gets or sets the distance between elements
  82192. */
  82193. margin: number;
  82194. /**
  82195. * Creates new StackPanel
  82196. * @param isVertical
  82197. */
  82198. constructor(isVertical?: boolean);
  82199. protected _arrangeChildren(): void;
  82200. }
  82201. }
  82202. declare module BABYLON {
  82203. /**
  82204. * Configuration for glTF validation
  82205. */
  82206. export interface IGLTFValidationConfiguration {
  82207. /**
  82208. * The url of the glTF validator.
  82209. */
  82210. url: string;
  82211. }
  82212. /**
  82213. * glTF validation
  82214. */
  82215. export class GLTFValidation {
  82216. /**
  82217. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82218. */
  82219. static Configuration: IGLTFValidationConfiguration;
  82220. private static _LoadScriptPromise;
  82221. /**
  82222. * Validate a glTF asset using the glTF-Validator.
  82223. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82224. * @param rootUrl The root url for the glTF
  82225. * @param fileName The file name for the glTF
  82226. * @param getExternalResource The callback to get external resources for the glTF validator
  82227. * @returns A promise that resolves with the glTF validation results once complete
  82228. */
  82229. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82230. }
  82231. }
  82232. declare module BABYLON {
  82233. /**
  82234. * Mode that determines the coordinate system to use.
  82235. */
  82236. export enum GLTFLoaderCoordinateSystemMode {
  82237. /**
  82238. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82239. */
  82240. AUTO = 0,
  82241. /**
  82242. * Sets the useRightHandedSystem flag on the scene.
  82243. */
  82244. FORCE_RIGHT_HANDED = 1
  82245. }
  82246. /**
  82247. * Mode that determines what animations will start.
  82248. */
  82249. export enum GLTFLoaderAnimationStartMode {
  82250. /**
  82251. * No animation will start.
  82252. */
  82253. NONE = 0,
  82254. /**
  82255. * The first animation will start.
  82256. */
  82257. FIRST = 1,
  82258. /**
  82259. * All animations will start.
  82260. */
  82261. ALL = 2
  82262. }
  82263. /**
  82264. * Interface that contains the data for the glTF asset.
  82265. */
  82266. export interface IGLTFLoaderData {
  82267. /**
  82268. * The object that represents the glTF JSON.
  82269. */
  82270. json: Object;
  82271. /**
  82272. * The BIN chunk of a binary glTF.
  82273. */
  82274. bin: Nullable<IDataBuffer>;
  82275. }
  82276. /**
  82277. * Interface for extending the loader.
  82278. */
  82279. export interface IGLTFLoaderExtension {
  82280. /**
  82281. * The name of this extension.
  82282. */
  82283. readonly name: string;
  82284. /**
  82285. * Defines whether this extension is enabled.
  82286. */
  82287. enabled: boolean;
  82288. /**
  82289. * Defines the order of this extension.
  82290. * The loader sorts the extensions using these values when loading.
  82291. */
  82292. order?: number;
  82293. }
  82294. /**
  82295. * Loader state.
  82296. */
  82297. export enum GLTFLoaderState {
  82298. /**
  82299. * The asset is loading.
  82300. */
  82301. LOADING = 0,
  82302. /**
  82303. * The asset is ready for rendering.
  82304. */
  82305. READY = 1,
  82306. /**
  82307. * The asset is completely loaded.
  82308. */
  82309. COMPLETE = 2
  82310. }
  82311. /** @hidden */
  82312. export interface IGLTFLoader extends IDisposable {
  82313. readonly state: Nullable<GLTFLoaderState>;
  82314. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82315. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82316. }
  82317. /**
  82318. * File loader for loading glTF files into a scene.
  82319. */
  82320. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82321. /** @hidden */
  82322. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82323. /** @hidden */
  82324. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82325. /**
  82326. * Raised when the asset has been parsed
  82327. */
  82328. onParsedObservable: Observable<IGLTFLoaderData>;
  82329. private _onParsedObserver;
  82330. /**
  82331. * Raised when the asset has been parsed
  82332. */
  82333. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82334. /**
  82335. * 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.
  82336. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82337. * Defaults to true.
  82338. * @hidden
  82339. */
  82340. static IncrementalLoading: boolean;
  82341. /**
  82342. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82343. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82344. * @hidden
  82345. */
  82346. static HomogeneousCoordinates: boolean;
  82347. /**
  82348. * The coordinate system mode. Defaults to AUTO.
  82349. */
  82350. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82351. /**
  82352. * The animation start mode. Defaults to FIRST.
  82353. */
  82354. animationStartMode: GLTFLoaderAnimationStartMode;
  82355. /**
  82356. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82357. */
  82358. compileMaterials: boolean;
  82359. /**
  82360. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82361. */
  82362. useClipPlane: boolean;
  82363. /**
  82364. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82365. */
  82366. compileShadowGenerators: boolean;
  82367. /**
  82368. * Defines if the Alpha blended materials are only applied as coverage.
  82369. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82370. * If true, no extra effects are applied to transparent pixels.
  82371. */
  82372. transparencyAsCoverage: boolean;
  82373. /**
  82374. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82375. * Enabling will disable offline support and glTF validator.
  82376. * Defaults to false.
  82377. */
  82378. useRangeRequests: boolean;
  82379. /**
  82380. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82381. */
  82382. createInstances: boolean;
  82383. /**
  82384. * 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.
  82385. */
  82386. alwaysComputeBoundingBox: boolean;
  82387. /**
  82388. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82389. */
  82390. loadAllMaterials: boolean;
  82391. /**
  82392. * Function called before loading a url referenced by the asset.
  82393. */
  82394. preprocessUrlAsync: (url: string) => Promise<string>;
  82395. /**
  82396. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82397. * 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, ...)
  82398. */
  82399. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82400. private _onMeshLoadedObserver;
  82401. /**
  82402. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82403. * 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, ...)
  82404. */
  82405. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82406. /**
  82407. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82408. */
  82409. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82410. private _onTextureLoadedObserver;
  82411. /**
  82412. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82413. */
  82414. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82415. /**
  82416. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82417. */
  82418. readonly onMaterialLoadedObservable: Observable<Material>;
  82419. private _onMaterialLoadedObserver;
  82420. /**
  82421. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82422. */
  82423. set onMaterialLoaded(callback: (material: Material) => void);
  82424. /**
  82425. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82426. */
  82427. readonly onCameraLoadedObservable: Observable<Camera>;
  82428. private _onCameraLoadedObserver;
  82429. /**
  82430. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82431. */
  82432. set onCameraLoaded(callback: (camera: Camera) => void);
  82433. /**
  82434. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82435. * For assets with LODs, raised when all of the LODs are complete.
  82436. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82437. */
  82438. readonly onCompleteObservable: Observable<void>;
  82439. private _onCompleteObserver;
  82440. /**
  82441. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82442. * For assets with LODs, raised when all of the LODs are complete.
  82443. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82444. */
  82445. set onComplete(callback: () => void);
  82446. /**
  82447. * Observable raised when an error occurs.
  82448. */
  82449. readonly onErrorObservable: Observable<any>;
  82450. private _onErrorObserver;
  82451. /**
  82452. * Callback raised when an error occurs.
  82453. */
  82454. set onError(callback: (reason: any) => void);
  82455. /**
  82456. * Observable raised after the loader is disposed.
  82457. */
  82458. readonly onDisposeObservable: Observable<void>;
  82459. private _onDisposeObserver;
  82460. /**
  82461. * Callback raised after the loader is disposed.
  82462. */
  82463. set onDispose(callback: () => void);
  82464. /**
  82465. * Observable raised after a loader extension is created.
  82466. * Set additional options for a loader extension in this event.
  82467. */
  82468. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82469. private _onExtensionLoadedObserver;
  82470. /**
  82471. * Callback raised after a loader extension is created.
  82472. */
  82473. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82474. /**
  82475. * Defines if the loader logging is enabled.
  82476. */
  82477. get loggingEnabled(): boolean;
  82478. set loggingEnabled(value: boolean);
  82479. /**
  82480. * Defines if the loader should capture performance counters.
  82481. */
  82482. get capturePerformanceCounters(): boolean;
  82483. set capturePerformanceCounters(value: boolean);
  82484. /**
  82485. * Defines if the loader should validate the asset.
  82486. */
  82487. validate: boolean;
  82488. /**
  82489. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82490. */
  82491. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82492. private _onValidatedObserver;
  82493. /**
  82494. * Callback raised after a loader extension is created.
  82495. */
  82496. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82497. private _loader;
  82498. private _progressCallback?;
  82499. private _requests;
  82500. private static magicBase64Encoded;
  82501. /**
  82502. * Name of the loader ("gltf")
  82503. */
  82504. name: string;
  82505. /** @hidden */
  82506. extensions: ISceneLoaderPluginExtensions;
  82507. /**
  82508. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82509. */
  82510. dispose(): void;
  82511. /** @hidden */
  82512. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82513. /** @hidden */
  82514. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82515. /** @hidden */
  82516. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82517. /** @hidden */
  82518. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82519. /** @hidden */
  82520. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82521. /** @hidden */
  82522. canDirectLoad(data: string): boolean;
  82523. /** @hidden */
  82524. directLoad(scene: Scene, data: string): Promise<any>;
  82525. /**
  82526. * The callback that allows custom handling of the root url based on the response url.
  82527. * @param rootUrl the original root url
  82528. * @param responseURL the response url if available
  82529. * @returns the new root url
  82530. */
  82531. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82532. /** @hidden */
  82533. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82534. /**
  82535. * The loader state or null if the loader is not active.
  82536. */
  82537. get loaderState(): Nullable<GLTFLoaderState>;
  82538. /**
  82539. * Returns a promise that resolves when the asset is completely loaded.
  82540. * @returns a promise that resolves when the asset is completely loaded.
  82541. */
  82542. whenCompleteAsync(): Promise<void>;
  82543. /** @hidden */
  82544. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82545. /** @hidden */
  82546. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82547. private _onProgress;
  82548. private _validate;
  82549. private _getLoader;
  82550. private _parseJson;
  82551. private _unpackBinaryAsync;
  82552. private _unpackBinaryV1Async;
  82553. private _unpackBinaryV2Async;
  82554. private static _parseVersion;
  82555. private static _compareVersion;
  82556. private static readonly _logSpaces;
  82557. private _logIndentLevel;
  82558. private _loggingEnabled;
  82559. /** @hidden */
  82560. _log: (message: string) => void;
  82561. /** @hidden */
  82562. _logOpen(message: string): void;
  82563. /** @hidden */
  82564. _logClose(): void;
  82565. private _logEnabled;
  82566. private _logDisabled;
  82567. private _capturePerformanceCounters;
  82568. /** @hidden */
  82569. _startPerformanceCounter: (counterName: string) => void;
  82570. /** @hidden */
  82571. _endPerformanceCounter: (counterName: string) => void;
  82572. private _startPerformanceCounterEnabled;
  82573. private _startPerformanceCounterDisabled;
  82574. private _endPerformanceCounterEnabled;
  82575. private _endPerformanceCounterDisabled;
  82576. }
  82577. }
  82578. declare module BABYLON.GLTF1 {
  82579. /**
  82580. * Enums
  82581. * @hidden
  82582. */
  82583. export enum EComponentType {
  82584. BYTE = 5120,
  82585. UNSIGNED_BYTE = 5121,
  82586. SHORT = 5122,
  82587. UNSIGNED_SHORT = 5123,
  82588. FLOAT = 5126
  82589. }
  82590. /** @hidden */
  82591. export enum EShaderType {
  82592. FRAGMENT = 35632,
  82593. VERTEX = 35633
  82594. }
  82595. /** @hidden */
  82596. export enum EParameterType {
  82597. BYTE = 5120,
  82598. UNSIGNED_BYTE = 5121,
  82599. SHORT = 5122,
  82600. UNSIGNED_SHORT = 5123,
  82601. INT = 5124,
  82602. UNSIGNED_INT = 5125,
  82603. FLOAT = 5126,
  82604. FLOAT_VEC2 = 35664,
  82605. FLOAT_VEC3 = 35665,
  82606. FLOAT_VEC4 = 35666,
  82607. INT_VEC2 = 35667,
  82608. INT_VEC3 = 35668,
  82609. INT_VEC4 = 35669,
  82610. BOOL = 35670,
  82611. BOOL_VEC2 = 35671,
  82612. BOOL_VEC3 = 35672,
  82613. BOOL_VEC4 = 35673,
  82614. FLOAT_MAT2 = 35674,
  82615. FLOAT_MAT3 = 35675,
  82616. FLOAT_MAT4 = 35676,
  82617. SAMPLER_2D = 35678
  82618. }
  82619. /** @hidden */
  82620. export enum ETextureWrapMode {
  82621. CLAMP_TO_EDGE = 33071,
  82622. MIRRORED_REPEAT = 33648,
  82623. REPEAT = 10497
  82624. }
  82625. /** @hidden */
  82626. export enum ETextureFilterType {
  82627. NEAREST = 9728,
  82628. LINEAR = 9728,
  82629. NEAREST_MIPMAP_NEAREST = 9984,
  82630. LINEAR_MIPMAP_NEAREST = 9985,
  82631. NEAREST_MIPMAP_LINEAR = 9986,
  82632. LINEAR_MIPMAP_LINEAR = 9987
  82633. }
  82634. /** @hidden */
  82635. export enum ETextureFormat {
  82636. ALPHA = 6406,
  82637. RGB = 6407,
  82638. RGBA = 6408,
  82639. LUMINANCE = 6409,
  82640. LUMINANCE_ALPHA = 6410
  82641. }
  82642. /** @hidden */
  82643. export enum ECullingType {
  82644. FRONT = 1028,
  82645. BACK = 1029,
  82646. FRONT_AND_BACK = 1032
  82647. }
  82648. /** @hidden */
  82649. export enum EBlendingFunction {
  82650. ZERO = 0,
  82651. ONE = 1,
  82652. SRC_COLOR = 768,
  82653. ONE_MINUS_SRC_COLOR = 769,
  82654. DST_COLOR = 774,
  82655. ONE_MINUS_DST_COLOR = 775,
  82656. SRC_ALPHA = 770,
  82657. ONE_MINUS_SRC_ALPHA = 771,
  82658. DST_ALPHA = 772,
  82659. ONE_MINUS_DST_ALPHA = 773,
  82660. CONSTANT_COLOR = 32769,
  82661. ONE_MINUS_CONSTANT_COLOR = 32770,
  82662. CONSTANT_ALPHA = 32771,
  82663. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82664. SRC_ALPHA_SATURATE = 776
  82665. }
  82666. /** @hidden */
  82667. export interface IGLTFProperty {
  82668. extensions?: {
  82669. [key: string]: any;
  82670. };
  82671. extras?: Object;
  82672. }
  82673. /** @hidden */
  82674. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82675. name?: string;
  82676. }
  82677. /** @hidden */
  82678. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82679. bufferView: string;
  82680. byteOffset: number;
  82681. byteStride: number;
  82682. count: number;
  82683. type: string;
  82684. componentType: EComponentType;
  82685. max?: number[];
  82686. min?: number[];
  82687. name?: string;
  82688. }
  82689. /** @hidden */
  82690. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82691. buffer: string;
  82692. byteOffset: number;
  82693. byteLength: number;
  82694. byteStride: number;
  82695. target?: number;
  82696. }
  82697. /** @hidden */
  82698. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82699. uri: string;
  82700. byteLength?: number;
  82701. type?: string;
  82702. }
  82703. /** @hidden */
  82704. export interface IGLTFShader extends IGLTFChildRootProperty {
  82705. uri: string;
  82706. type: EShaderType;
  82707. }
  82708. /** @hidden */
  82709. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82710. attributes: string[];
  82711. fragmentShader: string;
  82712. vertexShader: string;
  82713. }
  82714. /** @hidden */
  82715. export interface IGLTFTechniqueParameter {
  82716. type: number;
  82717. count?: number;
  82718. semantic?: string;
  82719. node?: string;
  82720. value?: number | boolean | string | Array<any>;
  82721. source?: string;
  82722. babylonValue?: any;
  82723. }
  82724. /** @hidden */
  82725. export interface IGLTFTechniqueCommonProfile {
  82726. lightingModel: string;
  82727. texcoordBindings: Object;
  82728. parameters?: Array<any>;
  82729. }
  82730. /** @hidden */
  82731. export interface IGLTFTechniqueStatesFunctions {
  82732. blendColor?: number[];
  82733. blendEquationSeparate?: number[];
  82734. blendFuncSeparate?: number[];
  82735. colorMask: boolean[];
  82736. cullFace: number[];
  82737. }
  82738. /** @hidden */
  82739. export interface IGLTFTechniqueStates {
  82740. enable: number[];
  82741. functions: IGLTFTechniqueStatesFunctions;
  82742. }
  82743. /** @hidden */
  82744. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82745. parameters: {
  82746. [key: string]: IGLTFTechniqueParameter;
  82747. };
  82748. program: string;
  82749. attributes: {
  82750. [key: string]: string;
  82751. };
  82752. uniforms: {
  82753. [key: string]: string;
  82754. };
  82755. states: IGLTFTechniqueStates;
  82756. }
  82757. /** @hidden */
  82758. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82759. technique?: string;
  82760. values: string[];
  82761. }
  82762. /** @hidden */
  82763. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82764. attributes: {
  82765. [key: string]: string;
  82766. };
  82767. indices: string;
  82768. material: string;
  82769. mode?: number;
  82770. }
  82771. /** @hidden */
  82772. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82773. primitives: IGLTFMeshPrimitive[];
  82774. }
  82775. /** @hidden */
  82776. export interface IGLTFImage extends IGLTFChildRootProperty {
  82777. uri: string;
  82778. }
  82779. /** @hidden */
  82780. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82781. magFilter?: number;
  82782. minFilter?: number;
  82783. wrapS?: number;
  82784. wrapT?: number;
  82785. }
  82786. /** @hidden */
  82787. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82788. sampler: string;
  82789. source: string;
  82790. format?: ETextureFormat;
  82791. internalFormat?: ETextureFormat;
  82792. target?: number;
  82793. type?: number;
  82794. babylonTexture?: Texture;
  82795. }
  82796. /** @hidden */
  82797. export interface IGLTFAmbienLight {
  82798. color?: number[];
  82799. }
  82800. /** @hidden */
  82801. export interface IGLTFDirectionalLight {
  82802. color?: number[];
  82803. }
  82804. /** @hidden */
  82805. export interface IGLTFPointLight {
  82806. color?: number[];
  82807. constantAttenuation?: number;
  82808. linearAttenuation?: number;
  82809. quadraticAttenuation?: number;
  82810. }
  82811. /** @hidden */
  82812. export interface IGLTFSpotLight {
  82813. color?: number[];
  82814. constantAttenuation?: number;
  82815. fallOfAngle?: number;
  82816. fallOffExponent?: number;
  82817. linearAttenuation?: number;
  82818. quadraticAttenuation?: number;
  82819. }
  82820. /** @hidden */
  82821. export interface IGLTFLight extends IGLTFChildRootProperty {
  82822. type: string;
  82823. }
  82824. /** @hidden */
  82825. export interface IGLTFCameraOrthographic {
  82826. xmag: number;
  82827. ymag: number;
  82828. zfar: number;
  82829. znear: number;
  82830. }
  82831. /** @hidden */
  82832. export interface IGLTFCameraPerspective {
  82833. aspectRatio: number;
  82834. yfov: number;
  82835. zfar: number;
  82836. znear: number;
  82837. }
  82838. /** @hidden */
  82839. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82840. type: string;
  82841. }
  82842. /** @hidden */
  82843. export interface IGLTFAnimationChannelTarget {
  82844. id: string;
  82845. path: string;
  82846. }
  82847. /** @hidden */
  82848. export interface IGLTFAnimationChannel {
  82849. sampler: string;
  82850. target: IGLTFAnimationChannelTarget;
  82851. }
  82852. /** @hidden */
  82853. export interface IGLTFAnimationSampler {
  82854. input: string;
  82855. output: string;
  82856. interpolation?: string;
  82857. }
  82858. /** @hidden */
  82859. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82860. channels?: IGLTFAnimationChannel[];
  82861. parameters?: {
  82862. [key: string]: string;
  82863. };
  82864. samplers?: {
  82865. [key: string]: IGLTFAnimationSampler;
  82866. };
  82867. }
  82868. /** @hidden */
  82869. export interface IGLTFNodeInstanceSkin {
  82870. skeletons: string[];
  82871. skin: string;
  82872. meshes: string[];
  82873. }
  82874. /** @hidden */
  82875. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82876. bindShapeMatrix: number[];
  82877. inverseBindMatrices: string;
  82878. jointNames: string[];
  82879. babylonSkeleton?: Skeleton;
  82880. }
  82881. /** @hidden */
  82882. export interface IGLTFNode extends IGLTFChildRootProperty {
  82883. camera?: string;
  82884. children: string[];
  82885. skin?: string;
  82886. jointName?: string;
  82887. light?: string;
  82888. matrix: number[];
  82889. mesh?: string;
  82890. meshes?: string[];
  82891. rotation?: number[];
  82892. scale?: number[];
  82893. translation?: number[];
  82894. babylonNode?: Node;
  82895. }
  82896. /** @hidden */
  82897. export interface IGLTFScene extends IGLTFChildRootProperty {
  82898. nodes: string[];
  82899. }
  82900. /** @hidden */
  82901. export interface IGLTFRuntime {
  82902. extensions: {
  82903. [key: string]: any;
  82904. };
  82905. accessors: {
  82906. [key: string]: IGLTFAccessor;
  82907. };
  82908. buffers: {
  82909. [key: string]: IGLTFBuffer;
  82910. };
  82911. bufferViews: {
  82912. [key: string]: IGLTFBufferView;
  82913. };
  82914. meshes: {
  82915. [key: string]: IGLTFMesh;
  82916. };
  82917. lights: {
  82918. [key: string]: IGLTFLight;
  82919. };
  82920. cameras: {
  82921. [key: string]: IGLTFCamera;
  82922. };
  82923. nodes: {
  82924. [key: string]: IGLTFNode;
  82925. };
  82926. images: {
  82927. [key: string]: IGLTFImage;
  82928. };
  82929. textures: {
  82930. [key: string]: IGLTFTexture;
  82931. };
  82932. shaders: {
  82933. [key: string]: IGLTFShader;
  82934. };
  82935. programs: {
  82936. [key: string]: IGLTFProgram;
  82937. };
  82938. samplers: {
  82939. [key: string]: IGLTFSampler;
  82940. };
  82941. techniques: {
  82942. [key: string]: IGLTFTechnique;
  82943. };
  82944. materials: {
  82945. [key: string]: IGLTFMaterial;
  82946. };
  82947. animations: {
  82948. [key: string]: IGLTFAnimation;
  82949. };
  82950. skins: {
  82951. [key: string]: IGLTFSkins;
  82952. };
  82953. currentScene?: Object;
  82954. scenes: {
  82955. [key: string]: IGLTFScene;
  82956. };
  82957. extensionsUsed: string[];
  82958. extensionsRequired?: string[];
  82959. buffersCount: number;
  82960. shaderscount: number;
  82961. scene: Scene;
  82962. rootUrl: string;
  82963. loadedBufferCount: number;
  82964. loadedBufferViews: {
  82965. [name: string]: ArrayBufferView;
  82966. };
  82967. loadedShaderCount: number;
  82968. importOnlyMeshes: boolean;
  82969. importMeshesNames?: string[];
  82970. dummyNodes: Node[];
  82971. forAssetContainer: boolean;
  82972. }
  82973. /** @hidden */
  82974. export interface INodeToRoot {
  82975. bone: Bone;
  82976. node: IGLTFNode;
  82977. id: string;
  82978. }
  82979. /** @hidden */
  82980. export interface IJointNode {
  82981. node: IGLTFNode;
  82982. id: string;
  82983. }
  82984. }
  82985. declare module BABYLON.GLTF1 {
  82986. /**
  82987. * Utils functions for GLTF
  82988. * @hidden
  82989. */
  82990. export class GLTFUtils {
  82991. /**
  82992. * Sets the given "parameter" matrix
  82993. * @param scene: the Scene object
  82994. * @param source: the source node where to pick the matrix
  82995. * @param parameter: the GLTF technique parameter
  82996. * @param uniformName: the name of the shader's uniform
  82997. * @param shaderMaterial: the shader material
  82998. */
  82999. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  83000. /**
  83001. * Sets the given "parameter" matrix
  83002. * @param shaderMaterial: the shader material
  83003. * @param uniform: the name of the shader's uniform
  83004. * @param value: the value of the uniform
  83005. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  83006. */
  83007. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  83008. /**
  83009. * Returns the wrap mode of the texture
  83010. * @param mode: the mode value
  83011. */
  83012. static GetWrapMode(mode: number): number;
  83013. /**
  83014. * Returns the byte stride giving an accessor
  83015. * @param accessor: the GLTF accessor objet
  83016. */
  83017. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  83018. /**
  83019. * Returns the texture filter mode giving a mode value
  83020. * @param mode: the filter mode value
  83021. */
  83022. static GetTextureFilterMode(mode: number): ETextureFilterType;
  83023. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  83024. /**
  83025. * Returns a buffer from its accessor
  83026. * @param gltfRuntime: the GLTF runtime
  83027. * @param accessor: the GLTF accessor
  83028. */
  83029. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  83030. /**
  83031. * Decodes a buffer view into a string
  83032. * @param view: the buffer view
  83033. */
  83034. static DecodeBufferToText(view: ArrayBufferView): string;
  83035. /**
  83036. * Returns the default material of gltf. Related to
  83037. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  83038. * @param scene: the Babylon.js scene
  83039. */
  83040. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  83041. private static _DefaultMaterial;
  83042. }
  83043. }
  83044. declare module BABYLON.GLTF1 {
  83045. /**
  83046. * Implementation of the base glTF spec
  83047. * @hidden
  83048. */
  83049. export class GLTFLoaderBase {
  83050. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  83051. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83052. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  83053. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83054. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  83055. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83056. }
  83057. /**
  83058. * glTF V1 Loader
  83059. * @hidden
  83060. */
  83061. export class GLTFLoader implements IGLTFLoader {
  83062. static Extensions: {
  83063. [name: string]: GLTFLoaderExtension;
  83064. };
  83065. static RegisterExtension(extension: GLTFLoaderExtension): void;
  83066. state: Nullable<GLTFLoaderState>;
  83067. dispose(): void;
  83068. private _importMeshAsync;
  83069. /**
  83070. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  83071. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83072. * @param scene the scene the meshes should be added to
  83073. * @param forAssetContainer defines if the entities must be stored in the scene
  83074. * @param data gltf data containing information of the meshes in a loaded file
  83075. * @param rootUrl root url to load from
  83076. * @param onProgress event that fires when loading progress has occured
  83077. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83078. */
  83079. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  83080. private _loadAsync;
  83081. /**
  83082. * Imports all objects from a loaded gltf file and adds them to the scene
  83083. * @param scene the scene the objects should be added to
  83084. * @param data gltf data containing information of the meshes in a loaded file
  83085. * @param rootUrl root url to load from
  83086. * @param onProgress event that fires when loading progress has occured
  83087. * @returns a promise which completes when objects have been loaded to the scene
  83088. */
  83089. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  83090. private _loadShadersAsync;
  83091. private _loadBuffersAsync;
  83092. private _createNodes;
  83093. }
  83094. /** @hidden */
  83095. export abstract class GLTFLoaderExtension {
  83096. private _name;
  83097. constructor(name: string);
  83098. get name(): string;
  83099. /**
  83100. * Defines an override for loading the runtime
  83101. * Return true to stop further extensions from loading the runtime
  83102. */
  83103. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  83104. /**
  83105. * Defines an onverride for creating gltf runtime
  83106. * Return true to stop further extensions from creating the runtime
  83107. */
  83108. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83109. /**
  83110. * Defines an override for loading buffers
  83111. * Return true to stop further extensions from loading this buffer
  83112. */
  83113. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  83114. /**
  83115. * Defines an override for loading texture buffers
  83116. * Return true to stop further extensions from loading this texture data
  83117. */
  83118. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83119. /**
  83120. * Defines an override for creating textures
  83121. * Return true to stop further extensions from loading this texture
  83122. */
  83123. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  83124. /**
  83125. * Defines an override for loading shader strings
  83126. * Return true to stop further extensions from loading this shader data
  83127. */
  83128. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83129. /**
  83130. * Defines an override for loading materials
  83131. * Return true to stop further extensions from loading this material
  83132. */
  83133. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83134. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  83135. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  83136. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83137. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83138. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  83139. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83140. private static LoadTextureBufferAsync;
  83141. private static CreateTextureAsync;
  83142. private static ApplyExtensions;
  83143. }
  83144. }
  83145. declare module BABYLON.GLTF1 {
  83146. /** @hidden */
  83147. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  83148. private _bin;
  83149. constructor();
  83150. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  83151. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83152. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83153. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83154. }
  83155. }
  83156. declare module BABYLON.GLTF1 {
  83157. /** @hidden */
  83158. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83159. constructor();
  83160. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83161. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83162. private _loadTexture;
  83163. }
  83164. }
  83165. declare module BABYLON.GLTF2.Loader {
  83166. /**
  83167. * Loader interface with an index field.
  83168. */
  83169. export interface IArrayItem {
  83170. /**
  83171. * The index of this item in the array.
  83172. */
  83173. index: number;
  83174. }
  83175. /**
  83176. * Loader interface with additional members.
  83177. */
  83178. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83179. /** @hidden */
  83180. _data?: Promise<ArrayBufferView>;
  83181. /** @hidden */
  83182. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83183. }
  83184. /**
  83185. * Loader interface with additional members.
  83186. */
  83187. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83188. }
  83189. /** @hidden */
  83190. export interface _IAnimationSamplerData {
  83191. input: Float32Array;
  83192. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83193. output: Float32Array;
  83194. }
  83195. /**
  83196. * Loader interface with additional members.
  83197. */
  83198. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83199. /** @hidden */
  83200. _data?: Promise<_IAnimationSamplerData>;
  83201. }
  83202. /**
  83203. * Loader interface with additional members.
  83204. */
  83205. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83206. channels: IAnimationChannel[];
  83207. samplers: IAnimationSampler[];
  83208. /** @hidden */
  83209. _babylonAnimationGroup?: AnimationGroup;
  83210. }
  83211. /**
  83212. * Loader interface with additional members.
  83213. */
  83214. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83215. /** @hidden */
  83216. _data?: Promise<ArrayBufferView>;
  83217. }
  83218. /**
  83219. * Loader interface with additional members.
  83220. */
  83221. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83222. /** @hidden */
  83223. _data?: Promise<ArrayBufferView>;
  83224. /** @hidden */
  83225. _babylonBuffer?: Promise<Buffer>;
  83226. }
  83227. /**
  83228. * Loader interface with additional members.
  83229. */
  83230. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83231. }
  83232. /**
  83233. * Loader interface with additional members.
  83234. */
  83235. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83236. /** @hidden */
  83237. _data?: Promise<ArrayBufferView>;
  83238. }
  83239. /**
  83240. * Loader interface with additional members.
  83241. */
  83242. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83243. }
  83244. /**
  83245. * Loader interface with additional members.
  83246. */
  83247. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83248. }
  83249. /**
  83250. * Loader interface with additional members.
  83251. */
  83252. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83253. baseColorTexture?: ITextureInfo;
  83254. metallicRoughnessTexture?: ITextureInfo;
  83255. }
  83256. /**
  83257. * Loader interface with additional members.
  83258. */
  83259. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83260. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83261. normalTexture?: IMaterialNormalTextureInfo;
  83262. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83263. emissiveTexture?: ITextureInfo;
  83264. /** @hidden */
  83265. _data?: {
  83266. [babylonDrawMode: number]: {
  83267. babylonMaterial: Material;
  83268. babylonMeshes: AbstractMesh[];
  83269. promise: Promise<void>;
  83270. };
  83271. };
  83272. }
  83273. /**
  83274. * Loader interface with additional members.
  83275. */
  83276. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83277. primitives: IMeshPrimitive[];
  83278. }
  83279. /**
  83280. * Loader interface with additional members.
  83281. */
  83282. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83283. /** @hidden */
  83284. _instanceData?: {
  83285. babylonSourceMesh: Mesh;
  83286. promise: Promise<any>;
  83287. };
  83288. }
  83289. /**
  83290. * Loader interface with additional members.
  83291. */
  83292. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83293. /**
  83294. * The parent glTF node.
  83295. */
  83296. parent?: INode;
  83297. /** @hidden */
  83298. _babylonTransformNode?: TransformNode;
  83299. /** @hidden */
  83300. _primitiveBabylonMeshes?: AbstractMesh[];
  83301. /** @hidden */
  83302. _babylonBones?: Bone[];
  83303. /** @hidden */
  83304. _numMorphTargets?: number;
  83305. }
  83306. /** @hidden */
  83307. export interface _ISamplerData {
  83308. noMipMaps: boolean;
  83309. samplingMode: number;
  83310. wrapU: number;
  83311. wrapV: number;
  83312. }
  83313. /**
  83314. * Loader interface with additional members.
  83315. */
  83316. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83317. /** @hidden */
  83318. _data?: _ISamplerData;
  83319. }
  83320. /**
  83321. * Loader interface with additional members.
  83322. */
  83323. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83324. }
  83325. /**
  83326. * Loader interface with additional members.
  83327. */
  83328. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83329. /** @hidden */
  83330. _data?: {
  83331. babylonSkeleton: Skeleton;
  83332. promise: Promise<void>;
  83333. };
  83334. }
  83335. /**
  83336. * Loader interface with additional members.
  83337. */
  83338. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83339. /** @hidden */
  83340. _textureInfo: ITextureInfo;
  83341. }
  83342. /**
  83343. * Loader interface with additional members.
  83344. */
  83345. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83346. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83347. nonColorData?: boolean;
  83348. }
  83349. /**
  83350. * Loader interface with additional members.
  83351. */
  83352. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83353. accessors?: IAccessor[];
  83354. animations?: IAnimation[];
  83355. buffers?: IBuffer[];
  83356. bufferViews?: IBufferView[];
  83357. cameras?: ICamera[];
  83358. images?: IImage[];
  83359. materials?: IMaterial[];
  83360. meshes?: IMesh[];
  83361. nodes?: INode[];
  83362. samplers?: ISampler[];
  83363. scenes?: IScene[];
  83364. skins?: ISkin[];
  83365. textures?: ITexture[];
  83366. }
  83367. }
  83368. declare module BABYLON.GLTF2 {
  83369. /**
  83370. * Interface for a glTF loader extension.
  83371. */
  83372. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83373. /**
  83374. * Called after the loader state changes to LOADING.
  83375. */
  83376. onLoading?(): void;
  83377. /**
  83378. * Called after the loader state changes to READY.
  83379. */
  83380. onReady?(): void;
  83381. /**
  83382. * Define this method to modify the default behavior when loading scenes.
  83383. * @param context The context when loading the asset
  83384. * @param scene The glTF scene property
  83385. * @returns A promise that resolves when the load is complete or null if not handled
  83386. */
  83387. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83388. /**
  83389. * Define this method to modify the default behavior when loading nodes.
  83390. * @param context The context when loading the asset
  83391. * @param node The glTF node property
  83392. * @param assign A function called synchronously after parsing the glTF properties
  83393. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83394. */
  83395. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83396. /**
  83397. * Define this method to modify the default behavior when loading cameras.
  83398. * @param context The context when loading the asset
  83399. * @param camera The glTF camera property
  83400. * @param assign A function called synchronously after parsing the glTF properties
  83401. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83402. */
  83403. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83404. /**
  83405. * @hidden
  83406. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83407. * @param context The context when loading the asset
  83408. * @param primitive The glTF mesh primitive property
  83409. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83410. */
  83411. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83412. /**
  83413. * @hidden
  83414. * Define this method to modify the default behavior when loading data for mesh primitives.
  83415. * @param context The context when loading the asset
  83416. * @param name The mesh name when loading the asset
  83417. * @param node The glTF node when loading the asset
  83418. * @param mesh The glTF mesh when loading the asset
  83419. * @param primitive The glTF mesh primitive property
  83420. * @param assign A function called synchronously after parsing the glTF properties
  83421. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83422. */
  83423. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83424. /**
  83425. * @hidden
  83426. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83427. * @param context The context when loading the asset
  83428. * @param material The glTF material property
  83429. * @param assign A function called synchronously after parsing the glTF properties
  83430. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83431. */
  83432. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83433. /**
  83434. * Define this method to modify the default behavior when creating materials.
  83435. * @param context The context when loading the asset
  83436. * @param material The glTF material property
  83437. * @param babylonDrawMode The draw mode for the Babylon material
  83438. * @returns The Babylon material or null if not handled
  83439. */
  83440. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83441. /**
  83442. * Define this method to modify the default behavior when loading material properties.
  83443. * @param context The context when loading the asset
  83444. * @param material The glTF material property
  83445. * @param babylonMaterial The Babylon material
  83446. * @returns A promise that resolves when the load is complete or null if not handled
  83447. */
  83448. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83449. /**
  83450. * Define this method to modify the default behavior when loading texture infos.
  83451. * @param context The context when loading the asset
  83452. * @param textureInfo The glTF texture info property
  83453. * @param assign A function called synchronously after parsing the glTF properties
  83454. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83455. */
  83456. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83457. /**
  83458. * @hidden
  83459. * Define this method to modify the default behavior when loading textures.
  83460. * @param context The context when loading the asset
  83461. * @param texture The glTF texture property
  83462. * @param assign A function called synchronously after parsing the glTF properties
  83463. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83464. */
  83465. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83466. /**
  83467. * Define this method to modify the default behavior when loading animations.
  83468. * @param context The context when loading the asset
  83469. * @param animation The glTF animation property
  83470. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83471. */
  83472. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83473. /**
  83474. * @hidden
  83475. * Define this method to modify the default behavior when loading skins.
  83476. * @param context The context when loading the asset
  83477. * @param node The glTF node property
  83478. * @param skin The glTF skin property
  83479. * @returns A promise that resolves when the load is complete or null if not handled
  83480. */
  83481. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83482. /**
  83483. * @hidden
  83484. * Define this method to modify the default behavior when loading uris.
  83485. * @param context The context when loading the asset
  83486. * @param property The glTF property associated with the uri
  83487. * @param uri The uri to load
  83488. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83489. */
  83490. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83491. /**
  83492. * Define this method to modify the default behavior when loading buffer views.
  83493. * @param context The context when loading the asset
  83494. * @param bufferView The glTF buffer view property
  83495. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83496. */
  83497. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83498. /**
  83499. * Define this method to modify the default behavior when loading buffers.
  83500. * @param context The context when loading the asset
  83501. * @param buffer The glTF buffer property
  83502. * @param byteOffset The byte offset to load
  83503. * @param byteLength The byte length to load
  83504. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83505. */
  83506. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83507. }
  83508. }
  83509. declare module BABYLON.GLTF2 {
  83510. /**
  83511. * Helper class for working with arrays when loading the glTF asset
  83512. */
  83513. export class ArrayItem {
  83514. /**
  83515. * Gets an item from the given array.
  83516. * @param context The context when loading the asset
  83517. * @param array The array to get the item from
  83518. * @param index The index to the array
  83519. * @returns The array item
  83520. */
  83521. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83522. /**
  83523. * Assign an `index` field to each item of the given array.
  83524. * @param array The array of items
  83525. */
  83526. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83527. }
  83528. /**
  83529. * The glTF 2.0 loader
  83530. */
  83531. export class GLTFLoader implements IGLTFLoader {
  83532. /** @hidden */
  83533. _completePromises: Promise<any>[];
  83534. /** @hidden */
  83535. _forAssetContainer: boolean;
  83536. /** Storage */
  83537. _babylonLights: Light[];
  83538. /** @hidden */
  83539. _disableInstancedMesh: number;
  83540. private _disposed;
  83541. private _parent;
  83542. private _state;
  83543. private _extensions;
  83544. private _rootUrl;
  83545. private _fileName;
  83546. private _uniqueRootUrl;
  83547. private _gltf;
  83548. private _bin;
  83549. private _babylonScene;
  83550. private _rootBabylonMesh;
  83551. private _defaultBabylonMaterialData;
  83552. private static _RegisteredExtensions;
  83553. /**
  83554. * The default glTF sampler.
  83555. */
  83556. static readonly DefaultSampler: ISampler;
  83557. /**
  83558. * Registers a loader extension.
  83559. * @param name The name of the loader extension.
  83560. * @param factory The factory function that creates the loader extension.
  83561. */
  83562. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83563. /**
  83564. * Unregisters a loader extension.
  83565. * @param name The name of the loader extension.
  83566. * @returns A boolean indicating whether the extension has been unregistered
  83567. */
  83568. static UnregisterExtension(name: string): boolean;
  83569. /**
  83570. * The loader state.
  83571. */
  83572. get state(): Nullable<GLTFLoaderState>;
  83573. /**
  83574. * The object that represents the glTF JSON.
  83575. */
  83576. get gltf(): IGLTF;
  83577. /**
  83578. * The BIN chunk of a binary glTF.
  83579. */
  83580. get bin(): Nullable<IDataBuffer>;
  83581. /**
  83582. * The parent file loader.
  83583. */
  83584. get parent(): GLTFFileLoader;
  83585. /**
  83586. * The Babylon scene when loading the asset.
  83587. */
  83588. get babylonScene(): Scene;
  83589. /**
  83590. * The root Babylon mesh when loading the asset.
  83591. */
  83592. get rootBabylonMesh(): Mesh;
  83593. /** @hidden */
  83594. constructor(parent: GLTFFileLoader);
  83595. /** @hidden */
  83596. dispose(): void;
  83597. /** @hidden */
  83598. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83599. /** @hidden */
  83600. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83601. private _loadAsync;
  83602. private _loadData;
  83603. private _setupData;
  83604. private _loadExtensions;
  83605. private _checkExtensions;
  83606. private _setState;
  83607. private _createRootNode;
  83608. /**
  83609. * Loads a glTF scene.
  83610. * @param context The context when loading the asset
  83611. * @param scene The glTF scene property
  83612. * @returns A promise that resolves when the load is complete
  83613. */
  83614. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83615. private _forEachPrimitive;
  83616. private _getGeometries;
  83617. private _getMeshes;
  83618. private _getTransformNodes;
  83619. private _getSkeletons;
  83620. private _getAnimationGroups;
  83621. private _startAnimations;
  83622. /**
  83623. * Loads a glTF node.
  83624. * @param context The context when loading the asset
  83625. * @param node The glTF node property
  83626. * @param assign A function called synchronously after parsing the glTF properties
  83627. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83628. */
  83629. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83630. private _loadMeshAsync;
  83631. /**
  83632. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83633. * @param context The context when loading the asset
  83634. * @param name The mesh name when loading the asset
  83635. * @param node The glTF node when loading the asset
  83636. * @param mesh The glTF mesh when loading the asset
  83637. * @param primitive The glTF mesh primitive property
  83638. * @param assign A function called synchronously after parsing the glTF properties
  83639. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83640. */
  83641. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83642. private _loadVertexDataAsync;
  83643. private _createMorphTargets;
  83644. private _loadMorphTargetsAsync;
  83645. private _loadMorphTargetVertexDataAsync;
  83646. private static _LoadTransform;
  83647. private _loadSkinAsync;
  83648. private _loadBones;
  83649. private _loadBone;
  83650. private _loadSkinInverseBindMatricesDataAsync;
  83651. private _updateBoneMatrices;
  83652. private _getNodeMatrix;
  83653. /**
  83654. * Loads a glTF camera.
  83655. * @param context The context when loading the asset
  83656. * @param camera The glTF camera property
  83657. * @param assign A function called synchronously after parsing the glTF properties
  83658. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83659. */
  83660. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83661. private _loadAnimationsAsync;
  83662. /**
  83663. * Loads a glTF animation.
  83664. * @param context The context when loading the asset
  83665. * @param animation The glTF animation property
  83666. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83667. */
  83668. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83669. /**
  83670. * @hidden Loads a glTF animation channel.
  83671. * @param context The context when loading the asset
  83672. * @param animationContext The context of the animation when loading the asset
  83673. * @param animation The glTF animation property
  83674. * @param channel The glTF animation channel property
  83675. * @param babylonAnimationGroup The babylon animation group property
  83676. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83677. * @returns A void promise when the channel load is complete
  83678. */
  83679. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83680. private _loadAnimationSamplerAsync;
  83681. private _loadBufferAsync;
  83682. /**
  83683. * Loads a glTF buffer view.
  83684. * @param context The context when loading the asset
  83685. * @param bufferView The glTF buffer view property
  83686. * @returns A promise that resolves with the loaded data when the load is complete
  83687. */
  83688. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83689. private _loadAccessorAsync;
  83690. /** @hidden */
  83691. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83692. private _loadIndicesAccessorAsync;
  83693. private _loadVertexBufferViewAsync;
  83694. private _loadVertexAccessorAsync;
  83695. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83696. /** @hidden */
  83697. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83698. private _createDefaultMaterial;
  83699. /**
  83700. * Creates a Babylon material from a glTF material.
  83701. * @param context The context when loading the asset
  83702. * @param material The glTF material property
  83703. * @param babylonDrawMode The draw mode for the Babylon material
  83704. * @returns The Babylon material
  83705. */
  83706. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83707. /**
  83708. * Loads properties from a glTF material into a Babylon material.
  83709. * @param context The context when loading the asset
  83710. * @param material The glTF material property
  83711. * @param babylonMaterial The Babylon material
  83712. * @returns A promise that resolves when the load is complete
  83713. */
  83714. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83715. /**
  83716. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83717. * @param context The context when loading the asset
  83718. * @param material The glTF material property
  83719. * @param babylonMaterial The Babylon material
  83720. * @returns A promise that resolves when the load is complete
  83721. */
  83722. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83723. /**
  83724. * Loads the alpha properties from a glTF material into a Babylon material.
  83725. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83726. * @param context The context when loading the asset
  83727. * @param material The glTF material property
  83728. * @param babylonMaterial The Babylon material
  83729. */
  83730. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83731. /**
  83732. * Loads a glTF texture info.
  83733. * @param context The context when loading the asset
  83734. * @param textureInfo The glTF texture info property
  83735. * @param assign A function called synchronously after parsing the glTF properties
  83736. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83737. */
  83738. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83739. /** @hidden */
  83740. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83741. /** @hidden */
  83742. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83743. private _loadSampler;
  83744. /**
  83745. * Loads a glTF image.
  83746. * @param context The context when loading the asset
  83747. * @param image The glTF image property
  83748. * @returns A promise that resolves with the loaded data when the load is complete
  83749. */
  83750. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83751. /**
  83752. * Loads a glTF uri.
  83753. * @param context The context when loading the asset
  83754. * @param property The glTF property associated with the uri
  83755. * @param uri The base64 or relative uri
  83756. * @returns A promise that resolves with the loaded data when the load is complete
  83757. */
  83758. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83759. /**
  83760. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83761. * @param babylonObject the Babylon object with metadata
  83762. * @param pointer the JSON pointer
  83763. */
  83764. static AddPointerMetadata(babylonObject: {
  83765. metadata: any;
  83766. }, pointer: string): void;
  83767. private static _GetTextureWrapMode;
  83768. private static _GetTextureSamplingMode;
  83769. private static _GetTypedArrayConstructor;
  83770. private static _GetTypedArray;
  83771. private static _GetNumComponents;
  83772. private static _ValidateUri;
  83773. /** @hidden */
  83774. static _GetDrawMode(context: string, mode: number | undefined): number;
  83775. private _compileMaterialsAsync;
  83776. private _compileShadowGeneratorsAsync;
  83777. private _forEachExtensions;
  83778. private _applyExtensions;
  83779. private _extensionsOnLoading;
  83780. private _extensionsOnReady;
  83781. private _extensionsLoadSceneAsync;
  83782. private _extensionsLoadNodeAsync;
  83783. private _extensionsLoadCameraAsync;
  83784. private _extensionsLoadVertexDataAsync;
  83785. private _extensionsLoadMeshPrimitiveAsync;
  83786. private _extensionsLoadMaterialAsync;
  83787. private _extensionsCreateMaterial;
  83788. private _extensionsLoadMaterialPropertiesAsync;
  83789. private _extensionsLoadTextureInfoAsync;
  83790. private _extensionsLoadTextureAsync;
  83791. private _extensionsLoadAnimationAsync;
  83792. private _extensionsLoadSkinAsync;
  83793. private _extensionsLoadUriAsync;
  83794. private _extensionsLoadBufferViewAsync;
  83795. private _extensionsLoadBufferAsync;
  83796. /**
  83797. * Helper method called by a loader extension to load an glTF extension.
  83798. * @param context The context when loading the asset
  83799. * @param property The glTF property to load the extension from
  83800. * @param extensionName The name of the extension to load
  83801. * @param actionAsync The action to run
  83802. * @returns The promise returned by actionAsync or null if the extension does not exist
  83803. */
  83804. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83805. /**
  83806. * Helper method called by a loader extension to load a glTF extra.
  83807. * @param context The context when loading the asset
  83808. * @param property The glTF property to load the extra from
  83809. * @param extensionName The name of the extension to load
  83810. * @param actionAsync The action to run
  83811. * @returns The promise returned by actionAsync or null if the extra does not exist
  83812. */
  83813. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83814. /**
  83815. * Checks for presence of an extension.
  83816. * @param name The name of the extension to check
  83817. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83818. */
  83819. isExtensionUsed(name: string): boolean;
  83820. /**
  83821. * Increments the indentation level and logs a message.
  83822. * @param message The message to log
  83823. */
  83824. logOpen(message: string): void;
  83825. /**
  83826. * Decrements the indentation level.
  83827. */
  83828. logClose(): void;
  83829. /**
  83830. * Logs a message
  83831. * @param message The message to log
  83832. */
  83833. log(message: string): void;
  83834. /**
  83835. * Starts a performance counter.
  83836. * @param counterName The name of the performance counter
  83837. */
  83838. startPerformanceCounter(counterName: string): void;
  83839. /**
  83840. * Ends a performance counter.
  83841. * @param counterName The name of the performance counter
  83842. */
  83843. endPerformanceCounter(counterName: string): void;
  83844. }
  83845. }
  83846. declare module BABYLON.GLTF2.Loader.Extensions {
  83847. /** @hidden */
  83848. interface IEXTLightsImageBased_LightImageBased {
  83849. _babylonTexture?: BaseTexture;
  83850. _loaded?: Promise<void>;
  83851. }
  83852. /**
  83853. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83854. */
  83855. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83856. /**
  83857. * The name of this extension.
  83858. */
  83859. readonly name: string;
  83860. /**
  83861. * Defines whether this extension is enabled.
  83862. */
  83863. enabled: boolean;
  83864. private _loader;
  83865. private _lights?;
  83866. /** @hidden */
  83867. constructor(loader: GLTFLoader);
  83868. /** @hidden */
  83869. dispose(): void;
  83870. /** @hidden */
  83871. onLoading(): void;
  83872. /** @hidden */
  83873. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83874. private _loadLightAsync;
  83875. }
  83876. }
  83877. declare module BABYLON.GLTF2.Loader.Extensions {
  83878. /**
  83879. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83880. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83881. * !!! Experimental Extension Subject to Changes !!!
  83882. */
  83883. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83884. /**
  83885. * The name of this extension.
  83886. */
  83887. readonly name: string;
  83888. /**
  83889. * Defines whether this extension is enabled.
  83890. */
  83891. enabled: boolean;
  83892. private _loader;
  83893. /** @hidden */
  83894. constructor(loader: GLTFLoader);
  83895. /** @hidden */
  83896. dispose(): void;
  83897. /** @hidden */
  83898. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83899. }
  83900. }
  83901. declare module BABYLON.GLTF2.Loader.Extensions {
  83902. /**
  83903. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83904. */
  83905. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83906. /** The name of this extension. */
  83907. readonly name: string;
  83908. /** Defines whether this extension is enabled. */
  83909. enabled: boolean;
  83910. private _loader;
  83911. /** @hidden */
  83912. constructor(loader: GLTFLoader);
  83913. /** @hidden */
  83914. dispose(): void;
  83915. /** @hidden */
  83916. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83917. }
  83918. }
  83919. declare module BABYLON.GLTF2.Loader.Extensions {
  83920. /**
  83921. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83922. */
  83923. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83924. /**
  83925. * The name of this extension.
  83926. */
  83927. readonly name: string;
  83928. /**
  83929. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83930. */
  83931. dracoCompression?: DracoCompression;
  83932. /**
  83933. * Defines whether this extension is enabled.
  83934. */
  83935. enabled: boolean;
  83936. private _loader;
  83937. /** @hidden */
  83938. constructor(loader: GLTFLoader);
  83939. /** @hidden */
  83940. dispose(): void;
  83941. /** @hidden */
  83942. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83943. }
  83944. }
  83945. declare module BABYLON.GLTF2.Loader.Extensions {
  83946. /**
  83947. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83948. */
  83949. export class KHR_lights implements IGLTFLoaderExtension {
  83950. /**
  83951. * The name of this extension.
  83952. */
  83953. readonly name: string;
  83954. /**
  83955. * Defines whether this extension is enabled.
  83956. */
  83957. enabled: boolean;
  83958. private _loader;
  83959. private _lights?;
  83960. /** @hidden */
  83961. constructor(loader: GLTFLoader);
  83962. /** @hidden */
  83963. dispose(): void;
  83964. /** @hidden */
  83965. onLoading(): void;
  83966. /** @hidden */
  83967. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83968. }
  83969. }
  83970. declare module BABYLON.GLTF2.Loader.Extensions {
  83971. /**
  83972. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83973. */
  83974. export class KHR_materials_pbrSpecularGlossiness 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 _loadSpecularGlossinessPropertiesAsync;
  83995. }
  83996. }
  83997. declare module BABYLON.GLTF2.Loader.Extensions {
  83998. /**
  83999. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  84000. */
  84001. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  84002. /**
  84003. * The name of this extension.
  84004. */
  84005. readonly name: string;
  84006. /**
  84007. * Defines whether this extension is enabled.
  84008. */
  84009. enabled: boolean;
  84010. /**
  84011. * Defines a number that determines the order the extensions are applied.
  84012. */
  84013. order: number;
  84014. private _loader;
  84015. /** @hidden */
  84016. constructor(loader: GLTFLoader);
  84017. /** @hidden */
  84018. dispose(): void;
  84019. /** @hidden */
  84020. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84021. private _loadUnlitPropertiesAsync;
  84022. }
  84023. }
  84024. declare module BABYLON.GLTF2.Loader.Extensions {
  84025. /**
  84026. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  84027. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  84028. */
  84029. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  84030. /**
  84031. * The name of this extension.
  84032. */
  84033. readonly name: string;
  84034. /**
  84035. * Defines whether this extension is enabled.
  84036. */
  84037. enabled: boolean;
  84038. /**
  84039. * Defines a number that determines the order the extensions are applied.
  84040. */
  84041. order: number;
  84042. private _loader;
  84043. /** @hidden */
  84044. constructor(loader: GLTFLoader);
  84045. /** @hidden */
  84046. dispose(): void;
  84047. /** @hidden */
  84048. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84049. private _loadClearCoatPropertiesAsync;
  84050. }
  84051. }
  84052. declare module BABYLON.GLTF2.Loader.Extensions {
  84053. /**
  84054. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  84055. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  84056. * !!! Experimental Extension Subject to Changes !!!
  84057. */
  84058. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  84059. /**
  84060. * The name of this extension.
  84061. */
  84062. readonly name: string;
  84063. /**
  84064. * Defines whether this extension is enabled.
  84065. */
  84066. enabled: boolean;
  84067. /**
  84068. * Defines a number that determines the order the extensions are applied.
  84069. */
  84070. order: number;
  84071. private _loader;
  84072. /** @hidden */
  84073. constructor(loader: GLTFLoader);
  84074. /** @hidden */
  84075. dispose(): void;
  84076. /** @hidden */
  84077. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84078. private _loadSheenPropertiesAsync;
  84079. }
  84080. }
  84081. declare module BABYLON.GLTF2.Loader.Extensions {
  84082. /**
  84083. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  84084. * !!! Experimental Extension Subject to Changes !!!
  84085. */
  84086. export class KHR_materials_specular implements IGLTFLoaderExtension {
  84087. /**
  84088. * The name of this extension.
  84089. */
  84090. readonly name: string;
  84091. /**
  84092. * Defines whether this extension is enabled.
  84093. */
  84094. enabled: boolean;
  84095. /**
  84096. * Defines a number that determines the order the extensions are applied.
  84097. */
  84098. order: number;
  84099. private _loader;
  84100. /** @hidden */
  84101. constructor(loader: GLTFLoader);
  84102. /** @hidden */
  84103. dispose(): void;
  84104. /** @hidden */
  84105. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84106. private _loadSpecularPropertiesAsync;
  84107. }
  84108. }
  84109. declare module BABYLON.GLTF2.Loader.Extensions {
  84110. /**
  84111. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  84112. * !!! Experimental Extension Subject to Changes !!!
  84113. */
  84114. export class KHR_materials_ior implements IGLTFLoaderExtension {
  84115. /**
  84116. * Default ior Value from the spec.
  84117. */
  84118. private static readonly _DEFAULT_IOR;
  84119. /**
  84120. * The name of this extension.
  84121. */
  84122. readonly name: string;
  84123. /**
  84124. * Defines whether this extension is enabled.
  84125. */
  84126. enabled: boolean;
  84127. /**
  84128. * Defines a number that determines the order the extensions are applied.
  84129. */
  84130. order: number;
  84131. private _loader;
  84132. /** @hidden */
  84133. constructor(loader: GLTFLoader);
  84134. /** @hidden */
  84135. dispose(): void;
  84136. /** @hidden */
  84137. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84138. private _loadIorPropertiesAsync;
  84139. }
  84140. }
  84141. declare module BABYLON.GLTF2.Loader.Extensions {
  84142. /**
  84143. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  84144. * !!! Experimental Extension Subject to Changes !!!
  84145. */
  84146. export class KHR_materials_variants implements IGLTFLoaderExtension {
  84147. /**
  84148. * The name of this extension.
  84149. */
  84150. readonly name: string;
  84151. /**
  84152. * Defines whether this extension is enabled.
  84153. */
  84154. enabled: boolean;
  84155. private _loader;
  84156. private _variants?;
  84157. /** @hidden */
  84158. constructor(loader: GLTFLoader);
  84159. /** @hidden */
  84160. dispose(): void;
  84161. /**
  84162. * Gets the list of available variant names for this asset.
  84163. * @param rootMesh The glTF root mesh
  84164. * @returns the list of all the variant names for this model
  84165. */
  84166. static GetAvailableVariants(rootMesh: Mesh): string[];
  84167. /**
  84168. * Gets the list of available variant names for this asset.
  84169. * @param rootMesh The glTF root mesh
  84170. * @returns the list of all the variant names for this model
  84171. */
  84172. getAvailableVariants(rootMesh: Mesh): string[];
  84173. /**
  84174. * Select a variant given a variant name or a list of variant names.
  84175. * @param rootMesh The glTF root mesh
  84176. * @param variantName The variant name(s) to select.
  84177. */
  84178. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84179. /**
  84180. * Select a variant given a variant name or a list of variant names.
  84181. * @param rootMesh The glTF root mesh
  84182. * @param variantName The variant name(s) to select.
  84183. */
  84184. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84185. /**
  84186. * Reset back to the original before selecting a variant.
  84187. * @param rootMesh The glTF root mesh
  84188. */
  84189. static Reset(rootMesh: Mesh): void;
  84190. /**
  84191. * Reset back to the original before selecting a variant.
  84192. * @param rootMesh The glTF root mesh
  84193. */
  84194. reset(rootMesh: Mesh): void;
  84195. /**
  84196. * Gets the last selected variant name(s) or null if original.
  84197. * @param rootMesh The glTF root mesh
  84198. * @returns The selected variant name(s).
  84199. */
  84200. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84201. /**
  84202. * Gets the last selected variant name(s) or null if original.
  84203. * @param rootMesh The glTF root mesh
  84204. * @returns The selected variant name(s).
  84205. */
  84206. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84207. private static _GetExtensionMetadata;
  84208. /** @hidden */
  84209. onLoading(): void;
  84210. /** @hidden */
  84211. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84212. }
  84213. }
  84214. declare module BABYLON.GLTF2.Loader.Extensions {
  84215. /**
  84216. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84217. * !!! Experimental Extension Subject to Changes !!!
  84218. */
  84219. export class KHR_materials_transmission 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. /**
  84229. * Defines a number that determines the order the extensions are applied.
  84230. */
  84231. order: number;
  84232. private _loader;
  84233. /** @hidden */
  84234. constructor(loader: GLTFLoader);
  84235. /** @hidden */
  84236. dispose(): void;
  84237. /** @hidden */
  84238. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84239. private _loadTransparentPropertiesAsync;
  84240. }
  84241. }
  84242. declare module BABYLON.GLTF2.Loader.Extensions {
  84243. /**
  84244. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84245. * !!! Experimental Extension Subject to Changes !!!
  84246. */
  84247. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84248. /**
  84249. * The name of this extension.
  84250. */
  84251. readonly name: string;
  84252. /**
  84253. * Defines whether this extension is enabled.
  84254. */
  84255. enabled: boolean;
  84256. /**
  84257. * Defines a number that determines the order the extensions are applied.
  84258. */
  84259. order: number;
  84260. private _loader;
  84261. /** @hidden */
  84262. constructor(loader: GLTFLoader);
  84263. /** @hidden */
  84264. dispose(): void;
  84265. /** @hidden */
  84266. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84267. private _loadTranslucentPropertiesAsync;
  84268. }
  84269. }
  84270. declare module BABYLON.GLTF2.Loader.Extensions {
  84271. /**
  84272. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84273. */
  84274. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84275. /**
  84276. * The name of this extension.
  84277. */
  84278. readonly name: string;
  84279. /**
  84280. * Defines whether this extension is enabled.
  84281. */
  84282. enabled: boolean;
  84283. /** @hidden */
  84284. constructor(loader: GLTFLoader);
  84285. /** @hidden */
  84286. dispose(): void;
  84287. }
  84288. }
  84289. declare module BABYLON.GLTF2.Loader.Extensions {
  84290. /**
  84291. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84292. * !!! Experimental Extension Subject to Changes !!!
  84293. */
  84294. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84295. /** The name of this extension. */
  84296. readonly name: string;
  84297. /** Defines whether this extension is enabled. */
  84298. enabled: boolean;
  84299. private _loader;
  84300. /** @hidden */
  84301. constructor(loader: GLTFLoader);
  84302. /** @hidden */
  84303. dispose(): void;
  84304. /** @hidden */
  84305. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84306. }
  84307. }
  84308. declare module BABYLON.GLTF2.Loader.Extensions {
  84309. /**
  84310. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84311. */
  84312. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84313. /**
  84314. * The name of this extension.
  84315. */
  84316. readonly name: string;
  84317. /**
  84318. * Defines whether this extension is enabled.
  84319. */
  84320. enabled: boolean;
  84321. private _loader;
  84322. /** @hidden */
  84323. constructor(loader: GLTFLoader);
  84324. /** @hidden */
  84325. dispose(): void;
  84326. /** @hidden */
  84327. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84328. }
  84329. }
  84330. declare module BABYLON.GLTF2.Loader.Extensions {
  84331. /**
  84332. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84333. */
  84334. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84335. /**
  84336. * The name of this extension.
  84337. */
  84338. readonly name: string;
  84339. /**
  84340. * Defines whether this extension is enabled.
  84341. */
  84342. enabled: boolean;
  84343. private _loader;
  84344. private _clips;
  84345. private _emitters;
  84346. /** @hidden */
  84347. constructor(loader: GLTFLoader);
  84348. /** @hidden */
  84349. dispose(): void;
  84350. /** @hidden */
  84351. onLoading(): void;
  84352. /** @hidden */
  84353. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84354. /** @hidden */
  84355. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84356. /** @hidden */
  84357. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84358. private _loadClipAsync;
  84359. private _loadEmitterAsync;
  84360. private _getEventAction;
  84361. private _loadAnimationEventAsync;
  84362. }
  84363. }
  84364. declare module BABYLON.GLTF2.Loader.Extensions {
  84365. /**
  84366. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84367. */
  84368. export class MSFT_lod implements IGLTFLoaderExtension {
  84369. /**
  84370. * The name of this extension.
  84371. */
  84372. readonly name: string;
  84373. /**
  84374. * Defines whether this extension is enabled.
  84375. */
  84376. enabled: boolean;
  84377. /**
  84378. * Defines a number that determines the order the extensions are applied.
  84379. */
  84380. order: number;
  84381. /**
  84382. * Maximum number of LODs to load, starting from the lowest LOD.
  84383. */
  84384. maxLODsToLoad: number;
  84385. /**
  84386. * Observable raised when all node LODs of one level are loaded.
  84387. * The event data is the index of the loaded LOD starting from zero.
  84388. * Dispose the loader to cancel the loading of the next level of LODs.
  84389. */
  84390. onNodeLODsLoadedObservable: Observable<number>;
  84391. /**
  84392. * Observable raised when all material LODs of one level are loaded.
  84393. * The event data is the index of the loaded LOD starting from zero.
  84394. * Dispose the loader to cancel the loading of the next level of LODs.
  84395. */
  84396. onMaterialLODsLoadedObservable: Observable<number>;
  84397. private _loader;
  84398. private _bufferLODs;
  84399. private _nodeIndexLOD;
  84400. private _nodeSignalLODs;
  84401. private _nodePromiseLODs;
  84402. private _nodeBufferLODs;
  84403. private _materialIndexLOD;
  84404. private _materialSignalLODs;
  84405. private _materialPromiseLODs;
  84406. private _materialBufferLODs;
  84407. /** @hidden */
  84408. constructor(loader: GLTFLoader);
  84409. /** @hidden */
  84410. dispose(): void;
  84411. /** @hidden */
  84412. onReady(): void;
  84413. /** @hidden */
  84414. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84415. /** @hidden */
  84416. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84417. /** @hidden */
  84418. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84419. /** @hidden */
  84420. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84421. /** @hidden */
  84422. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84423. private _loadBufferLOD;
  84424. /**
  84425. * Gets an array of LOD properties from lowest to highest.
  84426. */
  84427. private _getLODs;
  84428. private _disposeTransformNode;
  84429. private _disposeMaterials;
  84430. }
  84431. }
  84432. declare module BABYLON.GLTF2.Loader.Extensions {
  84433. /** @hidden */
  84434. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84435. readonly name: string;
  84436. enabled: boolean;
  84437. private _loader;
  84438. constructor(loader: GLTFLoader);
  84439. dispose(): void;
  84440. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84441. }
  84442. }
  84443. declare module BABYLON.GLTF2.Loader.Extensions {
  84444. /** @hidden */
  84445. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84446. readonly name: string;
  84447. enabled: boolean;
  84448. private _loader;
  84449. constructor(loader: GLTFLoader);
  84450. dispose(): void;
  84451. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84452. }
  84453. }
  84454. declare module BABYLON.GLTF2.Loader.Extensions {
  84455. /**
  84456. * Store glTF extras (if present) in BJS objects' metadata
  84457. */
  84458. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84459. /**
  84460. * The name of this extension.
  84461. */
  84462. readonly name: string;
  84463. /**
  84464. * Defines whether this extension is enabled.
  84465. */
  84466. enabled: boolean;
  84467. private _loader;
  84468. private _assignExtras;
  84469. /** @hidden */
  84470. constructor(loader: GLTFLoader);
  84471. /** @hidden */
  84472. dispose(): void;
  84473. /** @hidden */
  84474. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84475. /** @hidden */
  84476. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84477. /** @hidden */
  84478. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84479. }
  84480. }
  84481. declare module BABYLON {
  84482. /**
  84483. * Class reading and parsing the MTL file bundled with the obj file.
  84484. */
  84485. export class MTLFileLoader {
  84486. /**
  84487. * Invert Y-Axis of referenced textures on load
  84488. */
  84489. static INVERT_TEXTURE_Y: boolean;
  84490. /**
  84491. * All material loaded from the mtl will be set here
  84492. */
  84493. materials: StandardMaterial[];
  84494. /**
  84495. * This function will read the mtl file and create each material described inside
  84496. * This function could be improve by adding :
  84497. * -some component missing (Ni, Tf...)
  84498. * -including the specific options available
  84499. *
  84500. * @param scene defines the scene the material will be created in
  84501. * @param data defines the mtl data to parse
  84502. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84503. * @param forAssetContainer defines if the material should be registered in the scene
  84504. */
  84505. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84506. /**
  84507. * Gets the texture for the material.
  84508. *
  84509. * If the material is imported from input file,
  84510. * We sanitize the url to ensure it takes the textre from aside the material.
  84511. *
  84512. * @param rootUrl The root url to load from
  84513. * @param value The value stored in the mtl
  84514. * @return The Texture
  84515. */
  84516. private static _getTexture;
  84517. }
  84518. }
  84519. declare module BABYLON {
  84520. /**
  84521. * Options for loading OBJ/MTL files
  84522. */
  84523. type MeshLoadOptions = {
  84524. /**
  84525. * Defines if UVs are optimized by default during load.
  84526. */
  84527. OptimizeWithUV: boolean;
  84528. /**
  84529. * Defines custom scaling of UV coordinates of loaded meshes.
  84530. */
  84531. UVScaling: Vector2;
  84532. /**
  84533. * Invert model on y-axis (does a model scaling inversion)
  84534. */
  84535. InvertY: boolean;
  84536. /**
  84537. * Invert Y-Axis of referenced textures on load
  84538. */
  84539. InvertTextureY: boolean;
  84540. /**
  84541. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84542. */
  84543. ImportVertexColors: boolean;
  84544. /**
  84545. * Compute the normals for the model, even if normals are present in the file.
  84546. */
  84547. ComputeNormals: boolean;
  84548. /**
  84549. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84550. */
  84551. SkipMaterials: boolean;
  84552. /**
  84553. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84554. */
  84555. MaterialLoadingFailsSilently: boolean;
  84556. };
  84557. /**
  84558. * OBJ file type loader.
  84559. * This is a babylon scene loader plugin.
  84560. */
  84561. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84562. /**
  84563. * Defines if UVs are optimized by default during load.
  84564. */
  84565. static OPTIMIZE_WITH_UV: boolean;
  84566. /**
  84567. * Invert model on y-axis (does a model scaling inversion)
  84568. */
  84569. static INVERT_Y: boolean;
  84570. /**
  84571. * Invert Y-Axis of referenced textures on load
  84572. */
  84573. static get INVERT_TEXTURE_Y(): boolean;
  84574. static set INVERT_TEXTURE_Y(value: boolean);
  84575. /**
  84576. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84577. */
  84578. static IMPORT_VERTEX_COLORS: boolean;
  84579. /**
  84580. * Compute the normals for the model, even if normals are present in the file.
  84581. */
  84582. static COMPUTE_NORMALS: boolean;
  84583. /**
  84584. * Defines custom scaling of UV coordinates of loaded meshes.
  84585. */
  84586. static UV_SCALING: Vector2;
  84587. /**
  84588. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84589. */
  84590. static SKIP_MATERIALS: boolean;
  84591. /**
  84592. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84593. *
  84594. * Defaults to true for backwards compatibility.
  84595. */
  84596. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84597. /**
  84598. * Defines the name of the plugin.
  84599. */
  84600. name: string;
  84601. /**
  84602. * Defines the extension the plugin is able to load.
  84603. */
  84604. extensions: string;
  84605. /** @hidden */
  84606. obj: RegExp;
  84607. /** @hidden */
  84608. group: RegExp;
  84609. /** @hidden */
  84610. mtllib: RegExp;
  84611. /** @hidden */
  84612. usemtl: RegExp;
  84613. /** @hidden */
  84614. smooth: RegExp;
  84615. /** @hidden */
  84616. vertexPattern: RegExp;
  84617. /** @hidden */
  84618. normalPattern: RegExp;
  84619. /** @hidden */
  84620. uvPattern: RegExp;
  84621. /** @hidden */
  84622. facePattern1: RegExp;
  84623. /** @hidden */
  84624. facePattern2: RegExp;
  84625. /** @hidden */
  84626. facePattern3: RegExp;
  84627. /** @hidden */
  84628. facePattern4: RegExp;
  84629. /** @hidden */
  84630. facePattern5: RegExp;
  84631. private _forAssetContainer;
  84632. private _meshLoadOptions;
  84633. /**
  84634. * Creates loader for .OBJ files
  84635. *
  84636. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84637. */
  84638. constructor(meshLoadOptions?: MeshLoadOptions);
  84639. private static get currentMeshLoadOptions();
  84640. /**
  84641. * Calls synchronously the MTL file attached to this obj.
  84642. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84643. * Without this function materials are not displayed in the first frame (but displayed after).
  84644. * In consequence it is impossible to get material information in your HTML file
  84645. *
  84646. * @param url The URL of the MTL file
  84647. * @param rootUrl
  84648. * @param onSuccess Callback function to be called when the MTL file is loaded
  84649. * @private
  84650. */
  84651. private _loadMTL;
  84652. /**
  84653. * Instantiates a OBJ file loader plugin.
  84654. * @returns the created plugin
  84655. */
  84656. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84657. /**
  84658. * If the data string can be loaded directly.
  84659. *
  84660. * @param data string containing the file data
  84661. * @returns if the data can be loaded directly
  84662. */
  84663. canDirectLoad(data: string): boolean;
  84664. /**
  84665. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84666. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84667. * @param scene the scene the meshes should be added to
  84668. * @param data the OBJ data to load
  84669. * @param rootUrl root url to load from
  84670. * @param onProgress event that fires when loading progress has occured
  84671. * @param fileName Defines the name of the file to load
  84672. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84673. */
  84674. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84675. /**
  84676. * Imports all objects from the loaded OBJ data and adds them to the scene
  84677. * @param scene the scene the objects should be added to
  84678. * @param data the OBJ data to load
  84679. * @param rootUrl root url to load from
  84680. * @param onProgress event that fires when loading progress has occured
  84681. * @param fileName Defines the name of the file to load
  84682. * @returns a promise which completes when objects have been loaded to the scene
  84683. */
  84684. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84685. /**
  84686. * Load into an asset container.
  84687. * @param scene The scene to load into
  84688. * @param data The data to import
  84689. * @param rootUrl The root url for scene and resources
  84690. * @param onProgress The callback when the load progresses
  84691. * @param fileName Defines the name of the file to load
  84692. * @returns The loaded asset container
  84693. */
  84694. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84695. /**
  84696. * Read the OBJ file and create an Array of meshes.
  84697. * Each mesh contains all information given by the OBJ and the MTL file.
  84698. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84699. *
  84700. * @param meshesNames
  84701. * @param scene Scene The scene where are displayed the data
  84702. * @param data String The content of the obj file
  84703. * @param rootUrl String The path to the folder
  84704. * @returns Array<AbstractMesh>
  84705. * @private
  84706. */
  84707. private _parseSolid;
  84708. }
  84709. }
  84710. declare module BABYLON {
  84711. /**
  84712. * STL file type loader.
  84713. * This is a babylon scene loader plugin.
  84714. */
  84715. export class STLFileLoader implements ISceneLoaderPlugin {
  84716. /** @hidden */
  84717. solidPattern: RegExp;
  84718. /** @hidden */
  84719. facetsPattern: RegExp;
  84720. /** @hidden */
  84721. normalPattern: RegExp;
  84722. /** @hidden */
  84723. vertexPattern: RegExp;
  84724. /**
  84725. * Defines the name of the plugin.
  84726. */
  84727. name: string;
  84728. /**
  84729. * Defines the extensions the stl loader is able to load.
  84730. * force data to come in as an ArrayBuffer
  84731. * we'll convert to string if it looks like it's an ASCII .stl
  84732. */
  84733. extensions: ISceneLoaderPluginExtensions;
  84734. /**
  84735. * Import meshes into a scene.
  84736. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84737. * @param scene The scene to import into
  84738. * @param data The data to import
  84739. * @param rootUrl The root url for scene and resources
  84740. * @param meshes The meshes array to import into
  84741. * @param particleSystems The particle systems array to import into
  84742. * @param skeletons The skeletons array to import into
  84743. * @param onError The callback when import fails
  84744. * @returns True if successful or false otherwise
  84745. */
  84746. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84747. /**
  84748. * Load into a scene.
  84749. * @param scene The scene to load into
  84750. * @param data The data to import
  84751. * @param rootUrl The root url for scene and resources
  84752. * @param onError The callback when import fails
  84753. * @returns true if successful or false otherwise
  84754. */
  84755. load(scene: Scene, data: any, rootUrl: string): boolean;
  84756. /**
  84757. * Load into an asset container.
  84758. * @param scene The scene to load into
  84759. * @param data The data to import
  84760. * @param rootUrl The root url for scene and resources
  84761. * @param onError The callback when import fails
  84762. * @returns The loaded asset container
  84763. */
  84764. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84765. private _isBinary;
  84766. private _parseBinary;
  84767. private _parseASCII;
  84768. }
  84769. }
  84770. declare module BABYLON {
  84771. /**
  84772. * Class for generating OBJ data from a Babylon scene.
  84773. */
  84774. export class OBJExport {
  84775. /**
  84776. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84777. * @param mesh defines the list of meshes to serialize
  84778. * @param materials defines if materials should be exported
  84779. * @param matlibname defines the name of the associated mtl file
  84780. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84781. * @returns the OBJ content
  84782. */
  84783. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84784. /**
  84785. * Exports the material(s) of a mesh in .MTL file format (text)
  84786. * @param mesh defines the mesh to extract the material from
  84787. * @returns the mtl content
  84788. */
  84789. static MTL(mesh: Mesh): string;
  84790. }
  84791. }
  84792. declare module BABYLON {
  84793. /** @hidden */
  84794. export var __IGLTFExporterExtension: number;
  84795. /**
  84796. * Interface for extending the exporter
  84797. * @hidden
  84798. */
  84799. export interface IGLTFExporterExtension {
  84800. /**
  84801. * The name of this extension
  84802. */
  84803. readonly name: string;
  84804. /**
  84805. * Defines whether this extension is enabled
  84806. */
  84807. enabled: boolean;
  84808. /**
  84809. * Defines whether this extension is required
  84810. */
  84811. required: boolean;
  84812. }
  84813. }
  84814. declare module BABYLON.GLTF2.Exporter {
  84815. /** @hidden */
  84816. export var __IGLTFExporterExtensionV2: number;
  84817. /**
  84818. * Interface for a glTF exporter extension
  84819. * @hidden
  84820. */
  84821. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84822. /**
  84823. * Define this method to modify the default behavior before exporting a texture
  84824. * @param context The context when loading the asset
  84825. * @param babylonTexture The Babylon.js texture
  84826. * @param mimeType The mime-type of the generated image
  84827. * @returns A promise that resolves with the exported texture
  84828. */
  84829. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84830. /**
  84831. * Define this method to get notified when a texture info is created
  84832. * @param context The context when loading the asset
  84833. * @param textureInfo The glTF texture info
  84834. * @param babylonTexture The Babylon.js texture
  84835. */
  84836. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84837. /**
  84838. * Define this method to modify the default behavior when exporting texture info
  84839. * @param context The context when loading the asset
  84840. * @param meshPrimitive glTF mesh primitive
  84841. * @param babylonSubMesh Babylon submesh
  84842. * @param binaryWriter glTF serializer binary writer instance
  84843. * @returns nullable IMeshPrimitive promise
  84844. */
  84845. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84846. /**
  84847. * Define this method to modify the default behavior when exporting a node
  84848. * @param context The context when exporting the node
  84849. * @param node glTF node
  84850. * @param babylonNode BabylonJS node
  84851. * @returns nullable INode promise
  84852. */
  84853. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84854. [key: number]: number;
  84855. }): Promise<Nullable<INode>>;
  84856. /**
  84857. * Define this method to modify the default behavior when exporting a material
  84858. * @param material glTF material
  84859. * @param babylonMaterial BabylonJS material
  84860. * @returns nullable IMaterial promise
  84861. */
  84862. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84863. /**
  84864. * Define this method to return additional textures to export from a material
  84865. * @param material glTF material
  84866. * @param babylonMaterial BabylonJS material
  84867. * @returns List of textures
  84868. */
  84869. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84870. /** Gets a boolean indicating that this extension was used */
  84871. wasUsed: boolean;
  84872. /** Gets a boolean indicating that this extension is required for the file to work */
  84873. required: boolean;
  84874. /**
  84875. * Called after the exporter state changes to EXPORTING
  84876. */
  84877. onExporting?(): void;
  84878. }
  84879. }
  84880. declare module BABYLON.GLTF2.Exporter {
  84881. /**
  84882. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84883. * @hidden
  84884. */
  84885. export class _GLTFMaterialExporter {
  84886. /**
  84887. * Represents the dielectric specular values for R, G and B
  84888. */
  84889. private static readonly _DielectricSpecular;
  84890. /**
  84891. * Allows the maximum specular power to be defined for material calculations
  84892. */
  84893. private static readonly _MaxSpecularPower;
  84894. /**
  84895. * Mapping to store textures
  84896. */
  84897. private _textureMap;
  84898. /**
  84899. * Numeric tolerance value
  84900. */
  84901. private static readonly _Epsilon;
  84902. /**
  84903. * Reference to the glTF Exporter
  84904. */
  84905. private _exporter;
  84906. constructor(exporter: _Exporter);
  84907. /**
  84908. * Specifies if two colors are approximately equal in value
  84909. * @param color1 first color to compare to
  84910. * @param color2 second color to compare to
  84911. * @param epsilon threshold value
  84912. */
  84913. private static FuzzyEquals;
  84914. /**
  84915. * Gets the materials from a Babylon scene and converts them to glTF materials
  84916. * @param scene babylonjs scene
  84917. * @param mimeType texture mime type
  84918. * @param images array of images
  84919. * @param textures array of textures
  84920. * @param materials array of materials
  84921. * @param imageData mapping of texture names to base64 textures
  84922. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84923. */
  84924. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84925. /**
  84926. * Makes a copy of the glTF material without the texture parameters
  84927. * @param originalMaterial original glTF material
  84928. * @returns glTF material without texture parameters
  84929. */
  84930. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84931. /**
  84932. * Specifies if the material has any texture parameters present
  84933. * @param material glTF Material
  84934. * @returns boolean specifying if texture parameters are present
  84935. */
  84936. _hasTexturesPresent(material: IMaterial): boolean;
  84937. /**
  84938. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84939. * @param babylonStandardMaterial
  84940. * @returns glTF Metallic Roughness Material representation
  84941. */
  84942. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84943. /**
  84944. * Computes the metallic factor
  84945. * @param diffuse diffused value
  84946. * @param specular specular value
  84947. * @param oneMinusSpecularStrength one minus the specular strength
  84948. * @returns metallic value
  84949. */
  84950. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84951. /**
  84952. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84953. * @param glTFMaterial glTF material
  84954. * @param babylonMaterial Babylon material
  84955. */
  84956. private static _SetAlphaMode;
  84957. /**
  84958. * Converts a Babylon Standard Material to a glTF Material
  84959. * @param babylonStandardMaterial BJS Standard Material
  84960. * @param mimeType mime type to use for the textures
  84961. * @param images array of glTF image interfaces
  84962. * @param textures array of glTF texture interfaces
  84963. * @param materials array of glTF material interfaces
  84964. * @param imageData map of image file name to data
  84965. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84966. */
  84967. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84968. private _finishMaterial;
  84969. /**
  84970. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84971. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84972. * @param mimeType mime type to use for the textures
  84973. * @param images array of glTF image interfaces
  84974. * @param textures array of glTF texture interfaces
  84975. * @param materials array of glTF material interfaces
  84976. * @param imageData map of image file name to data
  84977. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84978. */
  84979. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84980. /**
  84981. * Converts an image typed array buffer to a base64 image
  84982. * @param buffer typed array buffer
  84983. * @param width width of the image
  84984. * @param height height of the image
  84985. * @param mimeType mimetype of the image
  84986. * @returns base64 image string
  84987. */
  84988. private _createBase64FromCanvasAsync;
  84989. /**
  84990. * Generates a white texture based on the specified width and height
  84991. * @param width width of the texture in pixels
  84992. * @param height height of the texture in pixels
  84993. * @param scene babylonjs scene
  84994. * @returns white texture
  84995. */
  84996. private _createWhiteTexture;
  84997. /**
  84998. * 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
  84999. * @param texture1 first texture to resize
  85000. * @param texture2 second texture to resize
  85001. * @param scene babylonjs scene
  85002. * @returns resized textures or null
  85003. */
  85004. private _resizeTexturesToSameDimensions;
  85005. /**
  85006. * Converts an array of pixels to a Float32Array
  85007. * Throws an error if the pixel format is not supported
  85008. * @param pixels - array buffer containing pixel values
  85009. * @returns Float32 of pixels
  85010. */
  85011. private _convertPixelArrayToFloat32;
  85012. /**
  85013. * Convert Specular Glossiness Textures to Metallic Roughness
  85014. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  85015. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  85016. * @param diffuseTexture texture used to store diffuse information
  85017. * @param specularGlossinessTexture texture used to store specular and glossiness information
  85018. * @param factors specular glossiness material factors
  85019. * @param mimeType the mime type to use for the texture
  85020. * @returns pbr metallic roughness interface or null
  85021. */
  85022. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  85023. /**
  85024. * Converts specular glossiness material properties to metallic roughness
  85025. * @param specularGlossiness interface with specular glossiness material properties
  85026. * @returns interface with metallic roughness material properties
  85027. */
  85028. private _convertSpecularGlossinessToMetallicRoughness;
  85029. /**
  85030. * Calculates the surface reflectance, independent of lighting conditions
  85031. * @param color Color source to calculate brightness from
  85032. * @returns number representing the perceived brightness, or zero if color is undefined
  85033. */
  85034. private _getPerceivedBrightness;
  85035. /**
  85036. * Returns the maximum color component value
  85037. * @param color
  85038. * @returns maximum color component value, or zero if color is null or undefined
  85039. */
  85040. private _getMaxComponent;
  85041. /**
  85042. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  85043. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85044. * @param mimeType mime type to use for the textures
  85045. * @param images array of glTF image interfaces
  85046. * @param textures array of glTF texture interfaces
  85047. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85048. * @param imageData map of image file name to data
  85049. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85050. * @returns glTF PBR Metallic Roughness factors
  85051. */
  85052. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  85053. private _getGLTFTextureSampler;
  85054. private _getGLTFTextureWrapMode;
  85055. private _getGLTFTextureWrapModesSampler;
  85056. /**
  85057. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  85058. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85059. * @param mimeType mime type to use for the textures
  85060. * @param images array of glTF image interfaces
  85061. * @param textures array of glTF texture interfaces
  85062. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85063. * @param imageData map of image file name to data
  85064. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85065. * @returns glTF PBR Metallic Roughness factors
  85066. */
  85067. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  85068. /**
  85069. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85070. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85071. * @param mimeType mime type to use for the textures
  85072. * @param images array of glTF image interfaces
  85073. * @param textures array of glTF texture interfaces
  85074. * @param materials array of glTF material interfaces
  85075. * @param imageData map of image file name to data
  85076. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85077. */
  85078. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85079. private setMetallicRoughnessPbrMaterial;
  85080. private getPixelsFromTexture;
  85081. /**
  85082. * Extracts a texture from a Babylon texture into file data and glTF data
  85083. * @param babylonTexture Babylon texture to extract
  85084. * @param mimeType Mime Type of the babylonTexture
  85085. * @return glTF texture info, or null if the texture format is not supported
  85086. */
  85087. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85088. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85089. /**
  85090. * Builds a texture from base64 string
  85091. * @param base64Texture base64 texture string
  85092. * @param baseTextureName Name to use for the texture
  85093. * @param mimeType image mime type for the texture
  85094. * @param images array of images
  85095. * @param textures array of textures
  85096. * @param imageData map of image data
  85097. * @returns glTF texture info, or null if the texture format is not supported
  85098. */
  85099. private _getTextureInfoFromBase64;
  85100. }
  85101. }
  85102. declare module BABYLON {
  85103. /**
  85104. * Class for holding and downloading glTF file data
  85105. */
  85106. export class GLTFData {
  85107. /**
  85108. * Object which contains the file name as the key and its data as the value
  85109. */
  85110. glTFFiles: {
  85111. [fileName: string]: string | Blob;
  85112. };
  85113. /**
  85114. * Initializes the glTF file object
  85115. */
  85116. constructor();
  85117. /**
  85118. * Downloads the glTF data as files based on their names and data
  85119. */
  85120. downloadFiles(): void;
  85121. }
  85122. }
  85123. declare module BABYLON {
  85124. /**
  85125. * Holds a collection of exporter options and parameters
  85126. */
  85127. export interface IExportOptions {
  85128. /**
  85129. * Function which indicates whether a babylon node should be exported or not
  85130. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  85131. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  85132. */
  85133. shouldExportNode?(node: Node): boolean;
  85134. /**
  85135. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  85136. * @param metadata source metadata to read from
  85137. * @returns the data to store to glTF node extras
  85138. */
  85139. metadataSelector?(metadata: any): any;
  85140. /**
  85141. * The sample rate to bake animation curves
  85142. */
  85143. animationSampleRate?: number;
  85144. /**
  85145. * Begin serialization without waiting for the scene to be ready
  85146. */
  85147. exportWithoutWaitingForScene?: boolean;
  85148. /**
  85149. * Indicates if coordinate system swapping root nodes should be included in export
  85150. */
  85151. includeCoordinateSystemConversionNodes?: boolean;
  85152. }
  85153. /**
  85154. * Class for generating glTF data from a Babylon scene.
  85155. */
  85156. export class GLTF2Export {
  85157. /**
  85158. * Exports the geometry of the scene to .gltf file format asynchronously
  85159. * @param scene Babylon scene with scene hierarchy information
  85160. * @param filePrefix File prefix to use when generating the glTF file
  85161. * @param options Exporter options
  85162. * @returns Returns an object with a .gltf file and associates texture names
  85163. * as keys and their data and paths as values
  85164. */
  85165. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85166. private static _PreExportAsync;
  85167. private static _PostExportAsync;
  85168. /**
  85169. * Exports the geometry of the scene to .glb file format asychronously
  85170. * @param scene Babylon scene with scene hierarchy information
  85171. * @param filePrefix File prefix to use when generating glb file
  85172. * @param options Exporter options
  85173. * @returns Returns an object with a .glb filename as key and data as value
  85174. */
  85175. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85176. }
  85177. }
  85178. declare module BABYLON.GLTF2.Exporter {
  85179. /**
  85180. * @hidden
  85181. */
  85182. export class _GLTFUtilities {
  85183. /**
  85184. * Creates a buffer view based on the supplied arguments
  85185. * @param bufferIndex index value of the specified buffer
  85186. * @param byteOffset byte offset value
  85187. * @param byteLength byte length of the bufferView
  85188. * @param byteStride byte distance between conequential elements
  85189. * @param name name of the buffer view
  85190. * @returns bufferView for glTF
  85191. */
  85192. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85193. /**
  85194. * Creates an accessor based on the supplied arguments
  85195. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85196. * @param name The name of the accessor
  85197. * @param type The type of the accessor
  85198. * @param componentType The datatype of components in the attribute
  85199. * @param count The number of attributes referenced by this accessor
  85200. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85201. * @param min Minimum value of each component in this attribute
  85202. * @param max Maximum value of each component in this attribute
  85203. * @returns accessor for glTF
  85204. */
  85205. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85206. /**
  85207. * Calculates the minimum and maximum values of an array of position floats
  85208. * @param positions Positions array of a mesh
  85209. * @param vertexStart Starting vertex offset to calculate min and max values
  85210. * @param vertexCount Number of vertices to check for min and max values
  85211. * @returns min number array and max number array
  85212. */
  85213. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85214. min: number[];
  85215. max: number[];
  85216. };
  85217. /**
  85218. * Converts a new right-handed Vector3
  85219. * @param vector vector3 array
  85220. * @returns right-handed Vector3
  85221. */
  85222. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85223. /**
  85224. * Converts a Vector3 to right-handed
  85225. * @param vector Vector3 to convert to right-handed
  85226. */
  85227. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85228. /**
  85229. * Converts a three element number array to right-handed
  85230. * @param vector number array to convert to right-handed
  85231. */
  85232. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85233. /**
  85234. * Converts a new right-handed Vector3
  85235. * @param vector vector3 array
  85236. * @returns right-handed Vector3
  85237. */
  85238. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85239. /**
  85240. * Converts a Vector3 to right-handed
  85241. * @param vector Vector3 to convert to right-handed
  85242. */
  85243. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85244. /**
  85245. * Converts a three element number array to right-handed
  85246. * @param vector number array to convert to right-handed
  85247. */
  85248. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85249. /**
  85250. * Converts a Vector4 to right-handed
  85251. * @param vector Vector4 to convert to right-handed
  85252. */
  85253. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85254. /**
  85255. * Converts a Vector4 to right-handed
  85256. * @param vector Vector4 to convert to right-handed
  85257. */
  85258. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85259. /**
  85260. * Converts a Quaternion to right-handed
  85261. * @param quaternion Source quaternion to convert to right-handed
  85262. */
  85263. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85264. /**
  85265. * Converts a Quaternion to right-handed
  85266. * @param quaternion Source quaternion to convert to right-handed
  85267. */
  85268. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85269. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85270. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85271. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85272. }
  85273. }
  85274. declare module BABYLON.GLTF2.Exporter {
  85275. /**
  85276. * Converts Babylon Scene into glTF 2.0.
  85277. * @hidden
  85278. */
  85279. export class _Exporter {
  85280. /**
  85281. * Stores the glTF to export
  85282. */
  85283. _glTF: IGLTF;
  85284. /**
  85285. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85286. */
  85287. _bufferViews: IBufferView[];
  85288. /**
  85289. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85290. */
  85291. _accessors: IAccessor[];
  85292. /**
  85293. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85294. */
  85295. _nodes: INode[];
  85296. /**
  85297. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85298. */
  85299. private _scenes;
  85300. /**
  85301. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85302. */
  85303. private _meshes;
  85304. /**
  85305. * Stores all the generated material information, which represents the appearance of each primitive
  85306. */
  85307. _materials: IMaterial[];
  85308. _materialMap: {
  85309. [materialID: number]: number;
  85310. };
  85311. /**
  85312. * Stores all the generated texture information, which is referenced by glTF materials
  85313. */
  85314. _textures: ITexture[];
  85315. /**
  85316. * Stores all the generated image information, which is referenced by glTF textures
  85317. */
  85318. _images: IImage[];
  85319. /**
  85320. * Stores all the texture samplers
  85321. */
  85322. _samplers: ISampler[];
  85323. /**
  85324. * Stores all the generated glTF skins
  85325. */
  85326. _skins: ISkin[];
  85327. /**
  85328. * Stores all the generated animation samplers, which is referenced by glTF animations
  85329. */
  85330. /**
  85331. * Stores the animations for glTF models
  85332. */
  85333. private _animations;
  85334. /**
  85335. * Stores the total amount of bytes stored in the glTF buffer
  85336. */
  85337. private _totalByteLength;
  85338. /**
  85339. * Stores a reference to the Babylon scene containing the source geometry and material information
  85340. */
  85341. _babylonScene: Scene;
  85342. /**
  85343. * Stores a map of the image data, where the key is the file name and the value
  85344. * is the image data
  85345. */
  85346. _imageData: {
  85347. [fileName: string]: {
  85348. data: Uint8Array;
  85349. mimeType: ImageMimeType;
  85350. };
  85351. };
  85352. protected _orderedImageData: Array<{
  85353. data: Uint8Array;
  85354. mimeType: ImageMimeType;
  85355. }>;
  85356. /**
  85357. * Stores a map of the unique id of a node to its index in the node array
  85358. */
  85359. _nodeMap: {
  85360. [key: number]: number;
  85361. };
  85362. /**
  85363. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85364. */
  85365. _convertToRightHandedSystem: boolean;
  85366. /**
  85367. * Specifies if a Babylon node should be converted to right-handed on export
  85368. */
  85369. _convertToRightHandedSystemMap: {
  85370. [nodeId: number]: boolean;
  85371. };
  85372. _includeCoordinateSystemConversionNodes: boolean;
  85373. /**
  85374. * Baked animation sample rate
  85375. */
  85376. private _animationSampleRate;
  85377. private _options;
  85378. private _localEngine;
  85379. _glTFMaterialExporter: _GLTFMaterialExporter;
  85380. private _extensions;
  85381. private static _ExtensionNames;
  85382. private static _ExtensionFactories;
  85383. private _applyExtension;
  85384. private _applyExtensions;
  85385. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85386. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85387. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85388. [key: number]: number;
  85389. }): Promise<Nullable<INode>>;
  85390. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85391. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85392. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85393. private _forEachExtensions;
  85394. private _extensionsOnExporting;
  85395. /**
  85396. * Load glTF serializer extensions
  85397. */
  85398. private _loadExtensions;
  85399. /**
  85400. * Creates a glTF Exporter instance, which can accept optional exporter options
  85401. * @param babylonScene Babylon scene object
  85402. * @param options Options to modify the behavior of the exporter
  85403. */
  85404. constructor(babylonScene: Scene, options?: IExportOptions);
  85405. dispose(): void;
  85406. /**
  85407. * Registers a glTF exporter extension
  85408. * @param name Name of the extension to export
  85409. * @param factory The factory function that creates the exporter extension
  85410. */
  85411. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85412. /**
  85413. * Un-registers an exporter extension
  85414. * @param name The name fo the exporter extension
  85415. * @returns A boolean indicating whether the extension has been un-registered
  85416. */
  85417. static UnregisterExtension(name: string): boolean;
  85418. /**
  85419. * Lazy load a local engine
  85420. */
  85421. _getLocalEngine(): Engine;
  85422. private reorderIndicesBasedOnPrimitiveMode;
  85423. /**
  85424. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85425. * clock-wise during export to glTF
  85426. * @param submesh BabylonJS submesh
  85427. * @param primitiveMode Primitive mode of the mesh
  85428. * @param sideOrientation the winding order of the submesh
  85429. * @param vertexBufferKind The type of vertex attribute
  85430. * @param meshAttributeArray The vertex attribute data
  85431. * @param byteOffset The offset to the binary data
  85432. * @param binaryWriter The binary data for the glTF file
  85433. * @param convertToRightHandedSystem Converts the values to right-handed
  85434. */
  85435. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85436. /**
  85437. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85438. * clock-wise during export to glTF
  85439. * @param submesh BabylonJS submesh
  85440. * @param primitiveMode Primitive mode of the mesh
  85441. * @param sideOrientation the winding order of the submesh
  85442. * @param vertexBufferKind The type of vertex attribute
  85443. * @param meshAttributeArray The vertex attribute data
  85444. * @param byteOffset The offset to the binary data
  85445. * @param binaryWriter The binary data for the glTF file
  85446. * @param convertToRightHandedSystem Converts the values to right-handed
  85447. */
  85448. private reorderTriangleFillMode;
  85449. /**
  85450. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85451. * clock-wise during export to glTF
  85452. * @param submesh BabylonJS submesh
  85453. * @param primitiveMode Primitive mode of the mesh
  85454. * @param sideOrientation the winding order of the submesh
  85455. * @param vertexBufferKind The type of vertex attribute
  85456. * @param meshAttributeArray The vertex attribute data
  85457. * @param byteOffset The offset to the binary data
  85458. * @param binaryWriter The binary data for the glTF file
  85459. * @param convertToRightHandedSystem Converts the values to right-handed
  85460. */
  85461. private reorderTriangleStripDrawMode;
  85462. /**
  85463. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85464. * clock-wise during export to glTF
  85465. * @param submesh BabylonJS submesh
  85466. * @param primitiveMode Primitive mode of the mesh
  85467. * @param sideOrientation the winding order of the submesh
  85468. * @param vertexBufferKind The type of vertex attribute
  85469. * @param meshAttributeArray The vertex attribute data
  85470. * @param byteOffset The offset to the binary data
  85471. * @param binaryWriter The binary data for the glTF file
  85472. * @param convertToRightHandedSystem Converts the values to right-handed
  85473. */
  85474. private reorderTriangleFanMode;
  85475. /**
  85476. * Writes the vertex attribute data to binary
  85477. * @param vertices The vertices to write to the binary writer
  85478. * @param byteOffset The offset into the binary writer to overwrite binary data
  85479. * @param vertexAttributeKind The vertex attribute type
  85480. * @param meshAttributeArray The vertex attribute data
  85481. * @param binaryWriter The writer containing the binary data
  85482. * @param convertToRightHandedSystem Converts the values to right-handed
  85483. */
  85484. private writeVertexAttributeData;
  85485. /**
  85486. * Writes mesh attribute data to a data buffer
  85487. * Returns the bytelength of the data
  85488. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85489. * @param meshAttributeArray Array containing the attribute data
  85490. * @param byteStride Specifies the space between data
  85491. * @param binaryWriter The buffer to write the binary data to
  85492. * @param convertToRightHandedSystem Converts the values to right-handed
  85493. */
  85494. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85495. /**
  85496. * Writes mesh attribute data to a data buffer
  85497. * Returns the bytelength of the data
  85498. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85499. * @param meshAttributeArray Array containing the attribute data
  85500. * @param byteStride Specifies the space between data
  85501. * @param binaryWriter The buffer to write the binary data to
  85502. * @param convertToRightHandedSystem Converts the values to right-handed
  85503. */
  85504. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85505. /**
  85506. * Generates glTF json data
  85507. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85508. * @param glTFPrefix Text to use when prefixing a glTF file
  85509. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85510. * @returns json data as string
  85511. */
  85512. private generateJSON;
  85513. /**
  85514. * Generates data for .gltf and .bin files based on the glTF prefix string
  85515. * @param glTFPrefix Text to use when prefixing a glTF file
  85516. * @param dispose Dispose the exporter
  85517. * @returns GLTFData with glTF file data
  85518. */
  85519. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85520. /**
  85521. * Creates a binary buffer for glTF
  85522. * @returns array buffer for binary data
  85523. */
  85524. private _generateBinaryAsync;
  85525. /**
  85526. * Pads the number to a multiple of 4
  85527. * @param num number to pad
  85528. * @returns padded number
  85529. */
  85530. private _getPadding;
  85531. /**
  85532. * @hidden
  85533. */
  85534. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85535. /**
  85536. * Sets the TRS for each node
  85537. * @param node glTF Node for storing the transformation data
  85538. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85539. * @param convertToRightHandedSystem Converts the values to right-handed
  85540. */
  85541. private setNodeTransformation;
  85542. private getVertexBufferFromMesh;
  85543. /**
  85544. * Creates a bufferview based on the vertices type for the Babylon mesh
  85545. * @param kind Indicates the type of vertices data
  85546. * @param componentType Indicates the numerical type used to store the data
  85547. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85548. * @param binaryWriter The buffer to write the bufferview data to
  85549. * @param convertToRightHandedSystem Converts the values to right-handed
  85550. */
  85551. private createBufferViewKind;
  85552. /**
  85553. * Creates a bufferview based on the vertices type for the Babylon mesh
  85554. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85555. * @param babylonMorphTarget the morph target to be exported
  85556. * @param binaryWriter The buffer to write the bufferview data to
  85557. * @param convertToRightHandedSystem Converts the values to right-handed
  85558. */
  85559. private setMorphTargetAttributes;
  85560. /**
  85561. * The primitive mode of the Babylon mesh
  85562. * @param babylonMesh The BabylonJS mesh
  85563. */
  85564. private getMeshPrimitiveMode;
  85565. /**
  85566. * Sets the primitive mode of the glTF mesh primitive
  85567. * @param meshPrimitive glTF mesh primitive
  85568. * @param primitiveMode The primitive mode
  85569. */
  85570. private setPrimitiveMode;
  85571. /**
  85572. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85573. * @param meshPrimitive glTF mesh primitive
  85574. * @param attributeKind vertex attribute
  85575. * @returns boolean specifying if uv coordinates are present
  85576. */
  85577. private setAttributeKind;
  85578. /**
  85579. * Sets data for the primitive attributes of each submesh
  85580. * @param mesh glTF Mesh object to store the primitive attribute information
  85581. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85582. * @param binaryWriter Buffer to write the attribute data to
  85583. * @param convertToRightHandedSystem Converts the values to right-handed
  85584. */
  85585. private setPrimitiveAttributesAsync;
  85586. /**
  85587. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85588. * @param node The node to check
  85589. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85590. */
  85591. private isBabylonCoordinateSystemConvertingNode;
  85592. /**
  85593. * Creates a glTF scene based on the array of meshes
  85594. * Returns the the total byte offset
  85595. * @param babylonScene Babylon scene to get the mesh data from
  85596. * @param binaryWriter Buffer to write binary data to
  85597. */
  85598. private createSceneAsync;
  85599. /**
  85600. * Creates a mapping of Node unique id to node index and handles animations
  85601. * @param babylonScene Babylon Scene
  85602. * @param nodes Babylon transform nodes
  85603. * @param binaryWriter Buffer to write binary data to
  85604. * @returns Node mapping of unique id to index
  85605. */
  85606. private createNodeMapAndAnimationsAsync;
  85607. /**
  85608. * Creates a glTF node from a Babylon mesh
  85609. * @param babylonMesh Source Babylon mesh
  85610. * @param binaryWriter Buffer for storing geometry data
  85611. * @param convertToRightHandedSystem Converts the values to right-handed
  85612. * @param nodeMap Node mapping of unique id to glTF node index
  85613. * @returns glTF node
  85614. */
  85615. private createNodeAsync;
  85616. /**
  85617. * Creates a glTF skin from a Babylon skeleton
  85618. * @param babylonScene Babylon Scene
  85619. * @param nodes Babylon transform nodes
  85620. * @param binaryWriter Buffer to write binary data to
  85621. * @returns Node mapping of unique id to index
  85622. */
  85623. private createSkinsAsync;
  85624. }
  85625. /**
  85626. * @hidden
  85627. *
  85628. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85629. */
  85630. export class _BinaryWriter {
  85631. /**
  85632. * Array buffer which stores all binary data
  85633. */
  85634. private _arrayBuffer;
  85635. /**
  85636. * View of the array buffer
  85637. */
  85638. private _dataView;
  85639. /**
  85640. * byte offset of data in array buffer
  85641. */
  85642. private _byteOffset;
  85643. /**
  85644. * Initialize binary writer with an initial byte length
  85645. * @param byteLength Initial byte length of the array buffer
  85646. */
  85647. constructor(byteLength: number);
  85648. /**
  85649. * Resize the array buffer to the specified byte length
  85650. * @param byteLength
  85651. */
  85652. private resizeBuffer;
  85653. /**
  85654. * Get an array buffer with the length of the byte offset
  85655. * @returns ArrayBuffer resized to the byte offset
  85656. */
  85657. getArrayBuffer(): ArrayBuffer;
  85658. /**
  85659. * Get the byte offset of the array buffer
  85660. * @returns byte offset
  85661. */
  85662. getByteOffset(): number;
  85663. /**
  85664. * Stores an UInt8 in the array buffer
  85665. * @param entry
  85666. * @param byteOffset If defined, specifies where to set the value as an offset.
  85667. */
  85668. setUInt8(entry: number, byteOffset?: number): void;
  85669. /**
  85670. * Stores an UInt16 in the array buffer
  85671. * @param entry
  85672. * @param byteOffset If defined, specifies where to set the value as an offset.
  85673. */
  85674. setUInt16(entry: number, byteOffset?: number): void;
  85675. /**
  85676. * Gets an UInt32 in the array buffer
  85677. * @param entry
  85678. * @param byteOffset If defined, specifies where to set the value as an offset.
  85679. */
  85680. getUInt32(byteOffset: number): number;
  85681. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85682. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85683. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85684. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85685. /**
  85686. * Stores a Float32 in the array buffer
  85687. * @param entry
  85688. */
  85689. setFloat32(entry: number, byteOffset?: number): void;
  85690. /**
  85691. * Stores an UInt32 in the array buffer
  85692. * @param entry
  85693. * @param byteOffset If defined, specifies where to set the value as an offset.
  85694. */
  85695. setUInt32(entry: number, byteOffset?: number): void;
  85696. }
  85697. }
  85698. declare module BABYLON.GLTF2.Exporter {
  85699. /**
  85700. * @hidden
  85701. * Interface to store animation data.
  85702. */
  85703. export interface _IAnimationData {
  85704. /**
  85705. * Keyframe data.
  85706. */
  85707. inputs: number[];
  85708. /**
  85709. * Value data.
  85710. */
  85711. outputs: number[][];
  85712. /**
  85713. * Animation interpolation data.
  85714. */
  85715. samplerInterpolation: AnimationSamplerInterpolation;
  85716. /**
  85717. * Minimum keyframe value.
  85718. */
  85719. inputsMin: number;
  85720. /**
  85721. * Maximum keyframe value.
  85722. */
  85723. inputsMax: number;
  85724. }
  85725. /**
  85726. * @hidden
  85727. */
  85728. export interface _IAnimationInfo {
  85729. /**
  85730. * The target channel for the animation
  85731. */
  85732. animationChannelTargetPath: AnimationChannelTargetPath;
  85733. /**
  85734. * The glTF accessor type for the data.
  85735. */
  85736. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85737. /**
  85738. * Specifies if quaternions should be used.
  85739. */
  85740. useQuaternion: boolean;
  85741. }
  85742. /**
  85743. * @hidden
  85744. * Utility class for generating glTF animation data from BabylonJS.
  85745. */
  85746. export class _GLTFAnimation {
  85747. /**
  85748. * @ignore
  85749. *
  85750. * Creates glTF channel animation from BabylonJS animation.
  85751. * @param babylonTransformNode - BabylonJS mesh.
  85752. * @param animation - animation.
  85753. * @param animationChannelTargetPath - The target animation channel.
  85754. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85755. * @param useQuaternion - Specifies if quaternions are used.
  85756. * @returns nullable IAnimationData
  85757. */
  85758. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85759. private static _DeduceAnimationInfo;
  85760. /**
  85761. * @ignore
  85762. * Create node animations from the transform node animations
  85763. * @param babylonNode
  85764. * @param runtimeGLTFAnimation
  85765. * @param idleGLTFAnimations
  85766. * @param nodeMap
  85767. * @param nodes
  85768. * @param binaryWriter
  85769. * @param bufferViews
  85770. * @param accessors
  85771. * @param convertToRightHandedSystem
  85772. * @param animationSampleRate
  85773. */
  85774. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85775. [key: number]: number;
  85776. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85777. /**
  85778. * @ignore
  85779. * Create individual morph animations from the mesh's morph target animation tracks
  85780. * @param babylonNode
  85781. * @param runtimeGLTFAnimation
  85782. * @param idleGLTFAnimations
  85783. * @param nodeMap
  85784. * @param nodes
  85785. * @param binaryWriter
  85786. * @param bufferViews
  85787. * @param accessors
  85788. * @param convertToRightHandedSystem
  85789. * @param animationSampleRate
  85790. */
  85791. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85792. [key: number]: number;
  85793. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85794. /**
  85795. * @ignore
  85796. * Create node and morph animations from the animation groups
  85797. * @param babylonScene
  85798. * @param glTFAnimations
  85799. * @param nodeMap
  85800. * @param nodes
  85801. * @param binaryWriter
  85802. * @param bufferViews
  85803. * @param accessors
  85804. * @param convertToRightHandedSystemMap
  85805. * @param animationSampleRate
  85806. */
  85807. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85808. [key: number]: number;
  85809. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85810. [nodeId: number]: boolean;
  85811. }, animationSampleRate: number): void;
  85812. private static AddAnimation;
  85813. /**
  85814. * Create a baked animation
  85815. * @param babylonTransformNode BabylonJS mesh
  85816. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85817. * @param animationChannelTargetPath animation target channel
  85818. * @param minFrame minimum animation frame
  85819. * @param maxFrame maximum animation frame
  85820. * @param fps frames per second of the animation
  85821. * @param inputs input key frames of the animation
  85822. * @param outputs output key frame data of the animation
  85823. * @param convertToRightHandedSystem converts the values to right-handed
  85824. * @param useQuaternion specifies if quaternions should be used
  85825. */
  85826. private static _CreateBakedAnimation;
  85827. private static _ConvertFactorToVector3OrQuaternion;
  85828. private static _SetInterpolatedValue;
  85829. /**
  85830. * Creates linear animation from the animation key frames
  85831. * @param babylonTransformNode BabylonJS mesh
  85832. * @param animation BabylonJS animation
  85833. * @param animationChannelTargetPath The target animation channel
  85834. * @param frameDelta The difference between the last and first frame of the animation
  85835. * @param inputs Array to store the key frame times
  85836. * @param outputs Array to store the key frame data
  85837. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85838. * @param useQuaternion Specifies if quaternions are used in the animation
  85839. */
  85840. private static _CreateLinearOrStepAnimation;
  85841. /**
  85842. * Creates cubic spline animation from the animation key frames
  85843. * @param babylonTransformNode BabylonJS mesh
  85844. * @param animation BabylonJS animation
  85845. * @param animationChannelTargetPath The target animation channel
  85846. * @param frameDelta The difference between the last and first frame of the animation
  85847. * @param inputs Array to store the key frame times
  85848. * @param outputs Array to store the key frame data
  85849. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85850. * @param useQuaternion Specifies if quaternions are used in the animation
  85851. */
  85852. private static _CreateCubicSplineAnimation;
  85853. private static _GetBasePositionRotationOrScale;
  85854. /**
  85855. * Adds a key frame value
  85856. * @param keyFrame
  85857. * @param animation
  85858. * @param outputs
  85859. * @param animationChannelTargetPath
  85860. * @param basePositionRotationOrScale
  85861. * @param convertToRightHandedSystem
  85862. * @param useQuaternion
  85863. */
  85864. private static _AddKeyframeValue;
  85865. /**
  85866. * Determine the interpolation based on the key frames
  85867. * @param keyFrames
  85868. * @param animationChannelTargetPath
  85869. * @param useQuaternion
  85870. */
  85871. private static _DeduceInterpolation;
  85872. /**
  85873. * Adds an input tangent or output tangent to the output data
  85874. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85875. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85876. * @param outputs The animation data by keyframe
  85877. * @param animationChannelTargetPath The target animation channel
  85878. * @param interpolation The interpolation type
  85879. * @param keyFrame The key frame with the animation data
  85880. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85881. * @param useQuaternion Specifies if quaternions are used
  85882. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85883. */
  85884. private static AddSplineTangent;
  85885. /**
  85886. * Get the minimum and maximum key frames' frame values
  85887. * @param keyFrames animation key frames
  85888. * @returns the minimum and maximum key frame value
  85889. */
  85890. private static calculateMinMaxKeyFrames;
  85891. }
  85892. }
  85893. declare module BABYLON.GLTF2.Exporter {
  85894. /** @hidden */
  85895. export var textureTransformPixelShader: {
  85896. name: string;
  85897. shader: string;
  85898. };
  85899. }
  85900. declare module BABYLON.GLTF2.Exporter.Extensions {
  85901. /**
  85902. * @hidden
  85903. */
  85904. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85905. private _recordedTextures;
  85906. /** Name of this extension */
  85907. readonly name: string;
  85908. /** Defines whether this extension is enabled */
  85909. enabled: boolean;
  85910. /** Defines whether this extension is required */
  85911. required: boolean;
  85912. /** Reference to the glTF exporter */
  85913. private _wasUsed;
  85914. constructor(exporter: _Exporter);
  85915. dispose(): void;
  85916. /** @hidden */
  85917. get wasUsed(): boolean;
  85918. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85919. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85920. /**
  85921. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85922. * @param babylonTexture
  85923. * @param offset
  85924. * @param rotation
  85925. * @param scale
  85926. * @param scene
  85927. */
  85928. private _textureTransformTextureAsync;
  85929. }
  85930. }
  85931. declare module BABYLON.GLTF2.Exporter.Extensions {
  85932. /**
  85933. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85934. */
  85935. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85936. /** The name of this extension. */
  85937. readonly name: string;
  85938. /** Defines whether this extension is enabled. */
  85939. enabled: boolean;
  85940. /** Defines whether this extension is required */
  85941. required: boolean;
  85942. /** Reference to the glTF exporter */
  85943. private _exporter;
  85944. private _lights;
  85945. /** @hidden */
  85946. constructor(exporter: _Exporter);
  85947. /** @hidden */
  85948. dispose(): void;
  85949. /** @hidden */
  85950. get wasUsed(): boolean;
  85951. /** @hidden */
  85952. onExporting(): void;
  85953. /**
  85954. * Define this method to modify the default behavior when exporting a node
  85955. * @param context The context when exporting the node
  85956. * @param node glTF node
  85957. * @param babylonNode BabylonJS node
  85958. * @param nodeMap Node mapping of unique id to glTF node index
  85959. * @returns nullable INode promise
  85960. */
  85961. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85962. [key: number]: number;
  85963. }): Promise<Nullable<INode>>;
  85964. }
  85965. }
  85966. declare module BABYLON.GLTF2.Exporter.Extensions {
  85967. /**
  85968. * @hidden
  85969. */
  85970. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85971. /** Name of this extension */
  85972. readonly name: string;
  85973. /** Defines whether this extension is enabled */
  85974. enabled: boolean;
  85975. /** Defines whether this extension is required */
  85976. required: boolean;
  85977. /** Reference to the glTF exporter */
  85978. private _textureInfos;
  85979. private _exportedTextures;
  85980. private _wasUsed;
  85981. constructor(exporter: _Exporter);
  85982. dispose(): void;
  85983. /** @hidden */
  85984. get wasUsed(): boolean;
  85985. private _getTextureIndex;
  85986. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85987. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85988. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85989. }
  85990. }
  85991. declare module BABYLON.GLTF2.Exporter.Extensions {
  85992. /**
  85993. * @hidden
  85994. */
  85995. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85996. /** Name of this extension */
  85997. readonly name: string;
  85998. /** Defines whether this extension is enabled */
  85999. enabled: boolean;
  86000. /** Defines whether this extension is required */
  86001. required: boolean;
  86002. private _wasUsed;
  86003. constructor(exporter: _Exporter);
  86004. /** @hidden */
  86005. get wasUsed(): boolean;
  86006. dispose(): void;
  86007. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  86008. }
  86009. }
  86010. declare module BABYLON {
  86011. /**
  86012. * Class for generating STL data from a Babylon scene.
  86013. */
  86014. export class STLExport {
  86015. /**
  86016. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  86017. * @param meshes list defines the mesh to serialize
  86018. * @param download triggers the automatic download of the file.
  86019. * @param fileName changes the downloads fileName.
  86020. * @param binary changes the STL to a binary type.
  86021. * @param isLittleEndian toggle for binary type exporter.
  86022. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  86023. * @returns the STL as UTF8 string
  86024. */
  86025. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  86026. }
  86027. }
  86028. declare module "babylonjs-gltf2interface" {
  86029. export = BABYLON.GLTF2;
  86030. }
  86031. /**
  86032. * Module for glTF 2.0 Interface
  86033. */
  86034. declare module BABYLON.GLTF2 {
  86035. /**
  86036. * The datatype of the components in the attribute
  86037. */
  86038. const enum AccessorComponentType {
  86039. /**
  86040. * Byte
  86041. */
  86042. BYTE = 5120,
  86043. /**
  86044. * Unsigned Byte
  86045. */
  86046. UNSIGNED_BYTE = 5121,
  86047. /**
  86048. * Short
  86049. */
  86050. SHORT = 5122,
  86051. /**
  86052. * Unsigned Short
  86053. */
  86054. UNSIGNED_SHORT = 5123,
  86055. /**
  86056. * Unsigned Int
  86057. */
  86058. UNSIGNED_INT = 5125,
  86059. /**
  86060. * Float
  86061. */
  86062. FLOAT = 5126,
  86063. }
  86064. /**
  86065. * Specifies if the attirbute is a scalar, vector, or matrix
  86066. */
  86067. const enum AccessorType {
  86068. /**
  86069. * Scalar
  86070. */
  86071. SCALAR = "SCALAR",
  86072. /**
  86073. * Vector2
  86074. */
  86075. VEC2 = "VEC2",
  86076. /**
  86077. * Vector3
  86078. */
  86079. VEC3 = "VEC3",
  86080. /**
  86081. * Vector4
  86082. */
  86083. VEC4 = "VEC4",
  86084. /**
  86085. * Matrix2x2
  86086. */
  86087. MAT2 = "MAT2",
  86088. /**
  86089. * Matrix3x3
  86090. */
  86091. MAT3 = "MAT3",
  86092. /**
  86093. * Matrix4x4
  86094. */
  86095. MAT4 = "MAT4",
  86096. }
  86097. /**
  86098. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86099. */
  86100. const enum AnimationChannelTargetPath {
  86101. /**
  86102. * Translation
  86103. */
  86104. TRANSLATION = "translation",
  86105. /**
  86106. * Rotation
  86107. */
  86108. ROTATION = "rotation",
  86109. /**
  86110. * Scale
  86111. */
  86112. SCALE = "scale",
  86113. /**
  86114. * Weights
  86115. */
  86116. WEIGHTS = "weights",
  86117. }
  86118. /**
  86119. * Interpolation algorithm
  86120. */
  86121. const enum AnimationSamplerInterpolation {
  86122. /**
  86123. * The animated values are linearly interpolated between keyframes
  86124. */
  86125. LINEAR = "LINEAR",
  86126. /**
  86127. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  86128. */
  86129. STEP = "STEP",
  86130. /**
  86131. * The animation's interpolation is computed using a cubic spline with specified tangents
  86132. */
  86133. CUBICSPLINE = "CUBICSPLINE",
  86134. }
  86135. /**
  86136. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86137. */
  86138. const enum CameraType {
  86139. /**
  86140. * A perspective camera containing properties to create a perspective projection matrix
  86141. */
  86142. PERSPECTIVE = "perspective",
  86143. /**
  86144. * An orthographic camera containing properties to create an orthographic projection matrix
  86145. */
  86146. ORTHOGRAPHIC = "orthographic",
  86147. }
  86148. /**
  86149. * The mime-type of the image
  86150. */
  86151. const enum ImageMimeType {
  86152. /**
  86153. * JPEG Mime-type
  86154. */
  86155. JPEG = "image/jpeg",
  86156. /**
  86157. * PNG Mime-type
  86158. */
  86159. PNG = "image/png",
  86160. }
  86161. /**
  86162. * The alpha rendering mode of the material
  86163. */
  86164. const enum MaterialAlphaMode {
  86165. /**
  86166. * The alpha value is ignored and the rendered output is fully opaque
  86167. */
  86168. OPAQUE = "OPAQUE",
  86169. /**
  86170. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86171. */
  86172. MASK = "MASK",
  86173. /**
  86174. * 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)
  86175. */
  86176. BLEND = "BLEND",
  86177. }
  86178. /**
  86179. * The type of the primitives to render
  86180. */
  86181. const enum MeshPrimitiveMode {
  86182. /**
  86183. * Points
  86184. */
  86185. POINTS = 0,
  86186. /**
  86187. * Lines
  86188. */
  86189. LINES = 1,
  86190. /**
  86191. * Line Loop
  86192. */
  86193. LINE_LOOP = 2,
  86194. /**
  86195. * Line Strip
  86196. */
  86197. LINE_STRIP = 3,
  86198. /**
  86199. * Triangles
  86200. */
  86201. TRIANGLES = 4,
  86202. /**
  86203. * Triangle Strip
  86204. */
  86205. TRIANGLE_STRIP = 5,
  86206. /**
  86207. * Triangle Fan
  86208. */
  86209. TRIANGLE_FAN = 6,
  86210. }
  86211. /**
  86212. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86213. */
  86214. const enum TextureMagFilter {
  86215. /**
  86216. * Nearest
  86217. */
  86218. NEAREST = 9728,
  86219. /**
  86220. * Linear
  86221. */
  86222. LINEAR = 9729,
  86223. }
  86224. /**
  86225. * Minification filter. All valid values correspond to WebGL enums
  86226. */
  86227. const enum TextureMinFilter {
  86228. /**
  86229. * Nearest
  86230. */
  86231. NEAREST = 9728,
  86232. /**
  86233. * Linear
  86234. */
  86235. LINEAR = 9729,
  86236. /**
  86237. * Nearest Mip-Map Nearest
  86238. */
  86239. NEAREST_MIPMAP_NEAREST = 9984,
  86240. /**
  86241. * Linear Mipmap Nearest
  86242. */
  86243. LINEAR_MIPMAP_NEAREST = 9985,
  86244. /**
  86245. * Nearest Mipmap Linear
  86246. */
  86247. NEAREST_MIPMAP_LINEAR = 9986,
  86248. /**
  86249. * Linear Mipmap Linear
  86250. */
  86251. LINEAR_MIPMAP_LINEAR = 9987,
  86252. }
  86253. /**
  86254. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86255. */
  86256. const enum TextureWrapMode {
  86257. /**
  86258. * Clamp to Edge
  86259. */
  86260. CLAMP_TO_EDGE = 33071,
  86261. /**
  86262. * Mirrored Repeat
  86263. */
  86264. MIRRORED_REPEAT = 33648,
  86265. /**
  86266. * Repeat
  86267. */
  86268. REPEAT = 10497,
  86269. }
  86270. /**
  86271. * glTF Property
  86272. */
  86273. interface IProperty {
  86274. /**
  86275. * Dictionary object with extension-specific objects
  86276. */
  86277. extensions?: {
  86278. [key: string]: any;
  86279. };
  86280. /**
  86281. * Application-Specific data
  86282. */
  86283. extras?: any;
  86284. }
  86285. /**
  86286. * glTF Child of Root Property
  86287. */
  86288. interface IChildRootProperty extends IProperty {
  86289. /**
  86290. * The user-defined name of this object
  86291. */
  86292. name?: string;
  86293. }
  86294. /**
  86295. * Indices of those attributes that deviate from their initialization value
  86296. */
  86297. interface IAccessorSparseIndices extends IProperty {
  86298. /**
  86299. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86300. */
  86301. bufferView: number;
  86302. /**
  86303. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86304. */
  86305. byteOffset?: number;
  86306. /**
  86307. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86308. */
  86309. componentType: AccessorComponentType;
  86310. }
  86311. /**
  86312. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86313. */
  86314. interface IAccessorSparseValues extends IProperty {
  86315. /**
  86316. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86317. */
  86318. bufferView: number;
  86319. /**
  86320. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86321. */
  86322. byteOffset?: number;
  86323. }
  86324. /**
  86325. * Sparse storage of attributes that deviate from their initialization value
  86326. */
  86327. interface IAccessorSparse extends IProperty {
  86328. /**
  86329. * The number of attributes encoded in this sparse accessor
  86330. */
  86331. count: number;
  86332. /**
  86333. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86334. */
  86335. indices: IAccessorSparseIndices;
  86336. /**
  86337. * 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
  86338. */
  86339. values: IAccessorSparseValues;
  86340. }
  86341. /**
  86342. * 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
  86343. */
  86344. interface IAccessor extends IChildRootProperty {
  86345. /**
  86346. * The index of the bufferview
  86347. */
  86348. bufferView?: number;
  86349. /**
  86350. * The offset relative to the start of the bufferView in bytes
  86351. */
  86352. byteOffset?: number;
  86353. /**
  86354. * The datatype of components in the attribute
  86355. */
  86356. componentType: AccessorComponentType;
  86357. /**
  86358. * Specifies whether integer data values should be normalized
  86359. */
  86360. normalized?: boolean;
  86361. /**
  86362. * The number of attributes referenced by this accessor
  86363. */
  86364. count: number;
  86365. /**
  86366. * Specifies if the attribute is a scalar, vector, or matrix
  86367. */
  86368. type: AccessorType;
  86369. /**
  86370. * Maximum value of each component in this attribute
  86371. */
  86372. max?: number[];
  86373. /**
  86374. * Minimum value of each component in this attribute
  86375. */
  86376. min?: number[];
  86377. /**
  86378. * Sparse storage of attributes that deviate from their initialization value
  86379. */
  86380. sparse?: IAccessorSparse;
  86381. }
  86382. /**
  86383. * Targets an animation's sampler at a node's property
  86384. */
  86385. interface IAnimationChannel extends IProperty {
  86386. /**
  86387. * The index of a sampler in this animation used to compute the value for the target
  86388. */
  86389. sampler: number;
  86390. /**
  86391. * The index of the node and TRS property to target
  86392. */
  86393. target: IAnimationChannelTarget;
  86394. }
  86395. /**
  86396. * The index of the node and TRS property that an animation channel targets
  86397. */
  86398. interface IAnimationChannelTarget extends IProperty {
  86399. /**
  86400. * The index of the node to target
  86401. */
  86402. node: number;
  86403. /**
  86404. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86405. */
  86406. path: AnimationChannelTargetPath;
  86407. }
  86408. /**
  86409. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86410. */
  86411. interface IAnimationSampler extends IProperty {
  86412. /**
  86413. * The index of an accessor containing keyframe input values, e.g., time
  86414. */
  86415. input: number;
  86416. /**
  86417. * Interpolation algorithm
  86418. */
  86419. interpolation?: AnimationSamplerInterpolation;
  86420. /**
  86421. * The index of an accessor, containing keyframe output values
  86422. */
  86423. output: number;
  86424. }
  86425. /**
  86426. * A keyframe animation
  86427. */
  86428. interface IAnimation extends IChildRootProperty {
  86429. /**
  86430. * An array of channels, each of which targets an animation's sampler at a node's property
  86431. */
  86432. channels: IAnimationChannel[];
  86433. /**
  86434. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86435. */
  86436. samplers: IAnimationSampler[];
  86437. }
  86438. /**
  86439. * Metadata about the glTF asset
  86440. */
  86441. interface IAsset extends IChildRootProperty {
  86442. /**
  86443. * A copyright message suitable for display to credit the content creator
  86444. */
  86445. copyright?: string;
  86446. /**
  86447. * Tool that generated this glTF model. Useful for debugging
  86448. */
  86449. generator?: string;
  86450. /**
  86451. * The glTF version that this asset targets
  86452. */
  86453. version: string;
  86454. /**
  86455. * The minimum glTF version that this asset targets
  86456. */
  86457. minVersion?: string;
  86458. }
  86459. /**
  86460. * A buffer points to binary geometry, animation, or skins
  86461. */
  86462. interface IBuffer extends IChildRootProperty {
  86463. /**
  86464. * 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
  86465. */
  86466. uri?: string;
  86467. /**
  86468. * The length of the buffer in bytes
  86469. */
  86470. byteLength: number;
  86471. }
  86472. /**
  86473. * A view into a buffer generally representing a subset of the buffer
  86474. */
  86475. interface IBufferView extends IChildRootProperty {
  86476. /**
  86477. * The index of the buffer
  86478. */
  86479. buffer: number;
  86480. /**
  86481. * The offset into the buffer in bytes
  86482. */
  86483. byteOffset?: number;
  86484. /**
  86485. * The lenth of the bufferView in bytes
  86486. */
  86487. byteLength: number;
  86488. /**
  86489. * The stride, in bytes
  86490. */
  86491. byteStride?: number;
  86492. }
  86493. /**
  86494. * An orthographic camera containing properties to create an orthographic projection matrix
  86495. */
  86496. interface ICameraOrthographic extends IProperty {
  86497. /**
  86498. * The floating-point horizontal magnification of the view. Must not be zero
  86499. */
  86500. xmag: number;
  86501. /**
  86502. * The floating-point vertical magnification of the view. Must not be zero
  86503. */
  86504. ymag: number;
  86505. /**
  86506. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86507. */
  86508. zfar: number;
  86509. /**
  86510. * The floating-point distance to the near clipping plane
  86511. */
  86512. znear: number;
  86513. }
  86514. /**
  86515. * A perspective camera containing properties to create a perspective projection matrix
  86516. */
  86517. interface ICameraPerspective extends IProperty {
  86518. /**
  86519. * The floating-point aspect ratio of the field of view
  86520. */
  86521. aspectRatio?: number;
  86522. /**
  86523. * The floating-point vertical field of view in radians
  86524. */
  86525. yfov: number;
  86526. /**
  86527. * The floating-point distance to the far clipping plane
  86528. */
  86529. zfar?: number;
  86530. /**
  86531. * The floating-point distance to the near clipping plane
  86532. */
  86533. znear: number;
  86534. }
  86535. /**
  86536. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86537. */
  86538. interface ICamera extends IChildRootProperty {
  86539. /**
  86540. * An orthographic camera containing properties to create an orthographic projection matrix
  86541. */
  86542. orthographic?: ICameraOrthographic;
  86543. /**
  86544. * A perspective camera containing properties to create a perspective projection matrix
  86545. */
  86546. perspective?: ICameraPerspective;
  86547. /**
  86548. * Specifies if the camera uses a perspective or orthographic projection
  86549. */
  86550. type: CameraType;
  86551. }
  86552. /**
  86553. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86554. */
  86555. interface IImage extends IChildRootProperty {
  86556. /**
  86557. * 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
  86558. */
  86559. uri?: string;
  86560. /**
  86561. * The image's MIME type
  86562. */
  86563. mimeType?: ImageMimeType;
  86564. /**
  86565. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86566. */
  86567. bufferView?: number;
  86568. }
  86569. /**
  86570. * Material Normal Texture Info
  86571. */
  86572. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86573. /**
  86574. * The scalar multiplier applied to each normal vector of the normal texture
  86575. */
  86576. scale?: number;
  86577. }
  86578. /**
  86579. * Material Occlusion Texture Info
  86580. */
  86581. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86582. /**
  86583. * A scalar multiplier controlling the amount of occlusion applied
  86584. */
  86585. strength?: number;
  86586. }
  86587. /**
  86588. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86589. */
  86590. interface IMaterialPbrMetallicRoughness {
  86591. /**
  86592. * The material's base color factor
  86593. */
  86594. baseColorFactor?: number[];
  86595. /**
  86596. * The base color texture
  86597. */
  86598. baseColorTexture?: ITextureInfo;
  86599. /**
  86600. * The metalness of the material
  86601. */
  86602. metallicFactor?: number;
  86603. /**
  86604. * The roughness of the material
  86605. */
  86606. roughnessFactor?: number;
  86607. /**
  86608. * The metallic-roughness texture
  86609. */
  86610. metallicRoughnessTexture?: ITextureInfo;
  86611. }
  86612. /**
  86613. * The material appearance of a primitive
  86614. */
  86615. interface IMaterial extends IChildRootProperty {
  86616. /**
  86617. * 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
  86618. */
  86619. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86620. /**
  86621. * The normal map texture
  86622. */
  86623. normalTexture?: IMaterialNormalTextureInfo;
  86624. /**
  86625. * The occlusion map texture
  86626. */
  86627. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86628. /**
  86629. * The emissive map texture
  86630. */
  86631. emissiveTexture?: ITextureInfo;
  86632. /**
  86633. * 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
  86634. */
  86635. emissiveFactor?: number[];
  86636. /**
  86637. * The alpha rendering mode of the material
  86638. */
  86639. alphaMode?: MaterialAlphaMode;
  86640. /**
  86641. * The alpha cutoff value of the material
  86642. */
  86643. alphaCutoff?: number;
  86644. /**
  86645. * Specifies whether the material is double sided
  86646. */
  86647. doubleSided?: boolean;
  86648. }
  86649. /**
  86650. * Geometry to be rendered with the given material
  86651. */
  86652. interface IMeshPrimitive extends IProperty {
  86653. /**
  86654. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86655. */
  86656. attributes: {
  86657. [name: string]: number;
  86658. };
  86659. /**
  86660. * The index of the accessor that contains the indices
  86661. */
  86662. indices?: number;
  86663. /**
  86664. * The index of the material to apply to this primitive when rendering
  86665. */
  86666. material?: number;
  86667. /**
  86668. * The type of primitives to render. All valid values correspond to WebGL enums
  86669. */
  86670. mode?: MeshPrimitiveMode;
  86671. /**
  86672. * 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
  86673. */
  86674. targets?: {
  86675. [name: string]: number;
  86676. }[];
  86677. }
  86678. /**
  86679. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86680. */
  86681. interface IMesh extends IChildRootProperty {
  86682. /**
  86683. * An array of primitives, each defining geometry to be rendered with a material
  86684. */
  86685. primitives: IMeshPrimitive[];
  86686. /**
  86687. * Array of weights to be applied to the Morph Targets
  86688. */
  86689. weights?: number[];
  86690. }
  86691. /**
  86692. * A node in the node hierarchy
  86693. */
  86694. interface INode extends IChildRootProperty {
  86695. /**
  86696. * The index of the camera referenced by this node
  86697. */
  86698. camera?: number;
  86699. /**
  86700. * The indices of this node's children
  86701. */
  86702. children?: number[];
  86703. /**
  86704. * The index of the skin referenced by this node
  86705. */
  86706. skin?: number;
  86707. /**
  86708. * A floating-point 4x4 transformation matrix stored in column-major order
  86709. */
  86710. matrix?: number[];
  86711. /**
  86712. * The index of the mesh in this node
  86713. */
  86714. mesh?: number;
  86715. /**
  86716. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86717. */
  86718. rotation?: number[];
  86719. /**
  86720. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86721. */
  86722. scale?: number[];
  86723. /**
  86724. * The node's translation along the x, y, and z axes
  86725. */
  86726. translation?: number[];
  86727. /**
  86728. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86729. */
  86730. weights?: number[];
  86731. }
  86732. /**
  86733. * Texture sampler properties for filtering and wrapping modes
  86734. */
  86735. interface ISampler extends IChildRootProperty {
  86736. /**
  86737. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86738. */
  86739. magFilter?: TextureMagFilter;
  86740. /**
  86741. * Minification filter. All valid values correspond to WebGL enums
  86742. */
  86743. minFilter?: TextureMinFilter;
  86744. /**
  86745. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86746. */
  86747. wrapS?: TextureWrapMode;
  86748. /**
  86749. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86750. */
  86751. wrapT?: TextureWrapMode;
  86752. }
  86753. /**
  86754. * The root nodes of a scene
  86755. */
  86756. interface IScene extends IChildRootProperty {
  86757. /**
  86758. * The indices of each root node
  86759. */
  86760. nodes: number[];
  86761. }
  86762. /**
  86763. * Joints and matrices defining a skin
  86764. */
  86765. interface ISkin extends IChildRootProperty {
  86766. /**
  86767. * 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
  86768. */
  86769. inverseBindMatrices?: number;
  86770. /**
  86771. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86772. */
  86773. skeleton?: number;
  86774. /**
  86775. * 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)
  86776. */
  86777. joints: number[];
  86778. }
  86779. /**
  86780. * A texture and its sampler
  86781. */
  86782. interface ITexture extends IChildRootProperty {
  86783. /**
  86784. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86785. */
  86786. sampler?: number;
  86787. /**
  86788. * The index of the image used by this texture
  86789. */
  86790. source: number;
  86791. }
  86792. /**
  86793. * Reference to a texture
  86794. */
  86795. interface ITextureInfo extends IProperty {
  86796. /**
  86797. * The index of the texture
  86798. */
  86799. index: number;
  86800. /**
  86801. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86802. */
  86803. texCoord?: number;
  86804. }
  86805. /**
  86806. * The root object for a glTF asset
  86807. */
  86808. interface IGLTF extends IProperty {
  86809. /**
  86810. * An array of accessors. An accessor is a typed view into a bufferView
  86811. */
  86812. accessors?: IAccessor[];
  86813. /**
  86814. * An array of keyframe animations
  86815. */
  86816. animations?: IAnimation[];
  86817. /**
  86818. * Metadata about the glTF asset
  86819. */
  86820. asset: IAsset;
  86821. /**
  86822. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86823. */
  86824. buffers?: IBuffer[];
  86825. /**
  86826. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86827. */
  86828. bufferViews?: IBufferView[];
  86829. /**
  86830. * An array of cameras
  86831. */
  86832. cameras?: ICamera[];
  86833. /**
  86834. * Names of glTF extensions used somewhere in this asset
  86835. */
  86836. extensionsUsed?: string[];
  86837. /**
  86838. * Names of glTF extensions required to properly load this asset
  86839. */
  86840. extensionsRequired?: string[];
  86841. /**
  86842. * An array of images. An image defines data used to create a texture
  86843. */
  86844. images?: IImage[];
  86845. /**
  86846. * An array of materials. A material defines the appearance of a primitive
  86847. */
  86848. materials?: IMaterial[];
  86849. /**
  86850. * An array of meshes. A mesh is a set of primitives to be rendered
  86851. */
  86852. meshes?: IMesh[];
  86853. /**
  86854. * An array of nodes
  86855. */
  86856. nodes?: INode[];
  86857. /**
  86858. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86859. */
  86860. samplers?: ISampler[];
  86861. /**
  86862. * The index of the default scene
  86863. */
  86864. scene?: number;
  86865. /**
  86866. * An array of scenes
  86867. */
  86868. scenes?: IScene[];
  86869. /**
  86870. * An array of skins. A skin is defined by joints and matrices
  86871. */
  86872. skins?: ISkin[];
  86873. /**
  86874. * An array of textures
  86875. */
  86876. textures?: ITexture[];
  86877. }
  86878. /**
  86879. * The glTF validation results
  86880. * @ignore
  86881. */
  86882. interface IGLTFValidationResults {
  86883. info: {
  86884. generator: string;
  86885. hasAnimations: boolean;
  86886. hasDefaultScene: boolean;
  86887. hasMaterials: boolean;
  86888. hasMorphTargets: boolean;
  86889. hasSkins: boolean;
  86890. hasTextures: boolean;
  86891. maxAttributesUsed: number;
  86892. primitivesCount: number
  86893. };
  86894. issues: {
  86895. messages: Array<string>;
  86896. numErrors: number;
  86897. numHints: number;
  86898. numInfos: number;
  86899. numWarnings: number;
  86900. truncated: boolean
  86901. };
  86902. mimeType: string;
  86903. uri: string;
  86904. validatedAt: string;
  86905. validatorVersion: string;
  86906. }
  86907. /**
  86908. * The glTF validation options
  86909. */
  86910. interface IGLTFValidationOptions {
  86911. /** Uri to use */
  86912. uri?: string;
  86913. /** Function used to load external resources */
  86914. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86915. /** Boolean indicating that we need to validate accessor data */
  86916. validateAccessorData?: boolean;
  86917. /** max number of issues allowed */
  86918. maxIssues?: number;
  86919. /** Ignored issues */
  86920. ignoredIssues?: Array<string>;
  86921. /** Value to override severy settings */
  86922. severityOverrides?: Object;
  86923. }
  86924. /**
  86925. * The glTF validator object
  86926. * @ignore
  86927. */
  86928. interface IGLTFValidator {
  86929. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86930. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86931. }
  86932. /**
  86933. * Interfaces from the EXT_lights_image_based extension
  86934. */
  86935. /** @hidden */
  86936. interface IEXTLightsImageBased_LightReferenceImageBased {
  86937. light: number;
  86938. }
  86939. /** @hidden */
  86940. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86941. intensity: number;
  86942. rotation: number[];
  86943. specularImageSize: number;
  86944. specularImages: number[][];
  86945. irradianceCoefficients: number[][];
  86946. }
  86947. /** @hidden */
  86948. interface IEXTLightsImageBased {
  86949. lights: IEXTLightsImageBased_LightImageBased[];
  86950. }
  86951. /**
  86952. * Interfaces from the EXT_mesh_gpu_instancing extension
  86953. * !!! Experimental Extension Subject to Changes !!!
  86954. */
  86955. /** @hidden */
  86956. interface IEXTMeshGpuInstancing {
  86957. mesh?: number;
  86958. attributes: { [name: string]: number };
  86959. }
  86960. /**
  86961. * Interfaces from the KHR_draco_mesh_compression extension
  86962. */
  86963. /** @hidden */
  86964. interface IKHRDracoMeshCompression {
  86965. bufferView: number;
  86966. attributes: { [name: string]: number };
  86967. }
  86968. /**
  86969. * Interfaces from the KHR_lights_punctual extension
  86970. */
  86971. /** @hidden */
  86972. const enum IKHRLightsPunctual_LightType {
  86973. DIRECTIONAL = "directional",
  86974. POINT = "point",
  86975. SPOT = "spot"
  86976. }
  86977. /** @hidden */
  86978. interface IKHRLightsPunctual_LightReference {
  86979. light: number;
  86980. }
  86981. /** @hidden */
  86982. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86983. type: IKHRLightsPunctual_LightType;
  86984. color?: number[];
  86985. intensity?: number;
  86986. range?: number;
  86987. spot?: {
  86988. innerConeAngle?: number;
  86989. outerConeAngle?: number;
  86990. };
  86991. }
  86992. /** @hidden */
  86993. interface IKHRLightsPunctual {
  86994. lights: IKHRLightsPunctual_Light[];
  86995. }
  86996. /**
  86997. * Interfaces from the KHR_materials_clearcoat extension
  86998. * !!! Experimental Extension Subject to Changes !!!
  86999. */
  87000. /** @hidden */
  87001. interface IKHRMaterialsClearcoat {
  87002. clearcoatFactor: number;
  87003. clearcoatTexture: ITextureInfo;
  87004. clearcoatRoughnessFactor: number;
  87005. clearcoatRoughnessTexture: ITextureInfo;
  87006. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  87007. }
  87008. /**
  87009. * Interfaces from the KHR_materials_ior extension
  87010. * !!! Experimental Extension Subject to Changes !!!
  87011. */
  87012. /** @hidden */
  87013. interface IKHRMaterialsIor {
  87014. ior: number;
  87015. }
  87016. /**
  87017. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  87018. */
  87019. /** @hidden */
  87020. interface IKHRMaterialsPbrSpecularGlossiness {
  87021. diffuseFactor: number[];
  87022. diffuseTexture: ITextureInfo;
  87023. specularFactor: number[];
  87024. glossinessFactor: number;
  87025. specularGlossinessTexture: ITextureInfo;
  87026. }
  87027. /**
  87028. * Interfaces from the KHR_materials_sheen extension
  87029. * !!! Experimental Extension Subject to Changes !!!
  87030. */
  87031. /** @hidden */
  87032. interface IKHRMaterialsSheen {
  87033. sheenColorFactor?: number[];
  87034. sheenColorTexture?: ITextureInfo;
  87035. sheenRoughnessFactor?: number;
  87036. sheenRoughnessTexture?: ITextureInfo;
  87037. }
  87038. /**
  87039. * Interfaces from the KHR_materials_specular extension
  87040. * !!! Experimental Extension Subject to Changes !!!
  87041. */
  87042. /** @hidden */
  87043. interface IKHRMaterialsSpecular {
  87044. specularFactor: number;
  87045. specularColorFactor: number[];
  87046. specularTexture: ITextureInfo;
  87047. }
  87048. /**
  87049. * Interfaces from the KHR_materials_transmission extension
  87050. * !!! Experimental Extension Subject to Changes !!!
  87051. */
  87052. /** @hidden */
  87053. interface IKHRMaterialsTransmission {
  87054. transmissionFactor?: number;
  87055. transmissionTexture?: ITextureInfo;
  87056. }
  87057. /**
  87058. * Interfaces from the KHR_materials_translucency extension
  87059. * !!! Experimental Extension Subject to Changes !!!
  87060. */
  87061. /** @hidden */
  87062. interface IKHRMaterialsTranslucency {
  87063. translucencyFactor?: number;
  87064. translucencyTexture?: ITextureInfo;
  87065. }
  87066. /**
  87067. * Interfaces from the KHR_materials_variants extension
  87068. * !!! Experimental Extension Subject to Changes !!!
  87069. */
  87070. /** @hidden */
  87071. interface IKHRMaterialVariants_Mapping extends IProperty {
  87072. mappings: Array<{
  87073. variants: number[];
  87074. material: number;
  87075. }>;
  87076. }
  87077. /** @hidden */
  87078. interface IKHRMaterialVariants_Variant extends IProperty {
  87079. name: string;
  87080. }
  87081. /** @hidden */
  87082. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  87083. variants: Array<IKHRMaterialVariants_Variant>;
  87084. }
  87085. /**
  87086. * Interfaces from the KHR_texture_basisu extension
  87087. * !!! Experimental Extension Subject to Changes !!!
  87088. */
  87089. /** @hidden */
  87090. interface IKHRTextureBasisU {
  87091. source: number;
  87092. }
  87093. /**
  87094. * Interfaces from the EXT_texture_webp extension
  87095. */
  87096. /** @hidden */
  87097. interface IEXTTextureWebP {
  87098. source: number;
  87099. }
  87100. /**
  87101. * Interfaces from the KHR_texture_transform extension
  87102. */
  87103. /** @hidden */
  87104. interface IKHRTextureTransform {
  87105. offset?: number[];
  87106. rotation?: number;
  87107. scale?: number[];
  87108. texCoord?: number;
  87109. }
  87110. /**
  87111. * Interfaces from the KHR_xmp extension
  87112. * !!! Experimental Extension Subject to Changes !!!
  87113. */
  87114. /** @hidden */
  87115. interface IKHRXmp_Data {
  87116. [key: string]: unknown;
  87117. }
  87118. /** @hidden */
  87119. interface IKHRXmp_Gltf {
  87120. packets: IKHRXmp_Data[];
  87121. }
  87122. /** @hidden */
  87123. interface IKHRXmp_Node {
  87124. packet: number;
  87125. }
  87126. /**
  87127. * Interfaces from the MSFT_audio_emitter extension
  87128. */
  87129. /** @hidden */
  87130. interface IMSFTAudioEmitter_ClipReference {
  87131. clip: number;
  87132. weight?: number;
  87133. }
  87134. /** @hidden */
  87135. interface IMSFTAudioEmitter_EmittersReference {
  87136. emitters: number[];
  87137. }
  87138. /** @hidden */
  87139. const enum IMSFTAudioEmitter_DistanceModel {
  87140. linear = "linear",
  87141. inverse = "inverse",
  87142. exponential = "exponential",
  87143. }
  87144. /** @hidden */
  87145. interface IMSFTAudioEmitter_Emitter {
  87146. name?: string;
  87147. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  87148. refDistance?: number;
  87149. maxDistance?: number;
  87150. rolloffFactor?: number;
  87151. innerAngle?: number;
  87152. outerAngle?: number;
  87153. loop?: boolean;
  87154. volume?: number;
  87155. clips: IMSFTAudioEmitter_ClipReference[];
  87156. }
  87157. /** @hidden */
  87158. const enum IMSFTAudioEmitter_AudioMimeType {
  87159. WAV = "audio/wav",
  87160. }
  87161. /** @hidden */
  87162. interface IMSFTAudioEmitter_Clip extends IProperty {
  87163. uri?: string;
  87164. bufferView?: number;
  87165. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87166. }
  87167. /** @hidden */
  87168. const enum IMSFTAudioEmitter_AnimationEventAction {
  87169. play = "play",
  87170. pause = "pause",
  87171. stop = "stop",
  87172. }
  87173. /** @hidden */
  87174. interface IMSFTAudioEmitter_AnimationEvent {
  87175. action: IMSFTAudioEmitter_AnimationEventAction;
  87176. emitter: number;
  87177. time: number;
  87178. startOffset?: number;
  87179. }
  87180. /**
  87181. * Interfaces from the MSFT_lod extension
  87182. */
  87183. /** @hidden */
  87184. interface IMSFTLOD {
  87185. ids: number[];
  87186. }
  87187. }
  87188. declare module BABYLON {
  87189. /** @hidden */
  87190. export var cellPixelShader: {
  87191. name: string;
  87192. shader: string;
  87193. };
  87194. }
  87195. declare module BABYLON {
  87196. /** @hidden */
  87197. export var cellVertexShader: {
  87198. name: string;
  87199. shader: string;
  87200. };
  87201. }
  87202. declare module BABYLON {
  87203. export class CellMaterial extends BABYLON.PushMaterial {
  87204. private _diffuseTexture;
  87205. diffuseTexture: BABYLON.BaseTexture;
  87206. diffuseColor: BABYLON.Color3;
  87207. _computeHighLevel: boolean;
  87208. computeHighLevel: boolean;
  87209. private _disableLighting;
  87210. disableLighting: boolean;
  87211. private _maxSimultaneousLights;
  87212. maxSimultaneousLights: number;
  87213. constructor(name: string, scene: BABYLON.Scene);
  87214. needAlphaBlending(): boolean;
  87215. needAlphaTesting(): boolean;
  87216. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87217. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87218. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87219. getAnimatables(): BABYLON.IAnimatable[];
  87220. getActiveTextures(): BABYLON.BaseTexture[];
  87221. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87222. dispose(forceDisposeEffect?: boolean): void;
  87223. getClassName(): string;
  87224. clone(name: string): CellMaterial;
  87225. serialize(): any;
  87226. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87227. }
  87228. }
  87229. declare module BABYLON {
  87230. export class CustomShaderStructure {
  87231. FragmentStore: string;
  87232. VertexStore: string;
  87233. constructor();
  87234. }
  87235. export class ShaderSpecialParts {
  87236. constructor();
  87237. Fragment_Begin: string;
  87238. Fragment_Definitions: string;
  87239. Fragment_MainBegin: string;
  87240. Fragment_Custom_Diffuse: string;
  87241. Fragment_Before_Lights: string;
  87242. Fragment_Before_Fog: string;
  87243. Fragment_Custom_Alpha: string;
  87244. Fragment_Before_FragColor: string;
  87245. Vertex_Begin: string;
  87246. Vertex_Definitions: string;
  87247. Vertex_MainBegin: string;
  87248. Vertex_Before_PositionUpdated: string;
  87249. Vertex_Before_NormalUpdated: string;
  87250. Vertex_After_WorldPosComputed: string;
  87251. Vertex_MainEnd: string;
  87252. }
  87253. export class CustomMaterial extends BABYLON.StandardMaterial {
  87254. static ShaderIndexer: number;
  87255. CustomParts: ShaderSpecialParts;
  87256. _isCreatedShader: boolean;
  87257. _createdShaderName: string;
  87258. _customUniform: string[];
  87259. _newUniforms: string[];
  87260. _newUniformInstances: {
  87261. [name: string]: any;
  87262. };
  87263. _newSamplerInstances: {
  87264. [name: string]: BABYLON.Texture;
  87265. };
  87266. _customAttributes: string[];
  87267. FragmentShader: string;
  87268. VertexShader: string;
  87269. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87270. ReviewUniform(name: string, arr: string[]): string[];
  87271. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87272. constructor(name: string, scene: BABYLON.Scene);
  87273. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87274. AddAttribute(name: string): CustomMaterial;
  87275. Fragment_Begin(shaderPart: string): CustomMaterial;
  87276. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87277. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87278. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87279. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87280. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87281. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87282. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87283. Vertex_Begin(shaderPart: string): CustomMaterial;
  87284. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87285. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87286. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87287. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87288. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87289. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87290. }
  87291. }
  87292. declare module BABYLON {
  87293. export class ShaderAlebdoParts {
  87294. constructor();
  87295. Fragment_Begin: string;
  87296. Fragment_Definitions: string;
  87297. Fragment_MainBegin: string;
  87298. Fragment_Custom_Albedo: string;
  87299. Fragment_Before_Lights: string;
  87300. Fragment_Custom_MetallicRoughness: string;
  87301. Fragment_Custom_MicroSurface: string;
  87302. Fragment_Before_Fog: string;
  87303. Fragment_Custom_Alpha: string;
  87304. Fragment_Before_FragColor: string;
  87305. Vertex_Begin: string;
  87306. Vertex_Definitions: string;
  87307. Vertex_MainBegin: string;
  87308. Vertex_Before_PositionUpdated: string;
  87309. Vertex_Before_NormalUpdated: string;
  87310. Vertex_After_WorldPosComputed: string;
  87311. Vertex_MainEnd: string;
  87312. }
  87313. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87314. static ShaderIndexer: number;
  87315. CustomParts: ShaderAlebdoParts;
  87316. _isCreatedShader: boolean;
  87317. _createdShaderName: string;
  87318. _customUniform: string[];
  87319. _newUniforms: string[];
  87320. _newUniformInstances: {
  87321. [name: string]: any;
  87322. };
  87323. _newSamplerInstances: {
  87324. [name: string]: BABYLON.Texture;
  87325. };
  87326. _customAttributes: string[];
  87327. FragmentShader: string;
  87328. VertexShader: string;
  87329. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87330. ReviewUniform(name: string, arr: string[]): string[];
  87331. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87332. constructor(name: string, scene: BABYLON.Scene);
  87333. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87334. AddAttribute(name: string): PBRCustomMaterial;
  87335. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87336. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87337. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87338. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87339. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87340. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87341. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87342. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87343. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87344. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87345. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87346. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87347. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87348. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87349. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87350. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87351. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87352. }
  87353. }
  87354. declare module BABYLON {
  87355. /** @hidden */
  87356. export var firePixelShader: {
  87357. name: string;
  87358. shader: string;
  87359. };
  87360. }
  87361. declare module BABYLON {
  87362. /** @hidden */
  87363. export var fireVertexShader: {
  87364. name: string;
  87365. shader: string;
  87366. };
  87367. }
  87368. declare module BABYLON {
  87369. export class FireMaterial extends BABYLON.PushMaterial {
  87370. private _diffuseTexture;
  87371. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87372. private _distortionTexture;
  87373. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87374. private _opacityTexture;
  87375. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87376. diffuseColor: BABYLON.Color3;
  87377. speed: number;
  87378. private _scaledDiffuse;
  87379. private _lastTime;
  87380. constructor(name: string, scene: BABYLON.Scene);
  87381. needAlphaBlending(): boolean;
  87382. needAlphaTesting(): boolean;
  87383. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87384. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87385. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87386. getAnimatables(): BABYLON.IAnimatable[];
  87387. getActiveTextures(): BABYLON.BaseTexture[];
  87388. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87389. getClassName(): string;
  87390. dispose(forceDisposeEffect?: boolean): void;
  87391. clone(name: string): FireMaterial;
  87392. serialize(): any;
  87393. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87394. }
  87395. }
  87396. declare module BABYLON {
  87397. /** @hidden */
  87398. export var furPixelShader: {
  87399. name: string;
  87400. shader: string;
  87401. };
  87402. }
  87403. declare module BABYLON {
  87404. /** @hidden */
  87405. export var furVertexShader: {
  87406. name: string;
  87407. shader: string;
  87408. };
  87409. }
  87410. declare module BABYLON {
  87411. export class FurMaterial extends BABYLON.PushMaterial {
  87412. private _diffuseTexture;
  87413. diffuseTexture: BABYLON.BaseTexture;
  87414. private _heightTexture;
  87415. heightTexture: BABYLON.BaseTexture;
  87416. diffuseColor: BABYLON.Color3;
  87417. furLength: number;
  87418. furAngle: number;
  87419. furColor: BABYLON.Color3;
  87420. furOffset: number;
  87421. furSpacing: number;
  87422. furGravity: BABYLON.Vector3;
  87423. furSpeed: number;
  87424. furDensity: number;
  87425. furOcclusion: number;
  87426. furTexture: BABYLON.DynamicTexture;
  87427. private _disableLighting;
  87428. disableLighting: boolean;
  87429. private _maxSimultaneousLights;
  87430. maxSimultaneousLights: number;
  87431. highLevelFur: boolean;
  87432. _meshes: BABYLON.AbstractMesh[];
  87433. private _furTime;
  87434. constructor(name: string, scene: BABYLON.Scene);
  87435. get furTime(): number;
  87436. set furTime(furTime: number);
  87437. needAlphaBlending(): boolean;
  87438. needAlphaTesting(): boolean;
  87439. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87440. updateFur(): void;
  87441. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87442. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87443. getAnimatables(): BABYLON.IAnimatable[];
  87444. getActiveTextures(): BABYLON.BaseTexture[];
  87445. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87446. dispose(forceDisposeEffect?: boolean): void;
  87447. clone(name: string): FurMaterial;
  87448. serialize(): any;
  87449. getClassName(): string;
  87450. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87451. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87452. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87453. }
  87454. }
  87455. declare module BABYLON {
  87456. /** @hidden */
  87457. export var gradientPixelShader: {
  87458. name: string;
  87459. shader: string;
  87460. };
  87461. }
  87462. declare module BABYLON {
  87463. /** @hidden */
  87464. export var gradientVertexShader: {
  87465. name: string;
  87466. shader: string;
  87467. };
  87468. }
  87469. declare module BABYLON {
  87470. export class GradientMaterial extends BABYLON.PushMaterial {
  87471. private _maxSimultaneousLights;
  87472. maxSimultaneousLights: number;
  87473. topColor: BABYLON.Color3;
  87474. topColorAlpha: number;
  87475. bottomColor: BABYLON.Color3;
  87476. bottomColorAlpha: number;
  87477. offset: number;
  87478. scale: number;
  87479. smoothness: number;
  87480. private _disableLighting;
  87481. disableLighting: boolean;
  87482. constructor(name: string, scene: BABYLON.Scene);
  87483. needAlphaBlending(): boolean;
  87484. needAlphaTesting(): boolean;
  87485. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87486. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87487. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87488. getAnimatables(): BABYLON.IAnimatable[];
  87489. dispose(forceDisposeEffect?: boolean): void;
  87490. clone(name: string): GradientMaterial;
  87491. serialize(): any;
  87492. getClassName(): string;
  87493. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87494. }
  87495. }
  87496. declare module BABYLON {
  87497. /** @hidden */
  87498. export var gridPixelShader: {
  87499. name: string;
  87500. shader: string;
  87501. };
  87502. }
  87503. declare module BABYLON {
  87504. /** @hidden */
  87505. export var gridVertexShader: {
  87506. name: string;
  87507. shader: string;
  87508. };
  87509. }
  87510. declare module BABYLON {
  87511. /**
  87512. * The grid materials allows you to wrap any shape with a grid.
  87513. * Colors are customizable.
  87514. */
  87515. export class GridMaterial extends BABYLON.PushMaterial {
  87516. /**
  87517. * Main color of the grid (e.g. between lines)
  87518. */
  87519. mainColor: BABYLON.Color3;
  87520. /**
  87521. * Color of the grid lines.
  87522. */
  87523. lineColor: BABYLON.Color3;
  87524. /**
  87525. * The scale of the grid compared to unit.
  87526. */
  87527. gridRatio: number;
  87528. /**
  87529. * Allows setting an offset for the grid lines.
  87530. */
  87531. gridOffset: BABYLON.Vector3;
  87532. /**
  87533. * The frequency of thicker lines.
  87534. */
  87535. majorUnitFrequency: number;
  87536. /**
  87537. * The visibility of minor units in the grid.
  87538. */
  87539. minorUnitVisibility: number;
  87540. /**
  87541. * The grid opacity outside of the lines.
  87542. */
  87543. opacity: number;
  87544. /**
  87545. * Determine RBG output is premultiplied by alpha value.
  87546. */
  87547. preMultiplyAlpha: boolean;
  87548. private _opacityTexture;
  87549. opacityTexture: BABYLON.BaseTexture;
  87550. private _gridControl;
  87551. /**
  87552. * constructor
  87553. * @param name The name given to the material in order to identify it afterwards.
  87554. * @param scene The scene the material is used in.
  87555. */
  87556. constructor(name: string, scene: BABYLON.Scene);
  87557. /**
  87558. * Returns wehter or not the grid requires alpha blending.
  87559. */
  87560. needAlphaBlending(): boolean;
  87561. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87564. /**
  87565. * Dispose the material and its associated resources.
  87566. * @param forceDisposeEffect will also dispose the used effect when true
  87567. */
  87568. dispose(forceDisposeEffect?: boolean): void;
  87569. clone(name: string): GridMaterial;
  87570. serialize(): any;
  87571. getClassName(): string;
  87572. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87573. }
  87574. }
  87575. declare module BABYLON {
  87576. /** @hidden */
  87577. export var lavaPixelShader: {
  87578. name: string;
  87579. shader: string;
  87580. };
  87581. }
  87582. declare module BABYLON {
  87583. /** @hidden */
  87584. export var lavaVertexShader: {
  87585. name: string;
  87586. shader: string;
  87587. };
  87588. }
  87589. declare module BABYLON {
  87590. export class LavaMaterial extends BABYLON.PushMaterial {
  87591. private _diffuseTexture;
  87592. diffuseTexture: BABYLON.BaseTexture;
  87593. noiseTexture: BABYLON.BaseTexture;
  87594. fogColor: BABYLON.Color3;
  87595. speed: number;
  87596. movingSpeed: number;
  87597. lowFrequencySpeed: number;
  87598. fogDensity: number;
  87599. private _lastTime;
  87600. diffuseColor: BABYLON.Color3;
  87601. private _disableLighting;
  87602. disableLighting: boolean;
  87603. private _unlit;
  87604. unlit: boolean;
  87605. private _maxSimultaneousLights;
  87606. maxSimultaneousLights: number;
  87607. private _scaledDiffuse;
  87608. constructor(name: string, scene: BABYLON.Scene);
  87609. needAlphaBlending(): boolean;
  87610. needAlphaTesting(): boolean;
  87611. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87612. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87613. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87614. getAnimatables(): BABYLON.IAnimatable[];
  87615. getActiveTextures(): BABYLON.BaseTexture[];
  87616. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87617. dispose(forceDisposeEffect?: boolean): void;
  87618. clone(name: string): LavaMaterial;
  87619. serialize(): any;
  87620. getClassName(): string;
  87621. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87622. }
  87623. }
  87624. declare module BABYLON {
  87625. /** @hidden */
  87626. export var mixPixelShader: {
  87627. name: string;
  87628. shader: string;
  87629. };
  87630. }
  87631. declare module BABYLON {
  87632. /** @hidden */
  87633. export var mixVertexShader: {
  87634. name: string;
  87635. shader: string;
  87636. };
  87637. }
  87638. declare module BABYLON {
  87639. export class MixMaterial extends BABYLON.PushMaterial {
  87640. /**
  87641. * Mix textures
  87642. */
  87643. private _mixTexture1;
  87644. mixTexture1: BABYLON.BaseTexture;
  87645. private _mixTexture2;
  87646. mixTexture2: BABYLON.BaseTexture;
  87647. /**
  87648. * Diffuse textures
  87649. */
  87650. private _diffuseTexture1;
  87651. diffuseTexture1: BABYLON.Texture;
  87652. private _diffuseTexture2;
  87653. diffuseTexture2: BABYLON.Texture;
  87654. private _diffuseTexture3;
  87655. diffuseTexture3: BABYLON.Texture;
  87656. private _diffuseTexture4;
  87657. diffuseTexture4: BABYLON.Texture;
  87658. private _diffuseTexture5;
  87659. diffuseTexture5: BABYLON.Texture;
  87660. private _diffuseTexture6;
  87661. diffuseTexture6: BABYLON.Texture;
  87662. private _diffuseTexture7;
  87663. diffuseTexture7: BABYLON.Texture;
  87664. private _diffuseTexture8;
  87665. diffuseTexture8: BABYLON.Texture;
  87666. /**
  87667. * Uniforms
  87668. */
  87669. diffuseColor: BABYLON.Color3;
  87670. specularColor: BABYLON.Color3;
  87671. specularPower: number;
  87672. private _disableLighting;
  87673. disableLighting: boolean;
  87674. private _maxSimultaneousLights;
  87675. maxSimultaneousLights: number;
  87676. constructor(name: string, scene: BABYLON.Scene);
  87677. needAlphaBlending(): boolean;
  87678. needAlphaTesting(): boolean;
  87679. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87680. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87681. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87682. getAnimatables(): BABYLON.IAnimatable[];
  87683. getActiveTextures(): BABYLON.BaseTexture[];
  87684. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87685. dispose(forceDisposeEffect?: boolean): void;
  87686. clone(name: string): MixMaterial;
  87687. serialize(): any;
  87688. getClassName(): string;
  87689. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /** @hidden */
  87694. export var normalPixelShader: {
  87695. name: string;
  87696. shader: string;
  87697. };
  87698. }
  87699. declare module BABYLON {
  87700. /** @hidden */
  87701. export var normalVertexShader: {
  87702. name: string;
  87703. shader: string;
  87704. };
  87705. }
  87706. declare module BABYLON {
  87707. export class NormalMaterial extends BABYLON.PushMaterial {
  87708. private _diffuseTexture;
  87709. diffuseTexture: BABYLON.BaseTexture;
  87710. diffuseColor: BABYLON.Color3;
  87711. private _disableLighting;
  87712. disableLighting: boolean;
  87713. private _maxSimultaneousLights;
  87714. maxSimultaneousLights: number;
  87715. constructor(name: string, scene: BABYLON.Scene);
  87716. needAlphaBlending(): boolean;
  87717. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87718. needAlphaTesting(): boolean;
  87719. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87720. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87721. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87722. getAnimatables(): BABYLON.IAnimatable[];
  87723. getActiveTextures(): BABYLON.BaseTexture[];
  87724. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87725. dispose(forceDisposeEffect?: boolean): void;
  87726. clone(name: string): NormalMaterial;
  87727. serialize(): any;
  87728. getClassName(): string;
  87729. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87730. }
  87731. }
  87732. declare module BABYLON {
  87733. /** @hidden */
  87734. export var shadowOnlyPixelShader: {
  87735. name: string;
  87736. shader: string;
  87737. };
  87738. }
  87739. declare module BABYLON {
  87740. /** @hidden */
  87741. export var shadowOnlyVertexShader: {
  87742. name: string;
  87743. shader: string;
  87744. };
  87745. }
  87746. declare module BABYLON {
  87747. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87748. private _activeLight;
  87749. private _needAlphaBlending;
  87750. constructor(name: string, scene: BABYLON.Scene);
  87751. shadowColor: BABYLON.Color3;
  87752. needAlphaBlending(): boolean;
  87753. needAlphaTesting(): boolean;
  87754. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87755. get activeLight(): BABYLON.IShadowLight;
  87756. set activeLight(light: BABYLON.IShadowLight);
  87757. private _getFirstShadowLightForMesh;
  87758. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87759. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87760. clone(name: string): ShadowOnlyMaterial;
  87761. serialize(): any;
  87762. getClassName(): string;
  87763. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87764. }
  87765. }
  87766. declare module BABYLON {
  87767. /** @hidden */
  87768. export var simplePixelShader: {
  87769. name: string;
  87770. shader: string;
  87771. };
  87772. }
  87773. declare module BABYLON {
  87774. /** @hidden */
  87775. export var simpleVertexShader: {
  87776. name: string;
  87777. shader: string;
  87778. };
  87779. }
  87780. declare module BABYLON {
  87781. export class SimpleMaterial extends BABYLON.PushMaterial {
  87782. private _diffuseTexture;
  87783. diffuseTexture: BABYLON.BaseTexture;
  87784. diffuseColor: BABYLON.Color3;
  87785. private _disableLighting;
  87786. disableLighting: boolean;
  87787. private _maxSimultaneousLights;
  87788. maxSimultaneousLights: number;
  87789. constructor(name: string, scene: BABYLON.Scene);
  87790. needAlphaBlending(): boolean;
  87791. needAlphaTesting(): boolean;
  87792. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87793. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87794. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87795. getAnimatables(): BABYLON.IAnimatable[];
  87796. getActiveTextures(): BABYLON.BaseTexture[];
  87797. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87798. dispose(forceDisposeEffect?: boolean): void;
  87799. clone(name: string): SimpleMaterial;
  87800. serialize(): any;
  87801. getClassName(): string;
  87802. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87803. }
  87804. }
  87805. declare module BABYLON {
  87806. /** @hidden */
  87807. export var skyPixelShader: {
  87808. name: string;
  87809. shader: string;
  87810. };
  87811. }
  87812. declare module BABYLON {
  87813. /** @hidden */
  87814. export var skyVertexShader: {
  87815. name: string;
  87816. shader: string;
  87817. };
  87818. }
  87819. declare module BABYLON {
  87820. /**
  87821. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87822. * @see https://doc.babylonjs.com/extensions/sky
  87823. */
  87824. export class SkyMaterial extends BABYLON.PushMaterial {
  87825. /**
  87826. * Defines the overall luminance of sky in interval ]0, 1[.
  87827. */
  87828. luminance: number;
  87829. /**
  87830. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87831. */
  87832. turbidity: number;
  87833. /**
  87834. * Defines the sky appearance (light intensity).
  87835. */
  87836. rayleigh: number;
  87837. /**
  87838. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87839. */
  87840. mieCoefficient: number;
  87841. /**
  87842. * Defines the amount of haze particles following the Mie scattering theory.
  87843. */
  87844. mieDirectionalG: number;
  87845. /**
  87846. * Defines the distance of the sun according to the active scene camera.
  87847. */
  87848. distance: number;
  87849. /**
  87850. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87851. * "inclined".
  87852. */
  87853. inclination: number;
  87854. /**
  87855. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87856. * an object direction and a reference direction.
  87857. */
  87858. azimuth: number;
  87859. /**
  87860. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87861. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87862. */
  87863. sunPosition: BABYLON.Vector3;
  87864. /**
  87865. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87866. * .sunPosition property.
  87867. */
  87868. useSunPosition: boolean;
  87869. /**
  87870. * Defines an offset vector used to get a horizon offset.
  87871. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87872. */
  87873. cameraOffset: BABYLON.Vector3;
  87874. private _cameraPosition;
  87875. /**
  87876. * Instantiates a new sky material.
  87877. * This material allows to create dynamic and texture free
  87878. * effects for skyboxes by taking care of the atmosphere state.
  87879. * @see https://doc.babylonjs.com/extensions/sky
  87880. * @param name Define the name of the material in the scene
  87881. * @param scene Define the scene the material belong to
  87882. */
  87883. constructor(name: string, scene: BABYLON.Scene);
  87884. /**
  87885. * Specifies if the material will require alpha blending
  87886. * @returns a boolean specifying if alpha blending is needed
  87887. */
  87888. needAlphaBlending(): boolean;
  87889. /**
  87890. * Specifies if this material should be rendered in alpha test mode
  87891. * @returns false as the sky material doesn't need alpha testing.
  87892. */
  87893. needAlphaTesting(): boolean;
  87894. /**
  87895. * Get the texture used for alpha test purpose.
  87896. * @returns null as the sky material has no texture.
  87897. */
  87898. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87899. /**
  87900. * Get if the submesh is ready to be used and all its information available.
  87901. * Child classes can use it to update shaders
  87902. * @param mesh defines the mesh to check
  87903. * @param subMesh defines which submesh to check
  87904. * @param useInstances specifies that instances should be used
  87905. * @returns a boolean indicating that the submesh is ready or not
  87906. */
  87907. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87908. /**
  87909. * Binds the submesh to this material by preparing the effect and shader to draw
  87910. * @param world defines the world transformation matrix
  87911. * @param mesh defines the mesh containing the submesh
  87912. * @param subMesh defines the submesh to bind the material to
  87913. */
  87914. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87915. /**
  87916. * Get the list of animatables in the material.
  87917. * @returns the list of animatables object used in the material
  87918. */
  87919. getAnimatables(): BABYLON.IAnimatable[];
  87920. /**
  87921. * Disposes the material
  87922. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87923. */
  87924. dispose(forceDisposeEffect?: boolean): void;
  87925. /**
  87926. * Makes a duplicate of the material, and gives it a new name
  87927. * @param name defines the new name for the duplicated material
  87928. * @returns the cloned material
  87929. */
  87930. clone(name: string): SkyMaterial;
  87931. /**
  87932. * Serializes this material in a JSON representation
  87933. * @returns the serialized material object
  87934. */
  87935. serialize(): any;
  87936. /**
  87937. * Gets the current class name of the material e.g. "SkyMaterial"
  87938. * Mainly use in serialization.
  87939. * @returns the class name
  87940. */
  87941. getClassName(): string;
  87942. /**
  87943. * Creates a sky material from parsed material data
  87944. * @param source defines the JSON representation of the material
  87945. * @param scene defines the hosting scene
  87946. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87947. * @returns a new sky material
  87948. */
  87949. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87950. }
  87951. }
  87952. declare module BABYLON {
  87953. /** @hidden */
  87954. export var terrainPixelShader: {
  87955. name: string;
  87956. shader: string;
  87957. };
  87958. }
  87959. declare module BABYLON {
  87960. /** @hidden */
  87961. export var terrainVertexShader: {
  87962. name: string;
  87963. shader: string;
  87964. };
  87965. }
  87966. declare module BABYLON {
  87967. export class TerrainMaterial extends BABYLON.PushMaterial {
  87968. private _mixTexture;
  87969. mixTexture: BABYLON.BaseTexture;
  87970. private _diffuseTexture1;
  87971. diffuseTexture1: BABYLON.Texture;
  87972. private _diffuseTexture2;
  87973. diffuseTexture2: BABYLON.Texture;
  87974. private _diffuseTexture3;
  87975. diffuseTexture3: BABYLON.Texture;
  87976. private _bumpTexture1;
  87977. bumpTexture1: BABYLON.Texture;
  87978. private _bumpTexture2;
  87979. bumpTexture2: BABYLON.Texture;
  87980. private _bumpTexture3;
  87981. bumpTexture3: BABYLON.Texture;
  87982. diffuseColor: BABYLON.Color3;
  87983. specularColor: BABYLON.Color3;
  87984. specularPower: number;
  87985. private _disableLighting;
  87986. disableLighting: boolean;
  87987. private _maxSimultaneousLights;
  87988. maxSimultaneousLights: number;
  87989. constructor(name: string, scene: BABYLON.Scene);
  87990. needAlphaBlending(): boolean;
  87991. needAlphaTesting(): boolean;
  87992. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87993. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87994. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87995. getAnimatables(): BABYLON.IAnimatable[];
  87996. getActiveTextures(): BABYLON.BaseTexture[];
  87997. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87998. dispose(forceDisposeEffect?: boolean): void;
  87999. clone(name: string): TerrainMaterial;
  88000. serialize(): any;
  88001. getClassName(): string;
  88002. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  88003. }
  88004. }
  88005. declare module BABYLON {
  88006. /** @hidden */
  88007. export var triplanarPixelShader: {
  88008. name: string;
  88009. shader: string;
  88010. };
  88011. }
  88012. declare module BABYLON {
  88013. /** @hidden */
  88014. export var triplanarVertexShader: {
  88015. name: string;
  88016. shader: string;
  88017. };
  88018. }
  88019. declare module BABYLON {
  88020. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  88021. mixTexture: BABYLON.BaseTexture;
  88022. private _diffuseTextureX;
  88023. diffuseTextureX: BABYLON.BaseTexture;
  88024. private _diffuseTextureY;
  88025. diffuseTextureY: BABYLON.BaseTexture;
  88026. private _diffuseTextureZ;
  88027. diffuseTextureZ: BABYLON.BaseTexture;
  88028. private _normalTextureX;
  88029. normalTextureX: BABYLON.BaseTexture;
  88030. private _normalTextureY;
  88031. normalTextureY: BABYLON.BaseTexture;
  88032. private _normalTextureZ;
  88033. normalTextureZ: BABYLON.BaseTexture;
  88034. tileSize: number;
  88035. diffuseColor: BABYLON.Color3;
  88036. specularColor: BABYLON.Color3;
  88037. specularPower: number;
  88038. private _disableLighting;
  88039. disableLighting: boolean;
  88040. private _maxSimultaneousLights;
  88041. maxSimultaneousLights: number;
  88042. constructor(name: string, scene: BABYLON.Scene);
  88043. needAlphaBlending(): boolean;
  88044. needAlphaTesting(): boolean;
  88045. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88046. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88047. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88048. getAnimatables(): BABYLON.IAnimatable[];
  88049. getActiveTextures(): BABYLON.BaseTexture[];
  88050. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88051. dispose(forceDisposeEffect?: boolean): void;
  88052. clone(name: string): TriPlanarMaterial;
  88053. serialize(): any;
  88054. getClassName(): string;
  88055. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  88056. }
  88057. }
  88058. declare module BABYLON {
  88059. /** @hidden */
  88060. export var waterPixelShader: {
  88061. name: string;
  88062. shader: string;
  88063. };
  88064. }
  88065. declare module BABYLON {
  88066. /** @hidden */
  88067. export var waterVertexShader: {
  88068. name: string;
  88069. shader: string;
  88070. };
  88071. }
  88072. declare module BABYLON {
  88073. export class WaterMaterial extends BABYLON.PushMaterial {
  88074. renderTargetSize: BABYLON.Vector2;
  88075. private _bumpTexture;
  88076. bumpTexture: BABYLON.BaseTexture;
  88077. diffuseColor: BABYLON.Color3;
  88078. specularColor: BABYLON.Color3;
  88079. specularPower: number;
  88080. private _disableLighting;
  88081. disableLighting: boolean;
  88082. private _maxSimultaneousLights;
  88083. maxSimultaneousLights: number;
  88084. /**
  88085. * Defines the wind force.
  88086. */
  88087. windForce: number;
  88088. /**
  88089. * Defines the direction of the wind in the plane (X, Z).
  88090. */
  88091. windDirection: BABYLON.Vector2;
  88092. /**
  88093. * Defines the height of the waves.
  88094. */
  88095. waveHeight: number;
  88096. /**
  88097. * Defines the bump height related to the bump map.
  88098. */
  88099. bumpHeight: number;
  88100. /**
  88101. * Defines wether or not: to add a smaller moving bump to less steady waves.
  88102. */
  88103. private _bumpSuperimpose;
  88104. bumpSuperimpose: boolean;
  88105. /**
  88106. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  88107. */
  88108. private _fresnelSeparate;
  88109. fresnelSeparate: boolean;
  88110. /**
  88111. * Defines wether or not bump Wwves modify the reflection.
  88112. */
  88113. private _bumpAffectsReflection;
  88114. bumpAffectsReflection: boolean;
  88115. /**
  88116. * Defines the water color blended with the refraction (near).
  88117. */
  88118. waterColor: BABYLON.Color3;
  88119. /**
  88120. * Defines the blend factor related to the water color.
  88121. */
  88122. colorBlendFactor: number;
  88123. /**
  88124. * Defines the water color blended with the reflection (far).
  88125. */
  88126. waterColor2: BABYLON.Color3;
  88127. /**
  88128. * Defines the blend factor related to the water color (reflection, far).
  88129. */
  88130. colorBlendFactor2: number;
  88131. /**
  88132. * Defines the maximum length of a wave.
  88133. */
  88134. waveLength: number;
  88135. /**
  88136. * Defines the waves speed.
  88137. */
  88138. waveSpeed: number;
  88139. /**
  88140. * 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.
  88141. */
  88142. waveCount: number;
  88143. /**
  88144. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  88145. * will avoid calculating useless pixels in the pixel shader of the water material.
  88146. */
  88147. disableClipPlane: boolean;
  88148. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  88149. private _mesh;
  88150. private _refractionRTT;
  88151. private _reflectionRTT;
  88152. private _reflectionTransform;
  88153. private _lastTime;
  88154. private _lastDeltaTime;
  88155. private _useLogarithmicDepth;
  88156. private _waitingRenderList;
  88157. private _imageProcessingConfiguration;
  88158. private _imageProcessingObserver;
  88159. /**
  88160. * Gets a boolean indicating that current material needs to register RTT
  88161. */
  88162. get hasRenderTargetTextures(): boolean;
  88163. /**
  88164. * Constructor
  88165. */
  88166. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88167. get useLogarithmicDepth(): boolean;
  88168. set useLogarithmicDepth(value: boolean);
  88169. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88170. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88171. addToRenderList(node: any): void;
  88172. enableRenderTargets(enable: boolean): void;
  88173. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88174. get renderTargetsEnabled(): boolean;
  88175. needAlphaBlending(): boolean;
  88176. needAlphaTesting(): boolean;
  88177. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88178. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88179. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88180. private _createRenderTargets;
  88181. getAnimatables(): BABYLON.IAnimatable[];
  88182. getActiveTextures(): BABYLON.BaseTexture[];
  88183. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88184. dispose(forceDisposeEffect?: boolean): void;
  88185. clone(name: string): WaterMaterial;
  88186. serialize(): any;
  88187. getClassName(): string;
  88188. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88189. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88190. }
  88191. }
  88192. declare module BABYLON {
  88193. /** @hidden */
  88194. export var asciiartPixelShader: {
  88195. name: string;
  88196. shader: string;
  88197. };
  88198. }
  88199. declare module BABYLON {
  88200. /**
  88201. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88202. *
  88203. * It basically takes care rendering the font front the given font size to a texture.
  88204. * This is used later on in the postprocess.
  88205. */
  88206. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88207. private _font;
  88208. private _text;
  88209. private _charSize;
  88210. /**
  88211. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88212. */
  88213. get charSize(): number;
  88214. /**
  88215. * Create a new instance of the Ascii Art FontTexture class
  88216. * @param name the name of the texture
  88217. * @param font the font to use, use the W3C CSS notation
  88218. * @param text the caracter set to use in the rendering.
  88219. * @param scene the scene that owns the texture
  88220. */
  88221. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88222. /**
  88223. * Gets the max char width of a font.
  88224. * @param font the font to use, use the W3C CSS notation
  88225. * @return the max char width
  88226. */
  88227. private getFontWidth;
  88228. /**
  88229. * Gets the max char height of a font.
  88230. * @param font the font to use, use the W3C CSS notation
  88231. * @return the max char height
  88232. */
  88233. private getFontHeight;
  88234. /**
  88235. * Clones the current AsciiArtTexture.
  88236. * @return the clone of the texture.
  88237. */
  88238. clone(): AsciiArtFontTexture;
  88239. /**
  88240. * Parses a json object representing the texture and returns an instance of it.
  88241. * @param source the source JSON representation
  88242. * @param scene the scene to create the texture for
  88243. * @return the parsed texture
  88244. */
  88245. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88246. }
  88247. /**
  88248. * Option available in the Ascii Art Post Process.
  88249. */
  88250. export interface IAsciiArtPostProcessOptions {
  88251. /**
  88252. * The font to use following the w3c font definition.
  88253. */
  88254. font?: string;
  88255. /**
  88256. * The character set to use in the postprocess.
  88257. */
  88258. characterSet?: string;
  88259. /**
  88260. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88261. * This number is defined between 0 and 1;
  88262. */
  88263. mixToTile?: number;
  88264. /**
  88265. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88266. * This number is defined between 0 and 1;
  88267. */
  88268. mixToNormal?: number;
  88269. }
  88270. /**
  88271. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88272. *
  88273. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88274. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88275. */
  88276. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88277. /**
  88278. * The font texture used to render the char in the post process.
  88279. */
  88280. private _asciiArtFontTexture;
  88281. /**
  88282. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88283. * This number is defined between 0 and 1;
  88284. */
  88285. mixToTile: number;
  88286. /**
  88287. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88288. * This number is defined between 0 and 1;
  88289. */
  88290. mixToNormal: number;
  88291. /**
  88292. * Instantiates a new Ascii Art Post Process.
  88293. * @param name the name to give to the postprocess
  88294. * @camera the camera to apply the post process to.
  88295. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88296. */
  88297. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88298. }
  88299. }
  88300. declare module BABYLON {
  88301. /** @hidden */
  88302. export var digitalrainPixelShader: {
  88303. name: string;
  88304. shader: string;
  88305. };
  88306. }
  88307. declare module BABYLON {
  88308. /**
  88309. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88310. *
  88311. * It basically takes care rendering the font front the given font size to a texture.
  88312. * This is used later on in the postprocess.
  88313. */
  88314. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88315. private _font;
  88316. private _text;
  88317. private _charSize;
  88318. /**
  88319. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88320. */
  88321. get charSize(): number;
  88322. /**
  88323. * Create a new instance of the Digital Rain FontTexture class
  88324. * @param name the name of the texture
  88325. * @param font the font to use, use the W3C CSS notation
  88326. * @param text the caracter set to use in the rendering.
  88327. * @param scene the scene that owns the texture
  88328. */
  88329. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88330. /**
  88331. * Gets the max char width of a font.
  88332. * @param font the font to use, use the W3C CSS notation
  88333. * @return the max char width
  88334. */
  88335. private getFontWidth;
  88336. /**
  88337. * Gets the max char height of a font.
  88338. * @param font the font to use, use the W3C CSS notation
  88339. * @return the max char height
  88340. */
  88341. private getFontHeight;
  88342. /**
  88343. * Clones the current DigitalRainFontTexture.
  88344. * @return the clone of the texture.
  88345. */
  88346. clone(): DigitalRainFontTexture;
  88347. /**
  88348. * Parses a json object representing the texture and returns an instance of it.
  88349. * @param source the source JSON representation
  88350. * @param scene the scene to create the texture for
  88351. * @return the parsed texture
  88352. */
  88353. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88354. }
  88355. /**
  88356. * Option available in the Digital Rain Post Process.
  88357. */
  88358. export interface IDigitalRainPostProcessOptions {
  88359. /**
  88360. * The font to use following the w3c font definition.
  88361. */
  88362. font?: string;
  88363. /**
  88364. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88365. * This number is defined between 0 and 1;
  88366. */
  88367. mixToTile?: number;
  88368. /**
  88369. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88370. * This number is defined between 0 and 1;
  88371. */
  88372. mixToNormal?: number;
  88373. }
  88374. /**
  88375. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88376. *
  88377. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88378. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88379. */
  88380. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88381. /**
  88382. * The font texture used to render the char in the post process.
  88383. */
  88384. private _digitalRainFontTexture;
  88385. /**
  88386. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88387. * This number is defined between 0 and 1;
  88388. */
  88389. mixToTile: number;
  88390. /**
  88391. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88392. * This number is defined between 0 and 1;
  88393. */
  88394. mixToNormal: number;
  88395. /**
  88396. * Instantiates a new Digital Rain Post Process.
  88397. * @param name the name to give to the postprocess
  88398. * @camera the camera to apply the post process to.
  88399. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88400. */
  88401. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88402. }
  88403. }
  88404. declare module BABYLON {
  88405. /** @hidden */
  88406. export var brickProceduralTexturePixelShader: {
  88407. name: string;
  88408. shader: string;
  88409. };
  88410. }
  88411. declare module BABYLON {
  88412. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88413. private _numberOfBricksHeight;
  88414. private _numberOfBricksWidth;
  88415. private _jointColor;
  88416. private _brickColor;
  88417. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88418. updateShaderUniforms(): void;
  88419. get numberOfBricksHeight(): number;
  88420. set numberOfBricksHeight(value: number);
  88421. get numberOfBricksWidth(): number;
  88422. set numberOfBricksWidth(value: number);
  88423. get jointColor(): BABYLON.Color3;
  88424. set jointColor(value: BABYLON.Color3);
  88425. get brickColor(): BABYLON.Color3;
  88426. set brickColor(value: BABYLON.Color3);
  88427. /**
  88428. * Serializes this brick procedural texture
  88429. * @returns a serialized brick procedural texture object
  88430. */
  88431. serialize(): any;
  88432. /**
  88433. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88434. * @param parsedTexture defines parsed texture data
  88435. * @param scene defines the current scene
  88436. * @param rootUrl defines the root URL containing brick procedural texture information
  88437. * @returns a parsed Brick Procedural BABYLON.Texture
  88438. */
  88439. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88440. }
  88441. }
  88442. declare module BABYLON {
  88443. /** @hidden */
  88444. export var cloudProceduralTexturePixelShader: {
  88445. name: string;
  88446. shader: string;
  88447. };
  88448. }
  88449. declare module BABYLON {
  88450. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88451. private _skyColor;
  88452. private _cloudColor;
  88453. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88454. updateShaderUniforms(): void;
  88455. get skyColor(): BABYLON.Color4;
  88456. set skyColor(value: BABYLON.Color4);
  88457. get cloudColor(): BABYLON.Color4;
  88458. set cloudColor(value: BABYLON.Color4);
  88459. /**
  88460. * Serializes this cloud procedural texture
  88461. * @returns a serialized cloud procedural texture object
  88462. */
  88463. serialize(): any;
  88464. /**
  88465. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88466. * @param parsedTexture defines parsed texture data
  88467. * @param scene defines the current scene
  88468. * @param rootUrl defines the root URL containing cloud procedural texture information
  88469. * @returns a parsed Cloud Procedural BABYLON.Texture
  88470. */
  88471. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88472. }
  88473. }
  88474. declare module BABYLON {
  88475. /** @hidden */
  88476. export var fireProceduralTexturePixelShader: {
  88477. name: string;
  88478. shader: string;
  88479. };
  88480. }
  88481. declare module BABYLON {
  88482. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88483. private _time;
  88484. private _speed;
  88485. private _autoGenerateTime;
  88486. private _fireColors;
  88487. private _alphaThreshold;
  88488. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88489. updateShaderUniforms(): void;
  88490. render(useCameraPostProcess?: boolean): void;
  88491. static get PurpleFireColors(): BABYLON.Color3[];
  88492. static get GreenFireColors(): BABYLON.Color3[];
  88493. static get RedFireColors(): BABYLON.Color3[];
  88494. static get BlueFireColors(): BABYLON.Color3[];
  88495. get autoGenerateTime(): boolean;
  88496. set autoGenerateTime(value: boolean);
  88497. get fireColors(): BABYLON.Color3[];
  88498. set fireColors(value: BABYLON.Color3[]);
  88499. get time(): number;
  88500. set time(value: number);
  88501. get speed(): BABYLON.Vector2;
  88502. set speed(value: BABYLON.Vector2);
  88503. get alphaThreshold(): number;
  88504. set alphaThreshold(value: number);
  88505. /**
  88506. * Serializes this fire procedural texture
  88507. * @returns a serialized fire procedural texture object
  88508. */
  88509. serialize(): any;
  88510. /**
  88511. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88512. * @param parsedTexture defines parsed texture data
  88513. * @param scene defines the current scene
  88514. * @param rootUrl defines the root URL containing fire procedural texture information
  88515. * @returns a parsed Fire Procedural BABYLON.Texture
  88516. */
  88517. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88518. }
  88519. }
  88520. declare module BABYLON {
  88521. /** @hidden */
  88522. export var grassProceduralTexturePixelShader: {
  88523. name: string;
  88524. shader: string;
  88525. };
  88526. }
  88527. declare module BABYLON {
  88528. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88529. private _grassColors;
  88530. private _groundColor;
  88531. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88532. updateShaderUniforms(): void;
  88533. get grassColors(): BABYLON.Color3[];
  88534. set grassColors(value: BABYLON.Color3[]);
  88535. get groundColor(): BABYLON.Color3;
  88536. set groundColor(value: BABYLON.Color3);
  88537. /**
  88538. * Serializes this grass procedural texture
  88539. * @returns a serialized grass procedural texture object
  88540. */
  88541. serialize(): any;
  88542. /**
  88543. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88544. * @param parsedTexture defines parsed texture data
  88545. * @param scene defines the current scene
  88546. * @param rootUrl defines the root URL containing grass procedural texture information
  88547. * @returns a parsed Grass Procedural BABYLON.Texture
  88548. */
  88549. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88550. }
  88551. }
  88552. declare module BABYLON {
  88553. /** @hidden */
  88554. export var marbleProceduralTexturePixelShader: {
  88555. name: string;
  88556. shader: string;
  88557. };
  88558. }
  88559. declare module BABYLON {
  88560. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88561. private _numberOfTilesHeight;
  88562. private _numberOfTilesWidth;
  88563. private _amplitude;
  88564. private _jointColor;
  88565. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88566. updateShaderUniforms(): void;
  88567. get numberOfTilesHeight(): number;
  88568. set numberOfTilesHeight(value: number);
  88569. get amplitude(): number;
  88570. set amplitude(value: number);
  88571. get numberOfTilesWidth(): number;
  88572. set numberOfTilesWidth(value: number);
  88573. get jointColor(): BABYLON.Color3;
  88574. set jointColor(value: BABYLON.Color3);
  88575. /**
  88576. * Serializes this marble procedural texture
  88577. * @returns a serialized marble procedural texture object
  88578. */
  88579. serialize(): any;
  88580. /**
  88581. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88582. * @param parsedTexture defines parsed texture data
  88583. * @param scene defines the current scene
  88584. * @param rootUrl defines the root URL containing marble procedural texture information
  88585. * @returns a parsed Marble Procedural BABYLON.Texture
  88586. */
  88587. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88588. }
  88589. }
  88590. declare module BABYLON {
  88591. /** @hidden */
  88592. export var normalMapProceduralTexturePixelShader: {
  88593. name: string;
  88594. shader: string;
  88595. };
  88596. }
  88597. declare module BABYLON {
  88598. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88599. private _baseTexture;
  88600. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88601. updateShaderUniforms(): void;
  88602. render(useCameraPostProcess?: boolean): void;
  88603. resize(size: any, generateMipMaps: any): void;
  88604. get baseTexture(): BABYLON.Texture;
  88605. set baseTexture(texture: BABYLON.Texture);
  88606. /**
  88607. * Serializes this normal map procedural texture
  88608. * @returns a serialized normal map procedural texture object
  88609. */
  88610. serialize(): any;
  88611. /**
  88612. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88613. * @param parsedTexture defines parsed texture data
  88614. * @param scene defines the current scene
  88615. * @param rootUrl defines the root URL containing normal map procedural texture information
  88616. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88617. */
  88618. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88619. }
  88620. }
  88621. declare module BABYLON {
  88622. /** @hidden */
  88623. export var perlinNoiseProceduralTexturePixelShader: {
  88624. name: string;
  88625. shader: string;
  88626. };
  88627. }
  88628. declare module BABYLON {
  88629. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88630. time: number;
  88631. timeScale: number;
  88632. translationSpeed: number;
  88633. private _currentTranslation;
  88634. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88635. updateShaderUniforms(): void;
  88636. render(useCameraPostProcess?: boolean): void;
  88637. resize(size: any, generateMipMaps: any): void;
  88638. /**
  88639. * Serializes this perlin noise procedural texture
  88640. * @returns a serialized perlin noise procedural texture object
  88641. */
  88642. serialize(): any;
  88643. /**
  88644. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88645. * @param parsedTexture defines parsed texture data
  88646. * @param scene defines the current scene
  88647. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88648. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88649. */
  88650. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88651. }
  88652. }
  88653. declare module BABYLON {
  88654. /** @hidden */
  88655. export var roadProceduralTexturePixelShader: {
  88656. name: string;
  88657. shader: string;
  88658. };
  88659. }
  88660. declare module BABYLON {
  88661. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88662. private _roadColor;
  88663. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88664. updateShaderUniforms(): void;
  88665. get roadColor(): BABYLON.Color3;
  88666. set roadColor(value: BABYLON.Color3);
  88667. /**
  88668. * Serializes this road procedural texture
  88669. * @returns a serialized road procedural texture object
  88670. */
  88671. serialize(): any;
  88672. /**
  88673. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88674. * @param parsedTexture defines parsed texture data
  88675. * @param scene defines the current scene
  88676. * @param rootUrl defines the root URL containing road procedural texture information
  88677. * @returns a parsed Road Procedural BABYLON.Texture
  88678. */
  88679. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88680. }
  88681. }
  88682. declare module BABYLON {
  88683. /** @hidden */
  88684. export var starfieldProceduralTexturePixelShader: {
  88685. name: string;
  88686. shader: string;
  88687. };
  88688. }
  88689. declare module BABYLON {
  88690. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88691. private _time;
  88692. private _alpha;
  88693. private _beta;
  88694. private _zoom;
  88695. private _formuparam;
  88696. private _stepsize;
  88697. private _tile;
  88698. private _brightness;
  88699. private _darkmatter;
  88700. private _distfading;
  88701. private _saturation;
  88702. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88703. updateShaderUniforms(): void;
  88704. get time(): number;
  88705. set time(value: number);
  88706. get alpha(): number;
  88707. set alpha(value: number);
  88708. get beta(): number;
  88709. set beta(value: number);
  88710. get formuparam(): number;
  88711. set formuparam(value: number);
  88712. get stepsize(): number;
  88713. set stepsize(value: number);
  88714. get zoom(): number;
  88715. set zoom(value: number);
  88716. get tile(): number;
  88717. set tile(value: number);
  88718. get brightness(): number;
  88719. set brightness(value: number);
  88720. get darkmatter(): number;
  88721. set darkmatter(value: number);
  88722. get distfading(): number;
  88723. set distfading(value: number);
  88724. get saturation(): number;
  88725. set saturation(value: number);
  88726. /**
  88727. * Serializes this starfield procedural texture
  88728. * @returns a serialized starfield procedural texture object
  88729. */
  88730. serialize(): any;
  88731. /**
  88732. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88733. * @param parsedTexture defines parsed texture data
  88734. * @param scene defines the current scene
  88735. * @param rootUrl defines the root URL containing startfield procedural texture information
  88736. * @returns a parsed Starfield Procedural BABYLON.Texture
  88737. */
  88738. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88739. }
  88740. }
  88741. declare module BABYLON {
  88742. /** @hidden */
  88743. export var woodProceduralTexturePixelShader: {
  88744. name: string;
  88745. shader: string;
  88746. };
  88747. }
  88748. declare module BABYLON {
  88749. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88750. private _ampScale;
  88751. private _woodColor;
  88752. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88753. updateShaderUniforms(): void;
  88754. get ampScale(): number;
  88755. set ampScale(value: number);
  88756. get woodColor(): BABYLON.Color3;
  88757. set woodColor(value: BABYLON.Color3);
  88758. /**
  88759. * Serializes this wood procedural texture
  88760. * @returns a serialized wood procedural texture object
  88761. */
  88762. serialize(): any;
  88763. /**
  88764. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88765. * @param parsedTexture defines parsed texture data
  88766. * @param scene defines the current scene
  88767. * @param rootUrl defines the root URL containing wood procedural texture information
  88768. * @returns a parsed Wood Procedural BABYLON.Texture
  88769. */
  88770. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88771. }
  88772. }