documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970
  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 parameter
  9515. * @returns the trigger parameter
  9516. */
  9517. getTriggerParameter(): any;
  9518. /**
  9519. * Sets the trigger parameter
  9520. * @param value defines the new trigger parameter
  9521. */
  9522. setTriggerParameter(value: any): void;
  9523. /**
  9524. * Internal only - executes current action event
  9525. * @hidden
  9526. */
  9527. _executeCurrent(evt?: ActionEvent): void;
  9528. /**
  9529. * Execute placeholder for child classes
  9530. * @param evt optional action event
  9531. */
  9532. execute(evt?: ActionEvent): void;
  9533. /**
  9534. * Skips to next active action
  9535. */
  9536. skipToNextActiveAction(): void;
  9537. /**
  9538. * Adds action to chain of actions, may be a DoNothingAction
  9539. * @param action defines the next action to execute
  9540. * @returns The action passed in
  9541. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9542. */
  9543. then(action: Action): Action;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. _getProperty(propertyPath: string): string;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. _getEffectiveTarget(target: any, propertyPath: string): any;
  9554. /**
  9555. * Serialize placeholder for child classes
  9556. * @param parent of child
  9557. * @returns the serialized object
  9558. */
  9559. serialize(parent: any): any;
  9560. /**
  9561. * Internal only called by serialize
  9562. * @hidden
  9563. */
  9564. protected _serialize(serializedAction: any, parent?: any): any;
  9565. /**
  9566. * Internal only
  9567. * @hidden
  9568. */
  9569. static _SerializeValueAsString: (value: any) => string;
  9570. /**
  9571. * Internal only
  9572. * @hidden
  9573. */
  9574. static _GetTargetProperty: (target: Scene | Node) => {
  9575. name: string;
  9576. targetType: string;
  9577. value: string;
  9578. };
  9579. }
  9580. }
  9581. declare module BABYLON {
  9582. /**
  9583. * A Condition applied to an Action
  9584. */
  9585. export class Condition {
  9586. /**
  9587. * Internal only - manager for action
  9588. * @hidden
  9589. */
  9590. _actionManager: ActionManager;
  9591. /**
  9592. * Internal only
  9593. * @hidden
  9594. */
  9595. _evaluationId: number;
  9596. /**
  9597. * Internal only
  9598. * @hidden
  9599. */
  9600. _currentResult: boolean;
  9601. /**
  9602. * Creates a new Condition
  9603. * @param actionManager the manager of the action the condition is applied to
  9604. */
  9605. constructor(actionManager: ActionManager);
  9606. /**
  9607. * Check if the current condition is valid
  9608. * @returns a boolean
  9609. */
  9610. isValid(): boolean;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. _getProperty(propertyPath: string): string;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. _getEffectiveTarget(target: any, propertyPath: string): any;
  9621. /**
  9622. * Serialize placeholder for child classes
  9623. * @returns the serialized object
  9624. */
  9625. serialize(): any;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. protected _serialize(serializedCondition: any): any;
  9631. }
  9632. /**
  9633. * Defines specific conditional operators as extensions of Condition
  9634. */
  9635. export class ValueCondition extends Condition {
  9636. /** path to specify the property of the target the conditional operator uses */
  9637. propertyPath: string;
  9638. /** the value compared by the conditional operator against the current value of the property */
  9639. value: any;
  9640. /** the conditional operator, default ValueCondition.IsEqual */
  9641. operator: number;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private static _IsEqual;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. private static _IsDifferent;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. private static _IsGreater;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private static _IsLesser;
  9662. /**
  9663. * returns the number for IsEqual
  9664. */
  9665. static get IsEqual(): number;
  9666. /**
  9667. * Returns the number for IsDifferent
  9668. */
  9669. static get IsDifferent(): number;
  9670. /**
  9671. * Returns the number for IsGreater
  9672. */
  9673. static get IsGreater(): number;
  9674. /**
  9675. * Returns the number for IsLesser
  9676. */
  9677. static get IsLesser(): number;
  9678. /**
  9679. * Internal only The action manager for the condition
  9680. * @hidden
  9681. */
  9682. _actionManager: ActionManager;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. private _target;
  9688. /**
  9689. * Internal only
  9690. * @hidden
  9691. */
  9692. private _effectiveTarget;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. private _property;
  9698. /**
  9699. * Creates a new ValueCondition
  9700. * @param actionManager manager for the action the condition applies to
  9701. * @param target for the action
  9702. * @param propertyPath path to specify the property of the target the conditional operator uses
  9703. * @param value the value compared by the conditional operator against the current value of the property
  9704. * @param operator the conditional operator, default ValueCondition.IsEqual
  9705. */
  9706. constructor(actionManager: ActionManager, target: any,
  9707. /** path to specify the property of the target the conditional operator uses */
  9708. propertyPath: string,
  9709. /** the value compared by the conditional operator against the current value of the property */
  9710. value: any,
  9711. /** the conditional operator, default ValueCondition.IsEqual */
  9712. operator?: number);
  9713. /**
  9714. * Compares the given value with the property value for the specified conditional operator
  9715. * @returns the result of the comparison
  9716. */
  9717. isValid(): boolean;
  9718. /**
  9719. * Serialize the ValueCondition into a JSON compatible object
  9720. * @returns serialization object
  9721. */
  9722. serialize(): any;
  9723. /**
  9724. * Gets the name of the conditional operator for the ValueCondition
  9725. * @param operator the conditional operator
  9726. * @returns the name
  9727. */
  9728. static GetOperatorName(operator: number): string;
  9729. }
  9730. /**
  9731. * Defines a predicate condition as an extension of Condition
  9732. */
  9733. export class PredicateCondition extends Condition {
  9734. /** defines the predicate function used to validate the condition */
  9735. predicate: () => boolean;
  9736. /**
  9737. * Internal only - manager for action
  9738. * @hidden
  9739. */
  9740. _actionManager: ActionManager;
  9741. /**
  9742. * Creates a new PredicateCondition
  9743. * @param actionManager manager for the action the condition applies to
  9744. * @param predicate defines the predicate function used to validate the condition
  9745. */
  9746. constructor(actionManager: ActionManager,
  9747. /** defines the predicate function used to validate the condition */
  9748. predicate: () => boolean);
  9749. /**
  9750. * @returns the validity of the predicate condition
  9751. */
  9752. isValid(): boolean;
  9753. }
  9754. /**
  9755. * Defines a state condition as an extension of Condition
  9756. */
  9757. export class StateCondition extends Condition {
  9758. /** Value to compare with target state */
  9759. value: string;
  9760. /**
  9761. * Internal only - manager for action
  9762. * @hidden
  9763. */
  9764. _actionManager: ActionManager;
  9765. /**
  9766. * Internal only
  9767. * @hidden
  9768. */
  9769. private _target;
  9770. /**
  9771. * Creates a new StateCondition
  9772. * @param actionManager manager for the action the condition applies to
  9773. * @param target of the condition
  9774. * @param value to compare with target state
  9775. */
  9776. constructor(actionManager: ActionManager, target: any,
  9777. /** Value to compare with target state */
  9778. value: string);
  9779. /**
  9780. * Gets a boolean indicating if the current condition is met
  9781. * @returns the validity of the state
  9782. */
  9783. isValid(): boolean;
  9784. /**
  9785. * Serialize the StateCondition into a JSON compatible object
  9786. * @returns serialization object
  9787. */
  9788. serialize(): any;
  9789. }
  9790. }
  9791. declare module BABYLON {
  9792. /**
  9793. * This defines an action responsible to toggle a boolean once triggered.
  9794. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9795. */
  9796. export class SwitchBooleanAction extends Action {
  9797. /**
  9798. * The path to the boolean property in the target object
  9799. */
  9800. propertyPath: string;
  9801. private _target;
  9802. private _effectiveTarget;
  9803. private _property;
  9804. /**
  9805. * Instantiate the action
  9806. * @param triggerOptions defines the trigger options
  9807. * @param target defines the object containing the boolean
  9808. * @param propertyPath defines the path to the boolean property in the target object
  9809. * @param condition defines the trigger related conditions
  9810. */
  9811. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9812. /** @hidden */
  9813. _prepare(): void;
  9814. /**
  9815. * Execute the action toggle the boolean value.
  9816. */
  9817. execute(): void;
  9818. /**
  9819. * Serializes the actions and its related information.
  9820. * @param parent defines the object to serialize in
  9821. * @returns the serialized object
  9822. */
  9823. serialize(parent: any): any;
  9824. }
  9825. /**
  9826. * This defines an action responsible to set a the state field of the target
  9827. * to a desired value once triggered.
  9828. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9829. */
  9830. export class SetStateAction extends Action {
  9831. /**
  9832. * The value to store in the state field.
  9833. */
  9834. value: string;
  9835. private _target;
  9836. /**
  9837. * Instantiate the action
  9838. * @param triggerOptions defines the trigger options
  9839. * @param target defines the object containing the state property
  9840. * @param value defines the value to store in the state field
  9841. * @param condition defines the trigger related conditions
  9842. */
  9843. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9844. /**
  9845. * Execute the action and store the value on the target state property.
  9846. */
  9847. execute(): void;
  9848. /**
  9849. * Serializes the actions and its related information.
  9850. * @param parent defines the object to serialize in
  9851. * @returns the serialized object
  9852. */
  9853. serialize(parent: any): any;
  9854. }
  9855. /**
  9856. * This defines an action responsible to set a property of the target
  9857. * to a desired value once triggered.
  9858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9859. */
  9860. export class SetValueAction extends Action {
  9861. /**
  9862. * The path of the property to set in the target.
  9863. */
  9864. propertyPath: string;
  9865. /**
  9866. * The value to set in the property
  9867. */
  9868. value: any;
  9869. private _target;
  9870. private _effectiveTarget;
  9871. private _property;
  9872. /**
  9873. * Instantiate the action
  9874. * @param triggerOptions defines the trigger options
  9875. * @param target defines the object containing the property
  9876. * @param propertyPath defines the path of the property to set in the target
  9877. * @param value defines the value to set in the property
  9878. * @param condition defines the trigger related conditions
  9879. */
  9880. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9881. /** @hidden */
  9882. _prepare(): void;
  9883. /**
  9884. * Execute the action and set the targetted property to the desired value.
  9885. */
  9886. execute(): void;
  9887. /**
  9888. * Serializes the actions and its related information.
  9889. * @param parent defines the object to serialize in
  9890. * @returns the serialized object
  9891. */
  9892. serialize(parent: any): any;
  9893. }
  9894. /**
  9895. * This defines an action responsible to increment the target value
  9896. * to a desired value once triggered.
  9897. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9898. */
  9899. export class IncrementValueAction extends Action {
  9900. /**
  9901. * The path of the property to increment in the target.
  9902. */
  9903. propertyPath: string;
  9904. /**
  9905. * The value we should increment the property by.
  9906. */
  9907. value: any;
  9908. private _target;
  9909. private _effectiveTarget;
  9910. private _property;
  9911. /**
  9912. * Instantiate the action
  9913. * @param triggerOptions defines the trigger options
  9914. * @param target defines the object containing the property
  9915. * @param propertyPath defines the path of the property to increment in the target
  9916. * @param value defines the value value we should increment the property by
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action and increment the target of the value amount.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to start an animation once triggered.
  9935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class PlayAnimationAction extends Action {
  9938. /**
  9939. * Where the animation should start (animation frame)
  9940. */
  9941. from: number;
  9942. /**
  9943. * Where the animation should stop (animation frame)
  9944. */
  9945. to: number;
  9946. /**
  9947. * Define if the animation should loop or stop after the first play.
  9948. */
  9949. loop?: boolean;
  9950. private _target;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the target animation or animation name
  9955. * @param from defines from where the animation should start (animation frame)
  9956. * @param end defines where the animation should stop (animation frame)
  9957. * @param loop defines if the animation should loop or stop after the first play
  9958. * @param condition defines the trigger related conditions
  9959. */
  9960. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9961. /** @hidden */
  9962. _prepare(): void;
  9963. /**
  9964. * Execute the action and play the animation.
  9965. */
  9966. execute(): void;
  9967. /**
  9968. * Serializes the actions and its related information.
  9969. * @param parent defines the object to serialize in
  9970. * @returns the serialized object
  9971. */
  9972. serialize(parent: any): any;
  9973. }
  9974. /**
  9975. * This defines an action responsible to stop an animation once triggered.
  9976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9977. */
  9978. export class StopAnimationAction extends Action {
  9979. private _target;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the target animation or animation name
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action and stop the animation.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible that does nothing once triggered.
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10003. */
  10004. export class DoNothingAction extends Action {
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param condition defines the trigger related conditions
  10009. */
  10010. constructor(triggerOptions?: any, condition?: Condition);
  10011. /**
  10012. * Execute the action and do nothing.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible to trigger several actions once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class CombineAction extends Action {
  10027. /**
  10028. * The list of aggregated animations to run.
  10029. */
  10030. children: Action[];
  10031. /**
  10032. * Instantiate the action
  10033. * @param triggerOptions defines the trigger options
  10034. * @param children defines the list of aggregated animations to run
  10035. * @param condition defines the trigger related conditions
  10036. */
  10037. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10038. /** @hidden */
  10039. _prepare(): void;
  10040. /**
  10041. * Execute the action and executes all the aggregated actions.
  10042. */
  10043. execute(evt: ActionEvent): void;
  10044. /**
  10045. * Serializes the actions and its related information.
  10046. * @param parent defines the object to serialize in
  10047. * @returns the serialized object
  10048. */
  10049. serialize(parent: any): any;
  10050. }
  10051. /**
  10052. * This defines an action responsible to run code (external event) once triggered.
  10053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10054. */
  10055. export class ExecuteCodeAction extends Action {
  10056. /**
  10057. * The callback function to run.
  10058. */
  10059. func: (evt: ActionEvent) => void;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param func defines the callback function to run
  10064. * @param condition defines the trigger related conditions
  10065. */
  10066. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10067. /**
  10068. * Execute the action and run the attached code.
  10069. */
  10070. execute(evt: ActionEvent): void;
  10071. }
  10072. /**
  10073. * This defines an action responsible to set the parent property of the target once triggered.
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class SetParentAction extends Action {
  10077. private _parent;
  10078. private _target;
  10079. /**
  10080. * Instantiate the action
  10081. * @param triggerOptions defines the trigger options
  10082. * @param target defines the target containing the parent property
  10083. * @param parent defines from where the animation should start (animation frame)
  10084. * @param condition defines the trigger related conditions
  10085. */
  10086. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10087. /** @hidden */
  10088. _prepare(): void;
  10089. /**
  10090. * Execute the action and set the parent property.
  10091. */
  10092. execute(): void;
  10093. /**
  10094. * Serializes the actions and its related information.
  10095. * @param parent defines the object to serialize in
  10096. * @returns the serialized object
  10097. */
  10098. serialize(parent: any): any;
  10099. }
  10100. }
  10101. declare module BABYLON {
  10102. /**
  10103. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10104. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10106. */
  10107. export class ActionManager extends AbstractActionManager {
  10108. /**
  10109. * Nothing
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10111. */
  10112. static readonly NothingTrigger: number;
  10113. /**
  10114. * On pick
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnPickTrigger: number;
  10118. /**
  10119. * On left pick
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnLeftPickTrigger: number;
  10123. /**
  10124. * On right pick
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnRightPickTrigger: number;
  10128. /**
  10129. * On center pick
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnCenterPickTrigger: number;
  10133. /**
  10134. * On pick down
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnPickDownTrigger: number;
  10138. /**
  10139. * On double pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnDoublePickTrigger: number;
  10143. /**
  10144. * On pick up
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickUpTrigger: number;
  10148. /**
  10149. * On pick out.
  10150. * This trigger will only be raised if you also declared a OnPickDown
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10152. */
  10153. static readonly OnPickOutTrigger: number;
  10154. /**
  10155. * On long press
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly OnLongPressTrigger: number;
  10159. /**
  10160. * On pointer over
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnPointerOverTrigger: number;
  10164. /**
  10165. * On pointer out
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnPointerOutTrigger: number;
  10169. /**
  10170. * On every frame
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnEveryFrameTrigger: number;
  10174. /**
  10175. * On intersection enter
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnIntersectionEnterTrigger: number;
  10179. /**
  10180. * On intersection exit
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnIntersectionExitTrigger: number;
  10184. /**
  10185. * On key down
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnKeyDownTrigger: number;
  10189. /**
  10190. * On key up
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnKeyUpTrigger: number;
  10194. private _scene;
  10195. /**
  10196. * Creates a new action manager
  10197. * @param scene defines the hosting scene
  10198. */
  10199. constructor(scene: Scene);
  10200. /**
  10201. * Releases all associated resources
  10202. */
  10203. dispose(): void;
  10204. /**
  10205. * Gets hosting scene
  10206. * @returns the hosting scene
  10207. */
  10208. getScene(): Scene;
  10209. /**
  10210. * Does this action manager handles actions of any of the given triggers
  10211. * @param triggers defines the triggers to be tested
  10212. * @return a boolean indicating whether one (or more) of the triggers is handled
  10213. */
  10214. hasSpecificTriggers(triggers: number[]): boolean;
  10215. /**
  10216. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10217. * speed.
  10218. * @param triggerA defines the trigger to be tested
  10219. * @param triggerB defines the trigger to be tested
  10220. * @return a boolean indicating whether one (or more) of the triggers is handled
  10221. */
  10222. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10223. /**
  10224. * Does this action manager handles actions of a given trigger
  10225. * @param trigger defines the trigger to be tested
  10226. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10227. * @return whether the trigger is handled
  10228. */
  10229. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10230. /**
  10231. * Does this action manager has pointer triggers
  10232. */
  10233. get hasPointerTriggers(): boolean;
  10234. /**
  10235. * Does this action manager has pick triggers
  10236. */
  10237. get hasPickTriggers(): boolean;
  10238. /**
  10239. * Registers an action to this action manager
  10240. * @param action defines the action to be registered
  10241. * @return the action amended (prepared) after registration
  10242. */
  10243. registerAction(action: IAction): Nullable<IAction>;
  10244. /**
  10245. * Unregisters an action to this action manager
  10246. * @param action defines the action to be unregistered
  10247. * @return a boolean indicating whether the action has been unregistered
  10248. */
  10249. unregisterAction(action: IAction): Boolean;
  10250. /**
  10251. * Process a specific trigger
  10252. * @param trigger defines the trigger to process
  10253. * @param evt defines the event details to be processed
  10254. */
  10255. processTrigger(trigger: number, evt?: IActionEvent): void;
  10256. /** @hidden */
  10257. _getEffectiveTarget(target: any, propertyPath: string): any;
  10258. /** @hidden */
  10259. _getProperty(propertyPath: string): string;
  10260. /**
  10261. * Serialize this manager to a JSON object
  10262. * @param name defines the property name to store this manager
  10263. * @returns a JSON representation of this manager
  10264. */
  10265. serialize(name: string): any;
  10266. /**
  10267. * Creates a new ActionManager from a JSON data
  10268. * @param parsedActions defines the JSON data to read from
  10269. * @param object defines the hosting mesh
  10270. * @param scene defines the hosting scene
  10271. */
  10272. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10273. /**
  10274. * Get a trigger name by index
  10275. * @param trigger defines the trigger index
  10276. * @returns a trigger name
  10277. */
  10278. static GetTriggerName(trigger: number): string;
  10279. }
  10280. }
  10281. declare module BABYLON {
  10282. /**
  10283. * Class representing a ray with position and direction
  10284. */
  10285. export class Ray {
  10286. /** origin point */
  10287. origin: Vector3;
  10288. /** direction */
  10289. direction: Vector3;
  10290. /** length of the ray */
  10291. length: number;
  10292. private static readonly _TmpVector3;
  10293. private _tmpRay;
  10294. /**
  10295. * Creates a new ray
  10296. * @param origin origin point
  10297. * @param direction direction
  10298. * @param length length of the ray
  10299. */
  10300. constructor(
  10301. /** origin point */
  10302. origin: Vector3,
  10303. /** direction */
  10304. direction: Vector3,
  10305. /** length of the ray */
  10306. length?: number);
  10307. /**
  10308. * Checks if the ray intersects a box
  10309. * This does not account for the ray lenght by design to improve perfs.
  10310. * @param minimum bound of the box
  10311. * @param maximum bound of the box
  10312. * @param intersectionTreshold extra extend to be added to the box in all direction
  10313. * @returns if the box was hit
  10314. */
  10315. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10316. /**
  10317. * Checks if the ray intersects a box
  10318. * This does not account for the ray lenght by design to improve perfs.
  10319. * @param box the bounding box to check
  10320. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10321. * @returns if the box was hit
  10322. */
  10323. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10324. /**
  10325. * If the ray hits a sphere
  10326. * @param sphere the bounding sphere to check
  10327. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10328. * @returns true if it hits the sphere
  10329. */
  10330. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10331. /**
  10332. * If the ray hits a triange
  10333. * @param vertex0 triangle vertex
  10334. * @param vertex1 triangle vertex
  10335. * @param vertex2 triangle vertex
  10336. * @returns intersection information if hit
  10337. */
  10338. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10339. /**
  10340. * Checks if ray intersects a plane
  10341. * @param plane the plane to check
  10342. * @returns the distance away it was hit
  10343. */
  10344. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10345. /**
  10346. * Calculate the intercept of a ray on a given axis
  10347. * @param axis to check 'x' | 'y' | 'z'
  10348. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10349. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10350. */
  10351. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10352. /**
  10353. * Checks if ray intersects a mesh
  10354. * @param mesh the mesh to check
  10355. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10356. * @returns picking info of the intersecton
  10357. */
  10358. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10359. /**
  10360. * Checks if ray intersects a mesh
  10361. * @param meshes the meshes to check
  10362. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10363. * @param results array to store result in
  10364. * @returns Array of picking infos
  10365. */
  10366. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10367. private _comparePickingInfo;
  10368. private static smallnum;
  10369. private static rayl;
  10370. /**
  10371. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10372. * @param sega the first point of the segment to test the intersection against
  10373. * @param segb the second point of the segment to test the intersection against
  10374. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10375. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10376. */
  10377. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10378. /**
  10379. * Update the ray from viewport position
  10380. * @param x position
  10381. * @param y y position
  10382. * @param viewportWidth viewport width
  10383. * @param viewportHeight viewport height
  10384. * @param world world matrix
  10385. * @param view view matrix
  10386. * @param projection projection matrix
  10387. * @returns this ray updated
  10388. */
  10389. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10390. /**
  10391. * Creates a ray with origin and direction of 0,0,0
  10392. * @returns the new ray
  10393. */
  10394. static Zero(): Ray;
  10395. /**
  10396. * Creates a new ray from screen space and viewport
  10397. * @param x position
  10398. * @param y y position
  10399. * @param viewportWidth viewport width
  10400. * @param viewportHeight viewport height
  10401. * @param world world matrix
  10402. * @param view view matrix
  10403. * @param projection projection matrix
  10404. * @returns new ray
  10405. */
  10406. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10407. /**
  10408. * 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
  10409. * transformed to the given world matrix.
  10410. * @param origin The origin point
  10411. * @param end The end point
  10412. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10413. * @returns the new ray
  10414. */
  10415. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10416. /**
  10417. * Transforms a ray by a matrix
  10418. * @param ray ray to transform
  10419. * @param matrix matrix to apply
  10420. * @returns the resulting new ray
  10421. */
  10422. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10423. /**
  10424. * Transforms a ray by a matrix
  10425. * @param ray ray to transform
  10426. * @param matrix matrix to apply
  10427. * @param result ray to store result in
  10428. */
  10429. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10430. /**
  10431. * Unproject a ray from screen space to object space
  10432. * @param sourceX defines the screen space x coordinate to use
  10433. * @param sourceY defines the screen space y coordinate to use
  10434. * @param viewportWidth defines the current width of the viewport
  10435. * @param viewportHeight defines the current height of the viewport
  10436. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10437. * @param view defines the view matrix to use
  10438. * @param projection defines the projection matrix to use
  10439. */
  10440. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10441. }
  10442. /**
  10443. * Type used to define predicate used to select faces when a mesh intersection is detected
  10444. */
  10445. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10446. interface Scene {
  10447. /** @hidden */
  10448. _tempPickingRay: Nullable<Ray>;
  10449. /** @hidden */
  10450. _cachedRayForTransform: Ray;
  10451. /** @hidden */
  10452. _pickWithRayInverseMatrix: Matrix;
  10453. /** @hidden */
  10454. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10455. /** @hidden */
  10456. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10457. /** @hidden */
  10458. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10459. }
  10460. }
  10461. declare module BABYLON {
  10462. /**
  10463. * Groups all the scene component constants in one place to ease maintenance.
  10464. * @hidden
  10465. */
  10466. export class SceneComponentConstants {
  10467. static readonly NAME_EFFECTLAYER: string;
  10468. static readonly NAME_LAYER: string;
  10469. static readonly NAME_LENSFLARESYSTEM: string;
  10470. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10471. static readonly NAME_PARTICLESYSTEM: string;
  10472. static readonly NAME_GAMEPAD: string;
  10473. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10474. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10475. static readonly NAME_PREPASSRENDERER: string;
  10476. static readonly NAME_DEPTHRENDERER: string;
  10477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10478. static readonly NAME_SPRITE: string;
  10479. static readonly NAME_SUBSURFACE: string;
  10480. static readonly NAME_OUTLINERENDERER: string;
  10481. static readonly NAME_PROCEDURALTEXTURE: string;
  10482. static readonly NAME_SHADOWGENERATOR: string;
  10483. static readonly NAME_OCTREE: string;
  10484. static readonly NAME_PHYSICSENGINE: string;
  10485. static readonly NAME_AUDIO: string;
  10486. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10487. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10488. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10489. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10490. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10491. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10492. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10493. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10494. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10495. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10496. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10497. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10498. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10499. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10500. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10501. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10502. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10503. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10504. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10505. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10506. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10507. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10508. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10509. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10510. static readonly STEP_AFTERRENDER_AUDIO: number;
  10511. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10512. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10513. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10514. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10515. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10516. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10517. static readonly STEP_POINTERMOVE_SPRITE: number;
  10518. static readonly STEP_POINTERDOWN_SPRITE: number;
  10519. static readonly STEP_POINTERUP_SPRITE: number;
  10520. }
  10521. /**
  10522. * This represents a scene component.
  10523. *
  10524. * This is used to decouple the dependency the scene is having on the different workloads like
  10525. * layers, post processes...
  10526. */
  10527. export interface ISceneComponent {
  10528. /**
  10529. * The name of the component. Each component must have a unique name.
  10530. */
  10531. name: string;
  10532. /**
  10533. * The scene the component belongs to.
  10534. */
  10535. scene: Scene;
  10536. /**
  10537. * Register the component to one instance of a scene.
  10538. */
  10539. register(): void;
  10540. /**
  10541. * Rebuilds the elements related to this component in case of
  10542. * context lost for instance.
  10543. */
  10544. rebuild(): void;
  10545. /**
  10546. * Disposes the component and the associated ressources.
  10547. */
  10548. dispose(): void;
  10549. }
  10550. /**
  10551. * This represents a SERIALIZABLE scene component.
  10552. *
  10553. * This extends Scene Component to add Serialization methods on top.
  10554. */
  10555. export interface ISceneSerializableComponent extends ISceneComponent {
  10556. /**
  10557. * Adds all the elements from the container to the scene
  10558. * @param container the container holding the elements
  10559. */
  10560. addFromContainer(container: AbstractScene): void;
  10561. /**
  10562. * Removes all the elements in the container from the scene
  10563. * @param container contains the elements to remove
  10564. * @param dispose if the removed element should be disposed (default: false)
  10565. */
  10566. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10567. /**
  10568. * Serializes the component data to the specified json object
  10569. * @param serializationObject The object to serialize to
  10570. */
  10571. serialize(serializationObject: any): void;
  10572. }
  10573. /**
  10574. * Strong typing of a Mesh related stage step action
  10575. */
  10576. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10577. /**
  10578. * Strong typing of a Evaluate Sub Mesh related stage step action
  10579. */
  10580. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10581. /**
  10582. * Strong typing of a pre active Mesh related stage step action
  10583. */
  10584. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10585. /**
  10586. * Strong typing of a Camera related stage step action
  10587. */
  10588. export type CameraStageAction = (camera: Camera) => void;
  10589. /**
  10590. * Strong typing of a Camera Frame buffer related stage step action
  10591. */
  10592. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10593. /**
  10594. * Strong typing of a Render Target related stage step action
  10595. */
  10596. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10597. /**
  10598. * Strong typing of a RenderingGroup related stage step action
  10599. */
  10600. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10601. /**
  10602. * Strong typing of a Mesh Render related stage step action
  10603. */
  10604. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10605. /**
  10606. * Strong typing of a simple stage step action
  10607. */
  10608. export type SimpleStageAction = () => void;
  10609. /**
  10610. * Strong typing of a render target action.
  10611. */
  10612. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10613. /**
  10614. * Strong typing of a pointer move action.
  10615. */
  10616. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10617. /**
  10618. * Strong typing of a pointer up/down action.
  10619. */
  10620. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10621. /**
  10622. * Representation of a stage in the scene (Basically a list of ordered steps)
  10623. * @hidden
  10624. */
  10625. export class Stage<T extends Function> extends Array<{
  10626. index: number;
  10627. component: ISceneComponent;
  10628. action: T;
  10629. }> {
  10630. /**
  10631. * Hide ctor from the rest of the world.
  10632. * @param items The items to add.
  10633. */
  10634. private constructor();
  10635. /**
  10636. * Creates a new Stage.
  10637. * @returns A new instance of a Stage
  10638. */
  10639. static Create<T extends Function>(): Stage<T>;
  10640. /**
  10641. * Registers a step in an ordered way in the targeted stage.
  10642. * @param index Defines the position to register the step in
  10643. * @param component Defines the component attached to the step
  10644. * @param action Defines the action to launch during the step
  10645. */
  10646. registerStep(index: number, component: ISceneComponent, action: T): void;
  10647. /**
  10648. * Clears all the steps from the stage.
  10649. */
  10650. clear(): void;
  10651. }
  10652. }
  10653. declare module BABYLON {
  10654. interface Scene {
  10655. /** @hidden */
  10656. _pointerOverSprite: Nullable<Sprite>;
  10657. /** @hidden */
  10658. _pickedDownSprite: Nullable<Sprite>;
  10659. /** @hidden */
  10660. _tempSpritePickingRay: Nullable<Ray>;
  10661. /**
  10662. * All of the sprite managers added to this scene
  10663. * @see https://doc.babylonjs.com/babylon101/sprites
  10664. */
  10665. spriteManagers: Array<ISpriteManager>;
  10666. /**
  10667. * An event triggered when sprites rendering is about to start
  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. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10671. /**
  10672. * An event triggered when sprites rendering is done
  10673. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10674. */
  10675. onAfterSpritesRenderingObservable: Observable<Scene>;
  10676. /** @hidden */
  10677. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10678. /** Launch a ray to try to pick a sprite in the scene
  10679. * @param x position on screen
  10680. * @param y position on screen
  10681. * @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
  10682. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10683. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10684. * @returns a PickingInfo
  10685. */
  10686. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10687. /** Use the given ray to pick a sprite in the scene
  10688. * @param ray The ray (in world space) to use to pick meshes
  10689. * @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
  10690. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10691. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10692. * @returns a PickingInfo
  10693. */
  10694. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10697. /** Launch a ray to try to pick sprites in the scene
  10698. * @param x position on screen
  10699. * @param y position on screen
  10700. * @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
  10701. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10702. * @returns a PickingInfo array
  10703. */
  10704. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10705. /** Use the given ray to pick sprites in the scene
  10706. * @param ray The ray (in world space) to use to pick meshes
  10707. * @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
  10708. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10709. * @returns a PickingInfo array
  10710. */
  10711. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10712. /**
  10713. * Force the sprite under the pointer
  10714. * @param sprite defines the sprite to use
  10715. */
  10716. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10717. /**
  10718. * Gets the sprite under the pointer
  10719. * @returns a Sprite or null if no sprite is under the pointer
  10720. */
  10721. getPointerOverSprite(): Nullable<Sprite>;
  10722. }
  10723. /**
  10724. * Defines the sprite scene component responsible to manage sprites
  10725. * in a given scene.
  10726. */
  10727. export class SpriteSceneComponent implements ISceneComponent {
  10728. /**
  10729. * The component name helpfull to identify the component in the list of scene components.
  10730. */
  10731. readonly name: string;
  10732. /**
  10733. * The scene the component belongs to.
  10734. */
  10735. scene: Scene;
  10736. /** @hidden */
  10737. private _spritePredicate;
  10738. /**
  10739. * Creates a new instance of the component for the given scene
  10740. * @param scene Defines the scene to register the component in
  10741. */
  10742. constructor(scene: Scene);
  10743. /**
  10744. * Registers the component in a given scene
  10745. */
  10746. register(): void;
  10747. /**
  10748. * Rebuilds the elements related to this component in case of
  10749. * context lost for instance.
  10750. */
  10751. rebuild(): void;
  10752. /**
  10753. * Disposes the component and the associated ressources.
  10754. */
  10755. dispose(): void;
  10756. private _pickSpriteButKeepRay;
  10757. private _pointerMove;
  10758. private _pointerDown;
  10759. private _pointerUp;
  10760. }
  10761. }
  10762. declare module BABYLON {
  10763. /**
  10764. * Class used to provide helper for timing
  10765. */
  10766. export class TimingTools {
  10767. /**
  10768. * Polyfill for setImmediate
  10769. * @param action defines the action to execute after the current execution block
  10770. */
  10771. static SetImmediate(action: () => void): void;
  10772. }
  10773. }
  10774. declare module BABYLON {
  10775. /**
  10776. * Class used to enable instatition of objects by class name
  10777. */
  10778. export class InstantiationTools {
  10779. /**
  10780. * Use this object to register external classes like custom textures or material
  10781. * to allow the laoders to instantiate them
  10782. */
  10783. static RegisteredExternalClasses: {
  10784. [key: string]: Object;
  10785. };
  10786. /**
  10787. * Tries to instantiate a new object from a given class name
  10788. * @param className defines the class name to instantiate
  10789. * @returns the new object or null if the system was not able to do the instantiation
  10790. */
  10791. static Instantiate(className: string): any;
  10792. }
  10793. }
  10794. declare module BABYLON {
  10795. /**
  10796. * Class used to host copy specific utilities
  10797. */
  10798. export class CopyTools {
  10799. /**
  10800. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10801. * @param texture defines the texture to read pixels from
  10802. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10803. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10804. * @returns The base64 encoded string or null
  10805. */
  10806. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10807. }
  10808. }
  10809. declare module BABYLON {
  10810. /**
  10811. * Define options used to create a depth texture
  10812. */
  10813. export class DepthTextureCreationOptions {
  10814. /** Specifies whether or not a stencil should be allocated in the texture */
  10815. generateStencil?: boolean;
  10816. /** Specifies whether or not bilinear filtering is enable on the texture */
  10817. bilinearFiltering?: boolean;
  10818. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10819. comparisonFunction?: number;
  10820. /** Specifies if the created texture is a cube texture */
  10821. isCube?: boolean;
  10822. }
  10823. }
  10824. declare module BABYLON {
  10825. interface ThinEngine {
  10826. /**
  10827. * Creates a depth stencil cube texture.
  10828. * This is only available in WebGL 2.
  10829. * @param size The size of face edge in the cube texture.
  10830. * @param options The options defining the cube texture.
  10831. * @returns The cube texture
  10832. */
  10833. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10834. /**
  10835. * Creates a cube texture
  10836. * @param rootUrl defines the url where the files to load is located
  10837. * @param scene defines the current scene
  10838. * @param files defines the list of files to load (1 per face)
  10839. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10840. * @param onLoad defines an optional callback raised when the texture is loaded
  10841. * @param onError defines an optional callback raised if there is an issue to load the texture
  10842. * @param format defines the format of the data
  10843. * @param forcedExtension defines the extension to use to pick the right loader
  10844. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10845. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10846. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10847. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10848. * @param loaderOptions options to be passed to the loader
  10849. * @returns the cube texture as an InternalTexture
  10850. */
  10851. 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;
  10852. /**
  10853. * Creates a cube texture
  10854. * @param rootUrl defines the url where the files to load is located
  10855. * @param scene defines the current scene
  10856. * @param files defines the list of files to load (1 per face)
  10857. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10858. * @param onLoad defines an optional callback raised when the texture is loaded
  10859. * @param onError defines an optional callback raised if there is an issue to load the texture
  10860. * @param format defines the format of the data
  10861. * @param forcedExtension defines the extension to use to pick the right loader
  10862. * @returns the cube texture as an InternalTexture
  10863. */
  10864. 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;
  10865. /**
  10866. * Creates a cube texture
  10867. * @param rootUrl defines the url where the files to load is located
  10868. * @param scene defines the current scene
  10869. * @param files defines the list of files to load (1 per face)
  10870. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10871. * @param onLoad defines an optional callback raised when the texture is loaded
  10872. * @param onError defines an optional callback raised if there is an issue to load the texture
  10873. * @param format defines the format of the data
  10874. * @param forcedExtension defines the extension to use to pick the right loader
  10875. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10876. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10877. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10878. * @returns the cube texture as an InternalTexture
  10879. */
  10880. 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;
  10881. /** @hidden */
  10882. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10883. /** @hidden */
  10884. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10885. /** @hidden */
  10886. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10887. /** @hidden */
  10888. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10889. /**
  10890. * @hidden
  10891. */
  10892. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10893. }
  10894. }
  10895. declare module BABYLON {
  10896. /**
  10897. * Class for creating a cube texture
  10898. */
  10899. export class CubeTexture extends BaseTexture {
  10900. private _delayedOnLoad;
  10901. /**
  10902. * Observable triggered once the texture has been loaded.
  10903. */
  10904. onLoadObservable: Observable<CubeTexture>;
  10905. /**
  10906. * The url of the texture
  10907. */
  10908. url: string;
  10909. /**
  10910. * Gets or sets the center of the bounding box associated with the cube texture.
  10911. * It must define where the camera used to render the texture was set
  10912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10913. */
  10914. boundingBoxPosition: Vector3;
  10915. private _boundingBoxSize;
  10916. /**
  10917. * Gets or sets the size of the bounding box associated with the cube texture
  10918. * When defined, the cubemap will switch to local mode
  10919. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10920. * @example https://www.babylonjs-playground.com/#RNASML
  10921. */
  10922. set boundingBoxSize(value: Vector3);
  10923. /**
  10924. * Returns the bounding box size
  10925. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10926. */
  10927. get boundingBoxSize(): Vector3;
  10928. protected _rotationY: number;
  10929. /**
  10930. * Sets texture matrix rotation angle around Y axis in radians.
  10931. */
  10932. set rotationY(value: number);
  10933. /**
  10934. * Gets texture matrix rotation angle around Y axis radians.
  10935. */
  10936. get rotationY(): number;
  10937. /**
  10938. * Are mip maps generated for this texture or not.
  10939. */
  10940. get noMipmap(): boolean;
  10941. private _noMipmap;
  10942. private _files;
  10943. protected _forcedExtension: Nullable<string>;
  10944. private _extensions;
  10945. private _textureMatrix;
  10946. private _format;
  10947. private _createPolynomials;
  10948. private _loaderOptions;
  10949. /**
  10950. * Creates a cube texture from an array of image urls
  10951. * @param files defines an array of image urls
  10952. * @param scene defines the hosting scene
  10953. * @param noMipmap specifies if mip maps are not used
  10954. * @returns a cube texture
  10955. */
  10956. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10957. /**
  10958. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10959. * @param url defines the url of the prefiltered texture
  10960. * @param scene defines the scene the texture is attached to
  10961. * @param forcedExtension defines the extension of the file if different from the url
  10962. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10963. * @return the prefiltered texture
  10964. */
  10965. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10966. /**
  10967. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10968. * as prefiltered data.
  10969. * @param rootUrl defines the url of the texture or the root name of the six images
  10970. * @param null defines the scene or engine the texture is attached to
  10971. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10972. * @param noMipmap defines if mipmaps should be created or not
  10973. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10974. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10975. * @param onError defines a callback triggered in case of error during load
  10976. * @param format defines the internal format to use for the texture once loaded
  10977. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10978. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10979. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10980. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10981. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10982. * @param loaderOptions options to be passed to the loader
  10983. * @return the cube texture
  10984. */
  10985. 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);
  10986. /**
  10987. * Get the current class name of the texture useful for serialization or dynamic coding.
  10988. * @returns "CubeTexture"
  10989. */
  10990. getClassName(): string;
  10991. /**
  10992. * Update the url (and optional buffer) of this texture if url was null during construction.
  10993. * @param url the url of the texture
  10994. * @param forcedExtension defines the extension to use
  10995. * @param onLoad callback called when the texture is loaded (defaults to null)
  10996. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10997. */
  10998. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10999. /**
  11000. * Delays loading of the cube texture
  11001. * @param forcedExtension defines the extension to use
  11002. */
  11003. delayLoad(forcedExtension?: string): void;
  11004. /**
  11005. * Returns the reflection texture matrix
  11006. * @returns the reflection texture matrix
  11007. */
  11008. getReflectionTextureMatrix(): Matrix;
  11009. /**
  11010. * Sets the reflection texture matrix
  11011. * @param value Reflection texture matrix
  11012. */
  11013. setReflectionTextureMatrix(value: Matrix): void;
  11014. /**
  11015. * Parses text to create a cube texture
  11016. * @param parsedTexture define the serialized text to read from
  11017. * @param scene defines the hosting scene
  11018. * @param rootUrl defines the root url of the cube texture
  11019. * @returns a cube texture
  11020. */
  11021. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11022. /**
  11023. * Makes a clone, or deep copy, of the cube texture
  11024. * @returns a new cube texture
  11025. */
  11026. clone(): CubeTexture;
  11027. }
  11028. }
  11029. declare module BABYLON {
  11030. /**
  11031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11033. * 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;
  11034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11035. */
  11036. export class ColorCurves {
  11037. private _dirty;
  11038. private _tempColor;
  11039. private _globalCurve;
  11040. private _highlightsCurve;
  11041. private _midtonesCurve;
  11042. private _shadowsCurve;
  11043. private _positiveCurve;
  11044. private _negativeCurve;
  11045. private _globalHue;
  11046. private _globalDensity;
  11047. private _globalSaturation;
  11048. private _globalExposure;
  11049. /**
  11050. * Gets 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. get globalHue(): number;
  11054. /**
  11055. * Sets the global Hue value.
  11056. * 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).
  11057. */
  11058. set globalHue(value: number);
  11059. /**
  11060. * Gets the global Density value.
  11061. * 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.
  11062. * Values less than zero provide a filter of opposite hue.
  11063. */
  11064. get globalDensity(): number;
  11065. /**
  11066. * Sets the global Density value.
  11067. * 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.
  11068. * Values less than zero provide a filter of opposite hue.
  11069. */
  11070. set globalDensity(value: number);
  11071. /**
  11072. * Gets 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. get globalSaturation(): number;
  11076. /**
  11077. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  11079. */
  11080. set globalSaturation(value: number);
  11081. /**
  11082. * Gets 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. get globalExposure(): number;
  11086. /**
  11087. * Sets the global Exposure value.
  11088. * 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.
  11089. */
  11090. set globalExposure(value: number);
  11091. private _highlightsHue;
  11092. private _highlightsDensity;
  11093. private _highlightsSaturation;
  11094. private _highlightsExposure;
  11095. /**
  11096. * Gets 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. get highlightsHue(): number;
  11100. /**
  11101. * Sets the highlights Hue value.
  11102. * 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).
  11103. */
  11104. set highlightsHue(value: number);
  11105. /**
  11106. * Gets the highlights Density value.
  11107. * 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.
  11108. * Values less than zero provide a filter of opposite hue.
  11109. */
  11110. get highlightsDensity(): number;
  11111. /**
  11112. * Sets the highlights Density value.
  11113. * 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.
  11114. * Values less than zero provide a filter of opposite hue.
  11115. */
  11116. set highlightsDensity(value: number);
  11117. /**
  11118. * Gets 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. get highlightsSaturation(): number;
  11122. /**
  11123. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  11125. */
  11126. set highlightsSaturation(value: number);
  11127. /**
  11128. * Gets 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. get highlightsExposure(): number;
  11132. /**
  11133. * Sets the highlights Exposure value.
  11134. * 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.
  11135. */
  11136. set highlightsExposure(value: number);
  11137. private _midtonesHue;
  11138. private _midtonesDensity;
  11139. private _midtonesSaturation;
  11140. private _midtonesExposure;
  11141. /**
  11142. * Gets 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. get midtonesHue(): number;
  11146. /**
  11147. * Sets the midtones Hue value.
  11148. * 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).
  11149. */
  11150. set midtonesHue(value: number);
  11151. /**
  11152. * Gets the midtones Density value.
  11153. * 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.
  11154. * Values less than zero provide a filter of opposite hue.
  11155. */
  11156. get midtonesDensity(): number;
  11157. /**
  11158. * Sets the midtones Density value.
  11159. * 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.
  11160. * Values less than zero provide a filter of opposite hue.
  11161. */
  11162. set midtonesDensity(value: number);
  11163. /**
  11164. * Gets 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. get midtonesSaturation(): number;
  11168. /**
  11169. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  11171. */
  11172. set midtonesSaturation(value: number);
  11173. /**
  11174. * Gets 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. get midtonesExposure(): number;
  11178. /**
  11179. * Sets the midtones Exposure value.
  11180. * 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.
  11181. */
  11182. set midtonesExposure(value: number);
  11183. private _shadowsHue;
  11184. private _shadowsDensity;
  11185. private _shadowsSaturation;
  11186. private _shadowsExposure;
  11187. /**
  11188. * Gets 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. get shadowsHue(): number;
  11192. /**
  11193. * Sets the shadows Hue value.
  11194. * 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).
  11195. */
  11196. set shadowsHue(value: number);
  11197. /**
  11198. * Gets the shadows Density value.
  11199. * 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.
  11200. * Values less than zero provide a filter of opposite hue.
  11201. */
  11202. get shadowsDensity(): number;
  11203. /**
  11204. * Sets the shadows Density value.
  11205. * 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.
  11206. * Values less than zero provide a filter of opposite hue.
  11207. */
  11208. set shadowsDensity(value: number);
  11209. /**
  11210. * Gets 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. get shadowsSaturation(): number;
  11214. /**
  11215. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  11217. */
  11218. set shadowsSaturation(value: number);
  11219. /**
  11220. * Gets 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. get shadowsExposure(): number;
  11224. /**
  11225. * Sets the shadows Exposure value.
  11226. * 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.
  11227. */
  11228. set shadowsExposure(value: number);
  11229. /**
  11230. * Returns the class name
  11231. * @returns The class name
  11232. */
  11233. getClassName(): string;
  11234. /**
  11235. * Binds the color curves to the shader.
  11236. * @param colorCurves The color curve to bind
  11237. * @param effect The effect to bind to
  11238. * @param positiveUniform The positive uniform shader parameter
  11239. * @param neutralUniform The neutral uniform shader parameter
  11240. * @param negativeUniform The negative uniform shader parameter
  11241. */
  11242. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11243. /**
  11244. * Prepare the list of uniforms associated with the ColorCurves effects.
  11245. * @param uniformsList The list of uniforms used in the effect
  11246. */
  11247. static PrepareUniforms(uniformsList: string[]): void;
  11248. /**
  11249. * Returns color grading data based on a hue, density, saturation and exposure value.
  11250. * @param filterHue The hue of the color filter.
  11251. * @param filterDensity The density of the color filter.
  11252. * @param saturation The saturation.
  11253. * @param exposure The exposure.
  11254. * @param result The result data container.
  11255. */
  11256. private getColorGradingDataToRef;
  11257. /**
  11258. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11259. * @param value The input slider value in range [-100,100].
  11260. * @returns Adjusted value.
  11261. */
  11262. private static applyColorGradingSliderNonlinear;
  11263. /**
  11264. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11265. * @param hue The hue (H) input.
  11266. * @param saturation The saturation (S) input.
  11267. * @param brightness The brightness (B) input.
  11268. * @result An RGBA color represented as Vector4.
  11269. */
  11270. private static fromHSBToRef;
  11271. /**
  11272. * Returns a value clamped between min and max
  11273. * @param value The value to clamp
  11274. * @param min The minimum of value
  11275. * @param max The maximum of value
  11276. * @returns The clamped value.
  11277. */
  11278. private static clamp;
  11279. /**
  11280. * Clones the current color curve instance.
  11281. * @return The cloned curves
  11282. */
  11283. clone(): ColorCurves;
  11284. /**
  11285. * Serializes the current color curve instance to a json representation.
  11286. * @return a JSON representation
  11287. */
  11288. serialize(): any;
  11289. /**
  11290. * Parses the color curve from a json representation.
  11291. * @param source the JSON source to parse
  11292. * @return The parsed curves
  11293. */
  11294. static Parse(source: any): ColorCurves;
  11295. }
  11296. }
  11297. declare module BABYLON {
  11298. /**
  11299. * Interface to follow in your material defines to integrate easily the
  11300. * Image proccessing functions.
  11301. * @hidden
  11302. */
  11303. export interface IImageProcessingConfigurationDefines {
  11304. IMAGEPROCESSING: boolean;
  11305. VIGNETTE: boolean;
  11306. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11307. VIGNETTEBLENDMODEOPAQUE: boolean;
  11308. TONEMAPPING: boolean;
  11309. TONEMAPPING_ACES: boolean;
  11310. CONTRAST: boolean;
  11311. EXPOSURE: boolean;
  11312. COLORCURVES: boolean;
  11313. COLORGRADING: boolean;
  11314. COLORGRADING3D: boolean;
  11315. SAMPLER3DGREENDEPTH: boolean;
  11316. SAMPLER3DBGRMAP: boolean;
  11317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11318. }
  11319. /**
  11320. * @hidden
  11321. */
  11322. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11323. IMAGEPROCESSING: boolean;
  11324. VIGNETTE: boolean;
  11325. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11326. VIGNETTEBLENDMODEOPAQUE: boolean;
  11327. TONEMAPPING: boolean;
  11328. TONEMAPPING_ACES: boolean;
  11329. CONTRAST: boolean;
  11330. COLORCURVES: boolean;
  11331. COLORGRADING: boolean;
  11332. COLORGRADING3D: boolean;
  11333. SAMPLER3DGREENDEPTH: boolean;
  11334. SAMPLER3DBGRMAP: boolean;
  11335. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11336. EXPOSURE: boolean;
  11337. constructor();
  11338. }
  11339. /**
  11340. * This groups together the common properties used for image processing either in direct forward pass
  11341. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11342. * or not.
  11343. */
  11344. export class ImageProcessingConfiguration {
  11345. /**
  11346. * Default tone mapping applied in BabylonJS.
  11347. */
  11348. static readonly TONEMAPPING_STANDARD: number;
  11349. /**
  11350. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11351. * to other engines rendering to increase portability.
  11352. */
  11353. static readonly TONEMAPPING_ACES: number;
  11354. /**
  11355. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11356. */
  11357. colorCurves: Nullable<ColorCurves>;
  11358. private _colorCurvesEnabled;
  11359. /**
  11360. * Gets wether the color curves effect is enabled.
  11361. */
  11362. get colorCurvesEnabled(): boolean;
  11363. /**
  11364. * Sets wether the color curves effect is enabled.
  11365. */
  11366. set colorCurvesEnabled(value: boolean);
  11367. private _colorGradingTexture;
  11368. /**
  11369. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11370. */
  11371. get colorGradingTexture(): Nullable<BaseTexture>;
  11372. /**
  11373. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11374. */
  11375. set colorGradingTexture(value: Nullable<BaseTexture>);
  11376. private _colorGradingEnabled;
  11377. /**
  11378. * Gets wether the color grading effect is enabled.
  11379. */
  11380. get colorGradingEnabled(): boolean;
  11381. /**
  11382. * Sets wether the color grading effect is enabled.
  11383. */
  11384. set colorGradingEnabled(value: boolean);
  11385. private _colorGradingWithGreenDepth;
  11386. /**
  11387. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11388. */
  11389. get colorGradingWithGreenDepth(): boolean;
  11390. /**
  11391. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11392. */
  11393. set colorGradingWithGreenDepth(value: boolean);
  11394. private _colorGradingBGR;
  11395. /**
  11396. * Gets wether the color grading texture contains BGR values.
  11397. */
  11398. get colorGradingBGR(): boolean;
  11399. /**
  11400. * Sets wether the color grading texture contains BGR values.
  11401. */
  11402. set colorGradingBGR(value: boolean);
  11403. /** @hidden */
  11404. _exposure: number;
  11405. /**
  11406. * Gets the Exposure used in the effect.
  11407. */
  11408. get exposure(): number;
  11409. /**
  11410. * Sets the Exposure used in the effect.
  11411. */
  11412. set exposure(value: number);
  11413. private _toneMappingEnabled;
  11414. /**
  11415. * Gets wether the tone mapping effect is enabled.
  11416. */
  11417. get toneMappingEnabled(): boolean;
  11418. /**
  11419. * Sets wether the tone mapping effect is enabled.
  11420. */
  11421. set toneMappingEnabled(value: boolean);
  11422. private _toneMappingType;
  11423. /**
  11424. * Gets the type of tone mapping effect.
  11425. */
  11426. get toneMappingType(): number;
  11427. /**
  11428. * Sets the type of tone mapping effect used in BabylonJS.
  11429. */
  11430. set toneMappingType(value: number);
  11431. protected _contrast: number;
  11432. /**
  11433. * Gets the contrast used in the effect.
  11434. */
  11435. get contrast(): number;
  11436. /**
  11437. * Sets the contrast used in the effect.
  11438. */
  11439. set contrast(value: number);
  11440. /**
  11441. * Vignette stretch size.
  11442. */
  11443. vignetteStretch: number;
  11444. /**
  11445. * Vignette centre X Offset.
  11446. */
  11447. vignetteCentreX: number;
  11448. /**
  11449. * Vignette centre Y Offset.
  11450. */
  11451. vignetteCentreY: number;
  11452. /**
  11453. * Vignette weight or intensity of the vignette effect.
  11454. */
  11455. vignetteWeight: number;
  11456. /**
  11457. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11458. * if vignetteEnabled is set to true.
  11459. */
  11460. vignetteColor: Color4;
  11461. /**
  11462. * Camera field of view used by the Vignette effect.
  11463. */
  11464. vignetteCameraFov: number;
  11465. private _vignetteBlendMode;
  11466. /**
  11467. * Gets the vignette blend mode allowing different kind of effect.
  11468. */
  11469. get vignetteBlendMode(): number;
  11470. /**
  11471. * Sets the vignette blend mode allowing different kind of effect.
  11472. */
  11473. set vignetteBlendMode(value: number);
  11474. private _vignetteEnabled;
  11475. /**
  11476. * Gets wether the vignette effect is enabled.
  11477. */
  11478. get vignetteEnabled(): boolean;
  11479. /**
  11480. * Sets wether the vignette effect is enabled.
  11481. */
  11482. set vignetteEnabled(value: boolean);
  11483. private _applyByPostProcess;
  11484. /**
  11485. * Gets wether the image processing is applied through a post process or not.
  11486. */
  11487. get applyByPostProcess(): boolean;
  11488. /**
  11489. * Sets wether the image processing is applied through a post process or not.
  11490. */
  11491. set applyByPostProcess(value: boolean);
  11492. private _isEnabled;
  11493. /**
  11494. * Gets wether the image processing is enabled or not.
  11495. */
  11496. get isEnabled(): boolean;
  11497. /**
  11498. * Sets wether the image processing is enabled or not.
  11499. */
  11500. set isEnabled(value: boolean);
  11501. /**
  11502. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11503. */
  11504. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11505. /**
  11506. * Method called each time the image processing information changes requires to recompile the effect.
  11507. */
  11508. protected _updateParameters(): void;
  11509. /**
  11510. * Gets the current class name.
  11511. * @return "ImageProcessingConfiguration"
  11512. */
  11513. getClassName(): string;
  11514. /**
  11515. * Prepare the list of uniforms associated with the Image Processing effects.
  11516. * @param uniforms The list of uniforms used in the effect
  11517. * @param defines the list of defines currently in use
  11518. */
  11519. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11520. /**
  11521. * Prepare the list of samplers associated with the Image Processing effects.
  11522. * @param samplersList The list of uniforms used in the effect
  11523. * @param defines the list of defines currently in use
  11524. */
  11525. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11526. /**
  11527. * Prepare the list of defines associated to the shader.
  11528. * @param defines the list of defines to complete
  11529. * @param forPostProcess Define if we are currently in post process mode or not
  11530. */
  11531. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11532. /**
  11533. * Returns true if all the image processing information are ready.
  11534. * @returns True if ready, otherwise, false
  11535. */
  11536. isReady(): boolean;
  11537. /**
  11538. * Binds the image processing to the shader.
  11539. * @param effect The effect to bind to
  11540. * @param overrideAspectRatio Override the aspect ratio of the effect
  11541. */
  11542. bind(effect: Effect, overrideAspectRatio?: number): void;
  11543. /**
  11544. * Clones the current image processing instance.
  11545. * @return The cloned image processing
  11546. */
  11547. clone(): ImageProcessingConfiguration;
  11548. /**
  11549. * Serializes the current image processing instance to a json representation.
  11550. * @return a JSON representation
  11551. */
  11552. serialize(): any;
  11553. /**
  11554. * Parses the image processing from a json representation.
  11555. * @param source the JSON source to parse
  11556. * @return The parsed image processing
  11557. */
  11558. static Parse(source: any): ImageProcessingConfiguration;
  11559. private static _VIGNETTEMODE_MULTIPLY;
  11560. private static _VIGNETTEMODE_OPAQUE;
  11561. /**
  11562. * Used to apply the vignette as a mix with the pixel color.
  11563. */
  11564. static get VIGNETTEMODE_MULTIPLY(): number;
  11565. /**
  11566. * Used to apply the vignette as a replacement of the pixel color.
  11567. */
  11568. static get VIGNETTEMODE_OPAQUE(): number;
  11569. }
  11570. }
  11571. declare module BABYLON {
  11572. /** @hidden */
  11573. export var postprocessVertexShader: {
  11574. name: string;
  11575. shader: string;
  11576. };
  11577. }
  11578. declare module BABYLON {
  11579. /**
  11580. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11581. */
  11582. export type RenderTargetTextureSize = number | {
  11583. width: number;
  11584. height: number;
  11585. layers?: number;
  11586. };
  11587. interface ThinEngine {
  11588. /**
  11589. * Creates a new render target texture
  11590. * @param size defines the size of the texture
  11591. * @param options defines the options used to create the texture
  11592. * @returns a new render target texture stored in an InternalTexture
  11593. */
  11594. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11595. /**
  11596. * Creates a depth stencil texture.
  11597. * This is only available in WebGL 2 or with the depth texture extension available.
  11598. * @param size The size of face edge in the texture.
  11599. * @param options The options defining the texture.
  11600. * @returns The texture
  11601. */
  11602. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11603. /** @hidden */
  11604. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11605. }
  11606. }
  11607. declare module BABYLON {
  11608. /**
  11609. * Defines the kind of connection point for node based material
  11610. */
  11611. export enum NodeMaterialBlockConnectionPointTypes {
  11612. /** Float */
  11613. Float = 1,
  11614. /** Int */
  11615. Int = 2,
  11616. /** Vector2 */
  11617. Vector2 = 4,
  11618. /** Vector3 */
  11619. Vector3 = 8,
  11620. /** Vector4 */
  11621. Vector4 = 16,
  11622. /** Color3 */
  11623. Color3 = 32,
  11624. /** Color4 */
  11625. Color4 = 64,
  11626. /** Matrix */
  11627. Matrix = 128,
  11628. /** Custom object */
  11629. Object = 256,
  11630. /** Detect type based on connection */
  11631. AutoDetect = 1024,
  11632. /** Output type that will be defined by input type */
  11633. BasedOnInput = 2048
  11634. }
  11635. }
  11636. declare module BABYLON {
  11637. /**
  11638. * Enum used to define the target of a block
  11639. */
  11640. export enum NodeMaterialBlockTargets {
  11641. /** Vertex shader */
  11642. Vertex = 1,
  11643. /** Fragment shader */
  11644. Fragment = 2,
  11645. /** Neutral */
  11646. Neutral = 4,
  11647. /** Vertex and Fragment */
  11648. VertexAndFragment = 3
  11649. }
  11650. }
  11651. declare module BABYLON {
  11652. /**
  11653. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11654. */
  11655. export enum NodeMaterialBlockConnectionPointMode {
  11656. /** Value is an uniform */
  11657. Uniform = 0,
  11658. /** Value is a mesh attribute */
  11659. Attribute = 1,
  11660. /** Value is a varying between vertex and fragment shaders */
  11661. Varying = 2,
  11662. /** Mode is undefined */
  11663. Undefined = 3
  11664. }
  11665. }
  11666. declare module BABYLON {
  11667. /**
  11668. * Enum used to define system values e.g. values automatically provided by the system
  11669. */
  11670. export enum NodeMaterialSystemValues {
  11671. /** World */
  11672. World = 1,
  11673. /** View */
  11674. View = 2,
  11675. /** Projection */
  11676. Projection = 3,
  11677. /** ViewProjection */
  11678. ViewProjection = 4,
  11679. /** WorldView */
  11680. WorldView = 5,
  11681. /** WorldViewProjection */
  11682. WorldViewProjection = 6,
  11683. /** CameraPosition */
  11684. CameraPosition = 7,
  11685. /** Fog Color */
  11686. FogColor = 8,
  11687. /** Delta time */
  11688. DeltaTime = 9
  11689. }
  11690. }
  11691. declare module BABYLON {
  11692. /**
  11693. * Represents a camera frustum
  11694. */
  11695. export class Frustum {
  11696. /**
  11697. * Gets the planes representing the frustum
  11698. * @param transform matrix to be applied to the returned planes
  11699. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11700. */
  11701. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11702. /**
  11703. * Gets the near frustum plane transformed by the transform matrix
  11704. * @param transform transformation matrix to be applied to the resulting frustum plane
  11705. * @param frustumPlane the resuling frustum plane
  11706. */
  11707. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11708. /**
  11709. * Gets the far frustum plane transformed by the transform matrix
  11710. * @param transform transformation matrix to be applied to the resulting frustum plane
  11711. * @param frustumPlane the resuling frustum plane
  11712. */
  11713. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11714. /**
  11715. * Gets the left frustum plane transformed by the transform matrix
  11716. * @param transform transformation matrix to be applied to the resulting frustum plane
  11717. * @param frustumPlane the resuling frustum plane
  11718. */
  11719. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11720. /**
  11721. * Gets the right frustum plane transformed by the transform matrix
  11722. * @param transform transformation matrix to be applied to the resulting frustum plane
  11723. * @param frustumPlane the resuling frustum plane
  11724. */
  11725. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11726. /**
  11727. * Gets the top frustum plane transformed by the transform matrix
  11728. * @param transform transformation matrix to be applied to the resulting frustum plane
  11729. * @param frustumPlane the resuling frustum plane
  11730. */
  11731. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11732. /**
  11733. * Gets the bottom frustum plane transformed by the transform matrix
  11734. * @param transform transformation matrix to be applied to the resulting frustum plane
  11735. * @param frustumPlane the resuling frustum plane
  11736. */
  11737. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11738. /**
  11739. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11740. * @param transform transformation matrix to be applied to the resulting frustum planes
  11741. * @param frustumPlanes the resuling frustum planes
  11742. */
  11743. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11744. }
  11745. }
  11746. declare module BABYLON {
  11747. /**
  11748. * Contains position and normal vectors for a vertex
  11749. */
  11750. export class PositionNormalVertex {
  11751. /** the position of the vertex (defaut: 0,0,0) */
  11752. position: Vector3;
  11753. /** the normal of the vertex (defaut: 0,1,0) */
  11754. normal: Vector3;
  11755. /**
  11756. * Creates a PositionNormalVertex
  11757. * @param position the position of the vertex (defaut: 0,0,0)
  11758. * @param normal the normal of the vertex (defaut: 0,1,0)
  11759. */
  11760. constructor(
  11761. /** the position of the vertex (defaut: 0,0,0) */
  11762. position?: Vector3,
  11763. /** the normal of the vertex (defaut: 0,1,0) */
  11764. normal?: Vector3);
  11765. /**
  11766. * Clones the PositionNormalVertex
  11767. * @returns the cloned PositionNormalVertex
  11768. */
  11769. clone(): PositionNormalVertex;
  11770. }
  11771. /**
  11772. * Contains position, normal and uv vectors for a vertex
  11773. */
  11774. export class PositionNormalTextureVertex {
  11775. /** the position of the vertex (defaut: 0,0,0) */
  11776. position: Vector3;
  11777. /** the normal of the vertex (defaut: 0,1,0) */
  11778. normal: Vector3;
  11779. /** the uv of the vertex (default: 0,0) */
  11780. uv: Vector2;
  11781. /**
  11782. * Creates a PositionNormalTextureVertex
  11783. * @param position the position of the vertex (defaut: 0,0,0)
  11784. * @param normal the normal of the vertex (defaut: 0,1,0)
  11785. * @param uv the uv of the vertex (default: 0,0)
  11786. */
  11787. constructor(
  11788. /** the position of the vertex (defaut: 0,0,0) */
  11789. position?: Vector3,
  11790. /** the normal of the vertex (defaut: 0,1,0) */
  11791. normal?: Vector3,
  11792. /** the uv of the vertex (default: 0,0) */
  11793. uv?: Vector2);
  11794. /**
  11795. * Clones the PositionNormalTextureVertex
  11796. * @returns the cloned PositionNormalTextureVertex
  11797. */
  11798. clone(): PositionNormalTextureVertex;
  11799. }
  11800. }
  11801. declare module BABYLON {
  11802. /**
  11803. * Enum defining the type of animations supported by InputBlock
  11804. */
  11805. export enum AnimatedInputBlockTypes {
  11806. /** No animation */
  11807. None = 0,
  11808. /** Time based animation. Will only work for floats */
  11809. Time = 1
  11810. }
  11811. }
  11812. declare module BABYLON {
  11813. /**
  11814. * Block used to expose an input value
  11815. */
  11816. export class InputBlock extends NodeMaterialBlock {
  11817. private _mode;
  11818. private _associatedVariableName;
  11819. private _storedValue;
  11820. private _valueCallback;
  11821. private _type;
  11822. private _animationType;
  11823. /** Gets or set a value used to limit the range of float values */
  11824. min: number;
  11825. /** Gets or set a value used to limit the range of float values */
  11826. max: number;
  11827. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11828. isBoolean: boolean;
  11829. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11830. matrixMode: number;
  11831. /** @hidden */
  11832. _systemValue: Nullable<NodeMaterialSystemValues>;
  11833. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11834. isConstant: boolean;
  11835. /** Gets or sets the group to use to display this block in the Inspector */
  11836. groupInInspector: string;
  11837. /** Gets an observable raised when the value is changed */
  11838. onValueChangedObservable: Observable<InputBlock>;
  11839. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  11840. convertToGammaSpace: boolean;
  11841. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  11842. convertToLinearSpace: boolean;
  11843. /**
  11844. * Gets or sets the connection point type (default is float)
  11845. */
  11846. get type(): NodeMaterialBlockConnectionPointTypes;
  11847. /**
  11848. * Creates a new InputBlock
  11849. * @param name defines the block name
  11850. * @param target defines the target of that block (Vertex by default)
  11851. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11852. */
  11853. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11854. /**
  11855. * Validates if a name is a reserve word.
  11856. * @param newName the new name to be given to the node.
  11857. * @returns false if the name is a reserve word, else true.
  11858. */
  11859. validateBlockName(newName: string): boolean;
  11860. /**
  11861. * Gets the output component
  11862. */
  11863. get output(): NodeMaterialConnectionPoint;
  11864. /**
  11865. * Set the source of this connection point to a vertex attribute
  11866. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11867. * @returns the current connection point
  11868. */
  11869. setAsAttribute(attributeName?: string): InputBlock;
  11870. /**
  11871. * Set the source of this connection point to a system value
  11872. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11873. * @returns the current connection point
  11874. */
  11875. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11876. /**
  11877. * Gets or sets the value of that point.
  11878. * Please note that this value will be ignored if valueCallback is defined
  11879. */
  11880. get value(): any;
  11881. set value(value: any);
  11882. /**
  11883. * Gets or sets a callback used to get the value of that point.
  11884. * Please note that setting this value will force the connection point to ignore the value property
  11885. */
  11886. get valueCallback(): () => any;
  11887. set valueCallback(value: () => any);
  11888. /**
  11889. * Gets or sets the associated variable name in the shader
  11890. */
  11891. get associatedVariableName(): string;
  11892. set associatedVariableName(value: string);
  11893. /** Gets or sets the type of animation applied to the input */
  11894. get animationType(): AnimatedInputBlockTypes;
  11895. set animationType(value: AnimatedInputBlockTypes);
  11896. /**
  11897. * Gets a boolean indicating that this connection point not defined yet
  11898. */
  11899. get isUndefined(): boolean;
  11900. /**
  11901. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11902. * In this case the connection point name must be the name of the uniform to use.
  11903. * Can only be set on inputs
  11904. */
  11905. get isUniform(): boolean;
  11906. set isUniform(value: boolean);
  11907. /**
  11908. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11909. * In this case the connection point name must be the name of the attribute to use
  11910. * Can only be set on inputs
  11911. */
  11912. get isAttribute(): boolean;
  11913. set isAttribute(value: boolean);
  11914. /**
  11915. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11916. * Can only be set on exit points
  11917. */
  11918. get isVarying(): boolean;
  11919. set isVarying(value: boolean);
  11920. /**
  11921. * Gets a boolean indicating that the current connection point is a system value
  11922. */
  11923. get isSystemValue(): boolean;
  11924. /**
  11925. * Gets or sets the current well known value or null if not defined as a system value
  11926. */
  11927. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11928. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11929. /**
  11930. * Gets the current class name
  11931. * @returns the class name
  11932. */
  11933. getClassName(): string;
  11934. /**
  11935. * Animate the input if animationType !== None
  11936. * @param scene defines the rendering scene
  11937. */
  11938. animate(scene: Scene): void;
  11939. private _emitDefine;
  11940. initialize(state: NodeMaterialBuildState): void;
  11941. /**
  11942. * Set the input block to its default value (based on its type)
  11943. */
  11944. setDefaultValue(): void;
  11945. private _emitConstant;
  11946. /** @hidden */
  11947. get _noContextSwitch(): boolean;
  11948. private _emit;
  11949. /** @hidden */
  11950. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11951. /** @hidden */
  11952. _transmit(effect: Effect, scene: Scene): void;
  11953. protected _buildBlock(state: NodeMaterialBuildState): void;
  11954. protected _dumpPropertiesCode(): string;
  11955. dispose(): void;
  11956. serialize(): any;
  11957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11958. }
  11959. }
  11960. declare module BABYLON {
  11961. /**
  11962. * Enum used to define the compatibility state between two connection points
  11963. */
  11964. export enum NodeMaterialConnectionPointCompatibilityStates {
  11965. /** Points are compatibles */
  11966. Compatible = 0,
  11967. /** Points are incompatible because of their types */
  11968. TypeIncompatible = 1,
  11969. /** Points are incompatible because of their targets (vertex vs fragment) */
  11970. TargetIncompatible = 2
  11971. }
  11972. /**
  11973. * Defines the direction of a connection point
  11974. */
  11975. export enum NodeMaterialConnectionPointDirection {
  11976. /** Input */
  11977. Input = 0,
  11978. /** Output */
  11979. Output = 1
  11980. }
  11981. /**
  11982. * Defines a connection point for a block
  11983. */
  11984. export class NodeMaterialConnectionPoint {
  11985. /**
  11986. * Checks if two types are equivalent
  11987. * @param type1 type 1 to check
  11988. * @param type2 type 2 to check
  11989. * @returns true if both types are equivalent, else false
  11990. */
  11991. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11992. /** @hidden */
  11993. _ownerBlock: NodeMaterialBlock;
  11994. /** @hidden */
  11995. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11996. private _endpoints;
  11997. private _associatedVariableName;
  11998. private _direction;
  11999. /** @hidden */
  12000. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12001. /** @hidden */
  12002. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12003. /** @hidden */
  12004. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12005. private _type;
  12006. /** @hidden */
  12007. _enforceAssociatedVariableName: boolean;
  12008. /** Gets the direction of the point */
  12009. get direction(): NodeMaterialConnectionPointDirection;
  12010. /** Indicates that this connection point needs dual validation before being connected to another point */
  12011. needDualDirectionValidation: boolean;
  12012. /**
  12013. * Gets or sets the additional types supported by this connection point
  12014. */
  12015. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12016. /**
  12017. * Gets or sets the additional types excluded by this connection point
  12018. */
  12019. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12020. /**
  12021. * Observable triggered when this point is connected
  12022. */
  12023. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12024. /**
  12025. * Gets or sets the associated variable name in the shader
  12026. */
  12027. get associatedVariableName(): string;
  12028. set associatedVariableName(value: string);
  12029. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12030. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12031. /**
  12032. * Gets or sets the connection point type (default is float)
  12033. */
  12034. get type(): NodeMaterialBlockConnectionPointTypes;
  12035. set type(value: NodeMaterialBlockConnectionPointTypes);
  12036. /**
  12037. * Gets or sets the connection point name
  12038. */
  12039. name: string;
  12040. /**
  12041. * Gets or sets the connection point name
  12042. */
  12043. displayName: string;
  12044. /**
  12045. * Gets or sets a boolean indicating that this connection point can be omitted
  12046. */
  12047. isOptional: boolean;
  12048. /**
  12049. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12050. */
  12051. isExposedOnFrame: boolean;
  12052. /**
  12053. * Gets or sets number indicating the position that the port is exposed to on a frame
  12054. */
  12055. exposedPortPosition: number;
  12056. /**
  12057. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12058. */
  12059. define: string;
  12060. /** @hidden */
  12061. _prioritizeVertex: boolean;
  12062. private _target;
  12063. /** Gets or sets the target of that connection point */
  12064. get target(): NodeMaterialBlockTargets;
  12065. set target(value: NodeMaterialBlockTargets);
  12066. /**
  12067. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12068. */
  12069. get isConnected(): boolean;
  12070. /**
  12071. * Gets a boolean indicating that the current point is connected to an input block
  12072. */
  12073. get isConnectedToInputBlock(): boolean;
  12074. /**
  12075. * Gets a the connected input block (if any)
  12076. */
  12077. get connectInputBlock(): Nullable<InputBlock>;
  12078. /** Get the other side of the connection (if any) */
  12079. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12080. /** Get the block that owns this connection point */
  12081. get ownerBlock(): NodeMaterialBlock;
  12082. /** Get the block connected on the other side of this connection (if any) */
  12083. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12084. /** Get the block connected on the endpoints of this connection (if any) */
  12085. get connectedBlocks(): Array<NodeMaterialBlock>;
  12086. /** Gets the list of connected endpoints */
  12087. get endpoints(): NodeMaterialConnectionPoint[];
  12088. /** Gets a boolean indicating if that output point is connected to at least one input */
  12089. get hasEndpoints(): boolean;
  12090. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12091. get isConnectedInVertexShader(): boolean;
  12092. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12093. get isConnectedInFragmentShader(): boolean;
  12094. /**
  12095. * Creates a block suitable to be used as an input for this input point.
  12096. * If null is returned, a block based on the point type will be created.
  12097. * @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
  12098. */
  12099. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12100. /**
  12101. * Creates a new connection point
  12102. * @param name defines the connection point name
  12103. * @param ownerBlock defines the block hosting this connection point
  12104. * @param direction defines the direction of the connection point
  12105. */
  12106. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12107. /**
  12108. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12109. * @returns the class name
  12110. */
  12111. getClassName(): string;
  12112. /**
  12113. * Gets a boolean indicating if the current point can be connected to another point
  12114. * @param connectionPoint defines the other connection point
  12115. * @returns a boolean
  12116. */
  12117. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12118. /**
  12119. * Gets a number indicating if the current point can be connected to another point
  12120. * @param connectionPoint defines the other connection point
  12121. * @returns a number defining the compatibility state
  12122. */
  12123. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12124. /**
  12125. * Connect this point to another connection point
  12126. * @param connectionPoint defines the other connection point
  12127. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12128. * @returns the current connection point
  12129. */
  12130. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12131. /**
  12132. * Disconnect this point from one of his endpoint
  12133. * @param endpoint defines the other connection point
  12134. * @returns the current connection point
  12135. */
  12136. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12137. /**
  12138. * Serializes this point in a JSON representation
  12139. * @param isInput defines if the connection point is an input (default is true)
  12140. * @returns the serialized point object
  12141. */
  12142. serialize(isInput?: boolean): any;
  12143. /**
  12144. * Release resources
  12145. */
  12146. dispose(): void;
  12147. }
  12148. }
  12149. declare module BABYLON {
  12150. /**
  12151. * Enum used to define the material modes
  12152. */
  12153. export enum NodeMaterialModes {
  12154. /** Regular material */
  12155. Material = 0,
  12156. /** For post process */
  12157. PostProcess = 1,
  12158. /** For particle system */
  12159. Particle = 2,
  12160. /** For procedural texture */
  12161. ProceduralTexture = 3
  12162. }
  12163. }
  12164. declare module BABYLON {
  12165. /** @hidden */
  12166. export var helperFunctions: {
  12167. name: string;
  12168. shader: string;
  12169. };
  12170. }
  12171. declare module BABYLON {
  12172. /**
  12173. * Block used to read a texture from a sampler
  12174. */
  12175. export class TextureBlock extends NodeMaterialBlock {
  12176. private _defineName;
  12177. private _linearDefineName;
  12178. private _gammaDefineName;
  12179. private _tempTextureRead;
  12180. private _samplerName;
  12181. private _transformedUVName;
  12182. private _textureTransformName;
  12183. private _textureInfoName;
  12184. private _mainUVName;
  12185. private _mainUVDefineName;
  12186. private _fragmentOnly;
  12187. /**
  12188. * Gets or sets the texture associated with the node
  12189. */
  12190. texture: Nullable<Texture>;
  12191. /**
  12192. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12193. */
  12194. convertToGammaSpace: boolean;
  12195. /**
  12196. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12197. */
  12198. convertToLinearSpace: boolean;
  12199. /**
  12200. * Create a new TextureBlock
  12201. * @param name defines the block name
  12202. */
  12203. constructor(name: string, fragmentOnly?: boolean);
  12204. /**
  12205. * Gets the current class name
  12206. * @returns the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Gets the uv input component
  12211. */
  12212. get uv(): NodeMaterialConnectionPoint;
  12213. /**
  12214. * Gets the rgba output component
  12215. */
  12216. get rgba(): NodeMaterialConnectionPoint;
  12217. /**
  12218. * Gets the rgb output component
  12219. */
  12220. get rgb(): NodeMaterialConnectionPoint;
  12221. /**
  12222. * Gets the r output component
  12223. */
  12224. get r(): NodeMaterialConnectionPoint;
  12225. /**
  12226. * Gets the g output component
  12227. */
  12228. get g(): NodeMaterialConnectionPoint;
  12229. /**
  12230. * Gets the b output component
  12231. */
  12232. get b(): NodeMaterialConnectionPoint;
  12233. /**
  12234. * Gets the a output component
  12235. */
  12236. get a(): NodeMaterialConnectionPoint;
  12237. get target(): NodeMaterialBlockTargets;
  12238. autoConfigure(material: NodeMaterial): void;
  12239. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12240. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12241. isReady(): boolean;
  12242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12243. private get _isMixed();
  12244. private _injectVertexCode;
  12245. private _writeTextureRead;
  12246. private _writeOutput;
  12247. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12248. protected _dumpPropertiesCode(): string;
  12249. serialize(): any;
  12250. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12251. }
  12252. }
  12253. declare module BABYLON {
  12254. /** @hidden */
  12255. export var reflectionFunction: {
  12256. name: string;
  12257. shader: string;
  12258. };
  12259. }
  12260. declare module BABYLON {
  12261. /**
  12262. * Base block used to read a reflection texture from a sampler
  12263. */
  12264. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12265. /** @hidden */
  12266. _define3DName: string;
  12267. /** @hidden */
  12268. _defineCubicName: string;
  12269. /** @hidden */
  12270. _defineExplicitName: string;
  12271. /** @hidden */
  12272. _defineProjectionName: string;
  12273. /** @hidden */
  12274. _defineLocalCubicName: string;
  12275. /** @hidden */
  12276. _defineSphericalName: string;
  12277. /** @hidden */
  12278. _definePlanarName: string;
  12279. /** @hidden */
  12280. _defineEquirectangularName: string;
  12281. /** @hidden */
  12282. _defineMirroredEquirectangularFixedName: string;
  12283. /** @hidden */
  12284. _defineEquirectangularFixedName: string;
  12285. /** @hidden */
  12286. _defineSkyboxName: string;
  12287. /** @hidden */
  12288. _defineOppositeZ: string;
  12289. /** @hidden */
  12290. _cubeSamplerName: string;
  12291. /** @hidden */
  12292. _2DSamplerName: string;
  12293. protected _positionUVWName: string;
  12294. protected _directionWName: string;
  12295. protected _reflectionVectorName: string;
  12296. /** @hidden */
  12297. _reflectionCoordsName: string;
  12298. /** @hidden */
  12299. _reflectionMatrixName: string;
  12300. protected _reflectionColorName: string;
  12301. /**
  12302. * Gets or sets the texture associated with the node
  12303. */
  12304. texture: Nullable<BaseTexture>;
  12305. /**
  12306. * Create a new ReflectionTextureBaseBlock
  12307. * @param name defines the block name
  12308. */
  12309. constructor(name: string);
  12310. /**
  12311. * Gets the current class name
  12312. * @returns the class name
  12313. */
  12314. getClassName(): string;
  12315. /**
  12316. * Gets the world position input component
  12317. */
  12318. abstract get position(): NodeMaterialConnectionPoint;
  12319. /**
  12320. * Gets the world position input component
  12321. */
  12322. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12323. /**
  12324. * Gets the world normal input component
  12325. */
  12326. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12327. /**
  12328. * Gets the world input component
  12329. */
  12330. abstract get world(): NodeMaterialConnectionPoint;
  12331. /**
  12332. * Gets the camera (or eye) position component
  12333. */
  12334. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12335. /**
  12336. * Gets the view input component
  12337. */
  12338. abstract get view(): NodeMaterialConnectionPoint;
  12339. protected _getTexture(): Nullable<BaseTexture>;
  12340. autoConfigure(material: NodeMaterial): void;
  12341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12342. isReady(): boolean;
  12343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12344. /**
  12345. * Gets the code to inject in the vertex shader
  12346. * @param state current state of the node material building
  12347. * @returns the shader code
  12348. */
  12349. handleVertexSide(state: NodeMaterialBuildState): string;
  12350. /**
  12351. * Handles the inits for the fragment code path
  12352. * @param state node material build state
  12353. */
  12354. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12355. /**
  12356. * Generates the reflection coords code for the fragment code path
  12357. * @param worldNormalVarName name of the world normal variable
  12358. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12359. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12360. * @returns the shader code
  12361. */
  12362. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12363. /**
  12364. * Generates the reflection color code for the fragment code path
  12365. * @param lodVarName name of the lod variable
  12366. * @param swizzleLookupTexture swizzle to use for the final color variable
  12367. * @returns the shader code
  12368. */
  12369. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12370. /**
  12371. * Generates the code corresponding to the connected output points
  12372. * @param state node material build state
  12373. * @param varName name of the variable to output
  12374. * @returns the shader code
  12375. */
  12376. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12377. protected _buildBlock(state: NodeMaterialBuildState): this;
  12378. protected _dumpPropertiesCode(): string;
  12379. serialize(): any;
  12380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12381. }
  12382. }
  12383. declare module BABYLON {
  12384. /**
  12385. * Defines a connection point to be used for points with a custom object type
  12386. */
  12387. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12388. private _blockType;
  12389. private _blockName;
  12390. private _nameForCheking?;
  12391. /**
  12392. * Creates a new connection point
  12393. * @param name defines the connection point name
  12394. * @param ownerBlock defines the block hosting this connection point
  12395. * @param direction defines the direction of the connection point
  12396. */
  12397. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12398. /**
  12399. * Gets a number indicating if the current point can be connected to another point
  12400. * @param connectionPoint defines the other connection point
  12401. * @returns a number defining the compatibility state
  12402. */
  12403. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12404. /**
  12405. * Creates a block suitable to be used as an input for this input point.
  12406. * If null is returned, a block based on the point type will be created.
  12407. * @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
  12408. */
  12409. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12410. }
  12411. }
  12412. declare module BABYLON {
  12413. /**
  12414. * Enum defining the type of properties that can be edited in the property pages in the NME
  12415. */
  12416. export enum PropertyTypeForEdition {
  12417. /** property is a boolean */
  12418. Boolean = 0,
  12419. /** property is a float */
  12420. Float = 1,
  12421. /** property is a Vector2 */
  12422. Vector2 = 2,
  12423. /** property is a list of values */
  12424. List = 3
  12425. }
  12426. /**
  12427. * Interface that defines an option in a variable of type list
  12428. */
  12429. export interface IEditablePropertyListOption {
  12430. /** label of the option */
  12431. "label": string;
  12432. /** value of the option */
  12433. "value": number;
  12434. }
  12435. /**
  12436. * Interface that defines the options available for an editable property
  12437. */
  12438. export interface IEditablePropertyOption {
  12439. /** min value */
  12440. "min"?: number;
  12441. /** max value */
  12442. "max"?: number;
  12443. /** notifiers: indicates which actions to take when the property is changed */
  12444. "notifiers"?: {
  12445. /** the material should be rebuilt */
  12446. "rebuild"?: boolean;
  12447. /** the preview should be updated */
  12448. "update"?: boolean;
  12449. };
  12450. /** list of the options for a variable of type list */
  12451. "options"?: IEditablePropertyListOption[];
  12452. }
  12453. /**
  12454. * Interface that describes an editable property
  12455. */
  12456. export interface IPropertyDescriptionForEdition {
  12457. /** name of the property */
  12458. "propertyName": string;
  12459. /** display name of the property */
  12460. "displayName": string;
  12461. /** type of the property */
  12462. "type": PropertyTypeForEdition;
  12463. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12464. "groupName": string;
  12465. /** options for the property */
  12466. "options": IEditablePropertyOption;
  12467. }
  12468. /**
  12469. * Decorator that flags a property in a node material block as being editable
  12470. */
  12471. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12472. }
  12473. declare module BABYLON {
  12474. /**
  12475. * Block used to implement the refraction part of the sub surface module of the PBR material
  12476. */
  12477. export class RefractionBlock extends NodeMaterialBlock {
  12478. /** @hidden */
  12479. _define3DName: string;
  12480. /** @hidden */
  12481. _refractionMatrixName: string;
  12482. /** @hidden */
  12483. _defineLODRefractionAlpha: string;
  12484. /** @hidden */
  12485. _defineLinearSpecularRefraction: string;
  12486. /** @hidden */
  12487. _defineOppositeZ: string;
  12488. /** @hidden */
  12489. _cubeSamplerName: string;
  12490. /** @hidden */
  12491. _2DSamplerName: string;
  12492. /** @hidden */
  12493. _vRefractionMicrosurfaceInfosName: string;
  12494. /** @hidden */
  12495. _vRefractionInfosName: string;
  12496. /** @hidden */
  12497. _vRefractionFilteringInfoName: string;
  12498. private _scene;
  12499. /**
  12500. * The properties below are set by the main PBR block prior to calling methods of this class.
  12501. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12502. * It's less burden on the user side in the editor part.
  12503. */
  12504. /** @hidden */
  12505. viewConnectionPoint: NodeMaterialConnectionPoint;
  12506. /** @hidden */
  12507. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12508. /**
  12509. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12510. * Materials half opaque for instance using refraction could benefit from this control.
  12511. */
  12512. linkRefractionWithTransparency: boolean;
  12513. /**
  12514. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12515. */
  12516. invertRefractionY: boolean;
  12517. /**
  12518. * Gets or sets the texture associated with the node
  12519. */
  12520. texture: Nullable<BaseTexture>;
  12521. /**
  12522. * Create a new RefractionBlock
  12523. * @param name defines the block name
  12524. */
  12525. constructor(name: string);
  12526. /**
  12527. * Gets the current class name
  12528. * @returns the class name
  12529. */
  12530. getClassName(): string;
  12531. /**
  12532. * Gets the intensity input component
  12533. */
  12534. get intensity(): NodeMaterialConnectionPoint;
  12535. /**
  12536. * Gets the tint at distance input component
  12537. */
  12538. get tintAtDistance(): NodeMaterialConnectionPoint;
  12539. /**
  12540. * Gets the view input component
  12541. */
  12542. get view(): NodeMaterialConnectionPoint;
  12543. /**
  12544. * Gets the refraction object output component
  12545. */
  12546. get refraction(): NodeMaterialConnectionPoint;
  12547. /**
  12548. * Returns true if the block has a texture
  12549. */
  12550. get hasTexture(): boolean;
  12551. protected _getTexture(): Nullable<BaseTexture>;
  12552. autoConfigure(material: NodeMaterial): void;
  12553. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12554. isReady(): boolean;
  12555. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12556. /**
  12557. * Gets the main code of the block (fragment side)
  12558. * @param state current state of the node material building
  12559. * @returns the shader code
  12560. */
  12561. getCode(state: NodeMaterialBuildState): string;
  12562. protected _buildBlock(state: NodeMaterialBuildState): this;
  12563. protected _dumpPropertiesCode(): string;
  12564. serialize(): any;
  12565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12566. }
  12567. }
  12568. declare module BABYLON {
  12569. /**
  12570. * Base block used as input for post process
  12571. */
  12572. export class CurrentScreenBlock extends NodeMaterialBlock {
  12573. private _samplerName;
  12574. private _linearDefineName;
  12575. private _gammaDefineName;
  12576. private _mainUVName;
  12577. private _tempTextureRead;
  12578. /**
  12579. * Gets or sets the texture associated with the node
  12580. */
  12581. texture: Nullable<BaseTexture>;
  12582. /**
  12583. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12584. */
  12585. convertToGammaSpace: boolean;
  12586. /**
  12587. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12588. */
  12589. convertToLinearSpace: boolean;
  12590. /**
  12591. * Create a new CurrentScreenBlock
  12592. * @param name defines the block name
  12593. */
  12594. constructor(name: string);
  12595. /**
  12596. * Gets the current class name
  12597. * @returns the class name
  12598. */
  12599. getClassName(): string;
  12600. /**
  12601. * Gets the uv input component
  12602. */
  12603. get uv(): NodeMaterialConnectionPoint;
  12604. /**
  12605. * Gets the rgba output component
  12606. */
  12607. get rgba(): NodeMaterialConnectionPoint;
  12608. /**
  12609. * Gets the rgb output component
  12610. */
  12611. get rgb(): NodeMaterialConnectionPoint;
  12612. /**
  12613. * Gets the r output component
  12614. */
  12615. get r(): NodeMaterialConnectionPoint;
  12616. /**
  12617. * Gets the g output component
  12618. */
  12619. get g(): NodeMaterialConnectionPoint;
  12620. /**
  12621. * Gets the b output component
  12622. */
  12623. get b(): NodeMaterialConnectionPoint;
  12624. /**
  12625. * Gets the a output component
  12626. */
  12627. get a(): NodeMaterialConnectionPoint;
  12628. /**
  12629. * Initialize the block and prepare the context for build
  12630. * @param state defines the state that will be used for the build
  12631. */
  12632. initialize(state: NodeMaterialBuildState): void;
  12633. get target(): NodeMaterialBlockTargets;
  12634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12635. isReady(): boolean;
  12636. private _injectVertexCode;
  12637. private _writeTextureRead;
  12638. private _writeOutput;
  12639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12640. serialize(): any;
  12641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12642. }
  12643. }
  12644. declare module BABYLON {
  12645. /**
  12646. * Base block used for the particle texture
  12647. */
  12648. export class ParticleTextureBlock extends NodeMaterialBlock {
  12649. private _samplerName;
  12650. private _linearDefineName;
  12651. private _gammaDefineName;
  12652. private _tempTextureRead;
  12653. /**
  12654. * Gets or sets the texture associated with the node
  12655. */
  12656. texture: Nullable<BaseTexture>;
  12657. /**
  12658. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12659. */
  12660. convertToGammaSpace: boolean;
  12661. /**
  12662. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12663. */
  12664. convertToLinearSpace: boolean;
  12665. /**
  12666. * Create a new ParticleTextureBlock
  12667. * @param name defines the block name
  12668. */
  12669. constructor(name: string);
  12670. /**
  12671. * Gets the current class name
  12672. * @returns the class name
  12673. */
  12674. getClassName(): string;
  12675. /**
  12676. * Gets the uv input component
  12677. */
  12678. get uv(): NodeMaterialConnectionPoint;
  12679. /**
  12680. * Gets the rgba output component
  12681. */
  12682. get rgba(): NodeMaterialConnectionPoint;
  12683. /**
  12684. * Gets the rgb output component
  12685. */
  12686. get rgb(): NodeMaterialConnectionPoint;
  12687. /**
  12688. * Gets the r output component
  12689. */
  12690. get r(): NodeMaterialConnectionPoint;
  12691. /**
  12692. * Gets the g output component
  12693. */
  12694. get g(): NodeMaterialConnectionPoint;
  12695. /**
  12696. * Gets the b output component
  12697. */
  12698. get b(): NodeMaterialConnectionPoint;
  12699. /**
  12700. * Gets the a output component
  12701. */
  12702. get a(): NodeMaterialConnectionPoint;
  12703. /**
  12704. * Initialize the block and prepare the context for build
  12705. * @param state defines the state that will be used for the build
  12706. */
  12707. initialize(state: NodeMaterialBuildState): void;
  12708. autoConfigure(material: NodeMaterial): void;
  12709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12710. isReady(): boolean;
  12711. private _writeOutput;
  12712. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12713. serialize(): any;
  12714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12715. }
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Class used to store shared data between 2 NodeMaterialBuildState
  12720. */
  12721. export class NodeMaterialBuildStateSharedData {
  12722. /**
  12723. * Gets the list of emitted varyings
  12724. */
  12725. temps: string[];
  12726. /**
  12727. * Gets the list of emitted varyings
  12728. */
  12729. varyings: string[];
  12730. /**
  12731. * Gets the varying declaration string
  12732. */
  12733. varyingDeclaration: string;
  12734. /**
  12735. * Input blocks
  12736. */
  12737. inputBlocks: InputBlock[];
  12738. /**
  12739. * Input blocks
  12740. */
  12741. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12742. /**
  12743. * Bindable blocks (Blocks that need to set data to the effect)
  12744. */
  12745. bindableBlocks: NodeMaterialBlock[];
  12746. /**
  12747. * List of blocks that can provide a compilation fallback
  12748. */
  12749. blocksWithFallbacks: NodeMaterialBlock[];
  12750. /**
  12751. * List of blocks that can provide a define update
  12752. */
  12753. blocksWithDefines: NodeMaterialBlock[];
  12754. /**
  12755. * List of blocks that can provide a repeatable content
  12756. */
  12757. repeatableContentBlocks: NodeMaterialBlock[];
  12758. /**
  12759. * List of blocks that can provide a dynamic list of uniforms
  12760. */
  12761. dynamicUniformBlocks: NodeMaterialBlock[];
  12762. /**
  12763. * List of blocks that can block the isReady function for the material
  12764. */
  12765. blockingBlocks: NodeMaterialBlock[];
  12766. /**
  12767. * Gets the list of animated inputs
  12768. */
  12769. animatedInputs: InputBlock[];
  12770. /**
  12771. * Build Id used to avoid multiple recompilations
  12772. */
  12773. buildId: number;
  12774. /** List of emitted variables */
  12775. variableNames: {
  12776. [key: string]: number;
  12777. };
  12778. /** List of emitted defines */
  12779. defineNames: {
  12780. [key: string]: number;
  12781. };
  12782. /** Should emit comments? */
  12783. emitComments: boolean;
  12784. /** Emit build activity */
  12785. verbose: boolean;
  12786. /** Gets or sets the hosting scene */
  12787. scene: Scene;
  12788. /**
  12789. * Gets the compilation hints emitted at compilation time
  12790. */
  12791. hints: {
  12792. needWorldViewMatrix: boolean;
  12793. needWorldViewProjectionMatrix: boolean;
  12794. needAlphaBlending: boolean;
  12795. needAlphaTesting: boolean;
  12796. };
  12797. /**
  12798. * List of compilation checks
  12799. */
  12800. checks: {
  12801. emitVertex: boolean;
  12802. emitFragment: boolean;
  12803. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12804. };
  12805. /**
  12806. * Is vertex program allowed to be empty?
  12807. */
  12808. allowEmptyVertexProgram: boolean;
  12809. /** Creates a new shared data */
  12810. constructor();
  12811. /**
  12812. * Emits console errors and exceptions if there is a failing check
  12813. */
  12814. emitErrors(): void;
  12815. }
  12816. }
  12817. declare module BABYLON {
  12818. /**
  12819. * Class used to store node based material build state
  12820. */
  12821. export class NodeMaterialBuildState {
  12822. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12823. supportUniformBuffers: boolean;
  12824. /**
  12825. * Gets the list of emitted attributes
  12826. */
  12827. attributes: string[];
  12828. /**
  12829. * Gets the list of emitted uniforms
  12830. */
  12831. uniforms: string[];
  12832. /**
  12833. * Gets the list of emitted constants
  12834. */
  12835. constants: string[];
  12836. /**
  12837. * Gets the list of emitted samplers
  12838. */
  12839. samplers: string[];
  12840. /**
  12841. * Gets the list of emitted functions
  12842. */
  12843. functions: {
  12844. [key: string]: string;
  12845. };
  12846. /**
  12847. * Gets the list of emitted extensions
  12848. */
  12849. extensions: {
  12850. [key: string]: string;
  12851. };
  12852. /**
  12853. * Gets the target of the compilation state
  12854. */
  12855. target: NodeMaterialBlockTargets;
  12856. /**
  12857. * Gets the list of emitted counters
  12858. */
  12859. counters: {
  12860. [key: string]: number;
  12861. };
  12862. /**
  12863. * Shared data between multiple NodeMaterialBuildState instances
  12864. */
  12865. sharedData: NodeMaterialBuildStateSharedData;
  12866. /** @hidden */
  12867. _vertexState: NodeMaterialBuildState;
  12868. /** @hidden */
  12869. _attributeDeclaration: string;
  12870. /** @hidden */
  12871. _uniformDeclaration: string;
  12872. /** @hidden */
  12873. _constantDeclaration: string;
  12874. /** @hidden */
  12875. _samplerDeclaration: string;
  12876. /** @hidden */
  12877. _varyingTransfer: string;
  12878. /** @hidden */
  12879. _injectAtEnd: string;
  12880. private _repeatableContentAnchorIndex;
  12881. /** @hidden */
  12882. _builtCompilationString: string;
  12883. /**
  12884. * Gets the emitted compilation strings
  12885. */
  12886. compilationString: string;
  12887. /**
  12888. * Finalize the compilation strings
  12889. * @param state defines the current compilation state
  12890. */
  12891. finalize(state: NodeMaterialBuildState): void;
  12892. /** @hidden */
  12893. get _repeatableContentAnchor(): string;
  12894. /** @hidden */
  12895. _getFreeVariableName(prefix: string): string;
  12896. /** @hidden */
  12897. _getFreeDefineName(prefix: string): string;
  12898. /** @hidden */
  12899. _excludeVariableName(name: string): void;
  12900. /** @hidden */
  12901. _emit2DSampler(name: string): void;
  12902. /** @hidden */
  12903. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12904. /** @hidden */
  12905. _emitExtension(name: string, extension: string, define?: string): void;
  12906. /** @hidden */
  12907. _emitFunction(name: string, code: string, comments: string): void;
  12908. /** @hidden */
  12909. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12910. replaceStrings?: {
  12911. search: RegExp;
  12912. replace: string;
  12913. }[];
  12914. repeatKey?: string;
  12915. }): string;
  12916. /** @hidden */
  12917. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12918. repeatKey?: string;
  12919. removeAttributes?: boolean;
  12920. removeUniforms?: boolean;
  12921. removeVaryings?: boolean;
  12922. removeIfDef?: boolean;
  12923. replaceStrings?: {
  12924. search: RegExp;
  12925. replace: string;
  12926. }[];
  12927. }, storeKey?: string): void;
  12928. /** @hidden */
  12929. _registerTempVariable(name: string): boolean;
  12930. /** @hidden */
  12931. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12932. /** @hidden */
  12933. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12934. /** @hidden */
  12935. _emitFloat(value: number): string;
  12936. }
  12937. }
  12938. declare module BABYLON {
  12939. /**
  12940. * Helper class used to generate session unique ID
  12941. */
  12942. export class UniqueIdGenerator {
  12943. private static _UniqueIdCounter;
  12944. /**
  12945. * Gets an unique (relatively to the current scene) Id
  12946. */
  12947. static get UniqueId(): number;
  12948. }
  12949. }
  12950. declare module BABYLON {
  12951. /**
  12952. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12953. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12954. */
  12955. export class EffectFallbacks implements IEffectFallbacks {
  12956. private _defines;
  12957. private _currentRank;
  12958. private _maxRank;
  12959. private _mesh;
  12960. /**
  12961. * Removes the fallback from the bound mesh.
  12962. */
  12963. unBindMesh(): void;
  12964. /**
  12965. * Adds a fallback on the specified property.
  12966. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12967. * @param define The name of the define in the shader
  12968. */
  12969. addFallback(rank: number, define: string): void;
  12970. /**
  12971. * Sets the mesh to use CPU skinning when needing to fallback.
  12972. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12973. * @param mesh The mesh to use the fallbacks.
  12974. */
  12975. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12976. /**
  12977. * Checks to see if more fallbacks are still availible.
  12978. */
  12979. get hasMoreFallbacks(): boolean;
  12980. /**
  12981. * Removes the defines that should be removed when falling back.
  12982. * @param currentDefines defines the current define statements for the shader.
  12983. * @param effect defines the current effect we try to compile
  12984. * @returns The resulting defines with defines of the current rank removed.
  12985. */
  12986. reduce(currentDefines: string, effect: Effect): string;
  12987. }
  12988. }
  12989. declare module BABYLON {
  12990. /**
  12991. * Defines a block that can be used inside a node based material
  12992. */
  12993. export class NodeMaterialBlock {
  12994. private _buildId;
  12995. private _buildTarget;
  12996. private _target;
  12997. private _isFinalMerger;
  12998. private _isInput;
  12999. private _name;
  13000. protected _isUnique: boolean;
  13001. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13002. inputsAreExclusive: boolean;
  13003. /** @hidden */
  13004. _codeVariableName: string;
  13005. /** @hidden */
  13006. _inputs: NodeMaterialConnectionPoint[];
  13007. /** @hidden */
  13008. _outputs: NodeMaterialConnectionPoint[];
  13009. /** @hidden */
  13010. _preparationId: number;
  13011. /**
  13012. * Gets the name of the block
  13013. */
  13014. get name(): string;
  13015. /**
  13016. * Sets the name of the block. Will check if the name is valid.
  13017. */
  13018. set name(newName: string);
  13019. /**
  13020. * Gets or sets the unique id of the node
  13021. */
  13022. uniqueId: number;
  13023. /**
  13024. * Gets or sets the comments associated with this block
  13025. */
  13026. comments: string;
  13027. /**
  13028. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13029. */
  13030. get isUnique(): boolean;
  13031. /**
  13032. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13033. */
  13034. get isFinalMerger(): boolean;
  13035. /**
  13036. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13037. */
  13038. get isInput(): boolean;
  13039. /**
  13040. * Gets or sets the build Id
  13041. */
  13042. get buildId(): number;
  13043. set buildId(value: number);
  13044. /**
  13045. * Gets or sets the target of the block
  13046. */
  13047. get target(): NodeMaterialBlockTargets;
  13048. set target(value: NodeMaterialBlockTargets);
  13049. /**
  13050. * Gets the list of input points
  13051. */
  13052. get inputs(): NodeMaterialConnectionPoint[];
  13053. /** Gets the list of output points */
  13054. get outputs(): NodeMaterialConnectionPoint[];
  13055. /**
  13056. * Find an input by its name
  13057. * @param name defines the name of the input to look for
  13058. * @returns the input or null if not found
  13059. */
  13060. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13061. /**
  13062. * Find an output by its name
  13063. * @param name defines the name of the outputto look for
  13064. * @returns the output or null if not found
  13065. */
  13066. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13067. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13068. visibleInInspector: boolean;
  13069. /**
  13070. * Creates a new NodeMaterialBlock
  13071. * @param name defines the block name
  13072. * @param target defines the target of that block (Vertex by default)
  13073. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13074. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13075. */
  13076. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13077. /**
  13078. * Initialize the block and prepare the context for build
  13079. * @param state defines the state that will be used for the build
  13080. */
  13081. initialize(state: NodeMaterialBuildState): void;
  13082. /**
  13083. * Bind data to effect. Will only be called for blocks with isBindable === true
  13084. * @param effect defines the effect to bind data to
  13085. * @param nodeMaterial defines the hosting NodeMaterial
  13086. * @param mesh defines the mesh that will be rendered
  13087. * @param subMesh defines the submesh that will be rendered
  13088. */
  13089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13090. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13091. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13092. protected _writeFloat(value: number): string;
  13093. /**
  13094. * Gets the current class name e.g. "NodeMaterialBlock"
  13095. * @returns the class name
  13096. */
  13097. getClassName(): string;
  13098. /**
  13099. * Register a new input. Must be called inside a block constructor
  13100. * @param name defines the connection point name
  13101. * @param type defines the connection point type
  13102. * @param isOptional defines a boolean indicating that this input can be omitted
  13103. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13104. * @param point an already created connection point. If not provided, create a new one
  13105. * @returns the current block
  13106. */
  13107. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13108. /**
  13109. * Register a new output. Must be called inside a block constructor
  13110. * @param name defines the connection point name
  13111. * @param type defines the connection point type
  13112. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13113. * @param point an already created connection point. If not provided, create a new one
  13114. * @returns the current block
  13115. */
  13116. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13117. /**
  13118. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13119. * @param forOutput defines an optional connection point to check compatibility with
  13120. * @returns the first available input or null
  13121. */
  13122. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13123. /**
  13124. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13125. * @param forBlock defines an optional block to check compatibility with
  13126. * @returns the first available input or null
  13127. */
  13128. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13129. /**
  13130. * Gets the sibling of the given output
  13131. * @param current defines the current output
  13132. * @returns the next output in the list or null
  13133. */
  13134. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13135. /**
  13136. * Connect current block with another block
  13137. * @param other defines the block to connect with
  13138. * @param options define the various options to help pick the right connections
  13139. * @returns the current block
  13140. */
  13141. connectTo(other: NodeMaterialBlock, options?: {
  13142. input?: string;
  13143. output?: string;
  13144. outputSwizzle?: string;
  13145. }): this | undefined;
  13146. protected _buildBlock(state: NodeMaterialBuildState): void;
  13147. /**
  13148. * Add uniforms, samplers and uniform buffers at compilation time
  13149. * @param state defines the state to update
  13150. * @param nodeMaterial defines the node material requesting the update
  13151. * @param defines defines the material defines to update
  13152. * @param uniformBuffers defines the list of uniform buffer names
  13153. */
  13154. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13155. /**
  13156. * Add potential fallbacks if shader compilation fails
  13157. * @param mesh defines the mesh to be rendered
  13158. * @param fallbacks defines the current prioritized list of fallbacks
  13159. */
  13160. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13161. /**
  13162. * Initialize defines for shader compilation
  13163. * @param mesh defines the mesh to be rendered
  13164. * @param nodeMaterial defines the node material requesting the update
  13165. * @param defines defines the material defines to update
  13166. * @param useInstances specifies that instances should be used
  13167. */
  13168. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13169. /**
  13170. * Update defines for shader compilation
  13171. * @param mesh defines the mesh to be rendered
  13172. * @param nodeMaterial defines the node material requesting the update
  13173. * @param defines defines the material defines to update
  13174. * @param useInstances specifies that instances should be used
  13175. * @param subMesh defines which submesh to render
  13176. */
  13177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13178. /**
  13179. * Lets the block try to connect some inputs automatically
  13180. * @param material defines the hosting NodeMaterial
  13181. */
  13182. autoConfigure(material: NodeMaterial): void;
  13183. /**
  13184. * Function called when a block is declared as repeatable content generator
  13185. * @param vertexShaderState defines the current compilation state for the vertex shader
  13186. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13187. * @param mesh defines the mesh to be rendered
  13188. * @param defines defines the material defines to update
  13189. */
  13190. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13191. /**
  13192. * Checks if the block is ready
  13193. * @param mesh defines the mesh to be rendered
  13194. * @param nodeMaterial defines the node material requesting the update
  13195. * @param defines defines the material defines to update
  13196. * @param useInstances specifies that instances should be used
  13197. * @returns true if the block is ready
  13198. */
  13199. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13200. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13201. private _processBuild;
  13202. /**
  13203. * Validates the new name for the block node.
  13204. * @param newName the new name to be given to the node.
  13205. * @returns false if the name is a reserve word, else true.
  13206. */
  13207. validateBlockName(newName: string): boolean;
  13208. /**
  13209. * Compile the current node and generate the shader code
  13210. * @param state defines the current compilation state (uniforms, samplers, current string)
  13211. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13212. * @returns true if already built
  13213. */
  13214. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13215. protected _inputRename(name: string): string;
  13216. protected _outputRename(name: string): string;
  13217. protected _dumpPropertiesCode(): string;
  13218. /** @hidden */
  13219. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13220. /** @hidden */
  13221. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13222. /**
  13223. * Clone the current block to a new identical block
  13224. * @param scene defines the hosting scene
  13225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13226. * @returns a copy of the current block
  13227. */
  13228. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13229. /**
  13230. * Serializes this block in a JSON representation
  13231. * @returns the serialized block object
  13232. */
  13233. serialize(): any;
  13234. /** @hidden */
  13235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13236. private _deserializePortDisplayNamesAndExposedOnFrame;
  13237. /**
  13238. * Release resources
  13239. */
  13240. dispose(): void;
  13241. }
  13242. }
  13243. declare module BABYLON {
  13244. /**
  13245. * Base class of materials working in push mode in babylon JS
  13246. * @hidden
  13247. */
  13248. export class PushMaterial extends Material {
  13249. protected _activeEffect: Effect;
  13250. protected _normalMatrix: Matrix;
  13251. constructor(name: string, scene: Scene);
  13252. getEffect(): Effect;
  13253. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13254. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13255. /**
  13256. * Binds the given world matrix to the active effect
  13257. *
  13258. * @param world the matrix to bind
  13259. */
  13260. bindOnlyWorldMatrix(world: Matrix): void;
  13261. /**
  13262. * Binds the given normal matrix to the active effect
  13263. *
  13264. * @param normalMatrix the matrix to bind
  13265. */
  13266. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13267. bind(world: Matrix, mesh?: Mesh): void;
  13268. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13269. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * Root class for all node material optimizers
  13275. */
  13276. export class NodeMaterialOptimizer {
  13277. /**
  13278. * Function used to optimize a NodeMaterial graph
  13279. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13280. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13281. */
  13282. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13283. }
  13284. }
  13285. declare module BABYLON {
  13286. /**
  13287. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13288. */
  13289. export class TransformBlock extends NodeMaterialBlock {
  13290. /**
  13291. * Defines the value to use to complement W value to transform it to a Vector4
  13292. */
  13293. complementW: number;
  13294. /**
  13295. * Defines the value to use to complement z value to transform it to a Vector4
  13296. */
  13297. complementZ: number;
  13298. /**
  13299. * Creates a new TransformBlock
  13300. * @param name defines the block name
  13301. */
  13302. constructor(name: string);
  13303. /**
  13304. * Gets the current class name
  13305. * @returns the class name
  13306. */
  13307. getClassName(): string;
  13308. /**
  13309. * Gets the vector input
  13310. */
  13311. get vector(): NodeMaterialConnectionPoint;
  13312. /**
  13313. * Gets the output component
  13314. */
  13315. get output(): NodeMaterialConnectionPoint;
  13316. /**
  13317. * Gets the xyz output component
  13318. */
  13319. get xyz(): NodeMaterialConnectionPoint;
  13320. /**
  13321. * Gets the matrix transform input
  13322. */
  13323. get transform(): NodeMaterialConnectionPoint;
  13324. protected _buildBlock(state: NodeMaterialBuildState): this;
  13325. /**
  13326. * Update defines for shader compilation
  13327. * @param mesh defines the mesh to be rendered
  13328. * @param nodeMaterial defines the node material requesting the update
  13329. * @param defines defines the material defines to update
  13330. * @param useInstances specifies that instances should be used
  13331. * @param subMesh defines which submesh to render
  13332. */
  13333. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13334. serialize(): any;
  13335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13336. protected _dumpPropertiesCode(): string;
  13337. }
  13338. }
  13339. declare module BABYLON {
  13340. /**
  13341. * Block used to output the vertex position
  13342. */
  13343. export class VertexOutputBlock extends NodeMaterialBlock {
  13344. /**
  13345. * Creates a new VertexOutputBlock
  13346. * @param name defines the block name
  13347. */
  13348. constructor(name: string);
  13349. /**
  13350. * Gets the current class name
  13351. * @returns the class name
  13352. */
  13353. getClassName(): string;
  13354. /**
  13355. * Gets the vector input component
  13356. */
  13357. get vector(): NodeMaterialConnectionPoint;
  13358. protected _buildBlock(state: NodeMaterialBuildState): this;
  13359. }
  13360. }
  13361. declare module BABYLON {
  13362. /**
  13363. * Block used to output the final color
  13364. */
  13365. export class FragmentOutputBlock extends NodeMaterialBlock {
  13366. /**
  13367. * Create a new FragmentOutputBlock
  13368. * @param name defines the block name
  13369. */
  13370. constructor(name: string);
  13371. /**
  13372. * Gets the current class name
  13373. * @returns the class name
  13374. */
  13375. getClassName(): string;
  13376. /**
  13377. * Gets the rgba input component
  13378. */
  13379. get rgba(): NodeMaterialConnectionPoint;
  13380. /**
  13381. * Gets the rgb input component
  13382. */
  13383. get rgb(): NodeMaterialConnectionPoint;
  13384. /**
  13385. * Gets the a input component
  13386. */
  13387. get a(): NodeMaterialConnectionPoint;
  13388. protected _buildBlock(state: NodeMaterialBuildState): this;
  13389. }
  13390. }
  13391. declare module BABYLON {
  13392. /**
  13393. * Block used for the particle ramp gradient section
  13394. */
  13395. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13396. /**
  13397. * Create a new ParticleRampGradientBlock
  13398. * @param name defines the block name
  13399. */
  13400. constructor(name: string);
  13401. /**
  13402. * Gets the current class name
  13403. * @returns the class name
  13404. */
  13405. getClassName(): string;
  13406. /**
  13407. * Gets the color input component
  13408. */
  13409. get color(): NodeMaterialConnectionPoint;
  13410. /**
  13411. * Gets the rampColor output component
  13412. */
  13413. get rampColor(): NodeMaterialConnectionPoint;
  13414. /**
  13415. * Initialize the block and prepare the context for build
  13416. * @param state defines the state that will be used for the build
  13417. */
  13418. initialize(state: NodeMaterialBuildState): void;
  13419. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13420. }
  13421. }
  13422. declare module BABYLON {
  13423. /**
  13424. * Block used for the particle blend multiply section
  13425. */
  13426. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13427. /**
  13428. * Create a new ParticleBlendMultiplyBlock
  13429. * @param name defines the block name
  13430. */
  13431. constructor(name: string);
  13432. /**
  13433. * Gets the current class name
  13434. * @returns the class name
  13435. */
  13436. getClassName(): string;
  13437. /**
  13438. * Gets the color input component
  13439. */
  13440. get color(): NodeMaterialConnectionPoint;
  13441. /**
  13442. * Gets the alphaTexture input component
  13443. */
  13444. get alphaTexture(): NodeMaterialConnectionPoint;
  13445. /**
  13446. * Gets the alphaColor input component
  13447. */
  13448. get alphaColor(): NodeMaterialConnectionPoint;
  13449. /**
  13450. * Gets the blendColor output component
  13451. */
  13452. get blendColor(): NodeMaterialConnectionPoint;
  13453. /**
  13454. * Initialize the block and prepare the context for build
  13455. * @param state defines the state that will be used for the build
  13456. */
  13457. initialize(state: NodeMaterialBuildState): void;
  13458. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13459. }
  13460. }
  13461. declare module BABYLON {
  13462. /**
  13463. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13464. */
  13465. export class VectorMergerBlock extends NodeMaterialBlock {
  13466. /**
  13467. * Create a new VectorMergerBlock
  13468. * @param name defines the block name
  13469. */
  13470. constructor(name: string);
  13471. /**
  13472. * Gets the current class name
  13473. * @returns the class name
  13474. */
  13475. getClassName(): string;
  13476. /**
  13477. * Gets the xyz component (input)
  13478. */
  13479. get xyzIn(): NodeMaterialConnectionPoint;
  13480. /**
  13481. * Gets the xy component (input)
  13482. */
  13483. get xyIn(): NodeMaterialConnectionPoint;
  13484. /**
  13485. * Gets the x component (input)
  13486. */
  13487. get x(): NodeMaterialConnectionPoint;
  13488. /**
  13489. * Gets the y component (input)
  13490. */
  13491. get y(): NodeMaterialConnectionPoint;
  13492. /**
  13493. * Gets the z component (input)
  13494. */
  13495. get z(): NodeMaterialConnectionPoint;
  13496. /**
  13497. * Gets the w component (input)
  13498. */
  13499. get w(): NodeMaterialConnectionPoint;
  13500. /**
  13501. * Gets the xyzw component (output)
  13502. */
  13503. get xyzw(): NodeMaterialConnectionPoint;
  13504. /**
  13505. * Gets the xyz component (output)
  13506. */
  13507. get xyzOut(): NodeMaterialConnectionPoint;
  13508. /**
  13509. * Gets the xy component (output)
  13510. */
  13511. get xyOut(): NodeMaterialConnectionPoint;
  13512. /**
  13513. * Gets the xy component (output)
  13514. * @deprecated Please use xyOut instead.
  13515. */
  13516. get xy(): NodeMaterialConnectionPoint;
  13517. /**
  13518. * Gets the xyz component (output)
  13519. * @deprecated Please use xyzOut instead.
  13520. */
  13521. get xyz(): NodeMaterialConnectionPoint;
  13522. protected _buildBlock(state: NodeMaterialBuildState): this;
  13523. }
  13524. }
  13525. declare module BABYLON {
  13526. /**
  13527. * Block used to remap a float from a range to a new one
  13528. */
  13529. export class RemapBlock extends NodeMaterialBlock {
  13530. /**
  13531. * Gets or sets the source range
  13532. */
  13533. sourceRange: Vector2;
  13534. /**
  13535. * Gets or sets the target range
  13536. */
  13537. targetRange: Vector2;
  13538. /**
  13539. * Creates a new RemapBlock
  13540. * @param name defines the block name
  13541. */
  13542. constructor(name: string);
  13543. /**
  13544. * Gets the current class name
  13545. * @returns the class name
  13546. */
  13547. getClassName(): string;
  13548. /**
  13549. * Gets the input component
  13550. */
  13551. get input(): NodeMaterialConnectionPoint;
  13552. /**
  13553. * Gets the source min input component
  13554. */
  13555. get sourceMin(): NodeMaterialConnectionPoint;
  13556. /**
  13557. * Gets the source max input component
  13558. */
  13559. get sourceMax(): NodeMaterialConnectionPoint;
  13560. /**
  13561. * Gets the target min input component
  13562. */
  13563. get targetMin(): NodeMaterialConnectionPoint;
  13564. /**
  13565. * Gets the target max input component
  13566. */
  13567. get targetMax(): NodeMaterialConnectionPoint;
  13568. /**
  13569. * Gets the output component
  13570. */
  13571. get output(): NodeMaterialConnectionPoint;
  13572. protected _buildBlock(state: NodeMaterialBuildState): this;
  13573. protected _dumpPropertiesCode(): string;
  13574. serialize(): any;
  13575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13576. }
  13577. }
  13578. declare module BABYLON {
  13579. /**
  13580. * Block used to multiply 2 values
  13581. */
  13582. export class MultiplyBlock extends NodeMaterialBlock {
  13583. /**
  13584. * Creates a new MultiplyBlock
  13585. * @param name defines the block name
  13586. */
  13587. constructor(name: string);
  13588. /**
  13589. * Gets the current class name
  13590. * @returns the class name
  13591. */
  13592. getClassName(): string;
  13593. /**
  13594. * Gets the left operand input component
  13595. */
  13596. get left(): NodeMaterialConnectionPoint;
  13597. /**
  13598. * Gets the right operand input component
  13599. */
  13600. get right(): NodeMaterialConnectionPoint;
  13601. /**
  13602. * Gets the output component
  13603. */
  13604. get output(): NodeMaterialConnectionPoint;
  13605. protected _buildBlock(state: NodeMaterialBuildState): this;
  13606. }
  13607. }
  13608. declare module BABYLON {
  13609. /** Interface used by value gradients (color, factor, ...) */
  13610. export interface IValueGradient {
  13611. /**
  13612. * Gets or sets the gradient value (between 0 and 1)
  13613. */
  13614. gradient: number;
  13615. }
  13616. /** Class used to store color4 gradient */
  13617. export class ColorGradient implements IValueGradient {
  13618. /**
  13619. * Gets or sets the gradient value (between 0 and 1)
  13620. */
  13621. gradient: number;
  13622. /**
  13623. * Gets or sets first associated color
  13624. */
  13625. color1: Color4;
  13626. /**
  13627. * Gets or sets second associated color
  13628. */
  13629. color2?: Color4 | undefined;
  13630. /**
  13631. * Creates a new color4 gradient
  13632. * @param gradient gets or sets the gradient value (between 0 and 1)
  13633. * @param color1 gets or sets first associated color
  13634. * @param color2 gets or sets first second color
  13635. */
  13636. constructor(
  13637. /**
  13638. * Gets or sets the gradient value (between 0 and 1)
  13639. */
  13640. gradient: number,
  13641. /**
  13642. * Gets or sets first associated color
  13643. */
  13644. color1: Color4,
  13645. /**
  13646. * Gets or sets second associated color
  13647. */
  13648. color2?: Color4 | undefined);
  13649. /**
  13650. * Will get a color picked randomly between color1 and color2.
  13651. * If color2 is undefined then color1 will be used
  13652. * @param result defines the target Color4 to store the result in
  13653. */
  13654. getColorToRef(result: Color4): void;
  13655. }
  13656. /** Class used to store color 3 gradient */
  13657. export class Color3Gradient implements IValueGradient {
  13658. /**
  13659. * Gets or sets the gradient value (between 0 and 1)
  13660. */
  13661. gradient: number;
  13662. /**
  13663. * Gets or sets the associated color
  13664. */
  13665. color: Color3;
  13666. /**
  13667. * Creates a new color3 gradient
  13668. * @param gradient gets or sets the gradient value (between 0 and 1)
  13669. * @param color gets or sets associated color
  13670. */
  13671. constructor(
  13672. /**
  13673. * Gets or sets the gradient value (between 0 and 1)
  13674. */
  13675. gradient: number,
  13676. /**
  13677. * Gets or sets the associated color
  13678. */
  13679. color: Color3);
  13680. }
  13681. /** Class used to store factor gradient */
  13682. export class FactorGradient implements IValueGradient {
  13683. /**
  13684. * Gets or sets the gradient value (between 0 and 1)
  13685. */
  13686. gradient: number;
  13687. /**
  13688. * Gets or sets first associated factor
  13689. */
  13690. factor1: number;
  13691. /**
  13692. * Gets or sets second associated factor
  13693. */
  13694. factor2?: number | undefined;
  13695. /**
  13696. * Creates a new factor gradient
  13697. * @param gradient gets or sets the gradient value (between 0 and 1)
  13698. * @param factor1 gets or sets first associated factor
  13699. * @param factor2 gets or sets second associated factor
  13700. */
  13701. constructor(
  13702. /**
  13703. * Gets or sets the gradient value (between 0 and 1)
  13704. */
  13705. gradient: number,
  13706. /**
  13707. * Gets or sets first associated factor
  13708. */
  13709. factor1: number,
  13710. /**
  13711. * Gets or sets second associated factor
  13712. */
  13713. factor2?: number | undefined);
  13714. /**
  13715. * Will get a number picked randomly between factor1 and factor2.
  13716. * If factor2 is undefined then factor1 will be used
  13717. * @returns the picked number
  13718. */
  13719. getFactor(): number;
  13720. }
  13721. /**
  13722. * Helper used to simplify some generic gradient tasks
  13723. */
  13724. export class GradientHelper {
  13725. /**
  13726. * Gets the current gradient from an array of IValueGradient
  13727. * @param ratio defines the current ratio to get
  13728. * @param gradients defines the array of IValueGradient
  13729. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13730. */
  13731. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13732. }
  13733. }
  13734. declare module BABYLON {
  13735. interface ThinEngine {
  13736. /**
  13737. * Creates a raw texture
  13738. * @param data defines the data to store in the texture
  13739. * @param width defines the width of the texture
  13740. * @param height defines the height of the texture
  13741. * @param format defines the format of the data
  13742. * @param generateMipMaps defines if the engine should generate the mip levels
  13743. * @param invertY defines if data must be stored with Y axis inverted
  13744. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13745. * @param compression defines the compression used (null by default)
  13746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13747. * @returns the raw texture inside an InternalTexture
  13748. */
  13749. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13750. /**
  13751. * Update a raw texture
  13752. * @param texture defines the texture to update
  13753. * @param data defines the data to store in the texture
  13754. * @param format defines the format of the data
  13755. * @param invertY defines if data must be stored with Y axis inverted
  13756. */
  13757. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13758. /**
  13759. * Update a raw texture
  13760. * @param texture defines the texture to update
  13761. * @param data defines the data to store in the texture
  13762. * @param format defines the format of the data
  13763. * @param invertY defines if data must be stored with Y axis inverted
  13764. * @param compression defines the compression used (null by default)
  13765. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13766. */
  13767. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13768. /**
  13769. * Creates a new raw cube texture
  13770. * @param data defines the array of data to use to create each face
  13771. * @param size defines the size of the textures
  13772. * @param format defines the format of the data
  13773. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13774. * @param generateMipMaps defines if the engine should generate the mip levels
  13775. * @param invertY defines if data must be stored with Y axis inverted
  13776. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13777. * @param compression defines the compression used (null by default)
  13778. * @returns the cube texture as an InternalTexture
  13779. */
  13780. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13781. /**
  13782. * Update a raw cube texture
  13783. * @param texture defines the texture to udpdate
  13784. * @param data defines the data to store
  13785. * @param format defines the data format
  13786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13787. * @param invertY defines if data must be stored with Y axis inverted
  13788. */
  13789. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13790. /**
  13791. * Update a raw cube texture
  13792. * @param texture defines the texture to udpdate
  13793. * @param data defines the data to store
  13794. * @param format defines the data format
  13795. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13796. * @param invertY defines if data must be stored with Y axis inverted
  13797. * @param compression defines the compression used (null by default)
  13798. */
  13799. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13800. /**
  13801. * Update a raw cube texture
  13802. * @param texture defines the texture to udpdate
  13803. * @param data defines the data to store
  13804. * @param format defines the data format
  13805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13806. * @param invertY defines if data must be stored with Y axis inverted
  13807. * @param compression defines the compression used (null by default)
  13808. * @param level defines which level of the texture to update
  13809. */
  13810. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13811. /**
  13812. * Creates a new raw cube texture from a specified url
  13813. * @param url defines the url where the data is located
  13814. * @param scene defines the current scene
  13815. * @param size defines the size of the textures
  13816. * @param format defines the format of the data
  13817. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13818. * @param noMipmap defines if the engine should avoid generating the mip levels
  13819. * @param callback defines a callback used to extract texture data from loaded data
  13820. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13821. * @param onLoad defines a callback called when texture is loaded
  13822. * @param onError defines a callback called if there is an error
  13823. * @returns the cube texture as an InternalTexture
  13824. */
  13825. 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;
  13826. /**
  13827. * Creates a new raw cube texture from a specified url
  13828. * @param url defines the url where the data is located
  13829. * @param scene defines the current scene
  13830. * @param size defines the size of the textures
  13831. * @param format defines the format of the data
  13832. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13833. * @param noMipmap defines if the engine should avoid generating the mip levels
  13834. * @param callback defines a callback used to extract texture data from loaded data
  13835. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13836. * @param onLoad defines a callback called when texture is loaded
  13837. * @param onError defines a callback called if there is an error
  13838. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13839. * @param invertY defines if data must be stored with Y axis inverted
  13840. * @returns the cube texture as an InternalTexture
  13841. */
  13842. 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;
  13843. /**
  13844. * Creates a new raw 3D texture
  13845. * @param data defines the data used to create the texture
  13846. * @param width defines the width of the texture
  13847. * @param height defines the height of the texture
  13848. * @param depth defines the depth of the texture
  13849. * @param format defines the format of the texture
  13850. * @param generateMipMaps defines if the engine must generate mip levels
  13851. * @param invertY defines if data must be stored with Y axis inverted
  13852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13853. * @param compression defines the compressed used (can be null)
  13854. * @param textureType defines the compressed used (can be null)
  13855. * @returns a new raw 3D texture (stored in an InternalTexture)
  13856. */
  13857. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13858. /**
  13859. * Update a raw 3D texture
  13860. * @param texture defines the texture to update
  13861. * @param data defines the data to store
  13862. * @param format defines the data format
  13863. * @param invertY defines if data must be stored with Y axis inverted
  13864. */
  13865. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13866. /**
  13867. * Update a raw 3D texture
  13868. * @param texture defines the texture to update
  13869. * @param data defines the data to store
  13870. * @param format defines the data format
  13871. * @param invertY defines if data must be stored with Y axis inverted
  13872. * @param compression defines the used compression (can be null)
  13873. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13874. */
  13875. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13876. /**
  13877. * Creates a new raw 2D array texture
  13878. * @param data defines the data used to create the texture
  13879. * @param width defines the width of the texture
  13880. * @param height defines the height of the texture
  13881. * @param depth defines the number of layers of the texture
  13882. * @param format defines the format of the texture
  13883. * @param generateMipMaps defines if the engine must generate mip levels
  13884. * @param invertY defines if data must be stored with Y axis inverted
  13885. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13886. * @param compression defines the compressed used (can be null)
  13887. * @param textureType defines the compressed used (can be null)
  13888. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13889. */
  13890. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13891. /**
  13892. * Update a raw 2D array texture
  13893. * @param texture defines the texture to update
  13894. * @param data defines the data to store
  13895. * @param format defines the data format
  13896. * @param invertY defines if data must be stored with Y axis inverted
  13897. */
  13898. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13899. /**
  13900. * Update a raw 2D array texture
  13901. * @param texture defines the texture to update
  13902. * @param data defines the data to store
  13903. * @param format defines the data format
  13904. * @param invertY defines if data must be stored with Y axis inverted
  13905. * @param compression defines the used compression (can be null)
  13906. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13907. */
  13908. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13909. }
  13910. }
  13911. declare module BABYLON {
  13912. /**
  13913. * Raw texture can help creating a texture directly from an array of data.
  13914. * This can be super useful if you either get the data from an uncompressed source or
  13915. * if you wish to create your texture pixel by pixel.
  13916. */
  13917. export class RawTexture extends Texture {
  13918. /**
  13919. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13920. */
  13921. format: number;
  13922. /**
  13923. * Instantiates a new RawTexture.
  13924. * Raw texture can help creating a texture directly from an array of data.
  13925. * This can be super useful if you either get the data from an uncompressed source or
  13926. * if you wish to create your texture pixel by pixel.
  13927. * @param data define the array of data to use to create the texture
  13928. * @param width define the width of the texture
  13929. * @param height define the height of the texture
  13930. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13931. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13932. * @param generateMipMaps define whether mip maps should be generated or not
  13933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13935. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13936. */
  13937. constructor(data: ArrayBufferView, width: number, height: number,
  13938. /**
  13939. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13940. */
  13941. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13942. /**
  13943. * Updates the texture underlying data.
  13944. * @param data Define the new data of the texture
  13945. */
  13946. update(data: ArrayBufferView): void;
  13947. /**
  13948. * Creates a luminance texture from some data.
  13949. * @param data Define the texture data
  13950. * @param width Define the width of the texture
  13951. * @param height Define the height of the texture
  13952. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13953. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13954. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13955. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13956. * @returns the luminance texture
  13957. */
  13958. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13959. /**
  13960. * Creates a luminance alpha texture from some data.
  13961. * @param data Define the texture data
  13962. * @param width Define the width of the texture
  13963. * @param height Define the height of the texture
  13964. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13965. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13966. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13967. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13968. * @returns the luminance alpha texture
  13969. */
  13970. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13971. /**
  13972. * Creates an alpha texture from some data.
  13973. * @param data Define the texture data
  13974. * @param width Define the width of the texture
  13975. * @param height Define the height of the texture
  13976. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13977. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13978. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13979. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13980. * @returns the alpha texture
  13981. */
  13982. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13983. /**
  13984. * Creates a RGB texture from some data.
  13985. * @param data Define the texture data
  13986. * @param width Define the width of the texture
  13987. * @param height Define the height of the texture
  13988. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13989. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13990. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13991. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13992. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13993. * @returns the RGB alpha texture
  13994. */
  13995. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13996. /**
  13997. * Creates a RGBA texture from some data.
  13998. * @param data Define the texture data
  13999. * @param width Define the width of the texture
  14000. * @param height Define the height of the texture
  14001. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14005. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14006. * @returns the RGBA texture
  14007. */
  14008. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14009. /**
  14010. * Creates a R texture from some data.
  14011. * @param data Define the texture data
  14012. * @param width Define the width of the texture
  14013. * @param height Define the height of the texture
  14014. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14015. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14016. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14017. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14018. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14019. * @returns the R texture
  14020. */
  14021. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. interface ThinEngine {
  14026. /**
  14027. * Update a dynamic index buffer
  14028. * @param indexBuffer defines the target index buffer
  14029. * @param indices defines the data to update
  14030. * @param offset defines the offset in the target index buffer where update should start
  14031. */
  14032. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14033. /**
  14034. * Updates a dynamic vertex buffer.
  14035. * @param vertexBuffer the vertex buffer to update
  14036. * @param data the data used to update the vertex buffer
  14037. * @param byteOffset the byte offset of the data
  14038. * @param byteLength the byte length of the data
  14039. */
  14040. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14041. }
  14042. }
  14043. declare module BABYLON {
  14044. interface AbstractScene {
  14045. /**
  14046. * The list of procedural textures added to the scene
  14047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14048. */
  14049. proceduralTextures: Array<ProceduralTexture>;
  14050. }
  14051. /**
  14052. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14053. * in a given scene.
  14054. */
  14055. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14056. /**
  14057. * The component name helpfull to identify the component in the list of scene components.
  14058. */
  14059. readonly name: string;
  14060. /**
  14061. * The scene the component belongs to.
  14062. */
  14063. scene: Scene;
  14064. /**
  14065. * Creates a new instance of the component for the given scene
  14066. * @param scene Defines the scene to register the component in
  14067. */
  14068. constructor(scene: Scene);
  14069. /**
  14070. * Registers the component in a given scene
  14071. */
  14072. register(): void;
  14073. /**
  14074. * Rebuilds the elements related to this component in case of
  14075. * context lost for instance.
  14076. */
  14077. rebuild(): void;
  14078. /**
  14079. * Disposes the component and the associated ressources.
  14080. */
  14081. dispose(): void;
  14082. private _beforeClear;
  14083. }
  14084. }
  14085. declare module BABYLON {
  14086. interface ThinEngine {
  14087. /**
  14088. * Creates a new render target cube texture
  14089. * @param size defines the size of the texture
  14090. * @param options defines the options used to create the texture
  14091. * @returns a new render target cube texture stored in an InternalTexture
  14092. */
  14093. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14094. }
  14095. }
  14096. declare module BABYLON {
  14097. /** @hidden */
  14098. export var proceduralVertexShader: {
  14099. name: string;
  14100. shader: string;
  14101. };
  14102. }
  14103. declare module BABYLON {
  14104. /**
  14105. * 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.
  14106. * This is the base class of any Procedural texture and contains most of the shareable code.
  14107. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14108. */
  14109. export class ProceduralTexture extends Texture {
  14110. /**
  14111. * Define if the texture is enabled or not (disabled texture will not render)
  14112. */
  14113. isEnabled: boolean;
  14114. /**
  14115. * Define if the texture must be cleared before rendering (default is true)
  14116. */
  14117. autoClear: boolean;
  14118. /**
  14119. * Callback called when the texture is generated
  14120. */
  14121. onGenerated: () => void;
  14122. /**
  14123. * Event raised when the texture is generated
  14124. */
  14125. onGeneratedObservable: Observable<ProceduralTexture>;
  14126. /**
  14127. * Event raised before the texture is generated
  14128. */
  14129. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14130. /**
  14131. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14132. */
  14133. nodeMaterialSource: Nullable<NodeMaterial>;
  14134. /** @hidden */
  14135. _generateMipMaps: boolean;
  14136. /** @hidden **/
  14137. _effect: Effect;
  14138. /** @hidden */
  14139. _textures: {
  14140. [key: string]: Texture;
  14141. };
  14142. /** @hidden */
  14143. protected _fallbackTexture: Nullable<Texture>;
  14144. private _size;
  14145. private _currentRefreshId;
  14146. private _frameId;
  14147. private _refreshRate;
  14148. private _vertexBuffers;
  14149. private _indexBuffer;
  14150. private _uniforms;
  14151. private _samplers;
  14152. private _fragment;
  14153. private _floats;
  14154. private _ints;
  14155. private _floatsArrays;
  14156. private _colors3;
  14157. private _colors4;
  14158. private _vectors2;
  14159. private _vectors3;
  14160. private _matrices;
  14161. private _fallbackTextureUsed;
  14162. private _fullEngine;
  14163. private _cachedDefines;
  14164. private _contentUpdateId;
  14165. private _contentData;
  14166. /**
  14167. * Instantiates a new procedural texture.
  14168. * 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.
  14169. * This is the base class of any Procedural texture and contains most of the shareable code.
  14170. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14171. * @param name Define the name of the texture
  14172. * @param size Define the size of the texture to create
  14173. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14174. * @param scene Define the scene the texture belongs to
  14175. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14176. * @param generateMipMaps Define if the texture should creates mip maps or not
  14177. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14178. * @param textureType The FBO internal texture type
  14179. */
  14180. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14181. /**
  14182. * The effect that is created when initializing the post process.
  14183. * @returns The created effect corresponding the the postprocess.
  14184. */
  14185. getEffect(): Effect;
  14186. /**
  14187. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14188. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14189. */
  14190. getContent(): Nullable<ArrayBufferView>;
  14191. private _createIndexBuffer;
  14192. /** @hidden */
  14193. _rebuild(): void;
  14194. /**
  14195. * Resets the texture in order to recreate its associated resources.
  14196. * This can be called in case of context loss
  14197. */
  14198. reset(): void;
  14199. protected _getDefines(): string;
  14200. /**
  14201. * Is the texture ready to be used ? (rendered at least once)
  14202. * @returns true if ready, otherwise, false.
  14203. */
  14204. isReady(): boolean;
  14205. /**
  14206. * Resets the refresh counter of the texture and start bak from scratch.
  14207. * Could be useful to regenerate the texture if it is setup to render only once.
  14208. */
  14209. resetRefreshCounter(): void;
  14210. /**
  14211. * Set the fragment shader to use in order to render the texture.
  14212. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14213. */
  14214. setFragment(fragment: any): void;
  14215. /**
  14216. * Define the refresh rate of the texture or the rendering frequency.
  14217. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14218. */
  14219. get refreshRate(): number;
  14220. set refreshRate(value: number);
  14221. /** @hidden */
  14222. _shouldRender(): boolean;
  14223. /**
  14224. * Get the size the texture is rendering at.
  14225. * @returns the size (on cube texture it is always squared)
  14226. */
  14227. getRenderSize(): RenderTargetTextureSize;
  14228. /**
  14229. * Resize the texture to new value.
  14230. * @param size Define the new size the texture should have
  14231. * @param generateMipMaps Define whether the new texture should create mip maps
  14232. */
  14233. resize(size: number, generateMipMaps: boolean): void;
  14234. private _checkUniform;
  14235. /**
  14236. * Set a texture in the shader program used to render.
  14237. * @param name Define the name of the uniform samplers as defined in the shader
  14238. * @param texture Define the texture to bind to this sampler
  14239. * @return the texture itself allowing "fluent" like uniform updates
  14240. */
  14241. setTexture(name: string, texture: Texture): ProceduralTexture;
  14242. /**
  14243. * Set a float in the shader.
  14244. * @param name Define the name of the uniform as defined in the shader
  14245. * @param value Define the value to give to the uniform
  14246. * @return the texture itself allowing "fluent" like uniform updates
  14247. */
  14248. setFloat(name: string, value: number): ProceduralTexture;
  14249. /**
  14250. * Set a int in the shader.
  14251. * @param name Define the name of the uniform as defined in the shader
  14252. * @param value Define the value to give to the uniform
  14253. * @return the texture itself allowing "fluent" like uniform updates
  14254. */
  14255. setInt(name: string, value: number): ProceduralTexture;
  14256. /**
  14257. * Set an array of floats in the shader.
  14258. * @param name Define the name of the uniform as defined in the shader
  14259. * @param value Define the value to give to the uniform
  14260. * @return the texture itself allowing "fluent" like uniform updates
  14261. */
  14262. setFloats(name: string, value: number[]): ProceduralTexture;
  14263. /**
  14264. * Set a vec3 in the shader from a Color3.
  14265. * @param name Define the name of the uniform as defined in the shader
  14266. * @param value Define the value to give to the uniform
  14267. * @return the texture itself allowing "fluent" like uniform updates
  14268. */
  14269. setColor3(name: string, value: Color3): ProceduralTexture;
  14270. /**
  14271. * Set a vec4 in the shader from a Color4.
  14272. * @param name Define the name of the uniform as defined in the shader
  14273. * @param value Define the value to give to the uniform
  14274. * @return the texture itself allowing "fluent" like uniform updates
  14275. */
  14276. setColor4(name: string, value: Color4): ProceduralTexture;
  14277. /**
  14278. * Set a vec2 in the shader from a Vector2.
  14279. * @param name Define the name of the uniform as defined in the shader
  14280. * @param value Define the value to give to the uniform
  14281. * @return the texture itself allowing "fluent" like uniform updates
  14282. */
  14283. setVector2(name: string, value: Vector2): ProceduralTexture;
  14284. /**
  14285. * Set a vec3 in the shader from a Vector3.
  14286. * @param name Define the name of the uniform as defined in the shader
  14287. * @param value Define the value to give to the uniform
  14288. * @return the texture itself allowing "fluent" like uniform updates
  14289. */
  14290. setVector3(name: string, value: Vector3): ProceduralTexture;
  14291. /**
  14292. * Set a mat4 in the shader from a MAtrix.
  14293. * @param name Define the name of the uniform as defined in the shader
  14294. * @param value Define the value to give to the uniform
  14295. * @return the texture itself allowing "fluent" like uniform updates
  14296. */
  14297. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14298. /**
  14299. * Render the texture to its associated render target.
  14300. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14301. */
  14302. render(useCameraPostProcess?: boolean): void;
  14303. /**
  14304. * Clone the texture.
  14305. * @returns the cloned texture
  14306. */
  14307. clone(): ProceduralTexture;
  14308. /**
  14309. * Dispose the texture and release its asoociated resources.
  14310. */
  14311. dispose(): void;
  14312. }
  14313. }
  14314. declare module BABYLON {
  14315. /**
  14316. * This represents the base class for particle system in Babylon.
  14317. * 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.
  14318. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14319. * @example https://doc.babylonjs.com/babylon101/particles
  14320. */
  14321. export class BaseParticleSystem {
  14322. /**
  14323. * Source color is added to the destination color without alpha affecting the result
  14324. */
  14325. static BLENDMODE_ONEONE: number;
  14326. /**
  14327. * Blend current color and particle color using particle’s alpha
  14328. */
  14329. static BLENDMODE_STANDARD: number;
  14330. /**
  14331. * Add current color and particle color multiplied by particle’s alpha
  14332. */
  14333. static BLENDMODE_ADD: number;
  14334. /**
  14335. * Multiply current color with particle color
  14336. */
  14337. static BLENDMODE_MULTIPLY: number;
  14338. /**
  14339. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14340. */
  14341. static BLENDMODE_MULTIPLYADD: number;
  14342. /**
  14343. * List of animations used by the particle system.
  14344. */
  14345. animations: Animation[];
  14346. /**
  14347. * Gets or sets the unique id of the particle system
  14348. */
  14349. uniqueId: number;
  14350. /**
  14351. * The id of the Particle system.
  14352. */
  14353. id: string;
  14354. /**
  14355. * The friendly name of the Particle system.
  14356. */
  14357. name: string;
  14358. /**
  14359. * Snippet ID if the particle system was created from the snippet server
  14360. */
  14361. snippetId: string;
  14362. /**
  14363. * The rendering group used by the Particle system to chose when to render.
  14364. */
  14365. renderingGroupId: number;
  14366. /**
  14367. * The emitter represents the Mesh or position we are attaching the particle system to.
  14368. */
  14369. emitter: Nullable<AbstractMesh | Vector3>;
  14370. /**
  14371. * The maximum number of particles to emit per frame
  14372. */
  14373. emitRate: number;
  14374. /**
  14375. * If you want to launch only a few particles at once, that can be done, as well.
  14376. */
  14377. manualEmitCount: number;
  14378. /**
  14379. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14380. */
  14381. updateSpeed: number;
  14382. /**
  14383. * The amount of time the particle system is running (depends of the overall update speed).
  14384. */
  14385. targetStopDuration: number;
  14386. /**
  14387. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14388. */
  14389. disposeOnStop: boolean;
  14390. /**
  14391. * Minimum power of emitting particles.
  14392. */
  14393. minEmitPower: number;
  14394. /**
  14395. * Maximum power of emitting particles.
  14396. */
  14397. maxEmitPower: number;
  14398. /**
  14399. * Minimum life time of emitting particles.
  14400. */
  14401. minLifeTime: number;
  14402. /**
  14403. * Maximum life time of emitting particles.
  14404. */
  14405. maxLifeTime: number;
  14406. /**
  14407. * Minimum Size of emitting particles.
  14408. */
  14409. minSize: number;
  14410. /**
  14411. * Maximum Size of emitting particles.
  14412. */
  14413. maxSize: number;
  14414. /**
  14415. * Minimum scale of emitting particles on X axis.
  14416. */
  14417. minScaleX: number;
  14418. /**
  14419. * Maximum scale of emitting particles on X axis.
  14420. */
  14421. maxScaleX: number;
  14422. /**
  14423. * Minimum scale of emitting particles on Y axis.
  14424. */
  14425. minScaleY: number;
  14426. /**
  14427. * Maximum scale of emitting particles on Y axis.
  14428. */
  14429. maxScaleY: number;
  14430. /**
  14431. * Gets or sets the minimal initial rotation in radians.
  14432. */
  14433. minInitialRotation: number;
  14434. /**
  14435. * Gets or sets the maximal initial rotation in radians.
  14436. */
  14437. maxInitialRotation: number;
  14438. /**
  14439. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14440. */
  14441. minAngularSpeed: number;
  14442. /**
  14443. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14444. */
  14445. maxAngularSpeed: number;
  14446. /**
  14447. * The texture used to render each particle. (this can be a spritesheet)
  14448. */
  14449. particleTexture: Nullable<BaseTexture>;
  14450. /**
  14451. * The layer mask we are rendering the particles through.
  14452. */
  14453. layerMask: number;
  14454. /**
  14455. * This can help using your own shader to render the particle system.
  14456. * The according effect will be created
  14457. */
  14458. customShader: any;
  14459. /**
  14460. * By default particle system starts as soon as they are created. This prevents the
  14461. * automatic start to happen and let you decide when to start emitting particles.
  14462. */
  14463. preventAutoStart: boolean;
  14464. private _noiseTexture;
  14465. /**
  14466. * Gets or sets a texture used to add random noise to particle positions
  14467. */
  14468. get noiseTexture(): Nullable<ProceduralTexture>;
  14469. set noiseTexture(value: Nullable<ProceduralTexture>);
  14470. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14471. noiseStrength: Vector3;
  14472. /**
  14473. * Callback triggered when the particle animation is ending.
  14474. */
  14475. onAnimationEnd: Nullable<() => void>;
  14476. /**
  14477. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14478. */
  14479. blendMode: number;
  14480. /**
  14481. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14482. * to override the particles.
  14483. */
  14484. forceDepthWrite: boolean;
  14485. /** 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 */
  14486. preWarmCycles: number;
  14487. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14488. preWarmStepOffset: number;
  14489. /**
  14490. * 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)
  14491. */
  14492. spriteCellChangeSpeed: number;
  14493. /**
  14494. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14495. */
  14496. startSpriteCellID: number;
  14497. /**
  14498. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14499. */
  14500. endSpriteCellID: number;
  14501. /**
  14502. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14503. */
  14504. spriteCellWidth: number;
  14505. /**
  14506. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14507. */
  14508. spriteCellHeight: number;
  14509. /**
  14510. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14511. */
  14512. spriteRandomStartCell: boolean;
  14513. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14514. translationPivot: Vector2;
  14515. /** @hidden */
  14516. protected _isAnimationSheetEnabled: boolean;
  14517. /**
  14518. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14519. */
  14520. beginAnimationOnStart: boolean;
  14521. /**
  14522. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14523. */
  14524. beginAnimationFrom: number;
  14525. /**
  14526. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14527. */
  14528. beginAnimationTo: number;
  14529. /**
  14530. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14531. */
  14532. beginAnimationLoop: boolean;
  14533. /**
  14534. * Gets or sets a world offset applied to all particles
  14535. */
  14536. worldOffset: Vector3;
  14537. /**
  14538. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14539. */
  14540. get isAnimationSheetEnabled(): boolean;
  14541. set isAnimationSheetEnabled(value: boolean);
  14542. /**
  14543. * Get hosting scene
  14544. * @returns the scene
  14545. */
  14546. getScene(): Nullable<Scene>;
  14547. /**
  14548. * You can use gravity if you want to give an orientation to your particles.
  14549. */
  14550. gravity: Vector3;
  14551. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14552. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14553. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14554. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14555. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14556. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14557. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14558. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14559. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14560. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14561. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14562. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14563. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14564. /**
  14565. * Defines the delay in milliseconds before starting the system (0 by default)
  14566. */
  14567. startDelay: number;
  14568. /**
  14569. * Gets the current list of drag gradients.
  14570. * You must use addDragGradient and removeDragGradient to udpate this list
  14571. * @returns the list of drag gradients
  14572. */
  14573. getDragGradients(): Nullable<Array<FactorGradient>>;
  14574. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14575. limitVelocityDamping: number;
  14576. /**
  14577. * Gets the current list of limit velocity gradients.
  14578. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14579. * @returns the list of limit velocity gradients
  14580. */
  14581. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14582. /**
  14583. * Gets the current list of color gradients.
  14584. * You must use addColorGradient and removeColorGradient to udpate this list
  14585. * @returns the list of color gradients
  14586. */
  14587. getColorGradients(): Nullable<Array<ColorGradient>>;
  14588. /**
  14589. * Gets the current list of size gradients.
  14590. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14591. * @returns the list of size gradients
  14592. */
  14593. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14594. /**
  14595. * Gets the current list of color remap gradients.
  14596. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14597. * @returns the list of color remap gradients
  14598. */
  14599. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14600. /**
  14601. * Gets the current list of alpha remap gradients.
  14602. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14603. * @returns the list of alpha remap gradients
  14604. */
  14605. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14606. /**
  14607. * Gets the current list of life time gradients.
  14608. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14609. * @returns the list of life time gradients
  14610. */
  14611. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14612. /**
  14613. * Gets the current list of angular speed gradients.
  14614. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14615. * @returns the list of angular speed gradients
  14616. */
  14617. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14618. /**
  14619. * Gets the current list of velocity gradients.
  14620. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14621. * @returns the list of velocity gradients
  14622. */
  14623. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14624. /**
  14625. * Gets the current list of start size gradients.
  14626. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14627. * @returns the list of start size gradients
  14628. */
  14629. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14630. /**
  14631. * Gets the current list of emit rate gradients.
  14632. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14633. * @returns the list of emit rate gradients
  14634. */
  14635. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14636. /**
  14637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14638. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14639. */
  14640. get direction1(): Vector3;
  14641. set direction1(value: Vector3);
  14642. /**
  14643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14644. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14645. */
  14646. get direction2(): Vector3;
  14647. set direction2(value: Vector3);
  14648. /**
  14649. * 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.
  14650. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14651. */
  14652. get minEmitBox(): Vector3;
  14653. set minEmitBox(value: Vector3);
  14654. /**
  14655. * 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.
  14656. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14657. */
  14658. get maxEmitBox(): Vector3;
  14659. set maxEmitBox(value: Vector3);
  14660. /**
  14661. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14662. */
  14663. color1: Color4;
  14664. /**
  14665. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14666. */
  14667. color2: Color4;
  14668. /**
  14669. * Color the particle will have at the end of its lifetime
  14670. */
  14671. colorDead: Color4;
  14672. /**
  14673. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14674. */
  14675. textureMask: Color4;
  14676. /**
  14677. * The particle emitter type defines the emitter used by the particle system.
  14678. * It can be for example box, sphere, or cone...
  14679. */
  14680. particleEmitterType: IParticleEmitterType;
  14681. /** @hidden */
  14682. _isSubEmitter: boolean;
  14683. /**
  14684. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14685. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14686. */
  14687. billboardMode: number;
  14688. protected _isBillboardBased: boolean;
  14689. /**
  14690. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14691. */
  14692. get isBillboardBased(): boolean;
  14693. set isBillboardBased(value: boolean);
  14694. /**
  14695. * The scene the particle system belongs to.
  14696. */
  14697. protected _scene: Nullable<Scene>;
  14698. /**
  14699. * The engine the particle system belongs to.
  14700. */
  14701. protected _engine: ThinEngine;
  14702. /**
  14703. * Local cache of defines for image processing.
  14704. */
  14705. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14706. /**
  14707. * Default configuration related to image processing available in the standard Material.
  14708. */
  14709. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14710. /**
  14711. * Gets the image processing configuration used either in this material.
  14712. */
  14713. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14714. /**
  14715. * Sets the Default image processing configuration used either in the this material.
  14716. *
  14717. * If sets to null, the scene one is in use.
  14718. */
  14719. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14720. /**
  14721. * Attaches a new image processing configuration to the Standard Material.
  14722. * @param configuration
  14723. */
  14724. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14725. /** @hidden */
  14726. protected _reset(): void;
  14727. /** @hidden */
  14728. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14729. /**
  14730. * Instantiates a particle system.
  14731. * 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.
  14732. * @param name The name of the particle system
  14733. */
  14734. constructor(name: string);
  14735. /**
  14736. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14739. * @returns the emitter
  14740. */
  14741. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14742. /**
  14743. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14744. * @param radius The radius of the hemisphere to emit from
  14745. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14746. * @returns the emitter
  14747. */
  14748. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14749. /**
  14750. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14751. * @param radius The radius of the sphere to emit from
  14752. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14753. * @returns the emitter
  14754. */
  14755. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14756. /**
  14757. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14758. * @param radius The radius of the sphere to emit from
  14759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14761. * @returns the emitter
  14762. */
  14763. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14764. /**
  14765. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14766. * @param radius The radius of the emission cylinder
  14767. * @param height The height of the emission cylinder
  14768. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14769. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14770. * @returns the emitter
  14771. */
  14772. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14773. /**
  14774. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14775. * @param radius The radius of the cylinder to emit from
  14776. * @param height The height of the emission cylinder
  14777. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14778. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14779. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14780. * @returns the emitter
  14781. */
  14782. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14783. /**
  14784. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14785. * @param radius The radius of the cone to emit from
  14786. * @param angle The base angle of the cone
  14787. * @returns the emitter
  14788. */
  14789. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14790. /**
  14791. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14792. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14793. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14794. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14795. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14796. * @returns the emitter
  14797. */
  14798. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14799. }
  14800. }
  14801. declare module BABYLON {
  14802. /**
  14803. * Type of sub emitter
  14804. */
  14805. export enum SubEmitterType {
  14806. /**
  14807. * Attached to the particle over it's lifetime
  14808. */
  14809. ATTACHED = 0,
  14810. /**
  14811. * Created when the particle dies
  14812. */
  14813. END = 1
  14814. }
  14815. /**
  14816. * Sub emitter class used to emit particles from an existing particle
  14817. */
  14818. export class SubEmitter {
  14819. /**
  14820. * the particle system to be used by the sub emitter
  14821. */
  14822. particleSystem: ParticleSystem;
  14823. /**
  14824. * Type of the submitter (Default: END)
  14825. */
  14826. type: SubEmitterType;
  14827. /**
  14828. * 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)
  14829. * Note: This only is supported when using an emitter of type Mesh
  14830. */
  14831. inheritDirection: boolean;
  14832. /**
  14833. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14834. */
  14835. inheritedVelocityAmount: number;
  14836. /**
  14837. * Creates a sub emitter
  14838. * @param particleSystem the particle system to be used by the sub emitter
  14839. */
  14840. constructor(
  14841. /**
  14842. * the particle system to be used by the sub emitter
  14843. */
  14844. particleSystem: ParticleSystem);
  14845. /**
  14846. * Clones the sub emitter
  14847. * @returns the cloned sub emitter
  14848. */
  14849. clone(): SubEmitter;
  14850. /**
  14851. * Serialize current object to a JSON object
  14852. * @returns the serialized object
  14853. */
  14854. serialize(): any;
  14855. /** @hidden */
  14856. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14857. /**
  14858. * Creates a new SubEmitter from a serialized JSON version
  14859. * @param serializationObject defines the JSON object to read from
  14860. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14861. * @param rootUrl defines the rootUrl for data loading
  14862. * @returns a new SubEmitter
  14863. */
  14864. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14865. /** Release associated resources */
  14866. dispose(): void;
  14867. }
  14868. }
  14869. declare module BABYLON {
  14870. /** @hidden */
  14871. export var clipPlaneFragmentDeclaration: {
  14872. name: string;
  14873. shader: string;
  14874. };
  14875. }
  14876. declare module BABYLON {
  14877. /** @hidden */
  14878. export var imageProcessingDeclaration: {
  14879. name: string;
  14880. shader: string;
  14881. };
  14882. }
  14883. declare module BABYLON {
  14884. /** @hidden */
  14885. export var imageProcessingFunctions: {
  14886. name: string;
  14887. shader: string;
  14888. };
  14889. }
  14890. declare module BABYLON {
  14891. /** @hidden */
  14892. export var clipPlaneFragment: {
  14893. name: string;
  14894. shader: string;
  14895. };
  14896. }
  14897. declare module BABYLON {
  14898. /** @hidden */
  14899. export var particlesPixelShader: {
  14900. name: string;
  14901. shader: string;
  14902. };
  14903. }
  14904. declare module BABYLON {
  14905. /** @hidden */
  14906. export var clipPlaneVertexDeclaration: {
  14907. name: string;
  14908. shader: string;
  14909. };
  14910. }
  14911. declare module BABYLON {
  14912. /** @hidden */
  14913. export var clipPlaneVertex: {
  14914. name: string;
  14915. shader: string;
  14916. };
  14917. }
  14918. declare module BABYLON {
  14919. /** @hidden */
  14920. export var particlesVertexShader: {
  14921. name: string;
  14922. shader: string;
  14923. };
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * Interface used to define entities containing multiple clip planes
  14928. */
  14929. export interface IClipPlanesHolder {
  14930. /**
  14931. * Gets or sets the active clipplane 1
  14932. */
  14933. clipPlane: Nullable<Plane>;
  14934. /**
  14935. * Gets or sets the active clipplane 2
  14936. */
  14937. clipPlane2: Nullable<Plane>;
  14938. /**
  14939. * Gets or sets the active clipplane 3
  14940. */
  14941. clipPlane3: Nullable<Plane>;
  14942. /**
  14943. * Gets or sets the active clipplane 4
  14944. */
  14945. clipPlane4: Nullable<Plane>;
  14946. /**
  14947. * Gets or sets the active clipplane 5
  14948. */
  14949. clipPlane5: Nullable<Plane>;
  14950. /**
  14951. * Gets or sets the active clipplane 6
  14952. */
  14953. clipPlane6: Nullable<Plane>;
  14954. }
  14955. }
  14956. declare module BABYLON {
  14957. /**
  14958. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14959. *
  14960. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14961. *
  14962. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14963. */
  14964. export class ThinMaterialHelper {
  14965. /**
  14966. * Binds the clip plane information from the holder to the effect.
  14967. * @param effect The effect we are binding the data to
  14968. * @param holder The entity containing the clip plane information
  14969. */
  14970. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14971. }
  14972. }
  14973. declare module BABYLON {
  14974. interface ThinEngine {
  14975. /**
  14976. * Sets alpha constants used by some alpha blending modes
  14977. * @param r defines the red component
  14978. * @param g defines the green component
  14979. * @param b defines the blue component
  14980. * @param a defines the alpha component
  14981. */
  14982. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14983. /**
  14984. * Sets the current alpha mode
  14985. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14986. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14987. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14988. */
  14989. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14990. /**
  14991. * Gets the current alpha mode
  14992. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14993. * @returns the current alpha mode
  14994. */
  14995. getAlphaMode(): number;
  14996. /**
  14997. * Sets the current alpha equation
  14998. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14999. */
  15000. setAlphaEquation(equation: number): void;
  15001. /**
  15002. * Gets the current alpha equation.
  15003. * @returns the current alpha equation
  15004. */
  15005. getAlphaEquation(): number;
  15006. }
  15007. }
  15008. declare module BABYLON {
  15009. /**
  15010. * This represents a particle system in Babylon.
  15011. * 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.
  15012. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15013. * @example https://doc.babylonjs.com/babylon101/particles
  15014. */
  15015. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15016. /**
  15017. * Billboard mode will only apply to Y axis
  15018. */
  15019. static readonly BILLBOARDMODE_Y: number;
  15020. /**
  15021. * Billboard mode will apply to all axes
  15022. */
  15023. static readonly BILLBOARDMODE_ALL: number;
  15024. /**
  15025. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15026. */
  15027. static readonly BILLBOARDMODE_STRETCHED: number;
  15028. /**
  15029. * This function can be defined to provide custom update for active particles.
  15030. * This function will be called instead of regular update (age, position, color, etc.).
  15031. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15032. */
  15033. updateFunction: (particles: Particle[]) => void;
  15034. private _emitterWorldMatrix;
  15035. /**
  15036. * This function can be defined to specify initial direction for every new particle.
  15037. * It by default use the emitterType defined function
  15038. */
  15039. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15040. /**
  15041. * This function can be defined to specify initial position for every new particle.
  15042. * It by default use the emitterType defined function
  15043. */
  15044. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15045. /**
  15046. * @hidden
  15047. */
  15048. _inheritedVelocityOffset: Vector3;
  15049. /**
  15050. * An event triggered when the system is disposed
  15051. */
  15052. onDisposeObservable: Observable<IParticleSystem>;
  15053. /**
  15054. * An event triggered when the system is stopped
  15055. */
  15056. onStoppedObservable: Observable<IParticleSystem>;
  15057. private _onDisposeObserver;
  15058. /**
  15059. * Sets a callback that will be triggered when the system is disposed
  15060. */
  15061. set onDispose(callback: () => void);
  15062. private _particles;
  15063. private _epsilon;
  15064. private _capacity;
  15065. private _stockParticles;
  15066. private _newPartsExcess;
  15067. private _vertexData;
  15068. private _vertexBuffer;
  15069. private _vertexBuffers;
  15070. private _spriteBuffer;
  15071. private _indexBuffer;
  15072. private _effect;
  15073. private _customEffect;
  15074. private _cachedDefines;
  15075. private _scaledColorStep;
  15076. private _colorDiff;
  15077. private _scaledDirection;
  15078. private _scaledGravity;
  15079. private _currentRenderId;
  15080. private _alive;
  15081. private _useInstancing;
  15082. private _vertexArrayObject;
  15083. private _started;
  15084. private _stopped;
  15085. private _actualFrame;
  15086. private _scaledUpdateSpeed;
  15087. private _vertexBufferSize;
  15088. /** @hidden */
  15089. _currentEmitRateGradient: Nullable<FactorGradient>;
  15090. /** @hidden */
  15091. _currentEmitRate1: number;
  15092. /** @hidden */
  15093. _currentEmitRate2: number;
  15094. /** @hidden */
  15095. _currentStartSizeGradient: Nullable<FactorGradient>;
  15096. /** @hidden */
  15097. _currentStartSize1: number;
  15098. /** @hidden */
  15099. _currentStartSize2: number;
  15100. private readonly _rawTextureWidth;
  15101. private _rampGradientsTexture;
  15102. private _useRampGradients;
  15103. /** Gets or sets a matrix to use to compute projection */
  15104. defaultProjectionMatrix: Matrix;
  15105. /** Gets or sets a matrix to use to compute view */
  15106. defaultViewMatrix: Matrix;
  15107. /** Gets or sets a boolean indicating that ramp gradients must be used
  15108. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15109. */
  15110. get useRampGradients(): boolean;
  15111. set useRampGradients(value: boolean);
  15112. /**
  15113. * 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.
  15114. * 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: [])
  15115. */
  15116. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15117. private _subEmitters;
  15118. /**
  15119. * @hidden
  15120. * If the particle systems emitter should be disposed when the particle system is disposed
  15121. */
  15122. _disposeEmitterOnDispose: boolean;
  15123. /**
  15124. * The current active Sub-systems, this property is used by the root particle system only.
  15125. */
  15126. activeSubSystems: Array<ParticleSystem>;
  15127. /**
  15128. * Specifies if the particles are updated in emitter local space or world space
  15129. */
  15130. isLocal: boolean;
  15131. private _rootParticleSystem;
  15132. /**
  15133. * Gets the current list of active particles
  15134. */
  15135. get particles(): Particle[];
  15136. /**
  15137. * Gets the number of particles active at the same time.
  15138. * @returns The number of active particles.
  15139. */
  15140. getActiveCount(): number;
  15141. /**
  15142. * Returns the string "ParticleSystem"
  15143. * @returns a string containing the class name
  15144. */
  15145. getClassName(): string;
  15146. /**
  15147. * Gets a boolean indicating that the system is stopping
  15148. * @returns true if the system is currently stopping
  15149. */
  15150. isStopping(): boolean;
  15151. /**
  15152. * Gets the custom effect used to render the particles
  15153. * @param blendMode Blend mode for which the effect should be retrieved
  15154. * @returns The effect
  15155. */
  15156. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15157. /**
  15158. * Sets the custom effect used to render the particles
  15159. * @param effect The effect to set
  15160. * @param blendMode Blend mode for which the effect should be set
  15161. */
  15162. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15163. /** @hidden */
  15164. private _onBeforeDrawParticlesObservable;
  15165. /**
  15166. * Observable that will be called just before the particles are drawn
  15167. */
  15168. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15169. /**
  15170. * Gets the name of the particle vertex shader
  15171. */
  15172. get vertexShaderName(): string;
  15173. /**
  15174. * Instantiates a particle system.
  15175. * 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.
  15176. * @param name The name of the particle system
  15177. * @param capacity The max number of particles alive at the same time
  15178. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15179. * @param customEffect a custom effect used to change the way particles are rendered by default
  15180. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15181. * @param epsilon Offset used to render the particles
  15182. */
  15183. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15184. private _addFactorGradient;
  15185. private _removeFactorGradient;
  15186. /**
  15187. * Adds a new life time gradient
  15188. * @param gradient defines the gradient to use (between 0 and 1)
  15189. * @param factor defines the life time factor to affect to the specified gradient
  15190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15191. * @returns the current particle system
  15192. */
  15193. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15194. /**
  15195. * Remove a specific life time gradient
  15196. * @param gradient defines the gradient to remove
  15197. * @returns the current particle system
  15198. */
  15199. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15200. /**
  15201. * Adds a new size gradient
  15202. * @param gradient defines the gradient to use (between 0 and 1)
  15203. * @param factor defines the size factor to affect to the specified gradient
  15204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15205. * @returns the current particle system
  15206. */
  15207. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15208. /**
  15209. * Remove a specific size gradient
  15210. * @param gradient defines the gradient to remove
  15211. * @returns the current particle system
  15212. */
  15213. removeSizeGradient(gradient: number): IParticleSystem;
  15214. /**
  15215. * Adds a new color remap gradient
  15216. * @param gradient defines the gradient to use (between 0 and 1)
  15217. * @param min defines the color remap minimal range
  15218. * @param max defines the color remap maximal range
  15219. * @returns the current particle system
  15220. */
  15221. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15222. /**
  15223. * Remove a specific color remap gradient
  15224. * @param gradient defines the gradient to remove
  15225. * @returns the current particle system
  15226. */
  15227. removeColorRemapGradient(gradient: number): IParticleSystem;
  15228. /**
  15229. * Adds a new alpha remap gradient
  15230. * @param gradient defines the gradient to use (between 0 and 1)
  15231. * @param min defines the alpha remap minimal range
  15232. * @param max defines the alpha remap maximal range
  15233. * @returns the current particle system
  15234. */
  15235. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15236. /**
  15237. * Remove a specific alpha remap gradient
  15238. * @param gradient defines the gradient to remove
  15239. * @returns the current particle system
  15240. */
  15241. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15242. /**
  15243. * Adds a new angular speed gradient
  15244. * @param gradient defines the gradient to use (between 0 and 1)
  15245. * @param factor defines the angular speed to affect to the specified gradient
  15246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15247. * @returns the current particle system
  15248. */
  15249. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15250. /**
  15251. * Remove a specific angular speed gradient
  15252. * @param gradient defines the gradient to remove
  15253. * @returns the current particle system
  15254. */
  15255. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15256. /**
  15257. * Adds a new velocity gradient
  15258. * @param gradient defines the gradient to use (between 0 and 1)
  15259. * @param factor defines the velocity to affect to the specified gradient
  15260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15261. * @returns the current particle system
  15262. */
  15263. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15264. /**
  15265. * Remove a specific velocity gradient
  15266. * @param gradient defines the gradient to remove
  15267. * @returns the current particle system
  15268. */
  15269. removeVelocityGradient(gradient: number): IParticleSystem;
  15270. /**
  15271. * Adds a new limit velocity gradient
  15272. * @param gradient defines the gradient to use (between 0 and 1)
  15273. * @param factor defines the limit velocity value to affect to the specified gradient
  15274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15275. * @returns the current particle system
  15276. */
  15277. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15278. /**
  15279. * Remove a specific limit velocity gradient
  15280. * @param gradient defines the gradient to remove
  15281. * @returns the current particle system
  15282. */
  15283. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15284. /**
  15285. * Adds a new drag gradient
  15286. * @param gradient defines the gradient to use (between 0 and 1)
  15287. * @param factor defines the drag value to affect to the specified gradient
  15288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15289. * @returns the current particle system
  15290. */
  15291. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15292. /**
  15293. * Remove a specific drag gradient
  15294. * @param gradient defines the gradient to remove
  15295. * @returns the current particle system
  15296. */
  15297. removeDragGradient(gradient: number): IParticleSystem;
  15298. /**
  15299. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15300. * @param gradient defines the gradient to use (between 0 and 1)
  15301. * @param factor defines the emit rate value to affect to the specified gradient
  15302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15303. * @returns the current particle system
  15304. */
  15305. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15306. /**
  15307. * Remove a specific emit rate gradient
  15308. * @param gradient defines the gradient to remove
  15309. * @returns the current particle system
  15310. */
  15311. removeEmitRateGradient(gradient: number): IParticleSystem;
  15312. /**
  15313. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15314. * @param gradient defines the gradient to use (between 0 and 1)
  15315. * @param factor defines the start size value to affect to the specified gradient
  15316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15317. * @returns the current particle system
  15318. */
  15319. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15320. /**
  15321. * Remove a specific start size gradient
  15322. * @param gradient defines the gradient to remove
  15323. * @returns the current particle system
  15324. */
  15325. removeStartSizeGradient(gradient: number): IParticleSystem;
  15326. private _createRampGradientTexture;
  15327. /**
  15328. * Gets the current list of ramp gradients.
  15329. * You must use addRampGradient and removeRampGradient to udpate this list
  15330. * @returns the list of ramp gradients
  15331. */
  15332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15333. /** Force the system to rebuild all gradients that need to be resync */
  15334. forceRefreshGradients(): void;
  15335. private _syncRampGradientTexture;
  15336. /**
  15337. * Adds a new ramp gradient used to remap particle colors
  15338. * @param gradient defines the gradient to use (between 0 and 1)
  15339. * @param color defines the color to affect to the specified gradient
  15340. * @returns the current particle system
  15341. */
  15342. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15343. /**
  15344. * Remove a specific ramp gradient
  15345. * @param gradient defines the gradient to remove
  15346. * @returns the current particle system
  15347. */
  15348. removeRampGradient(gradient: number): ParticleSystem;
  15349. /**
  15350. * Adds a new color gradient
  15351. * @param gradient defines the gradient to use (between 0 and 1)
  15352. * @param color1 defines the color to affect to the specified gradient
  15353. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15354. * @returns this particle system
  15355. */
  15356. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15357. /**
  15358. * Remove a specific color gradient
  15359. * @param gradient defines the gradient to remove
  15360. * @returns this particle system
  15361. */
  15362. removeColorGradient(gradient: number): IParticleSystem;
  15363. private _fetchR;
  15364. protected _reset(): void;
  15365. private _resetEffect;
  15366. private _createVertexBuffers;
  15367. private _createIndexBuffer;
  15368. /**
  15369. * Gets the maximum number of particles active at the same time.
  15370. * @returns The max number of active particles.
  15371. */
  15372. getCapacity(): number;
  15373. /**
  15374. * Gets whether there are still active particles in the system.
  15375. * @returns True if it is alive, otherwise false.
  15376. */
  15377. isAlive(): boolean;
  15378. /**
  15379. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15380. * @returns True if it has been started, otherwise false.
  15381. */
  15382. isStarted(): boolean;
  15383. private _prepareSubEmitterInternalArray;
  15384. /**
  15385. * Starts the particle system and begins to emit
  15386. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15387. */
  15388. start(delay?: number): void;
  15389. /**
  15390. * Stops the particle system.
  15391. * @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.
  15392. */
  15393. stop(stopSubEmitters?: boolean): void;
  15394. /**
  15395. * Remove all active particles
  15396. */
  15397. reset(): void;
  15398. /**
  15399. * @hidden (for internal use only)
  15400. */
  15401. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15402. /**
  15403. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15404. * Its lifetime will start back at 0.
  15405. */
  15406. recycleParticle: (particle: Particle) => void;
  15407. private _stopSubEmitters;
  15408. private _createParticle;
  15409. private _removeFromRoot;
  15410. private _emitFromParticle;
  15411. private _update;
  15412. /** @hidden */
  15413. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15414. /** @hidden */
  15415. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15416. /**
  15417. * Fill the defines array according to the current settings of the particle system
  15418. * @param defines Array to be updated
  15419. * @param blendMode blend mode to take into account when updating the array
  15420. */
  15421. fillDefines(defines: Array<string>, blendMode: number): void;
  15422. /**
  15423. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15424. * @param uniforms Uniforms array to fill
  15425. * @param attributes Attributes array to fill
  15426. * @param samplers Samplers array to fill
  15427. */
  15428. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15429. /** @hidden */
  15430. private _getEffect;
  15431. /**
  15432. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15433. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15434. */
  15435. animate(preWarmOnly?: boolean): void;
  15436. private _appendParticleVertices;
  15437. /**
  15438. * Rebuilds the particle system.
  15439. */
  15440. rebuild(): void;
  15441. /**
  15442. * Is this system ready to be used/rendered
  15443. * @return true if the system is ready
  15444. */
  15445. isReady(): boolean;
  15446. private _render;
  15447. /**
  15448. * Renders the particle system in its current state.
  15449. * @returns the current number of particles
  15450. */
  15451. render(): number;
  15452. /**
  15453. * Disposes the particle system and free the associated resources
  15454. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15455. */
  15456. dispose(disposeTexture?: boolean): void;
  15457. /**
  15458. * Clones the particle system.
  15459. * @param name The name of the cloned object
  15460. * @param newEmitter The new emitter to use
  15461. * @returns the cloned particle system
  15462. */
  15463. clone(name: string, newEmitter: any): ParticleSystem;
  15464. /**
  15465. * Serializes the particle system to a JSON object
  15466. * @param serializeTexture defines if the texture must be serialized as well
  15467. * @returns the JSON object
  15468. */
  15469. serialize(serializeTexture?: boolean): any;
  15470. /** @hidden */
  15471. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15472. /** @hidden */
  15473. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15474. /**
  15475. * Parses a JSON object to create a particle system.
  15476. * @param parsedParticleSystem The JSON object to parse
  15477. * @param sceneOrEngine The scene or the engine to create the particle system in
  15478. * @param rootUrl The root url to use to load external dependencies like texture
  15479. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15480. * @returns the Parsed particle system
  15481. */
  15482. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15483. }
  15484. }
  15485. declare module BABYLON {
  15486. /**
  15487. * A particle represents one of the element emitted by a particle system.
  15488. * This is mainly define by its coordinates, direction, velocity and age.
  15489. */
  15490. export class Particle {
  15491. /**
  15492. * The particle system the particle belongs to.
  15493. */
  15494. particleSystem: ParticleSystem;
  15495. private static _Count;
  15496. /**
  15497. * Unique ID of the particle
  15498. */
  15499. id: number;
  15500. /**
  15501. * The world position of the particle in the scene.
  15502. */
  15503. position: Vector3;
  15504. /**
  15505. * The world direction of the particle in the scene.
  15506. */
  15507. direction: Vector3;
  15508. /**
  15509. * The color of the particle.
  15510. */
  15511. color: Color4;
  15512. /**
  15513. * The color change of the particle per step.
  15514. */
  15515. colorStep: Color4;
  15516. /**
  15517. * Defines how long will the life of the particle be.
  15518. */
  15519. lifeTime: number;
  15520. /**
  15521. * The current age of the particle.
  15522. */
  15523. age: number;
  15524. /**
  15525. * The current size of the particle.
  15526. */
  15527. size: number;
  15528. /**
  15529. * The current scale of the particle.
  15530. */
  15531. scale: Vector2;
  15532. /**
  15533. * The current angle of the particle.
  15534. */
  15535. angle: number;
  15536. /**
  15537. * Defines how fast is the angle changing.
  15538. */
  15539. angularSpeed: number;
  15540. /**
  15541. * Defines the cell index used by the particle to be rendered from a sprite.
  15542. */
  15543. cellIndex: number;
  15544. /**
  15545. * The information required to support color remapping
  15546. */
  15547. remapData: Vector4;
  15548. /** @hidden */
  15549. _randomCellOffset?: number;
  15550. /** @hidden */
  15551. _initialDirection: Nullable<Vector3>;
  15552. /** @hidden */
  15553. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15554. /** @hidden */
  15555. _initialStartSpriteCellID: number;
  15556. /** @hidden */
  15557. _initialEndSpriteCellID: number;
  15558. /** @hidden */
  15559. _currentColorGradient: Nullable<ColorGradient>;
  15560. /** @hidden */
  15561. _currentColor1: Color4;
  15562. /** @hidden */
  15563. _currentColor2: Color4;
  15564. /** @hidden */
  15565. _currentSizeGradient: Nullable<FactorGradient>;
  15566. /** @hidden */
  15567. _currentSize1: number;
  15568. /** @hidden */
  15569. _currentSize2: number;
  15570. /** @hidden */
  15571. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15572. /** @hidden */
  15573. _currentAngularSpeed1: number;
  15574. /** @hidden */
  15575. _currentAngularSpeed2: number;
  15576. /** @hidden */
  15577. _currentVelocityGradient: Nullable<FactorGradient>;
  15578. /** @hidden */
  15579. _currentVelocity1: number;
  15580. /** @hidden */
  15581. _currentVelocity2: number;
  15582. /** @hidden */
  15583. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15584. /** @hidden */
  15585. _currentLimitVelocity1: number;
  15586. /** @hidden */
  15587. _currentLimitVelocity2: number;
  15588. /** @hidden */
  15589. _currentDragGradient: Nullable<FactorGradient>;
  15590. /** @hidden */
  15591. _currentDrag1: number;
  15592. /** @hidden */
  15593. _currentDrag2: number;
  15594. /** @hidden */
  15595. _randomNoiseCoordinates1: Vector3;
  15596. /** @hidden */
  15597. _randomNoiseCoordinates2: Vector3;
  15598. /** @hidden */
  15599. _localPosition?: Vector3;
  15600. /**
  15601. * Creates a new instance Particle
  15602. * @param particleSystem the particle system the particle belongs to
  15603. */
  15604. constructor(
  15605. /**
  15606. * The particle system the particle belongs to.
  15607. */
  15608. particleSystem: ParticleSystem);
  15609. private updateCellInfoFromSystem;
  15610. /**
  15611. * Defines how the sprite cell index is updated for the particle
  15612. */
  15613. updateCellIndex(): void;
  15614. /** @hidden */
  15615. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15616. /** @hidden */
  15617. _inheritParticleInfoToSubEmitters(): void;
  15618. /** @hidden */
  15619. _reset(): void;
  15620. /**
  15621. * Copy the properties of particle to another one.
  15622. * @param other the particle to copy the information to.
  15623. */
  15624. copyTo(other: Particle): void;
  15625. }
  15626. }
  15627. declare module BABYLON {
  15628. /**
  15629. * Particle emitter represents a volume emitting particles.
  15630. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15631. */
  15632. export interface IParticleEmitterType {
  15633. /**
  15634. * Called by the particle System when the direction is computed for the created particle.
  15635. * @param worldMatrix is the world matrix of the particle system
  15636. * @param directionToUpdate is the direction vector to update with the result
  15637. * @param particle is the particle we are computed the direction for
  15638. * @param isLocal defines if the direction should be set in local space
  15639. */
  15640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15641. /**
  15642. * Called by the particle System when the position is computed for the created particle.
  15643. * @param worldMatrix is the world matrix of the particle system
  15644. * @param positionToUpdate is the position vector to update with the result
  15645. * @param particle is the particle we are computed the position for
  15646. * @param isLocal defines if the position should be set in local space
  15647. */
  15648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15649. /**
  15650. * Clones the current emitter and returns a copy of it
  15651. * @returns the new emitter
  15652. */
  15653. clone(): IParticleEmitterType;
  15654. /**
  15655. * Called by the GPUParticleSystem to setup the update shader
  15656. * @param effect defines the update shader
  15657. */
  15658. applyToShader(effect: Effect): void;
  15659. /**
  15660. * Returns a string to use to update the GPU particles update shader
  15661. * @returns the effect defines string
  15662. */
  15663. getEffectDefines(): string;
  15664. /**
  15665. * Returns a string representing the class name
  15666. * @returns a string containing the class name
  15667. */
  15668. getClassName(): string;
  15669. /**
  15670. * Serializes the particle system to a JSON object.
  15671. * @returns the JSON object
  15672. */
  15673. serialize(): any;
  15674. /**
  15675. * Parse properties from a JSON object
  15676. * @param serializationObject defines the JSON object
  15677. * @param scene defines the hosting scene
  15678. */
  15679. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15680. }
  15681. }
  15682. declare module BABYLON {
  15683. /**
  15684. * Particle emitter emitting particles from the inside of a box.
  15685. * It emits the particles randomly between 2 given directions.
  15686. */
  15687. export class BoxParticleEmitter implements IParticleEmitterType {
  15688. /**
  15689. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15690. */
  15691. direction1: Vector3;
  15692. /**
  15693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15694. */
  15695. direction2: Vector3;
  15696. /**
  15697. * 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.
  15698. */
  15699. minEmitBox: Vector3;
  15700. /**
  15701. * 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.
  15702. */
  15703. maxEmitBox: Vector3;
  15704. /**
  15705. * Creates a new instance BoxParticleEmitter
  15706. */
  15707. constructor();
  15708. /**
  15709. * Called by the particle System when the direction is computed for the created particle.
  15710. * @param worldMatrix is the world matrix of the particle system
  15711. * @param directionToUpdate is the direction vector to update with the result
  15712. * @param particle is the particle we are computed the direction for
  15713. * @param isLocal defines if the direction should be set in local space
  15714. */
  15715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15716. /**
  15717. * Called by the particle System when the position is computed for the created particle.
  15718. * @param worldMatrix is the world matrix of the particle system
  15719. * @param positionToUpdate is the position vector to update with the result
  15720. * @param particle is the particle we are computed the position for
  15721. * @param isLocal defines if the position should be set in local space
  15722. */
  15723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15724. /**
  15725. * Clones the current emitter and returns a copy of it
  15726. * @returns the new emitter
  15727. */
  15728. clone(): BoxParticleEmitter;
  15729. /**
  15730. * Called by the GPUParticleSystem to setup the update shader
  15731. * @param effect defines the update shader
  15732. */
  15733. applyToShader(effect: Effect): void;
  15734. /**
  15735. * Returns a string to use to update the GPU particles update shader
  15736. * @returns a string containng the defines string
  15737. */
  15738. getEffectDefines(): string;
  15739. /**
  15740. * Returns the string "BoxParticleEmitter"
  15741. * @returns a string containing the class name
  15742. */
  15743. getClassName(): string;
  15744. /**
  15745. * Serializes the particle system to a JSON object.
  15746. * @returns the JSON object
  15747. */
  15748. serialize(): any;
  15749. /**
  15750. * Parse properties from a JSON object
  15751. * @param serializationObject defines the JSON object
  15752. */
  15753. parse(serializationObject: any): void;
  15754. }
  15755. }
  15756. declare module BABYLON {
  15757. /**
  15758. * Particle emitter emitting particles from the inside of a cone.
  15759. * It emits the particles alongside the cone volume from the base to the particle.
  15760. * The emission direction might be randomized.
  15761. */
  15762. export class ConeParticleEmitter implements IParticleEmitterType {
  15763. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15764. directionRandomizer: number;
  15765. private _radius;
  15766. private _angle;
  15767. private _height;
  15768. /**
  15769. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15770. */
  15771. radiusRange: number;
  15772. /**
  15773. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15774. */
  15775. heightRange: number;
  15776. /**
  15777. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15778. */
  15779. emitFromSpawnPointOnly: boolean;
  15780. /**
  15781. * Gets or sets the radius of the emission cone
  15782. */
  15783. get radius(): number;
  15784. set radius(value: number);
  15785. /**
  15786. * Gets or sets the angle of the emission cone
  15787. */
  15788. get angle(): number;
  15789. set angle(value: number);
  15790. private _buildHeight;
  15791. /**
  15792. * Creates a new instance ConeParticleEmitter
  15793. * @param radius the radius of the emission cone (1 by default)
  15794. * @param angle the cone base angle (PI by default)
  15795. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15796. */
  15797. constructor(radius?: number, angle?: number,
  15798. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15799. directionRandomizer?: number);
  15800. /**
  15801. * Called by the particle System when the direction is computed for the created particle.
  15802. * @param worldMatrix is the world matrix of the particle system
  15803. * @param directionToUpdate is the direction vector to update with the result
  15804. * @param particle is the particle we are computed the direction for
  15805. * @param isLocal defines if the direction should be set in local space
  15806. */
  15807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15808. /**
  15809. * Called by the particle System when the position is computed for the created particle.
  15810. * @param worldMatrix is the world matrix of the particle system
  15811. * @param positionToUpdate is the position vector to update with the result
  15812. * @param particle is the particle we are computed the position for
  15813. * @param isLocal defines if the position should be set in local space
  15814. */
  15815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15816. /**
  15817. * Clones the current emitter and returns a copy of it
  15818. * @returns the new emitter
  15819. */
  15820. clone(): ConeParticleEmitter;
  15821. /**
  15822. * Called by the GPUParticleSystem to setup the update shader
  15823. * @param effect defines the update shader
  15824. */
  15825. applyToShader(effect: Effect): void;
  15826. /**
  15827. * Returns a string to use to update the GPU particles update shader
  15828. * @returns a string containng the defines string
  15829. */
  15830. getEffectDefines(): string;
  15831. /**
  15832. * Returns the string "ConeParticleEmitter"
  15833. * @returns a string containing the class name
  15834. */
  15835. getClassName(): string;
  15836. /**
  15837. * Serializes the particle system to a JSON object.
  15838. * @returns the JSON object
  15839. */
  15840. serialize(): any;
  15841. /**
  15842. * Parse properties from a JSON object
  15843. * @param serializationObject defines the JSON object
  15844. */
  15845. parse(serializationObject: any): void;
  15846. }
  15847. }
  15848. declare module BABYLON {
  15849. /**
  15850. * Particle emitter emitting particles from the inside of a cylinder.
  15851. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15852. */
  15853. export class CylinderParticleEmitter implements IParticleEmitterType {
  15854. /**
  15855. * The radius of the emission cylinder.
  15856. */
  15857. radius: number;
  15858. /**
  15859. * The height of the emission cylinder.
  15860. */
  15861. height: number;
  15862. /**
  15863. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15864. */
  15865. radiusRange: number;
  15866. /**
  15867. * How much to randomize the particle direction [0-1].
  15868. */
  15869. directionRandomizer: number;
  15870. /**
  15871. * Creates a new instance CylinderParticleEmitter
  15872. * @param radius the radius of the emission cylinder (1 by default)
  15873. * @param height the height of the emission cylinder (1 by default)
  15874. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15875. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15876. */
  15877. constructor(
  15878. /**
  15879. * The radius of the emission cylinder.
  15880. */
  15881. radius?: number,
  15882. /**
  15883. * The height of the emission cylinder.
  15884. */
  15885. height?: number,
  15886. /**
  15887. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15888. */
  15889. radiusRange?: number,
  15890. /**
  15891. * How much to randomize the particle direction [0-1].
  15892. */
  15893. directionRandomizer?: number);
  15894. /**
  15895. * Called by the particle System when the direction is computed for the created particle.
  15896. * @param worldMatrix is the world matrix of the particle system
  15897. * @param directionToUpdate is the direction vector to update with the result
  15898. * @param particle is the particle we are computed the direction for
  15899. * @param isLocal defines if the direction should be set in local space
  15900. */
  15901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15902. /**
  15903. * Called by the particle System when the position is computed for the created particle.
  15904. * @param worldMatrix is the world matrix of the particle system
  15905. * @param positionToUpdate is the position vector to update with the result
  15906. * @param particle is the particle we are computed the position for
  15907. * @param isLocal defines if the position should be set in local space
  15908. */
  15909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15910. /**
  15911. * Clones the current emitter and returns a copy of it
  15912. * @returns the new emitter
  15913. */
  15914. clone(): CylinderParticleEmitter;
  15915. /**
  15916. * Called by the GPUParticleSystem to setup the update shader
  15917. * @param effect defines the update shader
  15918. */
  15919. applyToShader(effect: Effect): void;
  15920. /**
  15921. * Returns a string to use to update the GPU particles update shader
  15922. * @returns a string containng the defines string
  15923. */
  15924. getEffectDefines(): string;
  15925. /**
  15926. * Returns the string "CylinderParticleEmitter"
  15927. * @returns a string containing the class name
  15928. */
  15929. getClassName(): string;
  15930. /**
  15931. * Serializes the particle system to a JSON object.
  15932. * @returns the JSON object
  15933. */
  15934. serialize(): any;
  15935. /**
  15936. * Parse properties from a JSON object
  15937. * @param serializationObject defines the JSON object
  15938. */
  15939. parse(serializationObject: any): void;
  15940. }
  15941. /**
  15942. * Particle emitter emitting particles from the inside of a cylinder.
  15943. * It emits the particles randomly between two vectors.
  15944. */
  15945. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15946. /**
  15947. * The min limit of the emission direction.
  15948. */
  15949. direction1: Vector3;
  15950. /**
  15951. * The max limit of the emission direction.
  15952. */
  15953. direction2: Vector3;
  15954. /**
  15955. * Creates a new instance CylinderDirectedParticleEmitter
  15956. * @param radius the radius of the emission cylinder (1 by default)
  15957. * @param height the height of the emission cylinder (1 by default)
  15958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15959. * @param direction1 the min limit of the emission direction (up vector by default)
  15960. * @param direction2 the max limit of the emission direction (up vector by default)
  15961. */
  15962. constructor(radius?: number, height?: number, radiusRange?: number,
  15963. /**
  15964. * The min limit of the emission direction.
  15965. */
  15966. direction1?: Vector3,
  15967. /**
  15968. * The max limit of the emission direction.
  15969. */
  15970. direction2?: Vector3);
  15971. /**
  15972. * Called by the particle System when the direction is computed for the created particle.
  15973. * @param worldMatrix is the world matrix of the particle system
  15974. * @param directionToUpdate is the direction vector to update with the result
  15975. * @param particle is the particle we are computed the direction for
  15976. */
  15977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15978. /**
  15979. * Clones the current emitter and returns a copy of it
  15980. * @returns the new emitter
  15981. */
  15982. clone(): CylinderDirectedParticleEmitter;
  15983. /**
  15984. * Called by the GPUParticleSystem to setup the update shader
  15985. * @param effect defines the update shader
  15986. */
  15987. applyToShader(effect: Effect): void;
  15988. /**
  15989. * Returns a string to use to update the GPU particles update shader
  15990. * @returns a string containng the defines string
  15991. */
  15992. getEffectDefines(): string;
  15993. /**
  15994. * Returns the string "CylinderDirectedParticleEmitter"
  15995. * @returns a string containing the class name
  15996. */
  15997. getClassName(): string;
  15998. /**
  15999. * Serializes the particle system to a JSON object.
  16000. * @returns the JSON object
  16001. */
  16002. serialize(): any;
  16003. /**
  16004. * Parse properties from a JSON object
  16005. * @param serializationObject defines the JSON object
  16006. */
  16007. parse(serializationObject: any): void;
  16008. }
  16009. }
  16010. declare module BABYLON {
  16011. /**
  16012. * Particle emitter emitting particles from the inside of a hemisphere.
  16013. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16014. */
  16015. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16016. /**
  16017. * The radius of the emission hemisphere.
  16018. */
  16019. radius: number;
  16020. /**
  16021. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16022. */
  16023. radiusRange: number;
  16024. /**
  16025. * How much to randomize the particle direction [0-1].
  16026. */
  16027. directionRandomizer: number;
  16028. /**
  16029. * Creates a new instance HemisphericParticleEmitter
  16030. * @param radius the radius of the emission hemisphere (1 by default)
  16031. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16032. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16033. */
  16034. constructor(
  16035. /**
  16036. * The radius of the emission hemisphere.
  16037. */
  16038. radius?: number,
  16039. /**
  16040. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16041. */
  16042. radiusRange?: number,
  16043. /**
  16044. * How much to randomize the particle direction [0-1].
  16045. */
  16046. directionRandomizer?: number);
  16047. /**
  16048. * Called by the particle System when the direction is computed for the created particle.
  16049. * @param worldMatrix is the world matrix of the particle system
  16050. * @param directionToUpdate is the direction vector to update with the result
  16051. * @param particle is the particle we are computed the direction for
  16052. * @param isLocal defines if the direction should be set in local space
  16053. */
  16054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16055. /**
  16056. * Called by the particle System when the position is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param positionToUpdate is the position vector to update with the result
  16059. * @param particle is the particle we are computed the position for
  16060. * @param isLocal defines if the position should be set in local space
  16061. */
  16062. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16063. /**
  16064. * Clones the current emitter and returns a copy of it
  16065. * @returns the new emitter
  16066. */
  16067. clone(): HemisphericParticleEmitter;
  16068. /**
  16069. * Called by the GPUParticleSystem to setup the update shader
  16070. * @param effect defines the update shader
  16071. */
  16072. applyToShader(effect: Effect): void;
  16073. /**
  16074. * Returns a string to use to update the GPU particles update shader
  16075. * @returns a string containng the defines string
  16076. */
  16077. getEffectDefines(): string;
  16078. /**
  16079. * Returns the string "HemisphericParticleEmitter"
  16080. * @returns a string containing the class name
  16081. */
  16082. getClassName(): string;
  16083. /**
  16084. * Serializes the particle system to a JSON object.
  16085. * @returns the JSON object
  16086. */
  16087. serialize(): any;
  16088. /**
  16089. * Parse properties from a JSON object
  16090. * @param serializationObject defines the JSON object
  16091. */
  16092. parse(serializationObject: any): void;
  16093. }
  16094. }
  16095. declare module BABYLON {
  16096. /**
  16097. * Particle emitter emitting particles from a point.
  16098. * It emits the particles randomly between 2 given directions.
  16099. */
  16100. export class PointParticleEmitter implements IParticleEmitterType {
  16101. /**
  16102. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16103. */
  16104. direction1: Vector3;
  16105. /**
  16106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16107. */
  16108. direction2: Vector3;
  16109. /**
  16110. * Creates a new instance PointParticleEmitter
  16111. */
  16112. constructor();
  16113. /**
  16114. * Called by the particle System when the direction is computed for the created particle.
  16115. * @param worldMatrix is the world matrix of the particle system
  16116. * @param directionToUpdate is the direction vector to update with the result
  16117. * @param particle is the particle we are computed the direction for
  16118. * @param isLocal defines if the direction should be set in local space
  16119. */
  16120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16121. /**
  16122. * Called by the particle System when the position is computed for the created particle.
  16123. * @param worldMatrix is the world matrix of the particle system
  16124. * @param positionToUpdate is the position vector to update with the result
  16125. * @param particle is the particle we are computed the position for
  16126. * @param isLocal defines if the position should be set in local space
  16127. */
  16128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16129. /**
  16130. * Clones the current emitter and returns a copy of it
  16131. * @returns the new emitter
  16132. */
  16133. clone(): PointParticleEmitter;
  16134. /**
  16135. * Called by the GPUParticleSystem to setup the update shader
  16136. * @param effect defines the update shader
  16137. */
  16138. applyToShader(effect: Effect): void;
  16139. /**
  16140. * Returns a string to use to update the GPU particles update shader
  16141. * @returns a string containng the defines string
  16142. */
  16143. getEffectDefines(): string;
  16144. /**
  16145. * Returns the string "PointParticleEmitter"
  16146. * @returns a string containing the class name
  16147. */
  16148. getClassName(): string;
  16149. /**
  16150. * Serializes the particle system to a JSON object.
  16151. * @returns the JSON object
  16152. */
  16153. serialize(): any;
  16154. /**
  16155. * Parse properties from a JSON object
  16156. * @param serializationObject defines the JSON object
  16157. */
  16158. parse(serializationObject: any): void;
  16159. }
  16160. }
  16161. declare module BABYLON {
  16162. /**
  16163. * Particle emitter emitting particles from the inside of a sphere.
  16164. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16165. */
  16166. export class SphereParticleEmitter implements IParticleEmitterType {
  16167. /**
  16168. * The radius of the emission sphere.
  16169. */
  16170. radius: number;
  16171. /**
  16172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16173. */
  16174. radiusRange: number;
  16175. /**
  16176. * How much to randomize the particle direction [0-1].
  16177. */
  16178. directionRandomizer: number;
  16179. /**
  16180. * Creates a new instance SphereParticleEmitter
  16181. * @param radius the radius of the emission sphere (1 by default)
  16182. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16184. */
  16185. constructor(
  16186. /**
  16187. * The radius of the emission sphere.
  16188. */
  16189. radius?: number,
  16190. /**
  16191. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16192. */
  16193. radiusRange?: number,
  16194. /**
  16195. * How much to randomize the particle direction [0-1].
  16196. */
  16197. directionRandomizer?: number);
  16198. /**
  16199. * Called by the particle System when the direction is computed for the created particle.
  16200. * @param worldMatrix is the world matrix of the particle system
  16201. * @param directionToUpdate is the direction vector to update with the result
  16202. * @param particle is the particle we are computed the direction for
  16203. * @param isLocal defines if the direction should be set in local space
  16204. */
  16205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16206. /**
  16207. * Called by the particle System when the position is computed for the created particle.
  16208. * @param worldMatrix is the world matrix of the particle system
  16209. * @param positionToUpdate is the position vector to update with the result
  16210. * @param particle is the particle we are computed the position for
  16211. * @param isLocal defines if the position should be set in local space
  16212. */
  16213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16214. /**
  16215. * Clones the current emitter and returns a copy of it
  16216. * @returns the new emitter
  16217. */
  16218. clone(): SphereParticleEmitter;
  16219. /**
  16220. * Called by the GPUParticleSystem to setup the update shader
  16221. * @param effect defines the update shader
  16222. */
  16223. applyToShader(effect: Effect): void;
  16224. /**
  16225. * Returns a string to use to update the GPU particles update shader
  16226. * @returns a string containng the defines string
  16227. */
  16228. getEffectDefines(): string;
  16229. /**
  16230. * Returns the string "SphereParticleEmitter"
  16231. * @returns a string containing the class name
  16232. */
  16233. getClassName(): string;
  16234. /**
  16235. * Serializes the particle system to a JSON object.
  16236. * @returns the JSON object
  16237. */
  16238. serialize(): any;
  16239. /**
  16240. * Parse properties from a JSON object
  16241. * @param serializationObject defines the JSON object
  16242. */
  16243. parse(serializationObject: any): void;
  16244. }
  16245. /**
  16246. * Particle emitter emitting particles from the inside of a sphere.
  16247. * It emits the particles randomly between two vectors.
  16248. */
  16249. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16250. /**
  16251. * The min limit of the emission direction.
  16252. */
  16253. direction1: Vector3;
  16254. /**
  16255. * The max limit of the emission direction.
  16256. */
  16257. direction2: Vector3;
  16258. /**
  16259. * Creates a new instance SphereDirectedParticleEmitter
  16260. * @param radius the radius of the emission sphere (1 by default)
  16261. * @param direction1 the min limit of the emission direction (up vector by default)
  16262. * @param direction2 the max limit of the emission direction (up vector by default)
  16263. */
  16264. constructor(radius?: number,
  16265. /**
  16266. * The min limit of the emission direction.
  16267. */
  16268. direction1?: Vector3,
  16269. /**
  16270. * The max limit of the emission direction.
  16271. */
  16272. direction2?: Vector3);
  16273. /**
  16274. * Called by the particle System when the direction is computed for the created particle.
  16275. * @param worldMatrix is the world matrix of the particle system
  16276. * @param directionToUpdate is the direction vector to update with the result
  16277. * @param particle is the particle we are computed the direction for
  16278. */
  16279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16280. /**
  16281. * Clones the current emitter and returns a copy of it
  16282. * @returns the new emitter
  16283. */
  16284. clone(): SphereDirectedParticleEmitter;
  16285. /**
  16286. * Called by the GPUParticleSystem to setup the update shader
  16287. * @param effect defines the update shader
  16288. */
  16289. applyToShader(effect: Effect): void;
  16290. /**
  16291. * Returns a string to use to update the GPU particles update shader
  16292. * @returns a string containng the defines string
  16293. */
  16294. getEffectDefines(): string;
  16295. /**
  16296. * Returns the string "SphereDirectedParticleEmitter"
  16297. * @returns a string containing the class name
  16298. */
  16299. getClassName(): string;
  16300. /**
  16301. * Serializes the particle system to a JSON object.
  16302. * @returns the JSON object
  16303. */
  16304. serialize(): any;
  16305. /**
  16306. * Parse properties from a JSON object
  16307. * @param serializationObject defines the JSON object
  16308. */
  16309. parse(serializationObject: any): void;
  16310. }
  16311. }
  16312. declare module BABYLON {
  16313. /**
  16314. * Particle emitter emitting particles from a custom list of positions.
  16315. */
  16316. export class CustomParticleEmitter implements IParticleEmitterType {
  16317. /**
  16318. * Gets or sets the position generator that will create the inital position of each particle.
  16319. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16320. */
  16321. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16322. /**
  16323. * Gets or sets the destination generator that will create the final destination of each particle.
  16324. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16325. */
  16326. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16327. /**
  16328. * Creates a new instance CustomParticleEmitter
  16329. */
  16330. constructor();
  16331. /**
  16332. * Called by the particle System when the direction is computed for the created particle.
  16333. * @param worldMatrix is the world matrix of the particle system
  16334. * @param directionToUpdate is the direction vector to update with the result
  16335. * @param particle is the particle we are computed the direction for
  16336. * @param isLocal defines if the direction should be set in local space
  16337. */
  16338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16339. /**
  16340. * Called by the particle System when the position is computed for the created particle.
  16341. * @param worldMatrix is the world matrix of the particle system
  16342. * @param positionToUpdate is the position vector to update with the result
  16343. * @param particle is the particle we are computed the position for
  16344. * @param isLocal defines if the position should be set in local space
  16345. */
  16346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16347. /**
  16348. * Clones the current emitter and returns a copy of it
  16349. * @returns the new emitter
  16350. */
  16351. clone(): CustomParticleEmitter;
  16352. /**
  16353. * Called by the GPUParticleSystem to setup the update shader
  16354. * @param effect defines the update shader
  16355. */
  16356. applyToShader(effect: Effect): void;
  16357. /**
  16358. * Returns a string to use to update the GPU particles update shader
  16359. * @returns a string containng the defines string
  16360. */
  16361. getEffectDefines(): string;
  16362. /**
  16363. * Returns the string "PointParticleEmitter"
  16364. * @returns a string containing the class name
  16365. */
  16366. getClassName(): string;
  16367. /**
  16368. * Serializes the particle system to a JSON object.
  16369. * @returns the JSON object
  16370. */
  16371. serialize(): any;
  16372. /**
  16373. * Parse properties from a JSON object
  16374. * @param serializationObject defines the JSON object
  16375. */
  16376. parse(serializationObject: any): void;
  16377. }
  16378. }
  16379. declare module BABYLON {
  16380. /**
  16381. * Particle emitter emitting particles from the inside of a box.
  16382. * It emits the particles randomly between 2 given directions.
  16383. */
  16384. export class MeshParticleEmitter implements IParticleEmitterType {
  16385. private _indices;
  16386. private _positions;
  16387. private _normals;
  16388. private _storedNormal;
  16389. private _mesh;
  16390. /**
  16391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16392. */
  16393. direction1: Vector3;
  16394. /**
  16395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16396. */
  16397. direction2: Vector3;
  16398. /**
  16399. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16400. */
  16401. useMeshNormalsForDirection: boolean;
  16402. /** Defines the mesh to use as source */
  16403. get mesh(): Nullable<AbstractMesh>;
  16404. set mesh(value: Nullable<AbstractMesh>);
  16405. /**
  16406. * Creates a new instance MeshParticleEmitter
  16407. * @param mesh defines the mesh to use as source
  16408. */
  16409. constructor(mesh?: Nullable<AbstractMesh>);
  16410. /**
  16411. * Called by the particle System when the direction is computed for the created particle.
  16412. * @param worldMatrix is the world matrix of the particle system
  16413. * @param directionToUpdate is the direction vector to update with the result
  16414. * @param particle is the particle we are computed the direction for
  16415. * @param isLocal defines if the direction should be set in local space
  16416. */
  16417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16418. /**
  16419. * Called by the particle System when the position is computed for the created particle.
  16420. * @param worldMatrix is the world matrix of the particle system
  16421. * @param positionToUpdate is the position vector to update with the result
  16422. * @param particle is the particle we are computed the position for
  16423. * @param isLocal defines if the position should be set in local space
  16424. */
  16425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16426. /**
  16427. * Clones the current emitter and returns a copy of it
  16428. * @returns the new emitter
  16429. */
  16430. clone(): MeshParticleEmitter;
  16431. /**
  16432. * Called by the GPUParticleSystem to setup the update shader
  16433. * @param effect defines the update shader
  16434. */
  16435. applyToShader(effect: Effect): void;
  16436. /**
  16437. * Returns a string to use to update the GPU particles update shader
  16438. * @returns a string containng the defines string
  16439. */
  16440. getEffectDefines(): string;
  16441. /**
  16442. * Returns the string "BoxParticleEmitter"
  16443. * @returns a string containing the class name
  16444. */
  16445. getClassName(): string;
  16446. /**
  16447. * Serializes the particle system to a JSON object.
  16448. * @returns the JSON object
  16449. */
  16450. serialize(): any;
  16451. /**
  16452. * Parse properties from a JSON object
  16453. * @param serializationObject defines the JSON object
  16454. * @param scene defines the hosting scene
  16455. */
  16456. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16457. }
  16458. }
  16459. declare module BABYLON {
  16460. /**
  16461. * Interface representing a particle system in Babylon.js.
  16462. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16463. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16464. */
  16465. export interface IParticleSystem {
  16466. /**
  16467. * List of animations used by the particle system.
  16468. */
  16469. animations: Animation[];
  16470. /**
  16471. * The id of the Particle system.
  16472. */
  16473. id: string;
  16474. /**
  16475. * The name of the Particle system.
  16476. */
  16477. name: string;
  16478. /**
  16479. * The emitter represents the Mesh or position we are attaching the particle system to.
  16480. */
  16481. emitter: Nullable<AbstractMesh | Vector3>;
  16482. /**
  16483. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16484. */
  16485. isBillboardBased: boolean;
  16486. /**
  16487. * The rendering group used by the Particle system to chose when to render.
  16488. */
  16489. renderingGroupId: number;
  16490. /**
  16491. * The layer mask we are rendering the particles through.
  16492. */
  16493. layerMask: number;
  16494. /**
  16495. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16496. */
  16497. updateSpeed: number;
  16498. /**
  16499. * The amount of time the particle system is running (depends of the overall update speed).
  16500. */
  16501. targetStopDuration: number;
  16502. /**
  16503. * The texture used to render each particle. (this can be a spritesheet)
  16504. */
  16505. particleTexture: Nullable<BaseTexture>;
  16506. /**
  16507. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16508. */
  16509. blendMode: number;
  16510. /**
  16511. * Minimum life time of emitting particles.
  16512. */
  16513. minLifeTime: number;
  16514. /**
  16515. * Maximum life time of emitting particles.
  16516. */
  16517. maxLifeTime: number;
  16518. /**
  16519. * Minimum Size of emitting particles.
  16520. */
  16521. minSize: number;
  16522. /**
  16523. * Maximum Size of emitting particles.
  16524. */
  16525. maxSize: number;
  16526. /**
  16527. * Minimum scale of emitting particles on X axis.
  16528. */
  16529. minScaleX: number;
  16530. /**
  16531. * Maximum scale of emitting particles on X axis.
  16532. */
  16533. maxScaleX: number;
  16534. /**
  16535. * Minimum scale of emitting particles on Y axis.
  16536. */
  16537. minScaleY: number;
  16538. /**
  16539. * Maximum scale of emitting particles on Y axis.
  16540. */
  16541. maxScaleY: number;
  16542. /**
  16543. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16544. */
  16545. color1: Color4;
  16546. /**
  16547. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16548. */
  16549. color2: Color4;
  16550. /**
  16551. * Color the particle will have at the end of its lifetime.
  16552. */
  16553. colorDead: Color4;
  16554. /**
  16555. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16556. */
  16557. emitRate: number;
  16558. /**
  16559. * You can use gravity if you want to give an orientation to your particles.
  16560. */
  16561. gravity: Vector3;
  16562. /**
  16563. * Minimum power of emitting particles.
  16564. */
  16565. minEmitPower: number;
  16566. /**
  16567. * Maximum power of emitting particles.
  16568. */
  16569. maxEmitPower: number;
  16570. /**
  16571. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16572. */
  16573. minAngularSpeed: number;
  16574. /**
  16575. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16576. */
  16577. maxAngularSpeed: number;
  16578. /**
  16579. * Gets or sets the minimal initial rotation in radians.
  16580. */
  16581. minInitialRotation: number;
  16582. /**
  16583. * Gets or sets the maximal initial rotation in radians.
  16584. */
  16585. maxInitialRotation: number;
  16586. /**
  16587. * The particle emitter type defines the emitter used by the particle system.
  16588. * It can be for example box, sphere, or cone...
  16589. */
  16590. particleEmitterType: Nullable<IParticleEmitterType>;
  16591. /**
  16592. * Defines the delay in milliseconds before starting the system (0 by default)
  16593. */
  16594. startDelay: number;
  16595. /**
  16596. * 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
  16597. */
  16598. preWarmCycles: number;
  16599. /**
  16600. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16601. */
  16602. preWarmStepOffset: number;
  16603. /**
  16604. * 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)
  16605. */
  16606. spriteCellChangeSpeed: number;
  16607. /**
  16608. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16609. */
  16610. startSpriteCellID: number;
  16611. /**
  16612. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16613. */
  16614. endSpriteCellID: number;
  16615. /**
  16616. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16617. */
  16618. spriteCellWidth: number;
  16619. /**
  16620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16621. */
  16622. spriteCellHeight: number;
  16623. /**
  16624. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16625. */
  16626. spriteRandomStartCell: boolean;
  16627. /**
  16628. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16629. */
  16630. isAnimationSheetEnabled: boolean;
  16631. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16632. translationPivot: Vector2;
  16633. /**
  16634. * Gets or sets a texture used to add random noise to particle positions
  16635. */
  16636. noiseTexture: Nullable<BaseTexture>;
  16637. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16638. noiseStrength: Vector3;
  16639. /**
  16640. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16641. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16642. */
  16643. billboardMode: number;
  16644. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16645. limitVelocityDamping: number;
  16646. /**
  16647. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16648. */
  16649. beginAnimationOnStart: boolean;
  16650. /**
  16651. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16652. */
  16653. beginAnimationFrom: number;
  16654. /**
  16655. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16656. */
  16657. beginAnimationTo: number;
  16658. /**
  16659. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16660. */
  16661. beginAnimationLoop: boolean;
  16662. /**
  16663. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16664. */
  16665. disposeOnStop: boolean;
  16666. /**
  16667. * Specifies if the particles are updated in emitter local space or world space
  16668. */
  16669. isLocal: boolean;
  16670. /** Snippet ID if the particle system was created from the snippet server */
  16671. snippetId: string;
  16672. /** Gets or sets a matrix to use to compute projection */
  16673. defaultProjectionMatrix: Matrix;
  16674. /**
  16675. * Gets the maximum number of particles active at the same time.
  16676. * @returns The max number of active particles.
  16677. */
  16678. getCapacity(): number;
  16679. /**
  16680. * Gets the number of particles active at the same time.
  16681. * @returns The number of active particles.
  16682. */
  16683. getActiveCount(): number;
  16684. /**
  16685. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16686. * @returns True if it has been started, otherwise false.
  16687. */
  16688. isStarted(): boolean;
  16689. /**
  16690. * Animates the particle system for this frame.
  16691. */
  16692. animate(): void;
  16693. /**
  16694. * Renders the particle system in its current state.
  16695. * @returns the current number of particles
  16696. */
  16697. render(): number;
  16698. /**
  16699. * Dispose the particle system and frees its associated resources.
  16700. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16701. */
  16702. dispose(disposeTexture?: boolean): void;
  16703. /**
  16704. * An event triggered when the system is disposed
  16705. */
  16706. onDisposeObservable: Observable<IParticleSystem>;
  16707. /**
  16708. * An event triggered when the system is stopped
  16709. */
  16710. onStoppedObservable: Observable<IParticleSystem>;
  16711. /**
  16712. * Clones the particle system.
  16713. * @param name The name of the cloned object
  16714. * @param newEmitter The new emitter to use
  16715. * @returns the cloned particle system
  16716. */
  16717. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16718. /**
  16719. * Serializes the particle system to a JSON object
  16720. * @param serializeTexture defines if the texture must be serialized as well
  16721. * @returns the JSON object
  16722. */
  16723. serialize(serializeTexture: boolean): any;
  16724. /**
  16725. * Rebuild the particle system
  16726. */
  16727. rebuild(): void;
  16728. /** Force the system to rebuild all gradients that need to be resync */
  16729. forceRefreshGradients(): void;
  16730. /**
  16731. * Starts the particle system and begins to emit
  16732. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16733. */
  16734. start(delay?: number): void;
  16735. /**
  16736. * Stops the particle system.
  16737. */
  16738. stop(): void;
  16739. /**
  16740. * Remove all active particles
  16741. */
  16742. reset(): void;
  16743. /**
  16744. * Gets a boolean indicating that the system is stopping
  16745. * @returns true if the system is currently stopping
  16746. */
  16747. isStopping(): boolean;
  16748. /**
  16749. * Is this system ready to be used/rendered
  16750. * @return true if the system is ready
  16751. */
  16752. isReady(): boolean;
  16753. /**
  16754. * Returns the string "ParticleSystem"
  16755. * @returns a string containing the class name
  16756. */
  16757. getClassName(): string;
  16758. /**
  16759. * Gets the custom effect used to render the particles
  16760. * @param blendMode Blend mode for which the effect should be retrieved
  16761. * @returns The effect
  16762. */
  16763. getCustomEffect(blendMode: number): Nullable<Effect>;
  16764. /**
  16765. * Sets the custom effect used to render the particles
  16766. * @param effect The effect to set
  16767. * @param blendMode Blend mode for which the effect should be set
  16768. */
  16769. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16770. /**
  16771. * Fill the defines array according to the current settings of the particle system
  16772. * @param defines Array to be updated
  16773. * @param blendMode blend mode to take into account when updating the array
  16774. */
  16775. fillDefines(defines: Array<string>, blendMode: number): void;
  16776. /**
  16777. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16778. * @param uniforms Uniforms array to fill
  16779. * @param attributes Attributes array to fill
  16780. * @param samplers Samplers array to fill
  16781. */
  16782. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16783. /**
  16784. * Observable that will be called just before the particles are drawn
  16785. */
  16786. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16787. /**
  16788. * Gets the name of the particle vertex shader
  16789. */
  16790. vertexShaderName: string;
  16791. /**
  16792. * Adds a new color gradient
  16793. * @param gradient defines the gradient to use (between 0 and 1)
  16794. * @param color1 defines the color to affect to the specified gradient
  16795. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16796. * @returns the current particle system
  16797. */
  16798. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16799. /**
  16800. * Remove a specific color gradient
  16801. * @param gradient defines the gradient to remove
  16802. * @returns the current particle system
  16803. */
  16804. removeColorGradient(gradient: number): IParticleSystem;
  16805. /**
  16806. * Adds a new size gradient
  16807. * @param gradient defines the gradient to use (between 0 and 1)
  16808. * @param factor defines the size factor to affect to the specified gradient
  16809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16810. * @returns the current particle system
  16811. */
  16812. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16813. /**
  16814. * Remove a specific size gradient
  16815. * @param gradient defines the gradient to remove
  16816. * @returns the current particle system
  16817. */
  16818. removeSizeGradient(gradient: number): IParticleSystem;
  16819. /**
  16820. * Gets the current list of color gradients.
  16821. * You must use addColorGradient and removeColorGradient to udpate this list
  16822. * @returns the list of color gradients
  16823. */
  16824. getColorGradients(): Nullable<Array<ColorGradient>>;
  16825. /**
  16826. * Gets the current list of size gradients.
  16827. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16828. * @returns the list of size gradients
  16829. */
  16830. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16831. /**
  16832. * Gets the current list of angular speed gradients.
  16833. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16834. * @returns the list of angular speed gradients
  16835. */
  16836. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Adds a new angular speed gradient
  16839. * @param gradient defines the gradient to use (between 0 and 1)
  16840. * @param factor defines the angular speed to affect to the specified gradient
  16841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16842. * @returns the current particle system
  16843. */
  16844. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16845. /**
  16846. * Remove a specific angular speed gradient
  16847. * @param gradient defines the gradient to remove
  16848. * @returns the current particle system
  16849. */
  16850. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16851. /**
  16852. * Gets the current list of velocity gradients.
  16853. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16854. * @returns the list of velocity gradients
  16855. */
  16856. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Adds a new velocity gradient
  16859. * @param gradient defines the gradient to use (between 0 and 1)
  16860. * @param factor defines the velocity to affect to the specified gradient
  16861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16862. * @returns the current particle system
  16863. */
  16864. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16865. /**
  16866. * Remove a specific velocity gradient
  16867. * @param gradient defines the gradient to remove
  16868. * @returns the current particle system
  16869. */
  16870. removeVelocityGradient(gradient: number): IParticleSystem;
  16871. /**
  16872. * Gets the current list of limit velocity gradients.
  16873. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16874. * @returns the list of limit velocity gradients
  16875. */
  16876. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16877. /**
  16878. * Adds a new limit velocity gradient
  16879. * @param gradient defines the gradient to use (between 0 and 1)
  16880. * @param factor defines the limit velocity to affect to the specified gradient
  16881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16882. * @returns the current particle system
  16883. */
  16884. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16885. /**
  16886. * Remove a specific limit velocity gradient
  16887. * @param gradient defines the gradient to remove
  16888. * @returns the current particle system
  16889. */
  16890. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16891. /**
  16892. * Adds a new drag gradient
  16893. * @param gradient defines the gradient to use (between 0 and 1)
  16894. * @param factor defines the drag to affect to the specified gradient
  16895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16896. * @returns the current particle system
  16897. */
  16898. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16899. /**
  16900. * Remove a specific drag gradient
  16901. * @param gradient defines the gradient to remove
  16902. * @returns the current particle system
  16903. */
  16904. removeDragGradient(gradient: number): IParticleSystem;
  16905. /**
  16906. * Gets the current list of drag gradients.
  16907. * You must use addDragGradient and removeDragGradient to udpate this list
  16908. * @returns the list of drag gradients
  16909. */
  16910. getDragGradients(): Nullable<Array<FactorGradient>>;
  16911. /**
  16912. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16913. * @param gradient defines the gradient to use (between 0 and 1)
  16914. * @param factor defines the emit rate to affect to the specified gradient
  16915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16916. * @returns the current particle system
  16917. */
  16918. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16919. /**
  16920. * Remove a specific emit rate gradient
  16921. * @param gradient defines the gradient to remove
  16922. * @returns the current particle system
  16923. */
  16924. removeEmitRateGradient(gradient: number): IParticleSystem;
  16925. /**
  16926. * Gets the current list of emit rate gradients.
  16927. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16928. * @returns the list of emit rate gradients
  16929. */
  16930. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16931. /**
  16932. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16933. * @param gradient defines the gradient to use (between 0 and 1)
  16934. * @param factor defines the start size to affect to the specified gradient
  16935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16936. * @returns the current particle system
  16937. */
  16938. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16939. /**
  16940. * Remove a specific start size gradient
  16941. * @param gradient defines the gradient to remove
  16942. * @returns the current particle system
  16943. */
  16944. removeStartSizeGradient(gradient: number): IParticleSystem;
  16945. /**
  16946. * Gets the current list of start size gradients.
  16947. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16948. * @returns the list of start size gradients
  16949. */
  16950. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16951. /**
  16952. * Adds a new life time gradient
  16953. * @param gradient defines the gradient to use (between 0 and 1)
  16954. * @param factor defines the life time factor to affect to the specified gradient
  16955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16956. * @returns the current particle system
  16957. */
  16958. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16959. /**
  16960. * Remove a specific life time gradient
  16961. * @param gradient defines the gradient to remove
  16962. * @returns the current particle system
  16963. */
  16964. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16965. /**
  16966. * Gets the current list of life time gradients.
  16967. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16968. * @returns the list of life time gradients
  16969. */
  16970. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16971. /**
  16972. * Gets the current list of color gradients.
  16973. * You must use addColorGradient and removeColorGradient to udpate this list
  16974. * @returns the list of color gradients
  16975. */
  16976. getColorGradients(): Nullable<Array<ColorGradient>>;
  16977. /**
  16978. * Adds a new ramp gradient used to remap particle colors
  16979. * @param gradient defines the gradient to use (between 0 and 1)
  16980. * @param color defines the color to affect to the specified gradient
  16981. * @returns the current particle system
  16982. */
  16983. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16984. /**
  16985. * Gets the current list of ramp gradients.
  16986. * You must use addRampGradient and removeRampGradient to udpate this list
  16987. * @returns the list of ramp gradients
  16988. */
  16989. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16990. /** Gets or sets a boolean indicating that ramp gradients must be used
  16991. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16992. */
  16993. useRampGradients: boolean;
  16994. /**
  16995. * Adds a new color remap gradient
  16996. * @param gradient defines the gradient to use (between 0 and 1)
  16997. * @param min defines the color remap minimal range
  16998. * @param max defines the color remap maximal range
  16999. * @returns the current particle system
  17000. */
  17001. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17002. /**
  17003. * Gets the current list of color remap gradients.
  17004. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17005. * @returns the list of color remap gradients
  17006. */
  17007. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17008. /**
  17009. * Adds a new alpha remap gradient
  17010. * @param gradient defines the gradient to use (between 0 and 1)
  17011. * @param min defines the alpha remap minimal range
  17012. * @param max defines the alpha remap maximal range
  17013. * @returns the current particle system
  17014. */
  17015. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17016. /**
  17017. * Gets the current list of alpha remap gradients.
  17018. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17019. * @returns the list of alpha remap gradients
  17020. */
  17021. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @returns the emitter
  17027. */
  17028. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17029. /**
  17030. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17031. * @param radius The radius of the hemisphere to emit from
  17032. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17033. * @returns the emitter
  17034. */
  17035. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17036. /**
  17037. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17038. * @param radius The radius of the sphere to emit from
  17039. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17040. * @returns the emitter
  17041. */
  17042. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17043. /**
  17044. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17045. * @param radius The radius of the sphere to emit from
  17046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @returns the emitter
  17049. */
  17050. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17051. /**
  17052. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17053. * @param radius The radius of the emission cylinder
  17054. * @param height The height of the emission cylinder
  17055. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17056. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17057. * @returns the emitter
  17058. */
  17059. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17060. /**
  17061. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17062. * @param radius The radius of the cylinder to emit from
  17063. * @param height The height of the emission cylinder
  17064. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17065. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17066. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @returns the emitter
  17068. */
  17069. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17070. /**
  17071. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17072. * @param radius The radius of the cone to emit from
  17073. * @param angle The base angle of the cone
  17074. * @returns the emitter
  17075. */
  17076. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17077. /**
  17078. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17082. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @returns the emitter
  17084. */
  17085. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17086. /**
  17087. * Get hosting scene
  17088. * @returns the scene
  17089. */
  17090. getScene(): Nullable<Scene>;
  17091. }
  17092. }
  17093. declare module BABYLON {
  17094. /**
  17095. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17096. */
  17097. export class ColorSplitterBlock extends NodeMaterialBlock {
  17098. /**
  17099. * Create a new ColorSplitterBlock
  17100. * @param name defines the block name
  17101. */
  17102. constructor(name: string);
  17103. /**
  17104. * Gets the current class name
  17105. * @returns the class name
  17106. */
  17107. getClassName(): string;
  17108. /**
  17109. * Gets the rgba component (input)
  17110. */
  17111. get rgba(): NodeMaterialConnectionPoint;
  17112. /**
  17113. * Gets the rgb component (input)
  17114. */
  17115. get rgbIn(): NodeMaterialConnectionPoint;
  17116. /**
  17117. * Gets the rgb component (output)
  17118. */
  17119. get rgbOut(): NodeMaterialConnectionPoint;
  17120. /**
  17121. * Gets the r component (output)
  17122. */
  17123. get r(): NodeMaterialConnectionPoint;
  17124. /**
  17125. * Gets the g component (output)
  17126. */
  17127. get g(): NodeMaterialConnectionPoint;
  17128. /**
  17129. * Gets the b component (output)
  17130. */
  17131. get b(): NodeMaterialConnectionPoint;
  17132. /**
  17133. * Gets the a component (output)
  17134. */
  17135. get a(): NodeMaterialConnectionPoint;
  17136. protected _inputRename(name: string): string;
  17137. protected _outputRename(name: string): string;
  17138. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17139. }
  17140. }
  17141. declare module BABYLON {
  17142. /**
  17143. * Operations supported by the Trigonometry block
  17144. */
  17145. export enum TrigonometryBlockOperations {
  17146. /** Cos */
  17147. Cos = 0,
  17148. /** Sin */
  17149. Sin = 1,
  17150. /** Abs */
  17151. Abs = 2,
  17152. /** Exp */
  17153. Exp = 3,
  17154. /** Exp2 */
  17155. Exp2 = 4,
  17156. /** Round */
  17157. Round = 5,
  17158. /** Floor */
  17159. Floor = 6,
  17160. /** Ceiling */
  17161. Ceiling = 7,
  17162. /** Square root */
  17163. Sqrt = 8,
  17164. /** Log */
  17165. Log = 9,
  17166. /** Tangent */
  17167. Tan = 10,
  17168. /** Arc tangent */
  17169. ArcTan = 11,
  17170. /** Arc cosinus */
  17171. ArcCos = 12,
  17172. /** Arc sinus */
  17173. ArcSin = 13,
  17174. /** Fraction */
  17175. Fract = 14,
  17176. /** Sign */
  17177. Sign = 15,
  17178. /** To radians (from degrees) */
  17179. Radians = 16,
  17180. /** To degrees (from radians) */
  17181. Degrees = 17
  17182. }
  17183. /**
  17184. * Block used to apply trigonometry operation to floats
  17185. */
  17186. export class TrigonometryBlock extends NodeMaterialBlock {
  17187. /**
  17188. * Gets or sets the operation applied by the block
  17189. */
  17190. operation: TrigonometryBlockOperations;
  17191. /**
  17192. * Creates a new TrigonometryBlock
  17193. * @param name defines the block name
  17194. */
  17195. constructor(name: string);
  17196. /**
  17197. * Gets the current class name
  17198. * @returns the class name
  17199. */
  17200. getClassName(): string;
  17201. /**
  17202. * Gets the input component
  17203. */
  17204. get input(): NodeMaterialConnectionPoint;
  17205. /**
  17206. * Gets the output component
  17207. */
  17208. get output(): NodeMaterialConnectionPoint;
  17209. protected _buildBlock(state: NodeMaterialBuildState): this;
  17210. serialize(): any;
  17211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17212. protected _dumpPropertiesCode(): string;
  17213. }
  17214. }
  17215. declare module BABYLON {
  17216. /**
  17217. * Interface used to configure the node material editor
  17218. */
  17219. export interface INodeMaterialEditorOptions {
  17220. /** Define the URl to load node editor script */
  17221. editorURL?: string;
  17222. }
  17223. /** @hidden */
  17224. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17225. NORMAL: boolean;
  17226. TANGENT: boolean;
  17227. UV1: boolean;
  17228. /** BONES */
  17229. NUM_BONE_INFLUENCERS: number;
  17230. BonesPerMesh: number;
  17231. BONETEXTURE: boolean;
  17232. /** MORPH TARGETS */
  17233. MORPHTARGETS: boolean;
  17234. MORPHTARGETS_NORMAL: boolean;
  17235. MORPHTARGETS_TANGENT: boolean;
  17236. MORPHTARGETS_UV: boolean;
  17237. NUM_MORPH_INFLUENCERS: number;
  17238. /** IMAGE PROCESSING */
  17239. IMAGEPROCESSING: boolean;
  17240. VIGNETTE: boolean;
  17241. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17242. VIGNETTEBLENDMODEOPAQUE: boolean;
  17243. TONEMAPPING: boolean;
  17244. TONEMAPPING_ACES: boolean;
  17245. CONTRAST: boolean;
  17246. EXPOSURE: boolean;
  17247. COLORCURVES: boolean;
  17248. COLORGRADING: boolean;
  17249. COLORGRADING3D: boolean;
  17250. SAMPLER3DGREENDEPTH: boolean;
  17251. SAMPLER3DBGRMAP: boolean;
  17252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17253. /** MISC. */
  17254. BUMPDIRECTUV: number;
  17255. constructor();
  17256. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17257. }
  17258. /**
  17259. * Class used to configure NodeMaterial
  17260. */
  17261. export interface INodeMaterialOptions {
  17262. /**
  17263. * Defines if blocks should emit comments
  17264. */
  17265. emitComments: boolean;
  17266. }
  17267. /**
  17268. * Class used to create a node based material built by assembling shader blocks
  17269. */
  17270. export class NodeMaterial extends PushMaterial {
  17271. private static _BuildIdGenerator;
  17272. private _options;
  17273. private _vertexCompilationState;
  17274. private _fragmentCompilationState;
  17275. private _sharedData;
  17276. private _buildId;
  17277. private _buildWasSuccessful;
  17278. private _cachedWorldViewMatrix;
  17279. private _cachedWorldViewProjectionMatrix;
  17280. private _optimizers;
  17281. private _animationFrame;
  17282. /** Define the Url to load node editor script */
  17283. static EditorURL: string;
  17284. /** Define the Url to load snippets */
  17285. static SnippetUrl: string;
  17286. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17287. static IgnoreTexturesAtLoadTime: boolean;
  17288. private BJSNODEMATERIALEDITOR;
  17289. /** Get the inspector from bundle or global */
  17290. private _getGlobalNodeMaterialEditor;
  17291. /**
  17292. * Snippet ID if the material was created from the snippet server
  17293. */
  17294. snippetId: string;
  17295. /**
  17296. * Gets or sets data used by visual editor
  17297. * @see https://nme.babylonjs.com
  17298. */
  17299. editorData: any;
  17300. /**
  17301. * 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)
  17302. */
  17303. ignoreAlpha: boolean;
  17304. /**
  17305. * Defines the maximum number of lights that can be used in the material
  17306. */
  17307. maxSimultaneousLights: number;
  17308. /**
  17309. * Observable raised when the material is built
  17310. */
  17311. onBuildObservable: Observable<NodeMaterial>;
  17312. /**
  17313. * Gets or sets the root nodes of the material vertex shader
  17314. */
  17315. _vertexOutputNodes: NodeMaterialBlock[];
  17316. /**
  17317. * Gets or sets the root nodes of the material fragment (pixel) shader
  17318. */
  17319. _fragmentOutputNodes: NodeMaterialBlock[];
  17320. /** Gets or sets options to control the node material overall behavior */
  17321. get options(): INodeMaterialOptions;
  17322. set options(options: INodeMaterialOptions);
  17323. /**
  17324. * Default configuration related to image processing available in the standard Material.
  17325. */
  17326. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17327. /**
  17328. * Gets the image processing configuration used either in this material.
  17329. */
  17330. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17331. /**
  17332. * Sets the Default image processing configuration used either in the this material.
  17333. *
  17334. * If sets to null, the scene one is in use.
  17335. */
  17336. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17337. /**
  17338. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17339. */
  17340. attachedBlocks: NodeMaterialBlock[];
  17341. /**
  17342. * Specifies the mode of the node material
  17343. * @hidden
  17344. */
  17345. _mode: NodeMaterialModes;
  17346. /**
  17347. * Gets the mode property
  17348. */
  17349. get mode(): NodeMaterialModes;
  17350. /**
  17351. * A free comment about the material
  17352. */
  17353. comment: string;
  17354. /**
  17355. * Create a new node based material
  17356. * @param name defines the material name
  17357. * @param scene defines the hosting scene
  17358. * @param options defines creation option
  17359. */
  17360. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17361. /**
  17362. * Gets the current class name of the material e.g. "NodeMaterial"
  17363. * @returns the class name
  17364. */
  17365. getClassName(): string;
  17366. /**
  17367. * Keep track of the image processing observer to allow dispose and replace.
  17368. */
  17369. private _imageProcessingObserver;
  17370. /**
  17371. * Attaches a new image processing configuration to the Standard Material.
  17372. * @param configuration
  17373. */
  17374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17375. /**
  17376. * Get a block by its name
  17377. * @param name defines the name of the block to retrieve
  17378. * @returns the required block or null if not found
  17379. */
  17380. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17381. /**
  17382. * Get a block by its name
  17383. * @param predicate defines the predicate used to find the good candidate
  17384. * @returns the required block or null if not found
  17385. */
  17386. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17387. /**
  17388. * Get an input block by its name
  17389. * @param predicate defines the predicate used to find the good candidate
  17390. * @returns the required input block or null if not found
  17391. */
  17392. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17393. /**
  17394. * Gets the list of input blocks attached to this material
  17395. * @returns an array of InputBlocks
  17396. */
  17397. getInputBlocks(): InputBlock[];
  17398. /**
  17399. * Adds a new optimizer to the list of optimizers
  17400. * @param optimizer defines the optimizers to add
  17401. * @returns the current material
  17402. */
  17403. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17404. /**
  17405. * Remove an optimizer from the list of optimizers
  17406. * @param optimizer defines the optimizers to remove
  17407. * @returns the current material
  17408. */
  17409. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17410. /**
  17411. * Add a new block to the list of output nodes
  17412. * @param node defines the node to add
  17413. * @returns the current material
  17414. */
  17415. addOutputNode(node: NodeMaterialBlock): this;
  17416. /**
  17417. * Remove a block from the list of root nodes
  17418. * @param node defines the node to remove
  17419. * @returns the current material
  17420. */
  17421. removeOutputNode(node: NodeMaterialBlock): this;
  17422. private _addVertexOutputNode;
  17423. private _removeVertexOutputNode;
  17424. private _addFragmentOutputNode;
  17425. private _removeFragmentOutputNode;
  17426. /**
  17427. * Specifies if the material will require alpha blending
  17428. * @returns a boolean specifying if alpha blending is needed
  17429. */
  17430. needAlphaBlending(): boolean;
  17431. /**
  17432. * Specifies if this material should be rendered in alpha test mode
  17433. * @returns a boolean specifying if an alpha test is needed.
  17434. */
  17435. needAlphaTesting(): boolean;
  17436. private _initializeBlock;
  17437. private _resetDualBlocks;
  17438. /**
  17439. * Remove a block from the current node material
  17440. * @param block defines the block to remove
  17441. */
  17442. removeBlock(block: NodeMaterialBlock): void;
  17443. /**
  17444. * Build the material and generates the inner effect
  17445. * @param verbose defines if the build should log activity
  17446. */
  17447. build(verbose?: boolean): void;
  17448. /**
  17449. * Runs an otpimization phase to try to improve the shader code
  17450. */
  17451. optimize(): void;
  17452. private _prepareDefinesForAttributes;
  17453. /**
  17454. * Create a post process from the material
  17455. * @param camera The camera to apply the render pass to.
  17456. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17458. * @param engine The engine which the post process will be applied. (default: current engine)
  17459. * @param reusable If the post process can be reused on the same frame. (default: false)
  17460. * @param textureType Type of textures used when performing the post process. (default: 0)
  17461. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17462. * @returns the post process created
  17463. */
  17464. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17465. /**
  17466. * Create the post process effect from the material
  17467. * @param postProcess The post process to create the effect for
  17468. */
  17469. createEffectForPostProcess(postProcess: PostProcess): void;
  17470. private _createEffectForPostProcess;
  17471. /**
  17472. * Create a new procedural texture based on this node material
  17473. * @param size defines the size of the texture
  17474. * @param scene defines the hosting scene
  17475. * @returns the new procedural texture attached to this node material
  17476. */
  17477. createProceduralTexture(size: number | {
  17478. width: number;
  17479. height: number;
  17480. layers?: number;
  17481. }, scene: Scene): Nullable<ProceduralTexture>;
  17482. private _createEffectForParticles;
  17483. private _checkInternals;
  17484. /**
  17485. * Create the effect to be used as the custom effect for a particle system
  17486. * @param particleSystem Particle system to create the effect for
  17487. * @param onCompiled defines a function to call when the effect creation is successful
  17488. * @param onError defines a function to call when the effect creation has failed
  17489. */
  17490. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17491. private _processDefines;
  17492. /**
  17493. * Get if the submesh is ready to be used and all its information available.
  17494. * Child classes can use it to update shaders
  17495. * @param mesh defines the mesh to check
  17496. * @param subMesh defines which submesh to check
  17497. * @param useInstances specifies that instances should be used
  17498. * @returns a boolean indicating that the submesh is ready or not
  17499. */
  17500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17501. /**
  17502. * Get a string representing the shaders built by the current node graph
  17503. */
  17504. get compiledShaders(): string;
  17505. /**
  17506. * Binds the world matrix to the material
  17507. * @param world defines the world transformation matrix
  17508. */
  17509. bindOnlyWorldMatrix(world: Matrix): void;
  17510. /**
  17511. * Binds the submesh to this material by preparing the effect and shader to draw
  17512. * @param world defines the world transformation matrix
  17513. * @param mesh defines the mesh containing the submesh
  17514. * @param subMesh defines the submesh to bind the material to
  17515. */
  17516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17517. /**
  17518. * Gets the active textures from the material
  17519. * @returns an array of textures
  17520. */
  17521. getActiveTextures(): BaseTexture[];
  17522. /**
  17523. * Gets the list of texture blocks
  17524. * @returns an array of texture blocks
  17525. */
  17526. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17527. /**
  17528. * Specifies if the material uses a texture
  17529. * @param texture defines the texture to check against the material
  17530. * @returns a boolean specifying if the material uses the texture
  17531. */
  17532. hasTexture(texture: BaseTexture): boolean;
  17533. /**
  17534. * Disposes the material
  17535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17536. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17537. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17538. */
  17539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17540. /** Creates the node editor window. */
  17541. private _createNodeEditor;
  17542. /**
  17543. * Launch the node material editor
  17544. * @param config Define the configuration of the editor
  17545. * @return a promise fulfilled when the node editor is visible
  17546. */
  17547. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17548. /**
  17549. * Clear the current material
  17550. */
  17551. clear(): void;
  17552. /**
  17553. * Clear the current material and set it to a default state
  17554. */
  17555. setToDefault(): void;
  17556. /**
  17557. * Clear the current material and set it to a default state for post process
  17558. */
  17559. setToDefaultPostProcess(): void;
  17560. /**
  17561. * Clear the current material and set it to a default state for procedural texture
  17562. */
  17563. setToDefaultProceduralTexture(): void;
  17564. /**
  17565. * Clear the current material and set it to a default state for particle
  17566. */
  17567. setToDefaultParticle(): void;
  17568. /**
  17569. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17570. * @param url defines the url to load from
  17571. * @returns a promise that will fullfil when the material is fully loaded
  17572. */
  17573. loadAsync(url: string): Promise<void>;
  17574. private _gatherBlocks;
  17575. /**
  17576. * Generate a string containing the code declaration required to create an equivalent of this material
  17577. * @returns a string
  17578. */
  17579. generateCode(): string;
  17580. /**
  17581. * Serializes this material in a JSON representation
  17582. * @returns the serialized material object
  17583. */
  17584. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17585. private _restoreConnections;
  17586. /**
  17587. * Clear the current graph and load a new one from a serialization object
  17588. * @param source defines the JSON representation of the material
  17589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17590. * @param merge defines whether or not the source must be merged or replace the current content
  17591. */
  17592. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17593. /**
  17594. * Makes a duplicate of the current material.
  17595. * @param name - name to use for the new material.
  17596. */
  17597. clone(name: string): NodeMaterial;
  17598. /**
  17599. * Creates a node material from parsed material data
  17600. * @param source defines the JSON representation of the material
  17601. * @param scene defines the hosting scene
  17602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17603. * @returns a new node material
  17604. */
  17605. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17606. /**
  17607. * Creates a node material from a snippet saved in a remote file
  17608. * @param name defines the name of the material to create
  17609. * @param url defines the url to load from
  17610. * @param scene defines the hosting scene
  17611. * @returns a promise that will resolve to the new node material
  17612. */
  17613. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17614. /**
  17615. * Creates a node material from a snippet saved by the node material editor
  17616. * @param snippetId defines the snippet to load
  17617. * @param scene defines the hosting scene
  17618. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17619. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17620. * @returns a promise that will resolve to the new node material
  17621. */
  17622. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17623. /**
  17624. * Creates a new node material set to default basic configuration
  17625. * @param name defines the name of the material
  17626. * @param scene defines the hosting scene
  17627. * @returns a new NodeMaterial
  17628. */
  17629. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17630. }
  17631. }
  17632. declare module BABYLON {
  17633. interface ThinEngine {
  17634. /**
  17635. * Unbind a list of render target textures from the webGL context
  17636. * This is used only when drawBuffer extension or webGL2 are active
  17637. * @param textures defines the render target textures to unbind
  17638. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17639. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17640. */
  17641. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17642. /**
  17643. * Create a multi render target texture
  17644. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17645. * @param size defines the size of the texture
  17646. * @param options defines the creation options
  17647. * @returns the cube texture as an InternalTexture
  17648. */
  17649. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17650. /**
  17651. * Update the sample count for a given multiple render target texture
  17652. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17653. * @param textures defines the textures to update
  17654. * @param samples defines the sample count to set
  17655. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17656. */
  17657. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17658. /**
  17659. * Select a subsets of attachments to draw to.
  17660. * @param attachments gl attachments
  17661. */
  17662. bindAttachments(attachments: number[]): void;
  17663. /**
  17664. * Creates a layout object to draw/clear on specific textures in a MRT
  17665. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17666. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17667. */
  17668. buildTextureLayout(textureStatus: boolean[]): number[];
  17669. /**
  17670. * Restores the webgl state to only draw on the main color attachment
  17671. */
  17672. restoreSingleAttachment(): void;
  17673. }
  17674. }
  17675. declare module BABYLON {
  17676. /**
  17677. * Creation options of the multi render target texture.
  17678. */
  17679. export interface IMultiRenderTargetOptions {
  17680. /**
  17681. * Define if the texture needs to create mip maps after render.
  17682. */
  17683. generateMipMaps?: boolean;
  17684. /**
  17685. * Define the types of all the draw buffers we want to create
  17686. */
  17687. types?: number[];
  17688. /**
  17689. * Define the sampling modes of all the draw buffers we want to create
  17690. */
  17691. samplingModes?: number[];
  17692. /**
  17693. * Define if a depth buffer is required
  17694. */
  17695. generateDepthBuffer?: boolean;
  17696. /**
  17697. * Define if a stencil buffer is required
  17698. */
  17699. generateStencilBuffer?: boolean;
  17700. /**
  17701. * Define if a depth texture is required instead of a depth buffer
  17702. */
  17703. generateDepthTexture?: boolean;
  17704. /**
  17705. * Define the number of desired draw buffers
  17706. */
  17707. textureCount?: number;
  17708. /**
  17709. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17710. */
  17711. doNotChangeAspectRatio?: boolean;
  17712. /**
  17713. * Define the default type of the buffers we are creating
  17714. */
  17715. defaultType?: number;
  17716. }
  17717. /**
  17718. * A multi render target, like a render target provides the ability to render to a texture.
  17719. * Unlike the render target, it can render to several draw buffers in one draw.
  17720. * This is specially interesting in deferred rendering or for any effects requiring more than
  17721. * just one color from a single pass.
  17722. */
  17723. export class MultiRenderTarget extends RenderTargetTexture {
  17724. private _internalTextures;
  17725. private _textures;
  17726. private _multiRenderTargetOptions;
  17727. private _count;
  17728. /**
  17729. * Get if draw buffers are currently supported by the used hardware and browser.
  17730. */
  17731. get isSupported(): boolean;
  17732. /**
  17733. * Get the list of textures generated by the multi render target.
  17734. */
  17735. get textures(): Texture[];
  17736. /**
  17737. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17738. */
  17739. get count(): number;
  17740. /**
  17741. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17742. */
  17743. get depthTexture(): Texture;
  17744. /**
  17745. * Set the wrapping mode on U 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 wrapU(wrap: number);
  17749. /**
  17750. * Set the wrapping mode on V of all the textures we are rendering to.
  17751. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17752. */
  17753. set wrapV(wrap: number);
  17754. /**
  17755. * Instantiate a new multi render target texture.
  17756. * A multi render target, like a render target provides the ability to render to a texture.
  17757. * Unlike the render target, it can render to several draw buffers in one draw.
  17758. * This is specially interesting in deferred rendering or for any effects requiring more than
  17759. * just one color from a single pass.
  17760. * @param name Define the name of the texture
  17761. * @param size Define the size of the buffers to render to
  17762. * @param count Define the number of target we are rendering into
  17763. * @param scene Define the scene the texture belongs to
  17764. * @param options Define the options used to create the multi render target
  17765. */
  17766. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17767. private _initTypes;
  17768. /** @hidden */
  17769. _rebuild(forceFullRebuild?: boolean): void;
  17770. private _createInternalTextures;
  17771. private _createTextures;
  17772. /**
  17773. * Replaces a texture within the MRT.
  17774. * @param texture The new texture to insert in the MRT
  17775. * @param index The index of the texture to replace
  17776. */
  17777. replaceTexture(texture: Texture, index: number): void;
  17778. /**
  17779. * Define the number of samples used if MSAA is enabled.
  17780. */
  17781. get samples(): number;
  17782. set samples(value: number);
  17783. /**
  17784. * Resize all the textures in the multi render target.
  17785. * Be careful as it will recreate all the data in the new texture.
  17786. * @param size Define the new size
  17787. */
  17788. resize(size: any): void;
  17789. /**
  17790. * Changes the number of render targets in this MRT
  17791. * Be careful as it will recreate all the data in the new texture.
  17792. * @param count new texture count
  17793. * @param options Specifies texture types and sampling modes for new textures
  17794. */
  17795. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17797. /**
  17798. * Dispose the render targets and their associated resources
  17799. */
  17800. dispose(): void;
  17801. /**
  17802. * Release all the underlying texture used as draw buffers.
  17803. */
  17804. releaseInternalTextures(): void;
  17805. }
  17806. }
  17807. declare module BABYLON {
  17808. /** @hidden */
  17809. export var imageProcessingPixelShader: {
  17810. name: string;
  17811. shader: string;
  17812. };
  17813. }
  17814. declare module BABYLON {
  17815. /**
  17816. * ImageProcessingPostProcess
  17817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17818. */
  17819. export class ImageProcessingPostProcess extends PostProcess {
  17820. /**
  17821. * Default configuration related to image processing available in the PBR Material.
  17822. */
  17823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17824. /**
  17825. * Gets the image processing configuration used either in this material.
  17826. */
  17827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17828. /**
  17829. * Sets the Default image processing configuration used either in the this material.
  17830. *
  17831. * If sets to null, the scene one is in use.
  17832. */
  17833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17834. /**
  17835. * Keep track of the image processing observer to allow dispose and replace.
  17836. */
  17837. private _imageProcessingObserver;
  17838. /**
  17839. * Attaches a new image processing configuration to the PBR Material.
  17840. * @param configuration
  17841. */
  17842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17843. /**
  17844. * If the post process is supported.
  17845. */
  17846. get isSupported(): boolean;
  17847. /**
  17848. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17849. */
  17850. get colorCurves(): Nullable<ColorCurves>;
  17851. /**
  17852. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17853. */
  17854. set colorCurves(value: Nullable<ColorCurves>);
  17855. /**
  17856. * Gets wether the color curves effect is enabled.
  17857. */
  17858. get colorCurvesEnabled(): boolean;
  17859. /**
  17860. * Sets wether the color curves effect is enabled.
  17861. */
  17862. set colorCurvesEnabled(value: boolean);
  17863. /**
  17864. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17865. */
  17866. get colorGradingTexture(): Nullable<BaseTexture>;
  17867. /**
  17868. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17869. */
  17870. set colorGradingTexture(value: Nullable<BaseTexture>);
  17871. /**
  17872. * Gets wether the color grading effect is enabled.
  17873. */
  17874. get colorGradingEnabled(): boolean;
  17875. /**
  17876. * Gets wether the color grading effect is enabled.
  17877. */
  17878. set colorGradingEnabled(value: boolean);
  17879. /**
  17880. * Gets exposure used in the effect.
  17881. */
  17882. get exposure(): number;
  17883. /**
  17884. * Sets exposure used in the effect.
  17885. */
  17886. set exposure(value: number);
  17887. /**
  17888. * Gets wether tonemapping is enabled or not.
  17889. */
  17890. get toneMappingEnabled(): boolean;
  17891. /**
  17892. * Sets wether tonemapping is enabled or not
  17893. */
  17894. set toneMappingEnabled(value: boolean);
  17895. /**
  17896. * Gets the type of tone mapping effect.
  17897. */
  17898. get toneMappingType(): number;
  17899. /**
  17900. * Sets the type of tone mapping effect.
  17901. */
  17902. set toneMappingType(value: number);
  17903. /**
  17904. * Gets contrast used in the effect.
  17905. */
  17906. get contrast(): number;
  17907. /**
  17908. * Sets contrast used in the effect.
  17909. */
  17910. set contrast(value: number);
  17911. /**
  17912. * Gets Vignette stretch size.
  17913. */
  17914. get vignetteStretch(): number;
  17915. /**
  17916. * Sets Vignette stretch size.
  17917. */
  17918. set vignetteStretch(value: number);
  17919. /**
  17920. * Gets Vignette centre X Offset.
  17921. */
  17922. get vignetteCentreX(): number;
  17923. /**
  17924. * Sets Vignette centre X Offset.
  17925. */
  17926. set vignetteCentreX(value: number);
  17927. /**
  17928. * Gets Vignette centre Y Offset.
  17929. */
  17930. get vignetteCentreY(): number;
  17931. /**
  17932. * Sets Vignette centre Y Offset.
  17933. */
  17934. set vignetteCentreY(value: number);
  17935. /**
  17936. * Gets Vignette weight or intensity of the vignette effect.
  17937. */
  17938. get vignetteWeight(): number;
  17939. /**
  17940. * Sets Vignette weight or intensity of the vignette effect.
  17941. */
  17942. set vignetteWeight(value: number);
  17943. /**
  17944. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17945. * if vignetteEnabled is set to true.
  17946. */
  17947. get vignetteColor(): Color4;
  17948. /**
  17949. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17950. * if vignetteEnabled is set to true.
  17951. */
  17952. set vignetteColor(value: Color4);
  17953. /**
  17954. * Gets Camera field of view used by the Vignette effect.
  17955. */
  17956. get vignetteCameraFov(): number;
  17957. /**
  17958. * Sets Camera field of view used by the Vignette effect.
  17959. */
  17960. set vignetteCameraFov(value: number);
  17961. /**
  17962. * Gets the vignette blend mode allowing different kind of effect.
  17963. */
  17964. get vignetteBlendMode(): number;
  17965. /**
  17966. * Sets the vignette blend mode allowing different kind of effect.
  17967. */
  17968. set vignetteBlendMode(value: number);
  17969. /**
  17970. * Gets wether the vignette effect is enabled.
  17971. */
  17972. get vignetteEnabled(): boolean;
  17973. /**
  17974. * Sets wether the vignette effect is enabled.
  17975. */
  17976. set vignetteEnabled(value: boolean);
  17977. private _fromLinearSpace;
  17978. /**
  17979. * Gets wether the input of the processing is in Gamma or Linear Space.
  17980. */
  17981. get fromLinearSpace(): boolean;
  17982. /**
  17983. * Sets wether the input of the processing is in Gamma or Linear Space.
  17984. */
  17985. set fromLinearSpace(value: boolean);
  17986. /**
  17987. * Defines cache preventing GC.
  17988. */
  17989. private _defines;
  17990. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17991. /**
  17992. * "ImageProcessingPostProcess"
  17993. * @returns "ImageProcessingPostProcess"
  17994. */
  17995. getClassName(): string;
  17996. /**
  17997. * @hidden
  17998. */
  17999. _updateParameters(): void;
  18000. dispose(camera?: Camera): void;
  18001. }
  18002. }
  18003. declare module BABYLON {
  18004. /**
  18005. * Interface for defining prepass effects in the prepass post-process pipeline
  18006. */
  18007. export interface PrePassEffectConfiguration {
  18008. /**
  18009. * Name of the effect
  18010. */
  18011. name: string;
  18012. /**
  18013. * Post process to attach for this effect
  18014. */
  18015. postProcess?: PostProcess;
  18016. /**
  18017. * Textures required in the MRT
  18018. */
  18019. texturesRequired: number[];
  18020. /**
  18021. * Is the effect enabled
  18022. */
  18023. enabled: boolean;
  18024. /**
  18025. * Disposes the effect configuration
  18026. */
  18027. dispose?: () => void;
  18028. /**
  18029. * Creates the associated post process
  18030. */
  18031. createPostProcess?: () => PostProcess;
  18032. }
  18033. }
  18034. declare module BABYLON {
  18035. /**
  18036. * Options to be used when creating a FresnelParameters.
  18037. */
  18038. export type IFresnelParametersCreationOptions = {
  18039. /**
  18040. * Define the color used on edges (grazing angle)
  18041. */
  18042. leftColor?: Color3;
  18043. /**
  18044. * Define the color used on center
  18045. */
  18046. rightColor?: Color3;
  18047. /**
  18048. * Define bias applied to computed fresnel term
  18049. */
  18050. bias?: number;
  18051. /**
  18052. * Defined the power exponent applied to fresnel term
  18053. */
  18054. power?: number;
  18055. /**
  18056. * Define if the fresnel effect is enable or not.
  18057. */
  18058. isEnabled?: boolean;
  18059. };
  18060. /**
  18061. * Serialized format for FresnelParameters.
  18062. */
  18063. export type IFresnelParametersSerialized = {
  18064. /**
  18065. * Define the color used on edges (grazing angle) [as an array]
  18066. */
  18067. leftColor: number[];
  18068. /**
  18069. * Define the color used on center [as an array]
  18070. */
  18071. rightColor: number[];
  18072. /**
  18073. * Define bias applied to computed fresnel term
  18074. */
  18075. bias: number;
  18076. /**
  18077. * Defined the power exponent applied to fresnel term
  18078. */
  18079. power?: number;
  18080. /**
  18081. * Define if the fresnel effect is enable or not.
  18082. */
  18083. isEnabled: boolean;
  18084. };
  18085. /**
  18086. * This represents all the required information to add a fresnel effect on a material:
  18087. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18088. */
  18089. export class FresnelParameters {
  18090. private _isEnabled;
  18091. /**
  18092. * Define if the fresnel effect is enable or not.
  18093. */
  18094. get isEnabled(): boolean;
  18095. set isEnabled(value: boolean);
  18096. /**
  18097. * Define the color used on edges (grazing angle)
  18098. */
  18099. leftColor: Color3;
  18100. /**
  18101. * Define the color used on center
  18102. */
  18103. rightColor: Color3;
  18104. /**
  18105. * Define bias applied to computed fresnel term
  18106. */
  18107. bias: number;
  18108. /**
  18109. * Defined the power exponent applied to fresnel term
  18110. */
  18111. power: number;
  18112. /**
  18113. * Creates a new FresnelParameters object.
  18114. *
  18115. * @param options provide your own settings to optionally to override defaults
  18116. */
  18117. constructor(options?: IFresnelParametersCreationOptions);
  18118. /**
  18119. * Clones the current fresnel and its valuues
  18120. * @returns a clone fresnel configuration
  18121. */
  18122. clone(): FresnelParameters;
  18123. /**
  18124. * Determines equality between FresnelParameters objects
  18125. * @param otherFresnelParameters defines the second operand
  18126. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18127. */
  18128. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18129. /**
  18130. * Serializes the current fresnel parameters to a JSON representation.
  18131. * @return the JSON serialization
  18132. */
  18133. serialize(): IFresnelParametersSerialized;
  18134. /**
  18135. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18136. * @param parsedFresnelParameters Define the JSON representation
  18137. * @returns the parsed parameters
  18138. */
  18139. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * This groups all the flags used to control the materials channel.
  18145. */
  18146. export class MaterialFlags {
  18147. private static _DiffuseTextureEnabled;
  18148. /**
  18149. * Are diffuse textures enabled in the application.
  18150. */
  18151. static get DiffuseTextureEnabled(): boolean;
  18152. static set DiffuseTextureEnabled(value: boolean);
  18153. private static _DetailTextureEnabled;
  18154. /**
  18155. * Are detail textures enabled in the application.
  18156. */
  18157. static get DetailTextureEnabled(): boolean;
  18158. static set DetailTextureEnabled(value: boolean);
  18159. private static _AmbientTextureEnabled;
  18160. /**
  18161. * Are ambient textures enabled in the application.
  18162. */
  18163. static get AmbientTextureEnabled(): boolean;
  18164. static set AmbientTextureEnabled(value: boolean);
  18165. private static _OpacityTextureEnabled;
  18166. /**
  18167. * Are opacity textures enabled in the application.
  18168. */
  18169. static get OpacityTextureEnabled(): boolean;
  18170. static set OpacityTextureEnabled(value: boolean);
  18171. private static _ReflectionTextureEnabled;
  18172. /**
  18173. * Are reflection textures enabled in the application.
  18174. */
  18175. static get ReflectionTextureEnabled(): boolean;
  18176. static set ReflectionTextureEnabled(value: boolean);
  18177. private static _EmissiveTextureEnabled;
  18178. /**
  18179. * Are emissive textures enabled in the application.
  18180. */
  18181. static get EmissiveTextureEnabled(): boolean;
  18182. static set EmissiveTextureEnabled(value: boolean);
  18183. private static _SpecularTextureEnabled;
  18184. /**
  18185. * Are specular textures enabled in the application.
  18186. */
  18187. static get SpecularTextureEnabled(): boolean;
  18188. static set SpecularTextureEnabled(value: boolean);
  18189. private static _BumpTextureEnabled;
  18190. /**
  18191. * Are bump textures enabled in the application.
  18192. */
  18193. static get BumpTextureEnabled(): boolean;
  18194. static set BumpTextureEnabled(value: boolean);
  18195. private static _LightmapTextureEnabled;
  18196. /**
  18197. * Are lightmap textures enabled in the application.
  18198. */
  18199. static get LightmapTextureEnabled(): boolean;
  18200. static set LightmapTextureEnabled(value: boolean);
  18201. private static _RefractionTextureEnabled;
  18202. /**
  18203. * Are refraction textures enabled in the application.
  18204. */
  18205. static get RefractionTextureEnabled(): boolean;
  18206. static set RefractionTextureEnabled(value: boolean);
  18207. private static _ColorGradingTextureEnabled;
  18208. /**
  18209. * Are color grading textures enabled in the application.
  18210. */
  18211. static get ColorGradingTextureEnabled(): boolean;
  18212. static set ColorGradingTextureEnabled(value: boolean);
  18213. private static _FresnelEnabled;
  18214. /**
  18215. * Are fresnels enabled in the application.
  18216. */
  18217. static get FresnelEnabled(): boolean;
  18218. static set FresnelEnabled(value: boolean);
  18219. private static _ClearCoatTextureEnabled;
  18220. /**
  18221. * Are clear coat textures enabled in the application.
  18222. */
  18223. static get ClearCoatTextureEnabled(): boolean;
  18224. static set ClearCoatTextureEnabled(value: boolean);
  18225. private static _ClearCoatBumpTextureEnabled;
  18226. /**
  18227. * Are clear coat bump textures enabled in the application.
  18228. */
  18229. static get ClearCoatBumpTextureEnabled(): boolean;
  18230. static set ClearCoatBumpTextureEnabled(value: boolean);
  18231. private static _ClearCoatTintTextureEnabled;
  18232. /**
  18233. * Are clear coat tint textures enabled in the application.
  18234. */
  18235. static get ClearCoatTintTextureEnabled(): boolean;
  18236. static set ClearCoatTintTextureEnabled(value: boolean);
  18237. private static _SheenTextureEnabled;
  18238. /**
  18239. * Are sheen textures enabled in the application.
  18240. */
  18241. static get SheenTextureEnabled(): boolean;
  18242. static set SheenTextureEnabled(value: boolean);
  18243. private static _AnisotropicTextureEnabled;
  18244. /**
  18245. * Are anisotropic textures enabled in the application.
  18246. */
  18247. static get AnisotropicTextureEnabled(): boolean;
  18248. static set AnisotropicTextureEnabled(value: boolean);
  18249. private static _ThicknessTextureEnabled;
  18250. /**
  18251. * Are thickness textures enabled in the application.
  18252. */
  18253. static get ThicknessTextureEnabled(): boolean;
  18254. static set ThicknessTextureEnabled(value: boolean);
  18255. }
  18256. }
  18257. declare module BABYLON {
  18258. /** @hidden */
  18259. export var defaultFragmentDeclaration: {
  18260. name: string;
  18261. shader: string;
  18262. };
  18263. }
  18264. declare module BABYLON {
  18265. /** @hidden */
  18266. export var defaultUboDeclaration: {
  18267. name: string;
  18268. shader: string;
  18269. };
  18270. }
  18271. declare module BABYLON {
  18272. /** @hidden */
  18273. export var prePassDeclaration: {
  18274. name: string;
  18275. shader: string;
  18276. };
  18277. }
  18278. declare module BABYLON {
  18279. /** @hidden */
  18280. export var lightFragmentDeclaration: {
  18281. name: string;
  18282. shader: string;
  18283. };
  18284. }
  18285. declare module BABYLON {
  18286. /** @hidden */
  18287. export var lightUboDeclaration: {
  18288. name: string;
  18289. shader: string;
  18290. };
  18291. }
  18292. declare module BABYLON {
  18293. /** @hidden */
  18294. export var lightsFragmentFunctions: {
  18295. name: string;
  18296. shader: string;
  18297. };
  18298. }
  18299. declare module BABYLON {
  18300. /** @hidden */
  18301. export var shadowsFragmentFunctions: {
  18302. name: string;
  18303. shader: string;
  18304. };
  18305. }
  18306. declare module BABYLON {
  18307. /** @hidden */
  18308. export var fresnelFunction: {
  18309. name: string;
  18310. shader: string;
  18311. };
  18312. }
  18313. declare module BABYLON {
  18314. /** @hidden */
  18315. export var bumpFragmentMainFunctions: {
  18316. name: string;
  18317. shader: string;
  18318. };
  18319. }
  18320. declare module BABYLON {
  18321. /** @hidden */
  18322. export var bumpFragmentFunctions: {
  18323. name: string;
  18324. shader: string;
  18325. };
  18326. }
  18327. declare module BABYLON {
  18328. /** @hidden */
  18329. export var logDepthDeclaration: {
  18330. name: string;
  18331. shader: string;
  18332. };
  18333. }
  18334. declare module BABYLON {
  18335. /** @hidden */
  18336. export var fogFragmentDeclaration: {
  18337. name: string;
  18338. shader: string;
  18339. };
  18340. }
  18341. declare module BABYLON {
  18342. /** @hidden */
  18343. export var bumpFragment: {
  18344. name: string;
  18345. shader: string;
  18346. };
  18347. }
  18348. declare module BABYLON {
  18349. /** @hidden */
  18350. export var depthPrePass: {
  18351. name: string;
  18352. shader: string;
  18353. };
  18354. }
  18355. declare module BABYLON {
  18356. /** @hidden */
  18357. export var lightFragment: {
  18358. name: string;
  18359. shader: string;
  18360. };
  18361. }
  18362. declare module BABYLON {
  18363. /** @hidden */
  18364. export var logDepthFragment: {
  18365. name: string;
  18366. shader: string;
  18367. };
  18368. }
  18369. declare module BABYLON {
  18370. /** @hidden */
  18371. export var fogFragment: {
  18372. name: string;
  18373. shader: string;
  18374. };
  18375. }
  18376. declare module BABYLON {
  18377. /** @hidden */
  18378. export var defaultPixelShader: {
  18379. name: string;
  18380. shader: string;
  18381. };
  18382. }
  18383. declare module BABYLON {
  18384. /** @hidden */
  18385. export var defaultVertexDeclaration: {
  18386. name: string;
  18387. shader: string;
  18388. };
  18389. }
  18390. declare module BABYLON {
  18391. /** @hidden */
  18392. export var bonesDeclaration: {
  18393. name: string;
  18394. shader: string;
  18395. };
  18396. }
  18397. declare module BABYLON {
  18398. /** @hidden */
  18399. export var instancesDeclaration: {
  18400. name: string;
  18401. shader: string;
  18402. };
  18403. }
  18404. declare module BABYLON {
  18405. /** @hidden */
  18406. export var prePassVertexDeclaration: {
  18407. name: string;
  18408. shader: string;
  18409. };
  18410. }
  18411. declare module BABYLON {
  18412. /** @hidden */
  18413. export var bumpVertexDeclaration: {
  18414. name: string;
  18415. shader: string;
  18416. };
  18417. }
  18418. declare module BABYLON {
  18419. /** @hidden */
  18420. export var fogVertexDeclaration: {
  18421. name: string;
  18422. shader: string;
  18423. };
  18424. }
  18425. declare module BABYLON {
  18426. /** @hidden */
  18427. export var morphTargetsVertexGlobalDeclaration: {
  18428. name: string;
  18429. shader: string;
  18430. };
  18431. }
  18432. declare module BABYLON {
  18433. /** @hidden */
  18434. export var morphTargetsVertexDeclaration: {
  18435. name: string;
  18436. shader: string;
  18437. };
  18438. }
  18439. declare module BABYLON {
  18440. /** @hidden */
  18441. export var morphTargetsVertex: {
  18442. name: string;
  18443. shader: string;
  18444. };
  18445. }
  18446. declare module BABYLON {
  18447. /** @hidden */
  18448. export var instancesVertex: {
  18449. name: string;
  18450. shader: string;
  18451. };
  18452. }
  18453. declare module BABYLON {
  18454. /** @hidden */
  18455. export var bonesVertex: {
  18456. name: string;
  18457. shader: string;
  18458. };
  18459. }
  18460. declare module BABYLON {
  18461. /** @hidden */
  18462. export var prePassVertex: {
  18463. name: string;
  18464. shader: string;
  18465. };
  18466. }
  18467. declare module BABYLON {
  18468. /** @hidden */
  18469. export var bumpVertex: {
  18470. name: string;
  18471. shader: string;
  18472. };
  18473. }
  18474. declare module BABYLON {
  18475. /** @hidden */
  18476. export var fogVertex: {
  18477. name: string;
  18478. shader: string;
  18479. };
  18480. }
  18481. declare module BABYLON {
  18482. /** @hidden */
  18483. export var shadowsVertex: {
  18484. name: string;
  18485. shader: string;
  18486. };
  18487. }
  18488. declare module BABYLON {
  18489. /** @hidden */
  18490. export var pointCloudVertex: {
  18491. name: string;
  18492. shader: string;
  18493. };
  18494. }
  18495. declare module BABYLON {
  18496. /** @hidden */
  18497. export var logDepthVertex: {
  18498. name: string;
  18499. shader: string;
  18500. };
  18501. }
  18502. declare module BABYLON {
  18503. /** @hidden */
  18504. export var defaultVertexShader: {
  18505. name: string;
  18506. shader: string;
  18507. };
  18508. }
  18509. declare module BABYLON {
  18510. /**
  18511. * @hidden
  18512. */
  18513. export interface IMaterialDetailMapDefines {
  18514. DETAIL: boolean;
  18515. DETAILDIRECTUV: number;
  18516. DETAIL_NORMALBLENDMETHOD: number;
  18517. /** @hidden */
  18518. _areTexturesDirty: boolean;
  18519. }
  18520. /**
  18521. * Define the code related to the detail map parameters of a material
  18522. *
  18523. * Inspired from:
  18524. * 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
  18525. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18526. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18527. */
  18528. export class DetailMapConfiguration {
  18529. private _texture;
  18530. /**
  18531. * The detail texture of the material.
  18532. */
  18533. texture: Nullable<BaseTexture>;
  18534. /**
  18535. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18536. * Bigger values mean stronger blending
  18537. */
  18538. diffuseBlendLevel: number;
  18539. /**
  18540. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18541. * Bigger values mean stronger blending. Only used with PBR materials
  18542. */
  18543. roughnessBlendLevel: number;
  18544. /**
  18545. * Defines how strong the bump effect from the detail map is
  18546. * Bigger values mean stronger effect
  18547. */
  18548. bumpLevel: number;
  18549. private _normalBlendMethod;
  18550. /**
  18551. * The method used to blend the bump and detail normals together
  18552. */
  18553. normalBlendMethod: number;
  18554. private _isEnabled;
  18555. /**
  18556. * Enable or disable the detail map on this material
  18557. */
  18558. isEnabled: boolean;
  18559. /** @hidden */
  18560. private _internalMarkAllSubMeshesAsTexturesDirty;
  18561. /** @hidden */
  18562. _markAllSubMeshesAsTexturesDirty(): void;
  18563. /**
  18564. * Instantiate a new detail map
  18565. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18566. */
  18567. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18568. /**
  18569. * Gets whether the submesh is ready to be used or not.
  18570. * @param defines the list of "defines" to update.
  18571. * @param scene defines the scene the material belongs to.
  18572. * @returns - boolean indicating that the submesh is ready or not.
  18573. */
  18574. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18575. /**
  18576. * Update the defines for detail map usage
  18577. * @param defines the list of "defines" to update.
  18578. * @param scene defines the scene the material belongs to.
  18579. */
  18580. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18581. /**
  18582. * Binds the material data.
  18583. * @param uniformBuffer defines the Uniform buffer to fill in.
  18584. * @param scene defines the scene the material belongs to.
  18585. * @param isFrozen defines whether the material is frozen or not.
  18586. */
  18587. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18588. /**
  18589. * Checks to see if a texture is used in the material.
  18590. * @param texture - Base texture to use.
  18591. * @returns - Boolean specifying if a texture is used in the material.
  18592. */
  18593. hasTexture(texture: BaseTexture): boolean;
  18594. /**
  18595. * Returns an array of the actively used textures.
  18596. * @param activeTextures Array of BaseTextures
  18597. */
  18598. getActiveTextures(activeTextures: BaseTexture[]): void;
  18599. /**
  18600. * Returns the animatable textures.
  18601. * @param animatables Array of animatable textures.
  18602. */
  18603. getAnimatables(animatables: IAnimatable[]): void;
  18604. /**
  18605. * Disposes the resources of the material.
  18606. * @param forceDisposeTextures - Forces the disposal of all textures.
  18607. */
  18608. dispose(forceDisposeTextures?: boolean): void;
  18609. /**
  18610. * Get the current class name useful for serialization or dynamic coding.
  18611. * @returns "DetailMap"
  18612. */
  18613. getClassName(): string;
  18614. /**
  18615. * Add the required uniforms to the current list.
  18616. * @param uniforms defines the current uniform list.
  18617. */
  18618. static AddUniforms(uniforms: string[]): void;
  18619. /**
  18620. * Add the required samplers to the current list.
  18621. * @param samplers defines the current sampler list.
  18622. */
  18623. static AddSamplers(samplers: string[]): void;
  18624. /**
  18625. * Add the required uniforms to the current buffer.
  18626. * @param uniformBuffer defines the current uniform buffer.
  18627. */
  18628. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18629. /**
  18630. * Makes a duplicate of the current instance into another one.
  18631. * @param detailMap define the instance where to copy the info
  18632. */
  18633. copyTo(detailMap: DetailMapConfiguration): void;
  18634. /**
  18635. * Serializes this detail map instance
  18636. * @returns - An object with the serialized instance.
  18637. */
  18638. serialize(): any;
  18639. /**
  18640. * Parses a detail map setting from a serialized object.
  18641. * @param source - Serialized object.
  18642. * @param scene Defines the scene we are parsing for
  18643. * @param rootUrl Defines the rootUrl to load from
  18644. */
  18645. parse(source: any, scene: Scene, rootUrl: string): void;
  18646. }
  18647. }
  18648. declare module BABYLON {
  18649. /** @hidden */
  18650. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18651. MAINUV1: boolean;
  18652. MAINUV2: boolean;
  18653. DIFFUSE: boolean;
  18654. DIFFUSEDIRECTUV: number;
  18655. DETAIL: boolean;
  18656. DETAILDIRECTUV: number;
  18657. DETAIL_NORMALBLENDMETHOD: number;
  18658. AMBIENT: boolean;
  18659. AMBIENTDIRECTUV: number;
  18660. OPACITY: boolean;
  18661. OPACITYDIRECTUV: number;
  18662. OPACITYRGB: boolean;
  18663. REFLECTION: boolean;
  18664. EMISSIVE: boolean;
  18665. EMISSIVEDIRECTUV: number;
  18666. SPECULAR: boolean;
  18667. SPECULARDIRECTUV: number;
  18668. BUMP: boolean;
  18669. BUMPDIRECTUV: number;
  18670. PARALLAX: boolean;
  18671. PARALLAXOCCLUSION: boolean;
  18672. SPECULAROVERALPHA: boolean;
  18673. CLIPPLANE: boolean;
  18674. CLIPPLANE2: boolean;
  18675. CLIPPLANE3: boolean;
  18676. CLIPPLANE4: boolean;
  18677. CLIPPLANE5: boolean;
  18678. CLIPPLANE6: boolean;
  18679. ALPHATEST: boolean;
  18680. DEPTHPREPASS: boolean;
  18681. ALPHAFROMDIFFUSE: boolean;
  18682. POINTSIZE: boolean;
  18683. FOG: boolean;
  18684. SPECULARTERM: boolean;
  18685. DIFFUSEFRESNEL: boolean;
  18686. OPACITYFRESNEL: boolean;
  18687. REFLECTIONFRESNEL: boolean;
  18688. REFRACTIONFRESNEL: boolean;
  18689. EMISSIVEFRESNEL: boolean;
  18690. FRESNEL: boolean;
  18691. NORMAL: boolean;
  18692. UV1: boolean;
  18693. UV2: boolean;
  18694. VERTEXCOLOR: boolean;
  18695. VERTEXALPHA: boolean;
  18696. NUM_BONE_INFLUENCERS: number;
  18697. BonesPerMesh: number;
  18698. BONETEXTURE: boolean;
  18699. BONES_VELOCITY_ENABLED: boolean;
  18700. INSTANCES: boolean;
  18701. THIN_INSTANCES: boolean;
  18702. GLOSSINESS: boolean;
  18703. ROUGHNESS: boolean;
  18704. EMISSIVEASILLUMINATION: boolean;
  18705. LINKEMISSIVEWITHDIFFUSE: boolean;
  18706. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18707. LIGHTMAP: boolean;
  18708. LIGHTMAPDIRECTUV: number;
  18709. OBJECTSPACE_NORMALMAP: boolean;
  18710. USELIGHTMAPASSHADOWMAP: boolean;
  18711. REFLECTIONMAP_3D: boolean;
  18712. REFLECTIONMAP_SPHERICAL: boolean;
  18713. REFLECTIONMAP_PLANAR: boolean;
  18714. REFLECTIONMAP_CUBIC: boolean;
  18715. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18716. REFLECTIONMAP_PROJECTION: boolean;
  18717. REFLECTIONMAP_SKYBOX: boolean;
  18718. REFLECTIONMAP_EXPLICIT: boolean;
  18719. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18720. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18721. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18722. INVERTCUBICMAP: boolean;
  18723. LOGARITHMICDEPTH: boolean;
  18724. REFRACTION: boolean;
  18725. REFRACTIONMAP_3D: boolean;
  18726. REFLECTIONOVERALPHA: boolean;
  18727. TWOSIDEDLIGHTING: boolean;
  18728. SHADOWFLOAT: boolean;
  18729. MORPHTARGETS: boolean;
  18730. MORPHTARGETS_NORMAL: boolean;
  18731. MORPHTARGETS_TANGENT: boolean;
  18732. MORPHTARGETS_UV: boolean;
  18733. NUM_MORPH_INFLUENCERS: number;
  18734. NONUNIFORMSCALING: boolean;
  18735. PREMULTIPLYALPHA: boolean;
  18736. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18737. ALPHABLEND: boolean;
  18738. PREPASS: boolean;
  18739. PREPASS_IRRADIANCE: boolean;
  18740. PREPASS_IRRADIANCE_INDEX: number;
  18741. PREPASS_ALBEDO: boolean;
  18742. PREPASS_ALBEDO_INDEX: number;
  18743. PREPASS_DEPTHNORMAL: boolean;
  18744. PREPASS_DEPTHNORMAL_INDEX: number;
  18745. PREPASS_POSITION: boolean;
  18746. PREPASS_POSITION_INDEX: number;
  18747. PREPASS_VELOCITY: boolean;
  18748. PREPASS_VELOCITY_INDEX: number;
  18749. PREPASS_REFLECTIVITY: boolean;
  18750. PREPASS_REFLECTIVITY_INDEX: number;
  18751. SCENE_MRT_COUNT: number;
  18752. RGBDLIGHTMAP: boolean;
  18753. RGBDREFLECTION: boolean;
  18754. RGBDREFRACTION: boolean;
  18755. IMAGEPROCESSING: boolean;
  18756. VIGNETTE: boolean;
  18757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18758. VIGNETTEBLENDMODEOPAQUE: boolean;
  18759. TONEMAPPING: boolean;
  18760. TONEMAPPING_ACES: boolean;
  18761. CONTRAST: boolean;
  18762. COLORCURVES: boolean;
  18763. COLORGRADING: boolean;
  18764. COLORGRADING3D: boolean;
  18765. SAMPLER3DGREENDEPTH: boolean;
  18766. SAMPLER3DBGRMAP: boolean;
  18767. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18768. MULTIVIEW: boolean;
  18769. /**
  18770. * If the reflection texture on this material is in linear color space
  18771. * @hidden
  18772. */
  18773. IS_REFLECTION_LINEAR: boolean;
  18774. /**
  18775. * If the refraction texture on this material is in linear color space
  18776. * @hidden
  18777. */
  18778. IS_REFRACTION_LINEAR: boolean;
  18779. EXPOSURE: boolean;
  18780. constructor();
  18781. setReflectionMode(modeToEnable: string): void;
  18782. }
  18783. /**
  18784. * This is the default material used in Babylon. It is the best trade off between quality
  18785. * and performances.
  18786. * @see https://doc.babylonjs.com/babylon101/materials
  18787. */
  18788. export class StandardMaterial extends PushMaterial {
  18789. private _diffuseTexture;
  18790. /**
  18791. * The basic texture of the material as viewed under a light.
  18792. */
  18793. diffuseTexture: Nullable<BaseTexture>;
  18794. private _ambientTexture;
  18795. /**
  18796. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18797. */
  18798. ambientTexture: Nullable<BaseTexture>;
  18799. private _opacityTexture;
  18800. /**
  18801. * Define the transparency of the material from a texture.
  18802. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18803. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18804. */
  18805. opacityTexture: Nullable<BaseTexture>;
  18806. private _reflectionTexture;
  18807. /**
  18808. * Define the texture used to display the reflection.
  18809. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18810. */
  18811. reflectionTexture: Nullable<BaseTexture>;
  18812. private _emissiveTexture;
  18813. /**
  18814. * Define texture of the material as if self lit.
  18815. * This will be mixed in the final result even in the absence of light.
  18816. */
  18817. emissiveTexture: Nullable<BaseTexture>;
  18818. private _specularTexture;
  18819. /**
  18820. * Define how the color and intensity of the highlight given by the light in the material.
  18821. */
  18822. specularTexture: Nullable<BaseTexture>;
  18823. private _bumpTexture;
  18824. /**
  18825. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18826. * 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.
  18827. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18828. */
  18829. bumpTexture: Nullable<BaseTexture>;
  18830. private _lightmapTexture;
  18831. /**
  18832. * Complex lighting can be computationally expensive to compute at runtime.
  18833. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18834. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18835. */
  18836. lightmapTexture: Nullable<BaseTexture>;
  18837. private _refractionTexture;
  18838. /**
  18839. * Define the texture used to display the refraction.
  18840. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18841. */
  18842. refractionTexture: Nullable<BaseTexture>;
  18843. /**
  18844. * The color of the material lit by the environmental background lighting.
  18845. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18846. */
  18847. ambientColor: Color3;
  18848. /**
  18849. * The basic color of the material as viewed under a light.
  18850. */
  18851. diffuseColor: Color3;
  18852. /**
  18853. * Define how the color and intensity of the highlight given by the light in the material.
  18854. */
  18855. specularColor: Color3;
  18856. /**
  18857. * Define the color of the material as if self lit.
  18858. * This will be mixed in the final result even in the absence of light.
  18859. */
  18860. emissiveColor: Color3;
  18861. /**
  18862. * Defines how sharp are the highlights in the material.
  18863. * The bigger the value the sharper giving a more glossy feeling to the result.
  18864. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18865. */
  18866. specularPower: number;
  18867. private _useAlphaFromDiffuseTexture;
  18868. /**
  18869. * Does the transparency come from the diffuse texture alpha channel.
  18870. */
  18871. useAlphaFromDiffuseTexture: boolean;
  18872. private _useEmissiveAsIllumination;
  18873. /**
  18874. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18875. */
  18876. useEmissiveAsIllumination: boolean;
  18877. private _linkEmissiveWithDiffuse;
  18878. /**
  18879. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18880. * the emissive level when the final color is close to one.
  18881. */
  18882. linkEmissiveWithDiffuse: boolean;
  18883. private _useSpecularOverAlpha;
  18884. /**
  18885. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18886. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18887. */
  18888. useSpecularOverAlpha: boolean;
  18889. private _useReflectionOverAlpha;
  18890. /**
  18891. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18892. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18893. */
  18894. useReflectionOverAlpha: boolean;
  18895. private _disableLighting;
  18896. /**
  18897. * Does lights from the scene impacts this material.
  18898. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18899. */
  18900. disableLighting: boolean;
  18901. private _useObjectSpaceNormalMap;
  18902. /**
  18903. * Allows using an object space normal map (instead of tangent space).
  18904. */
  18905. useObjectSpaceNormalMap: boolean;
  18906. private _useParallax;
  18907. /**
  18908. * Is parallax enabled or not.
  18909. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18910. */
  18911. useParallax: boolean;
  18912. private _useParallaxOcclusion;
  18913. /**
  18914. * Is parallax occlusion enabled or not.
  18915. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18916. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18917. */
  18918. useParallaxOcclusion: boolean;
  18919. /**
  18920. * 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.
  18921. */
  18922. parallaxScaleBias: number;
  18923. private _roughness;
  18924. /**
  18925. * Helps to define how blurry the reflections should appears in the material.
  18926. */
  18927. roughness: number;
  18928. /**
  18929. * In case of refraction, define the value of the index of refraction.
  18930. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18931. */
  18932. indexOfRefraction: number;
  18933. /**
  18934. * Invert the refraction texture alongside the y axis.
  18935. * It can be useful with procedural textures or probe for instance.
  18936. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18937. */
  18938. invertRefractionY: boolean;
  18939. /**
  18940. * Defines the alpha limits in alpha test mode.
  18941. */
  18942. alphaCutOff: number;
  18943. private _useLightmapAsShadowmap;
  18944. /**
  18945. * In case of light mapping, define whether the map contains light or shadow informations.
  18946. */
  18947. useLightmapAsShadowmap: boolean;
  18948. private _diffuseFresnelParameters;
  18949. /**
  18950. * Define the diffuse fresnel parameters of the material.
  18951. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18952. */
  18953. diffuseFresnelParameters: FresnelParameters;
  18954. private _opacityFresnelParameters;
  18955. /**
  18956. * Define the opacity fresnel parameters of the material.
  18957. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18958. */
  18959. opacityFresnelParameters: FresnelParameters;
  18960. private _reflectionFresnelParameters;
  18961. /**
  18962. * Define the reflection fresnel parameters of the material.
  18963. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18964. */
  18965. reflectionFresnelParameters: FresnelParameters;
  18966. private _refractionFresnelParameters;
  18967. /**
  18968. * Define the refraction fresnel parameters of the material.
  18969. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18970. */
  18971. refractionFresnelParameters: FresnelParameters;
  18972. private _emissiveFresnelParameters;
  18973. /**
  18974. * Define the emissive fresnel parameters of the material.
  18975. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18976. */
  18977. emissiveFresnelParameters: FresnelParameters;
  18978. private _useReflectionFresnelFromSpecular;
  18979. /**
  18980. * If true automatically deducts the fresnels values from the material specularity.
  18981. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18982. */
  18983. useReflectionFresnelFromSpecular: boolean;
  18984. private _useGlossinessFromSpecularMapAlpha;
  18985. /**
  18986. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18987. */
  18988. useGlossinessFromSpecularMapAlpha: boolean;
  18989. private _maxSimultaneousLights;
  18990. /**
  18991. * Defines the maximum number of lights that can be used in the material
  18992. */
  18993. maxSimultaneousLights: number;
  18994. private _invertNormalMapX;
  18995. /**
  18996. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18997. */
  18998. invertNormalMapX: boolean;
  18999. private _invertNormalMapY;
  19000. /**
  19001. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19002. */
  19003. invertNormalMapY: boolean;
  19004. private _twoSidedLighting;
  19005. /**
  19006. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19007. */
  19008. twoSidedLighting: boolean;
  19009. /**
  19010. * Default configuration related to image processing available in the standard Material.
  19011. */
  19012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19013. /**
  19014. * Gets the image processing configuration used either in this material.
  19015. */
  19016. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19017. /**
  19018. * Sets the Default image processing configuration used either in the this material.
  19019. *
  19020. * If sets to null, the scene one is in use.
  19021. */
  19022. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19023. /**
  19024. * Keep track of the image processing observer to allow dispose and replace.
  19025. */
  19026. private _imageProcessingObserver;
  19027. /**
  19028. * Attaches a new image processing configuration to the Standard Material.
  19029. * @param configuration
  19030. */
  19031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19032. /**
  19033. * Defines additionnal PrePass parameters for the material.
  19034. */
  19035. readonly prePassConfiguration: PrePassConfiguration;
  19036. /**
  19037. * Gets wether the color curves effect is enabled.
  19038. */
  19039. get cameraColorCurvesEnabled(): boolean;
  19040. /**
  19041. * Sets wether the color curves effect is enabled.
  19042. */
  19043. set cameraColorCurvesEnabled(value: boolean);
  19044. /**
  19045. * Gets wether the color grading effect is enabled.
  19046. */
  19047. get cameraColorGradingEnabled(): boolean;
  19048. /**
  19049. * Gets wether the color grading effect is enabled.
  19050. */
  19051. set cameraColorGradingEnabled(value: boolean);
  19052. /**
  19053. * Gets wether tonemapping is enabled or not.
  19054. */
  19055. get cameraToneMappingEnabled(): boolean;
  19056. /**
  19057. * Sets wether tonemapping is enabled or not
  19058. */
  19059. set cameraToneMappingEnabled(value: boolean);
  19060. /**
  19061. * The camera exposure used on this material.
  19062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19063. * This corresponds to a photographic exposure.
  19064. */
  19065. get cameraExposure(): number;
  19066. /**
  19067. * The camera exposure used on this material.
  19068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19069. * This corresponds to a photographic exposure.
  19070. */
  19071. set cameraExposure(value: number);
  19072. /**
  19073. * Gets The camera contrast used on this material.
  19074. */
  19075. get cameraContrast(): number;
  19076. /**
  19077. * Sets The camera contrast used on this material.
  19078. */
  19079. set cameraContrast(value: number);
  19080. /**
  19081. * Gets the Color Grading 2D Lookup Texture.
  19082. */
  19083. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19084. /**
  19085. * Sets the Color Grading 2D Lookup Texture.
  19086. */
  19087. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19088. /**
  19089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19091. * 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;
  19092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19093. */
  19094. get cameraColorCurves(): Nullable<ColorCurves>;
  19095. /**
  19096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19098. * 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;
  19099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19100. */
  19101. set cameraColorCurves(value: Nullable<ColorCurves>);
  19102. /**
  19103. * Can this material render to several textures at once
  19104. */
  19105. get canRenderToMRT(): boolean;
  19106. /**
  19107. * Defines the detail map parameters for the material.
  19108. */
  19109. readonly detailMap: DetailMapConfiguration;
  19110. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19111. protected _worldViewProjectionMatrix: Matrix;
  19112. protected _globalAmbientColor: Color3;
  19113. protected _useLogarithmicDepth: boolean;
  19114. protected _rebuildInParallel: boolean;
  19115. /**
  19116. * Instantiates a new standard material.
  19117. * This is the default material used in Babylon. It is the best trade off between quality
  19118. * and performances.
  19119. * @see https://doc.babylonjs.com/babylon101/materials
  19120. * @param name Define the name of the material in the scene
  19121. * @param scene Define the scene the material belong to
  19122. */
  19123. constructor(name: string, scene: Scene);
  19124. /**
  19125. * Gets a boolean indicating that current material needs to register RTT
  19126. */
  19127. get hasRenderTargetTextures(): boolean;
  19128. /**
  19129. * Gets the current class name of the material e.g. "StandardMaterial"
  19130. * Mainly use in serialization.
  19131. * @returns the class name
  19132. */
  19133. getClassName(): string;
  19134. /**
  19135. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19136. * You can try switching to logarithmic depth.
  19137. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19138. */
  19139. get useLogarithmicDepth(): boolean;
  19140. set useLogarithmicDepth(value: boolean);
  19141. /**
  19142. * Specifies if the material will require alpha blending
  19143. * @returns a boolean specifying if alpha blending is needed
  19144. */
  19145. needAlphaBlending(): boolean;
  19146. /**
  19147. * Specifies if this material should be rendered in alpha test mode
  19148. * @returns a boolean specifying if an alpha test is needed.
  19149. */
  19150. needAlphaTesting(): boolean;
  19151. /**
  19152. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19153. */
  19154. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19155. /**
  19156. * Specifies whether or not there is a usable alpha channel for transparency.
  19157. */
  19158. protected _hasAlphaChannel(): boolean;
  19159. /**
  19160. * Get the texture used for alpha test purpose.
  19161. * @returns the diffuse texture in case of the standard material.
  19162. */
  19163. getAlphaTestTexture(): Nullable<BaseTexture>;
  19164. /**
  19165. * Get if the submesh is ready to be used and all its information available.
  19166. * Child classes can use it to update shaders
  19167. * @param mesh defines the mesh to check
  19168. * @param subMesh defines which submesh to check
  19169. * @param useInstances specifies that instances should be used
  19170. * @returns a boolean indicating that the submesh is ready or not
  19171. */
  19172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19173. /**
  19174. * Builds the material UBO layouts.
  19175. * Used internally during the effect preparation.
  19176. */
  19177. buildUniformLayout(): void;
  19178. /**
  19179. * Unbinds the material from the mesh
  19180. */
  19181. unbind(): void;
  19182. /**
  19183. * Binds the submesh to this material by preparing the effect and shader to draw
  19184. * @param world defines the world transformation matrix
  19185. * @param mesh defines the mesh containing the submesh
  19186. * @param subMesh defines the submesh to bind the material to
  19187. */
  19188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19189. /**
  19190. * Get the list of animatables in the material.
  19191. * @returns the list of animatables object used in the material
  19192. */
  19193. getAnimatables(): IAnimatable[];
  19194. /**
  19195. * Gets the active textures from the material
  19196. * @returns an array of textures
  19197. */
  19198. getActiveTextures(): BaseTexture[];
  19199. /**
  19200. * Specifies if the material uses a texture
  19201. * @param texture defines the texture to check against the material
  19202. * @returns a boolean specifying if the material uses the texture
  19203. */
  19204. hasTexture(texture: BaseTexture): boolean;
  19205. /**
  19206. * Disposes the material
  19207. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19208. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19209. */
  19210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19211. /**
  19212. * Makes a duplicate of the material, and gives it a new name
  19213. * @param name defines the new name for the duplicated material
  19214. * @returns the cloned material
  19215. */
  19216. clone(name: string): StandardMaterial;
  19217. /**
  19218. * Serializes this material in a JSON representation
  19219. * @returns the serialized material object
  19220. */
  19221. serialize(): any;
  19222. /**
  19223. * Creates a standard material from parsed material data
  19224. * @param source defines the JSON representation of the material
  19225. * @param scene defines the hosting scene
  19226. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19227. * @returns a new standard material
  19228. */
  19229. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19230. /**
  19231. * Are diffuse textures enabled in the application.
  19232. */
  19233. static get DiffuseTextureEnabled(): boolean;
  19234. static set DiffuseTextureEnabled(value: boolean);
  19235. /**
  19236. * Are detail textures enabled in the application.
  19237. */
  19238. static get DetailTextureEnabled(): boolean;
  19239. static set DetailTextureEnabled(value: boolean);
  19240. /**
  19241. * Are ambient textures enabled in the application.
  19242. */
  19243. static get AmbientTextureEnabled(): boolean;
  19244. static set AmbientTextureEnabled(value: boolean);
  19245. /**
  19246. * Are opacity textures enabled in the application.
  19247. */
  19248. static get OpacityTextureEnabled(): boolean;
  19249. static set OpacityTextureEnabled(value: boolean);
  19250. /**
  19251. * Are reflection textures enabled in the application.
  19252. */
  19253. static get ReflectionTextureEnabled(): boolean;
  19254. static set ReflectionTextureEnabled(value: boolean);
  19255. /**
  19256. * Are emissive textures enabled in the application.
  19257. */
  19258. static get EmissiveTextureEnabled(): boolean;
  19259. static set EmissiveTextureEnabled(value: boolean);
  19260. /**
  19261. * Are specular textures enabled in the application.
  19262. */
  19263. static get SpecularTextureEnabled(): boolean;
  19264. static set SpecularTextureEnabled(value: boolean);
  19265. /**
  19266. * Are bump textures enabled in the application.
  19267. */
  19268. static get BumpTextureEnabled(): boolean;
  19269. static set BumpTextureEnabled(value: boolean);
  19270. /**
  19271. * Are lightmap textures enabled in the application.
  19272. */
  19273. static get LightmapTextureEnabled(): boolean;
  19274. static set LightmapTextureEnabled(value: boolean);
  19275. /**
  19276. * Are refraction textures enabled in the application.
  19277. */
  19278. static get RefractionTextureEnabled(): boolean;
  19279. static set RefractionTextureEnabled(value: boolean);
  19280. /**
  19281. * Are color grading textures enabled in the application.
  19282. */
  19283. static get ColorGradingTextureEnabled(): boolean;
  19284. static set ColorGradingTextureEnabled(value: boolean);
  19285. /**
  19286. * Are fresnels enabled in the application.
  19287. */
  19288. static get FresnelEnabled(): boolean;
  19289. static set FresnelEnabled(value: boolean);
  19290. }
  19291. }
  19292. declare module BABYLON {
  19293. /** @hidden */
  19294. export var rgbdDecodePixelShader: {
  19295. name: string;
  19296. shader: string;
  19297. };
  19298. }
  19299. declare module BABYLON {
  19300. /**
  19301. * Class used to host RGBD texture specific utilities
  19302. */
  19303. export class RGBDTextureTools {
  19304. /**
  19305. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19306. * @param texture the texture to expand.
  19307. */
  19308. static ExpandRGBDTexture(texture: Texture): void;
  19309. }
  19310. }
  19311. declare module BABYLON {
  19312. /**
  19313. * Class used to host texture specific utilities
  19314. */
  19315. export class BRDFTextureTools {
  19316. /**
  19317. * Prevents texture cache collision
  19318. */
  19319. private static _instanceNumber;
  19320. /**
  19321. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19322. * @param scene defines the hosting scene
  19323. * @returns the environment BRDF texture
  19324. */
  19325. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19326. private static _environmentBRDFBase64Texture;
  19327. }
  19328. }
  19329. declare module BABYLON {
  19330. /**
  19331. * @hidden
  19332. */
  19333. export interface IMaterialClearCoatDefines {
  19334. CLEARCOAT: boolean;
  19335. CLEARCOAT_DEFAULTIOR: boolean;
  19336. CLEARCOAT_TEXTURE: boolean;
  19337. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19338. CLEARCOAT_TEXTUREDIRECTUV: number;
  19339. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19340. CLEARCOAT_BUMP: boolean;
  19341. CLEARCOAT_BUMPDIRECTUV: number;
  19342. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19343. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19344. CLEARCOAT_REMAP_F0: boolean;
  19345. CLEARCOAT_TINT: boolean;
  19346. CLEARCOAT_TINT_TEXTURE: boolean;
  19347. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19348. /** @hidden */
  19349. _areTexturesDirty: boolean;
  19350. }
  19351. /**
  19352. * Define the code related to the clear coat parameters of the pbr material.
  19353. */
  19354. export class PBRClearCoatConfiguration {
  19355. /**
  19356. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19357. * The default fits with a polyurethane material.
  19358. * @hidden
  19359. */
  19360. static readonly _DefaultIndexOfRefraction: number;
  19361. private _isEnabled;
  19362. /**
  19363. * Defines if the clear coat is enabled in the material.
  19364. */
  19365. isEnabled: boolean;
  19366. /**
  19367. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19368. */
  19369. intensity: number;
  19370. /**
  19371. * Defines the clear coat layer roughness.
  19372. */
  19373. roughness: number;
  19374. private _indexOfRefraction;
  19375. /**
  19376. * Defines the index of refraction of the clear coat.
  19377. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19378. * The default fits with a polyurethane material.
  19379. * Changing the default value is more performance intensive.
  19380. */
  19381. indexOfRefraction: number;
  19382. private _texture;
  19383. /**
  19384. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19385. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19386. * if textureRoughness is not empty, else no texture roughness is used
  19387. */
  19388. texture: Nullable<BaseTexture>;
  19389. private _useRoughnessFromMainTexture;
  19390. /**
  19391. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19392. * If false, the green channel from textureRoughness is used for roughness
  19393. */
  19394. useRoughnessFromMainTexture: boolean;
  19395. private _textureRoughness;
  19396. /**
  19397. * Stores the clear coat roughness in a texture (green channel)
  19398. * Not used if useRoughnessFromMainTexture is true
  19399. */
  19400. textureRoughness: Nullable<BaseTexture>;
  19401. private _remapF0OnInterfaceChange;
  19402. /**
  19403. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19404. */
  19405. remapF0OnInterfaceChange: boolean;
  19406. private _bumpTexture;
  19407. /**
  19408. * Define the clear coat specific bump texture.
  19409. */
  19410. bumpTexture: Nullable<BaseTexture>;
  19411. private _isTintEnabled;
  19412. /**
  19413. * Defines if the clear coat tint is enabled in the material.
  19414. */
  19415. isTintEnabled: boolean;
  19416. /**
  19417. * Defines the clear coat tint of the material.
  19418. * This is only use if tint is enabled
  19419. */
  19420. tintColor: Color3;
  19421. /**
  19422. * Defines the distance at which the tint color should be found in the
  19423. * clear coat media.
  19424. * This is only use if tint is enabled
  19425. */
  19426. tintColorAtDistance: number;
  19427. /**
  19428. * Defines the clear coat layer thickness.
  19429. * This is only use if tint is enabled
  19430. */
  19431. tintThickness: number;
  19432. private _tintTexture;
  19433. /**
  19434. * Stores the clear tint values in a texture.
  19435. * rgb is tint
  19436. * a is a thickness factor
  19437. */
  19438. tintTexture: Nullable<BaseTexture>;
  19439. /** @hidden */
  19440. private _internalMarkAllSubMeshesAsTexturesDirty;
  19441. /** @hidden */
  19442. _markAllSubMeshesAsTexturesDirty(): void;
  19443. /**
  19444. * Instantiate a new istance of clear coat configuration.
  19445. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19446. */
  19447. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19448. /**
  19449. * Gets wehter the submesh is ready to be used or not.
  19450. * @param defines the list of "defines" to update.
  19451. * @param scene defines the scene the material belongs to.
  19452. * @param engine defines the engine the material belongs to.
  19453. * @param disableBumpMap defines wether the material disables bump or not.
  19454. * @returns - boolean indicating that the submesh is ready or not.
  19455. */
  19456. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19457. /**
  19458. * Checks to see if a texture is used in the material.
  19459. * @param defines the list of "defines" to update.
  19460. * @param scene defines the scene to the material belongs to.
  19461. */
  19462. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19463. /**
  19464. * Binds the material data.
  19465. * @param uniformBuffer defines the Uniform buffer to fill in.
  19466. * @param scene defines the scene the material belongs to.
  19467. * @param engine defines the engine the material belongs to.
  19468. * @param disableBumpMap defines wether the material disables bump or not.
  19469. * @param isFrozen defines wether the material is frozen or not.
  19470. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19471. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19472. * @param subMesh the submesh to bind data for
  19473. */
  19474. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19475. /**
  19476. * Checks to see if a texture is used in the material.
  19477. * @param texture - Base texture to use.
  19478. * @returns - Boolean specifying if a texture is used in the material.
  19479. */
  19480. hasTexture(texture: BaseTexture): boolean;
  19481. /**
  19482. * Returns an array of the actively used textures.
  19483. * @param activeTextures Array of BaseTextures
  19484. */
  19485. getActiveTextures(activeTextures: BaseTexture[]): void;
  19486. /**
  19487. * Returns the animatable textures.
  19488. * @param animatables Array of animatable textures.
  19489. */
  19490. getAnimatables(animatables: IAnimatable[]): void;
  19491. /**
  19492. * Disposes the resources of the material.
  19493. * @param forceDisposeTextures - Forces the disposal of all textures.
  19494. */
  19495. dispose(forceDisposeTextures?: boolean): void;
  19496. /**
  19497. * Get the current class name of the texture useful for serialization or dynamic coding.
  19498. * @returns "PBRClearCoatConfiguration"
  19499. */
  19500. getClassName(): string;
  19501. /**
  19502. * Add fallbacks to the effect fallbacks list.
  19503. * @param defines defines the Base texture to use.
  19504. * @param fallbacks defines the current fallback list.
  19505. * @param currentRank defines the current fallback rank.
  19506. * @returns the new fallback rank.
  19507. */
  19508. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19509. /**
  19510. * Add the required uniforms to the current list.
  19511. * @param uniforms defines the current uniform list.
  19512. */
  19513. static AddUniforms(uniforms: string[]): void;
  19514. /**
  19515. * Add the required samplers to the current list.
  19516. * @param samplers defines the current sampler list.
  19517. */
  19518. static AddSamplers(samplers: string[]): void;
  19519. /**
  19520. * Add the required uniforms to the current buffer.
  19521. * @param uniformBuffer defines the current uniform buffer.
  19522. */
  19523. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19524. /**
  19525. * Makes a duplicate of the current configuration into another one.
  19526. * @param clearCoatConfiguration define the config where to copy the info
  19527. */
  19528. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19529. /**
  19530. * Serializes this clear coat configuration.
  19531. * @returns - An object with the serialized config.
  19532. */
  19533. serialize(): any;
  19534. /**
  19535. * Parses a anisotropy Configuration from a serialized object.
  19536. * @param source - Serialized object.
  19537. * @param scene Defines the scene we are parsing for
  19538. * @param rootUrl Defines the rootUrl to load from
  19539. */
  19540. parse(source: any, scene: Scene, rootUrl: string): void;
  19541. }
  19542. }
  19543. declare module BABYLON {
  19544. /**
  19545. * @hidden
  19546. */
  19547. export interface IMaterialAnisotropicDefines {
  19548. ANISOTROPIC: boolean;
  19549. ANISOTROPIC_TEXTURE: boolean;
  19550. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19551. MAINUV1: boolean;
  19552. _areTexturesDirty: boolean;
  19553. _needUVs: boolean;
  19554. }
  19555. /**
  19556. * Define the code related to the anisotropic parameters of the pbr material.
  19557. */
  19558. export class PBRAnisotropicConfiguration {
  19559. private _isEnabled;
  19560. /**
  19561. * Defines if the anisotropy is enabled in the material.
  19562. */
  19563. isEnabled: boolean;
  19564. /**
  19565. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19566. */
  19567. intensity: number;
  19568. /**
  19569. * Defines if the effect is along the tangents, bitangents or in between.
  19570. * By default, the effect is "strectching" the highlights along the tangents.
  19571. */
  19572. direction: Vector2;
  19573. private _texture;
  19574. /**
  19575. * Stores the anisotropy values in a texture.
  19576. * rg is direction (like normal from -1 to 1)
  19577. * b is a intensity
  19578. */
  19579. texture: Nullable<BaseTexture>;
  19580. /** @hidden */
  19581. private _internalMarkAllSubMeshesAsTexturesDirty;
  19582. /** @hidden */
  19583. _markAllSubMeshesAsTexturesDirty(): void;
  19584. /**
  19585. * Instantiate a new istance of anisotropy configuration.
  19586. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19587. */
  19588. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19589. /**
  19590. * Specifies that the submesh is ready to be used.
  19591. * @param defines the list of "defines" to update.
  19592. * @param scene defines the scene the material belongs to.
  19593. * @returns - boolean indicating that the submesh is ready or not.
  19594. */
  19595. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19596. /**
  19597. * Checks to see if a texture is used in the material.
  19598. * @param defines the list of "defines" to update.
  19599. * @param mesh the mesh we are preparing the defines for.
  19600. * @param scene defines the scene the material belongs to.
  19601. */
  19602. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19603. /**
  19604. * Binds the material data.
  19605. * @param uniformBuffer defines the Uniform buffer to fill in.
  19606. * @param scene defines the scene the material belongs to.
  19607. * @param isFrozen defines wether the material is frozen or not.
  19608. */
  19609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19610. /**
  19611. * Checks to see if a texture is used in the material.
  19612. * @param texture - Base texture to use.
  19613. * @returns - Boolean specifying if a texture is used in the material.
  19614. */
  19615. hasTexture(texture: BaseTexture): boolean;
  19616. /**
  19617. * Returns an array of the actively used textures.
  19618. * @param activeTextures Array of BaseTextures
  19619. */
  19620. getActiveTextures(activeTextures: BaseTexture[]): void;
  19621. /**
  19622. * Returns the animatable textures.
  19623. * @param animatables Array of animatable textures.
  19624. */
  19625. getAnimatables(animatables: IAnimatable[]): void;
  19626. /**
  19627. * Disposes the resources of the material.
  19628. * @param forceDisposeTextures - Forces the disposal of all textures.
  19629. */
  19630. dispose(forceDisposeTextures?: boolean): void;
  19631. /**
  19632. * Get the current class name of the texture useful for serialization or dynamic coding.
  19633. * @returns "PBRAnisotropicConfiguration"
  19634. */
  19635. getClassName(): string;
  19636. /**
  19637. * Add fallbacks to the effect fallbacks list.
  19638. * @param defines defines the Base texture to use.
  19639. * @param fallbacks defines the current fallback list.
  19640. * @param currentRank defines the current fallback rank.
  19641. * @returns the new fallback rank.
  19642. */
  19643. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19644. /**
  19645. * Add the required uniforms to the current list.
  19646. * @param uniforms defines the current uniform list.
  19647. */
  19648. static AddUniforms(uniforms: string[]): void;
  19649. /**
  19650. * Add the required uniforms to the current buffer.
  19651. * @param uniformBuffer defines the current uniform buffer.
  19652. */
  19653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19654. /**
  19655. * Add the required samplers to the current list.
  19656. * @param samplers defines the current sampler list.
  19657. */
  19658. static AddSamplers(samplers: string[]): void;
  19659. /**
  19660. * Makes a duplicate of the current configuration into another one.
  19661. * @param anisotropicConfiguration define the config where to copy the info
  19662. */
  19663. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19664. /**
  19665. * Serializes this anisotropy configuration.
  19666. * @returns - An object with the serialized config.
  19667. */
  19668. serialize(): any;
  19669. /**
  19670. * Parses a anisotropy Configuration from a serialized object.
  19671. * @param source - Serialized object.
  19672. * @param scene Defines the scene we are parsing for
  19673. * @param rootUrl Defines the rootUrl to load from
  19674. */
  19675. parse(source: any, scene: Scene, rootUrl: string): void;
  19676. }
  19677. }
  19678. declare module BABYLON {
  19679. /**
  19680. * @hidden
  19681. */
  19682. export interface IMaterialBRDFDefines {
  19683. BRDF_V_HEIGHT_CORRELATED: boolean;
  19684. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19685. SPHERICAL_HARMONICS: boolean;
  19686. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19687. /** @hidden */
  19688. _areMiscDirty: boolean;
  19689. }
  19690. /**
  19691. * Define the code related to the BRDF parameters of the pbr material.
  19692. */
  19693. export class PBRBRDFConfiguration {
  19694. /**
  19695. * Default value used for the energy conservation.
  19696. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19697. */
  19698. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19699. /**
  19700. * Default value used for the Smith Visibility Height Correlated mode.
  19701. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19702. */
  19703. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19704. /**
  19705. * Default value used for the IBL diffuse part.
  19706. * This can help switching back to the polynomials mode globally which is a tiny bit
  19707. * less GPU intensive at the drawback of a lower quality.
  19708. */
  19709. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19710. /**
  19711. * Default value used for activating energy conservation for the specular workflow.
  19712. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19713. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19714. */
  19715. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19716. private _useEnergyConservation;
  19717. /**
  19718. * Defines if the material uses energy conservation.
  19719. */
  19720. useEnergyConservation: boolean;
  19721. private _useSmithVisibilityHeightCorrelated;
  19722. /**
  19723. * LEGACY Mode set to false
  19724. * Defines if the material uses height smith correlated visibility term.
  19725. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19726. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19727. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19728. * Not relying on height correlated will also disable energy conservation.
  19729. */
  19730. useSmithVisibilityHeightCorrelated: boolean;
  19731. private _useSphericalHarmonics;
  19732. /**
  19733. * LEGACY Mode set to false
  19734. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19735. * diffuse part of the IBL.
  19736. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19737. * to the ground truth.
  19738. */
  19739. useSphericalHarmonics: boolean;
  19740. private _useSpecularGlossinessInputEnergyConservation;
  19741. /**
  19742. * Defines if the material uses energy conservation, when the specular workflow is active.
  19743. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19744. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19745. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19746. */
  19747. useSpecularGlossinessInputEnergyConservation: boolean;
  19748. /** @hidden */
  19749. private _internalMarkAllSubMeshesAsMiscDirty;
  19750. /** @hidden */
  19751. _markAllSubMeshesAsMiscDirty(): void;
  19752. /**
  19753. * Instantiate a new istance of clear coat configuration.
  19754. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19755. */
  19756. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19757. /**
  19758. * Checks to see if a texture is used in the material.
  19759. * @param defines the list of "defines" to update.
  19760. */
  19761. prepareDefines(defines: IMaterialBRDFDefines): void;
  19762. /**
  19763. * Get the current class name of the texture useful for serialization or dynamic coding.
  19764. * @returns "PBRClearCoatConfiguration"
  19765. */
  19766. getClassName(): string;
  19767. /**
  19768. * Makes a duplicate of the current configuration into another one.
  19769. * @param brdfConfiguration define the config where to copy the info
  19770. */
  19771. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19772. /**
  19773. * Serializes this BRDF configuration.
  19774. * @returns - An object with the serialized config.
  19775. */
  19776. serialize(): any;
  19777. /**
  19778. * Parses a anisotropy Configuration from a serialized object.
  19779. * @param source - Serialized object.
  19780. * @param scene Defines the scene we are parsing for
  19781. * @param rootUrl Defines the rootUrl to load from
  19782. */
  19783. parse(source: any, scene: Scene, rootUrl: string): void;
  19784. }
  19785. }
  19786. declare module BABYLON {
  19787. /**
  19788. * @hidden
  19789. */
  19790. export interface IMaterialSheenDefines {
  19791. SHEEN: boolean;
  19792. SHEEN_TEXTURE: boolean;
  19793. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19794. SHEEN_TEXTUREDIRECTUV: number;
  19795. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19796. SHEEN_LINKWITHALBEDO: boolean;
  19797. SHEEN_ROUGHNESS: boolean;
  19798. SHEEN_ALBEDOSCALING: boolean;
  19799. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19800. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19801. /** @hidden */
  19802. _areTexturesDirty: boolean;
  19803. }
  19804. /**
  19805. * Define the code related to the Sheen parameters of the pbr material.
  19806. */
  19807. export class PBRSheenConfiguration {
  19808. private _isEnabled;
  19809. /**
  19810. * Defines if the material uses sheen.
  19811. */
  19812. isEnabled: boolean;
  19813. private _linkSheenWithAlbedo;
  19814. /**
  19815. * Defines if the sheen is linked to the sheen color.
  19816. */
  19817. linkSheenWithAlbedo: boolean;
  19818. /**
  19819. * Defines the sheen intensity.
  19820. */
  19821. intensity: number;
  19822. /**
  19823. * Defines the sheen color.
  19824. */
  19825. color: Color3;
  19826. private _texture;
  19827. /**
  19828. * Stores the sheen tint values in a texture.
  19829. * rgb is tint
  19830. * 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)
  19831. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19832. */
  19833. texture: Nullable<BaseTexture>;
  19834. private _useRoughnessFromMainTexture;
  19835. /**
  19836. * Indicates that the alpha channel of the texture property will be used for roughness.
  19837. * Has no effect if the roughness (and texture!) property is not defined
  19838. */
  19839. useRoughnessFromMainTexture: boolean;
  19840. private _roughness;
  19841. /**
  19842. * Defines the sheen roughness.
  19843. * It is not taken into account if linkSheenWithAlbedo is true.
  19844. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19845. */
  19846. roughness: Nullable<number>;
  19847. private _textureRoughness;
  19848. /**
  19849. * Stores the sheen roughness in a texture.
  19850. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19851. */
  19852. textureRoughness: Nullable<BaseTexture>;
  19853. private _albedoScaling;
  19854. /**
  19855. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19856. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19857. * making it easier to setup and tweak the effect
  19858. */
  19859. albedoScaling: boolean;
  19860. /** @hidden */
  19861. private _internalMarkAllSubMeshesAsTexturesDirty;
  19862. /** @hidden */
  19863. _markAllSubMeshesAsTexturesDirty(): void;
  19864. /**
  19865. * Instantiate a new istance of clear coat configuration.
  19866. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19867. */
  19868. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19869. /**
  19870. * Specifies that the submesh is ready to be used.
  19871. * @param defines the list of "defines" to update.
  19872. * @param scene defines the scene the material belongs to.
  19873. * @returns - boolean indicating that the submesh is ready or not.
  19874. */
  19875. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19876. /**
  19877. * Checks to see if a texture is used in the material.
  19878. * @param defines the list of "defines" to update.
  19879. * @param scene defines the scene the material belongs to.
  19880. */
  19881. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19882. /**
  19883. * Binds the material data.
  19884. * @param uniformBuffer defines the Uniform buffer to fill in.
  19885. * @param scene defines the scene the material belongs to.
  19886. * @param isFrozen defines wether the material is frozen or not.
  19887. * @param subMesh the submesh to bind data for
  19888. */
  19889. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19890. /**
  19891. * Checks to see if a texture is used in the material.
  19892. * @param texture - Base texture to use.
  19893. * @returns - Boolean specifying if a texture is used in the material.
  19894. */
  19895. hasTexture(texture: BaseTexture): boolean;
  19896. /**
  19897. * Returns an array of the actively used textures.
  19898. * @param activeTextures Array of BaseTextures
  19899. */
  19900. getActiveTextures(activeTextures: BaseTexture[]): void;
  19901. /**
  19902. * Returns the animatable textures.
  19903. * @param animatables Array of animatable textures.
  19904. */
  19905. getAnimatables(animatables: IAnimatable[]): void;
  19906. /**
  19907. * Disposes the resources of the material.
  19908. * @param forceDisposeTextures - Forces the disposal of all textures.
  19909. */
  19910. dispose(forceDisposeTextures?: boolean): void;
  19911. /**
  19912. * Get the current class name of the texture useful for serialization or dynamic coding.
  19913. * @returns "PBRSheenConfiguration"
  19914. */
  19915. getClassName(): string;
  19916. /**
  19917. * Add fallbacks to the effect fallbacks list.
  19918. * @param defines defines the Base texture to use.
  19919. * @param fallbacks defines the current fallback list.
  19920. * @param currentRank defines the current fallback rank.
  19921. * @returns the new fallback rank.
  19922. */
  19923. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19924. /**
  19925. * Add the required uniforms to the current list.
  19926. * @param uniforms defines the current uniform list.
  19927. */
  19928. static AddUniforms(uniforms: string[]): void;
  19929. /**
  19930. * Add the required uniforms to the current buffer.
  19931. * @param uniformBuffer defines the current uniform buffer.
  19932. */
  19933. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19934. /**
  19935. * Add the required samplers to the current list.
  19936. * @param samplers defines the current sampler list.
  19937. */
  19938. static AddSamplers(samplers: string[]): void;
  19939. /**
  19940. * Makes a duplicate of the current configuration into another one.
  19941. * @param sheenConfiguration define the config where to copy the info
  19942. */
  19943. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19944. /**
  19945. * Serializes this BRDF configuration.
  19946. * @returns - An object with the serialized config.
  19947. */
  19948. serialize(): any;
  19949. /**
  19950. * Parses a anisotropy Configuration from a serialized object.
  19951. * @param source - Serialized object.
  19952. * @param scene Defines the scene we are parsing for
  19953. * @param rootUrl Defines the rootUrl to load from
  19954. */
  19955. parse(source: any, scene: Scene, rootUrl: string): void;
  19956. }
  19957. }
  19958. declare module BABYLON {
  19959. /**
  19960. * @hidden
  19961. */
  19962. export interface IMaterialSubSurfaceDefines {
  19963. SUBSURFACE: boolean;
  19964. SS_REFRACTION: boolean;
  19965. SS_TRANSLUCENCY: boolean;
  19966. SS_SCATTERING: boolean;
  19967. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19968. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19969. SS_REFRACTIONMAP_3D: boolean;
  19970. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19971. SS_LODINREFRACTIONALPHA: boolean;
  19972. SS_GAMMAREFRACTION: boolean;
  19973. SS_RGBDREFRACTION: boolean;
  19974. SS_LINEARSPECULARREFRACTION: boolean;
  19975. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19976. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19977. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19978. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19979. /** @hidden */
  19980. _areTexturesDirty: boolean;
  19981. }
  19982. /**
  19983. * Define the code related to the sub surface parameters of the pbr material.
  19984. */
  19985. export class PBRSubSurfaceConfiguration {
  19986. private _isRefractionEnabled;
  19987. /**
  19988. * Defines if the refraction is enabled in the material.
  19989. */
  19990. isRefractionEnabled: boolean;
  19991. private _isTranslucencyEnabled;
  19992. /**
  19993. * Defines if the translucency is enabled in the material.
  19994. */
  19995. isTranslucencyEnabled: boolean;
  19996. private _isScatteringEnabled;
  19997. /**
  19998. * Defines if the sub surface scattering is enabled in the material.
  19999. */
  20000. isScatteringEnabled: boolean;
  20001. private _scatteringDiffusionProfileIndex;
  20002. /**
  20003. * Diffusion profile for subsurface scattering.
  20004. * Useful for better scattering in the skins or foliages.
  20005. */
  20006. get scatteringDiffusionProfile(): Nullable<Color3>;
  20007. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20008. /**
  20009. * Defines the refraction intensity of the material.
  20010. * The refraction when enabled replaces the Diffuse part of the material.
  20011. * The intensity helps transitionning between diffuse and refraction.
  20012. */
  20013. refractionIntensity: number;
  20014. /**
  20015. * Defines the translucency intensity of the material.
  20016. * When translucency has been enabled, this defines how much of the "translucency"
  20017. * is addded to the diffuse part of the material.
  20018. */
  20019. translucencyIntensity: number;
  20020. /**
  20021. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20022. */
  20023. useAlbedoToTintRefraction: boolean;
  20024. private _thicknessTexture;
  20025. /**
  20026. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20027. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20028. * 0 would mean minimumThickness
  20029. * 1 would mean maximumThickness
  20030. * The other channels might be use as a mask to vary the different effects intensity.
  20031. */
  20032. thicknessTexture: Nullable<BaseTexture>;
  20033. private _refractionTexture;
  20034. /**
  20035. * Defines the texture to use for refraction.
  20036. */
  20037. refractionTexture: Nullable<BaseTexture>;
  20038. private _indexOfRefraction;
  20039. /**
  20040. * Index of refraction of the material base layer.
  20041. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20042. *
  20043. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20044. *
  20045. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20046. */
  20047. indexOfRefraction: number;
  20048. private _volumeIndexOfRefraction;
  20049. /**
  20050. * Index of refraction of the material's volume.
  20051. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20052. *
  20053. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20054. * the volume will use the same IOR as the surface.
  20055. */
  20056. get volumeIndexOfRefraction(): number;
  20057. set volumeIndexOfRefraction(value: number);
  20058. private _invertRefractionY;
  20059. /**
  20060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20061. */
  20062. invertRefractionY: boolean;
  20063. private _linkRefractionWithTransparency;
  20064. /**
  20065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20066. * Materials half opaque for instance using refraction could benefit from this control.
  20067. */
  20068. linkRefractionWithTransparency: boolean;
  20069. /**
  20070. * Defines the minimum thickness stored in the thickness map.
  20071. * If no thickness map is defined, this value will be used to simulate thickness.
  20072. */
  20073. minimumThickness: number;
  20074. /**
  20075. * Defines the maximum thickness stored in the thickness map.
  20076. */
  20077. maximumThickness: number;
  20078. /**
  20079. * Defines the volume tint of the material.
  20080. * This is used for both translucency and scattering.
  20081. */
  20082. tintColor: Color3;
  20083. /**
  20084. * Defines the distance at which the tint color should be found in the media.
  20085. * This is used for refraction only.
  20086. */
  20087. tintColorAtDistance: number;
  20088. /**
  20089. * Defines how far each channel transmit through the media.
  20090. * It is defined as a color to simplify it selection.
  20091. */
  20092. diffusionDistance: Color3;
  20093. private _useMaskFromThicknessTexture;
  20094. /**
  20095. * Stores the intensity of the different subsurface effects in the thickness texture.
  20096. * * the green channel is the translucency intensity.
  20097. * * the blue channel is the scattering intensity.
  20098. * * the alpha channel is the refraction intensity.
  20099. */
  20100. useMaskFromThicknessTexture: boolean;
  20101. private _scene;
  20102. private _useMaskFromThicknessTextureGltf;
  20103. /**
  20104. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20105. * matches the channel-packing that is used by glTF.
  20106. * * the red channel is the transmission/translucency intensity.
  20107. * * the green channel is the thickness.
  20108. */
  20109. useMaskFromThicknessTextureGltf: boolean;
  20110. /** @hidden */
  20111. private _internalMarkAllSubMeshesAsTexturesDirty;
  20112. private _internalMarkScenePrePassDirty;
  20113. /** @hidden */
  20114. _markAllSubMeshesAsTexturesDirty(): void;
  20115. /** @hidden */
  20116. _markScenePrePassDirty(): void;
  20117. /**
  20118. * Instantiate a new istance of sub surface configuration.
  20119. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20120. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20121. * @param scene The scene
  20122. */
  20123. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20124. /**
  20125. * Gets wehter the submesh is ready to be used or not.
  20126. * @param defines the list of "defines" to update.
  20127. * @param scene defines the scene the material belongs to.
  20128. * @returns - boolean indicating that the submesh is ready or not.
  20129. */
  20130. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20131. /**
  20132. * Checks to see if a texture is used in the material.
  20133. * @param defines the list of "defines" to update.
  20134. * @param scene defines the scene to the material belongs to.
  20135. */
  20136. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20137. /**
  20138. * Binds the material data.
  20139. * @param uniformBuffer defines the Uniform buffer to fill in.
  20140. * @param scene defines the scene the material belongs to.
  20141. * @param engine defines the engine the material belongs to.
  20142. * @param isFrozen defines whether the material is frozen or not.
  20143. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20144. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20145. */
  20146. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20147. /**
  20148. * Unbinds the material from the mesh.
  20149. * @param activeEffect defines the effect that should be unbound from.
  20150. * @returns true if unbound, otherwise false
  20151. */
  20152. unbind(activeEffect: Effect): boolean;
  20153. /**
  20154. * Returns the texture used for refraction or null if none is used.
  20155. * @param scene defines the scene the material belongs to.
  20156. * @returns - Refraction texture if present. If no refraction texture and refraction
  20157. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20158. */
  20159. private _getRefractionTexture;
  20160. /**
  20161. * Returns true if alpha blending should be disabled.
  20162. */
  20163. get disableAlphaBlending(): boolean;
  20164. /**
  20165. * Fills the list of render target textures.
  20166. * @param renderTargets the list of render targets to update
  20167. */
  20168. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20169. /**
  20170. * Checks to see if a texture is used in the material.
  20171. * @param texture - Base texture to use.
  20172. * @returns - Boolean specifying if a texture is used in the material.
  20173. */
  20174. hasTexture(texture: BaseTexture): boolean;
  20175. /**
  20176. * Gets a boolean indicating that current material needs to register RTT
  20177. * @returns true if this uses a render target otherwise false.
  20178. */
  20179. hasRenderTargetTextures(): boolean;
  20180. /**
  20181. * Returns an array of the actively used textures.
  20182. * @param activeTextures Array of BaseTextures
  20183. */
  20184. getActiveTextures(activeTextures: BaseTexture[]): void;
  20185. /**
  20186. * Returns the animatable textures.
  20187. * @param animatables Array of animatable textures.
  20188. */
  20189. getAnimatables(animatables: IAnimatable[]): void;
  20190. /**
  20191. * Disposes the resources of the material.
  20192. * @param forceDisposeTextures - Forces the disposal of all textures.
  20193. */
  20194. dispose(forceDisposeTextures?: boolean): void;
  20195. /**
  20196. * Get the current class name of the texture useful for serialization or dynamic coding.
  20197. * @returns "PBRSubSurfaceConfiguration"
  20198. */
  20199. getClassName(): string;
  20200. /**
  20201. * Add fallbacks to the effect fallbacks list.
  20202. * @param defines defines the Base texture to use.
  20203. * @param fallbacks defines the current fallback list.
  20204. * @param currentRank defines the current fallback rank.
  20205. * @returns the new fallback rank.
  20206. */
  20207. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20208. /**
  20209. * Add the required uniforms to the current list.
  20210. * @param uniforms defines the current uniform list.
  20211. */
  20212. static AddUniforms(uniforms: string[]): void;
  20213. /**
  20214. * Add the required samplers to the current list.
  20215. * @param samplers defines the current sampler list.
  20216. */
  20217. static AddSamplers(samplers: string[]): void;
  20218. /**
  20219. * Add the required uniforms to the current buffer.
  20220. * @param uniformBuffer defines the current uniform buffer.
  20221. */
  20222. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20223. /**
  20224. * Makes a duplicate of the current configuration into another one.
  20225. * @param configuration define the config where to copy the info
  20226. */
  20227. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20228. /**
  20229. * Serializes this Sub Surface configuration.
  20230. * @returns - An object with the serialized config.
  20231. */
  20232. serialize(): any;
  20233. /**
  20234. * Parses a anisotropy Configuration from a serialized object.
  20235. * @param source - Serialized object.
  20236. * @param scene Defines the scene we are parsing for
  20237. * @param rootUrl Defines the rootUrl to load from
  20238. */
  20239. parse(source: any, scene: Scene, rootUrl: string): void;
  20240. }
  20241. }
  20242. declare module BABYLON {
  20243. /**
  20244. * Class representing spherical harmonics coefficients to the 3rd degree
  20245. */
  20246. export class SphericalHarmonics {
  20247. /**
  20248. * Defines whether or not the harmonics have been prescaled for rendering.
  20249. */
  20250. preScaled: boolean;
  20251. /**
  20252. * The l0,0 coefficients of the spherical harmonics
  20253. */
  20254. l00: Vector3;
  20255. /**
  20256. * The l1,-1 coefficients of the spherical harmonics
  20257. */
  20258. l1_1: Vector3;
  20259. /**
  20260. * The l1,0 coefficients of the spherical harmonics
  20261. */
  20262. l10: Vector3;
  20263. /**
  20264. * The l1,1 coefficients of the spherical harmonics
  20265. */
  20266. l11: Vector3;
  20267. /**
  20268. * The l2,-2 coefficients of the spherical harmonics
  20269. */
  20270. l2_2: Vector3;
  20271. /**
  20272. * The l2,-1 coefficients of the spherical harmonics
  20273. */
  20274. l2_1: Vector3;
  20275. /**
  20276. * The l2,0 coefficients of the spherical harmonics
  20277. */
  20278. l20: Vector3;
  20279. /**
  20280. * The l2,1 coefficients of the spherical harmonics
  20281. */
  20282. l21: Vector3;
  20283. /**
  20284. * The l2,2 coefficients of the spherical harmonics
  20285. */
  20286. l22: Vector3;
  20287. /**
  20288. * Adds a light to the spherical harmonics
  20289. * @param direction the direction of the light
  20290. * @param color the color of the light
  20291. * @param deltaSolidAngle the delta solid angle of the light
  20292. */
  20293. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20294. /**
  20295. * Scales the spherical harmonics by the given amount
  20296. * @param scale the amount to scale
  20297. */
  20298. scaleInPlace(scale: number): void;
  20299. /**
  20300. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20301. *
  20302. * ```
  20303. * E_lm = A_l * L_lm
  20304. * ```
  20305. *
  20306. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20307. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20308. * the scaling factors are given in equation 9.
  20309. */
  20310. convertIncidentRadianceToIrradiance(): void;
  20311. /**
  20312. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20313. *
  20314. * ```
  20315. * L = (1/pi) * E * rho
  20316. * ```
  20317. *
  20318. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20319. */
  20320. convertIrradianceToLambertianRadiance(): void;
  20321. /**
  20322. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20323. * required operations at run time.
  20324. *
  20325. * This is simply done by scaling back the SH with Ylm constants parameter.
  20326. * The trigonometric part being applied by the shader at run time.
  20327. */
  20328. preScaleForRendering(): void;
  20329. /**
  20330. * Constructs a spherical harmonics from an array.
  20331. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20332. * @returns the spherical harmonics
  20333. */
  20334. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20335. /**
  20336. * Gets the spherical harmonics from polynomial
  20337. * @param polynomial the spherical polynomial
  20338. * @returns the spherical harmonics
  20339. */
  20340. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20341. }
  20342. /**
  20343. * Class representing spherical polynomial coefficients to the 3rd degree
  20344. */
  20345. export class SphericalPolynomial {
  20346. private _harmonics;
  20347. /**
  20348. * The spherical harmonics used to create the polynomials.
  20349. */
  20350. get preScaledHarmonics(): SphericalHarmonics;
  20351. /**
  20352. * The x coefficients of the spherical polynomial
  20353. */
  20354. x: Vector3;
  20355. /**
  20356. * The y coefficients of the spherical polynomial
  20357. */
  20358. y: Vector3;
  20359. /**
  20360. * The z coefficients of the spherical polynomial
  20361. */
  20362. z: Vector3;
  20363. /**
  20364. * The xx coefficients of the spherical polynomial
  20365. */
  20366. xx: Vector3;
  20367. /**
  20368. * The yy coefficients of the spherical polynomial
  20369. */
  20370. yy: Vector3;
  20371. /**
  20372. * The zz coefficients of the spherical polynomial
  20373. */
  20374. zz: Vector3;
  20375. /**
  20376. * The xy coefficients of the spherical polynomial
  20377. */
  20378. xy: Vector3;
  20379. /**
  20380. * The yz coefficients of the spherical polynomial
  20381. */
  20382. yz: Vector3;
  20383. /**
  20384. * The zx coefficients of the spherical polynomial
  20385. */
  20386. zx: Vector3;
  20387. /**
  20388. * Adds an ambient color to the spherical polynomial
  20389. * @param color the color to add
  20390. */
  20391. addAmbient(color: Color3): void;
  20392. /**
  20393. * Scales the spherical polynomial by the given amount
  20394. * @param scale the amount to scale
  20395. */
  20396. scaleInPlace(scale: number): void;
  20397. /**
  20398. * Gets the spherical polynomial from harmonics
  20399. * @param harmonics the spherical harmonics
  20400. * @returns the spherical polynomial
  20401. */
  20402. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20403. /**
  20404. * Constructs a spherical polynomial from an array.
  20405. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20406. * @returns the spherical polynomial
  20407. */
  20408. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20414. */
  20415. export interface CubeMapInfo {
  20416. /**
  20417. * The pixel array for the front face.
  20418. * This is stored in format, left to right, up to down format.
  20419. */
  20420. front: Nullable<ArrayBufferView>;
  20421. /**
  20422. * The pixel array for the back face.
  20423. * This is stored in format, left to right, up to down format.
  20424. */
  20425. back: Nullable<ArrayBufferView>;
  20426. /**
  20427. * The pixel array for the left face.
  20428. * This is stored in format, left to right, up to down format.
  20429. */
  20430. left: Nullable<ArrayBufferView>;
  20431. /**
  20432. * The pixel array for the right face.
  20433. * This is stored in format, left to right, up to down format.
  20434. */
  20435. right: Nullable<ArrayBufferView>;
  20436. /**
  20437. * The pixel array for the up face.
  20438. * This is stored in format, left to right, up to down format.
  20439. */
  20440. up: Nullable<ArrayBufferView>;
  20441. /**
  20442. * The pixel array for the down face.
  20443. * This is stored in format, left to right, up to down format.
  20444. */
  20445. down: Nullable<ArrayBufferView>;
  20446. /**
  20447. * The size of the cubemap stored.
  20448. *
  20449. * Each faces will be size * size pixels.
  20450. */
  20451. size: number;
  20452. /**
  20453. * The format of the texture.
  20454. *
  20455. * RGBA, RGB.
  20456. */
  20457. format: number;
  20458. /**
  20459. * The type of the texture data.
  20460. *
  20461. * UNSIGNED_INT, FLOAT.
  20462. */
  20463. type: number;
  20464. /**
  20465. * Specifies whether the texture is in gamma space.
  20466. */
  20467. gammaSpace: boolean;
  20468. }
  20469. /**
  20470. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20471. */
  20472. export class PanoramaToCubeMapTools {
  20473. private static FACE_LEFT;
  20474. private static FACE_RIGHT;
  20475. private static FACE_FRONT;
  20476. private static FACE_BACK;
  20477. private static FACE_DOWN;
  20478. private static FACE_UP;
  20479. /**
  20480. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20481. *
  20482. * @param float32Array The source data.
  20483. * @param inputWidth The width of the input panorama.
  20484. * @param inputHeight The height of the input panorama.
  20485. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20486. * @return The cubemap data
  20487. */
  20488. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20489. private static CreateCubemapTexture;
  20490. private static CalcProjectionSpherical;
  20491. }
  20492. }
  20493. declare module BABYLON {
  20494. /**
  20495. * Helper class dealing with the extraction of spherical polynomial dataArray
  20496. * from a cube map.
  20497. */
  20498. export class CubeMapToSphericalPolynomialTools {
  20499. private static FileFaces;
  20500. /**
  20501. * Converts a texture to the according Spherical Polynomial data.
  20502. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20503. *
  20504. * @param texture The texture to extract the information from.
  20505. * @return The Spherical Polynomial data.
  20506. */
  20507. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20508. /**
  20509. * Converts a cubemap to the according Spherical Polynomial data.
  20510. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20511. *
  20512. * @param cubeInfo The Cube map to extract the information from.
  20513. * @return The Spherical Polynomial data.
  20514. */
  20515. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20516. }
  20517. }
  20518. declare module BABYLON {
  20519. interface BaseTexture {
  20520. /**
  20521. * Get the polynomial representation of the texture data.
  20522. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20523. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20524. */
  20525. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20526. }
  20527. }
  20528. declare module BABYLON {
  20529. /** @hidden */
  20530. export var pbrFragmentDeclaration: {
  20531. name: string;
  20532. shader: string;
  20533. };
  20534. }
  20535. declare module BABYLON {
  20536. /** @hidden */
  20537. export var pbrUboDeclaration: {
  20538. name: string;
  20539. shader: string;
  20540. };
  20541. }
  20542. declare module BABYLON {
  20543. /** @hidden */
  20544. export var pbrFragmentExtraDeclaration: {
  20545. name: string;
  20546. shader: string;
  20547. };
  20548. }
  20549. declare module BABYLON {
  20550. /** @hidden */
  20551. export var pbrFragmentSamplersDeclaration: {
  20552. name: string;
  20553. shader: string;
  20554. };
  20555. }
  20556. declare module BABYLON {
  20557. /** @hidden */
  20558. export var subSurfaceScatteringFunctions: {
  20559. name: string;
  20560. shader: string;
  20561. };
  20562. }
  20563. declare module BABYLON {
  20564. /** @hidden */
  20565. export var importanceSampling: {
  20566. name: string;
  20567. shader: string;
  20568. };
  20569. }
  20570. declare module BABYLON {
  20571. /** @hidden */
  20572. export var pbrHelperFunctions: {
  20573. name: string;
  20574. shader: string;
  20575. };
  20576. }
  20577. declare module BABYLON {
  20578. /** @hidden */
  20579. export var harmonicsFunctions: {
  20580. name: string;
  20581. shader: string;
  20582. };
  20583. }
  20584. declare module BABYLON {
  20585. /** @hidden */
  20586. export var pbrDirectLightingSetupFunctions: {
  20587. name: string;
  20588. shader: string;
  20589. };
  20590. }
  20591. declare module BABYLON {
  20592. /** @hidden */
  20593. export var pbrDirectLightingFalloffFunctions: {
  20594. name: string;
  20595. shader: string;
  20596. };
  20597. }
  20598. declare module BABYLON {
  20599. /** @hidden */
  20600. export var pbrBRDFFunctions: {
  20601. name: string;
  20602. shader: string;
  20603. };
  20604. }
  20605. declare module BABYLON {
  20606. /** @hidden */
  20607. export var hdrFilteringFunctions: {
  20608. name: string;
  20609. shader: string;
  20610. };
  20611. }
  20612. declare module BABYLON {
  20613. /** @hidden */
  20614. export var pbrDirectLightingFunctions: {
  20615. name: string;
  20616. shader: string;
  20617. };
  20618. }
  20619. declare module BABYLON {
  20620. /** @hidden */
  20621. export var pbrIBLFunctions: {
  20622. name: string;
  20623. shader: string;
  20624. };
  20625. }
  20626. declare module BABYLON {
  20627. /** @hidden */
  20628. export var pbrBlockAlbedoOpacity: {
  20629. name: string;
  20630. shader: string;
  20631. };
  20632. }
  20633. declare module BABYLON {
  20634. /** @hidden */
  20635. export var pbrBlockReflectivity: {
  20636. name: string;
  20637. shader: string;
  20638. };
  20639. }
  20640. declare module BABYLON {
  20641. /** @hidden */
  20642. export var pbrBlockAmbientOcclusion: {
  20643. name: string;
  20644. shader: string;
  20645. };
  20646. }
  20647. declare module BABYLON {
  20648. /** @hidden */
  20649. export var pbrBlockAlphaFresnel: {
  20650. name: string;
  20651. shader: string;
  20652. };
  20653. }
  20654. declare module BABYLON {
  20655. /** @hidden */
  20656. export var pbrBlockAnisotropic: {
  20657. name: string;
  20658. shader: string;
  20659. };
  20660. }
  20661. declare module BABYLON {
  20662. /** @hidden */
  20663. export var pbrBlockReflection: {
  20664. name: string;
  20665. shader: string;
  20666. };
  20667. }
  20668. declare module BABYLON {
  20669. /** @hidden */
  20670. export var pbrBlockSheen: {
  20671. name: string;
  20672. shader: string;
  20673. };
  20674. }
  20675. declare module BABYLON {
  20676. /** @hidden */
  20677. export var pbrBlockClearcoat: {
  20678. name: string;
  20679. shader: string;
  20680. };
  20681. }
  20682. declare module BABYLON {
  20683. /** @hidden */
  20684. export var pbrBlockSubSurface: {
  20685. name: string;
  20686. shader: string;
  20687. };
  20688. }
  20689. declare module BABYLON {
  20690. /** @hidden */
  20691. export var pbrBlockNormalGeometric: {
  20692. name: string;
  20693. shader: string;
  20694. };
  20695. }
  20696. declare module BABYLON {
  20697. /** @hidden */
  20698. export var pbrBlockNormalFinal: {
  20699. name: string;
  20700. shader: string;
  20701. };
  20702. }
  20703. declare module BABYLON {
  20704. /** @hidden */
  20705. export var pbrBlockLightmapInit: {
  20706. name: string;
  20707. shader: string;
  20708. };
  20709. }
  20710. declare module BABYLON {
  20711. /** @hidden */
  20712. export var pbrBlockGeometryInfo: {
  20713. name: string;
  20714. shader: string;
  20715. };
  20716. }
  20717. declare module BABYLON {
  20718. /** @hidden */
  20719. export var pbrBlockReflectance0: {
  20720. name: string;
  20721. shader: string;
  20722. };
  20723. }
  20724. declare module BABYLON {
  20725. /** @hidden */
  20726. export var pbrBlockReflectance: {
  20727. name: string;
  20728. shader: string;
  20729. };
  20730. }
  20731. declare module BABYLON {
  20732. /** @hidden */
  20733. export var pbrBlockDirectLighting: {
  20734. name: string;
  20735. shader: string;
  20736. };
  20737. }
  20738. declare module BABYLON {
  20739. /** @hidden */
  20740. export var pbrBlockFinalLitComponents: {
  20741. name: string;
  20742. shader: string;
  20743. };
  20744. }
  20745. declare module BABYLON {
  20746. /** @hidden */
  20747. export var pbrBlockFinalUnlitComponents: {
  20748. name: string;
  20749. shader: string;
  20750. };
  20751. }
  20752. declare module BABYLON {
  20753. /** @hidden */
  20754. export var pbrBlockFinalColorComposition: {
  20755. name: string;
  20756. shader: string;
  20757. };
  20758. }
  20759. declare module BABYLON {
  20760. /** @hidden */
  20761. export var pbrBlockImageProcessing: {
  20762. name: string;
  20763. shader: string;
  20764. };
  20765. }
  20766. declare module BABYLON {
  20767. /** @hidden */
  20768. export var pbrDebug: {
  20769. name: string;
  20770. shader: string;
  20771. };
  20772. }
  20773. declare module BABYLON {
  20774. /** @hidden */
  20775. export var pbrPixelShader: {
  20776. name: string;
  20777. shader: string;
  20778. };
  20779. }
  20780. declare module BABYLON {
  20781. /** @hidden */
  20782. export var pbrVertexDeclaration: {
  20783. name: string;
  20784. shader: string;
  20785. };
  20786. }
  20787. declare module BABYLON {
  20788. /** @hidden */
  20789. export var pbrVertexShader: {
  20790. name: string;
  20791. shader: string;
  20792. };
  20793. }
  20794. declare module BABYLON {
  20795. /**
  20796. * Manages the defines for the PBR Material.
  20797. * @hidden
  20798. */
  20799. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20800. PBR: boolean;
  20801. NUM_SAMPLES: string;
  20802. REALTIME_FILTERING: boolean;
  20803. MAINUV1: boolean;
  20804. MAINUV2: boolean;
  20805. UV1: boolean;
  20806. UV2: boolean;
  20807. ALBEDO: boolean;
  20808. GAMMAALBEDO: boolean;
  20809. ALBEDODIRECTUV: number;
  20810. VERTEXCOLOR: boolean;
  20811. DETAIL: boolean;
  20812. DETAILDIRECTUV: number;
  20813. DETAIL_NORMALBLENDMETHOD: number;
  20814. AMBIENT: boolean;
  20815. AMBIENTDIRECTUV: number;
  20816. AMBIENTINGRAYSCALE: boolean;
  20817. OPACITY: boolean;
  20818. VERTEXALPHA: boolean;
  20819. OPACITYDIRECTUV: number;
  20820. OPACITYRGB: boolean;
  20821. ALPHATEST: boolean;
  20822. DEPTHPREPASS: boolean;
  20823. ALPHABLEND: boolean;
  20824. ALPHAFROMALBEDO: boolean;
  20825. ALPHATESTVALUE: string;
  20826. SPECULAROVERALPHA: boolean;
  20827. RADIANCEOVERALPHA: boolean;
  20828. ALPHAFRESNEL: boolean;
  20829. LINEARALPHAFRESNEL: boolean;
  20830. PREMULTIPLYALPHA: boolean;
  20831. EMISSIVE: boolean;
  20832. EMISSIVEDIRECTUV: number;
  20833. REFLECTIVITY: boolean;
  20834. REFLECTIVITYDIRECTUV: number;
  20835. SPECULARTERM: boolean;
  20836. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20837. MICROSURFACEAUTOMATIC: boolean;
  20838. LODBASEDMICROSFURACE: boolean;
  20839. MICROSURFACEMAP: boolean;
  20840. MICROSURFACEMAPDIRECTUV: number;
  20841. METALLICWORKFLOW: boolean;
  20842. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20843. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20844. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20845. AOSTOREINMETALMAPRED: boolean;
  20846. METALLIC_REFLECTANCE: boolean;
  20847. METALLIC_REFLECTANCEDIRECTUV: number;
  20848. ENVIRONMENTBRDF: boolean;
  20849. ENVIRONMENTBRDF_RGBD: boolean;
  20850. NORMAL: boolean;
  20851. TANGENT: boolean;
  20852. BUMP: boolean;
  20853. BUMPDIRECTUV: number;
  20854. OBJECTSPACE_NORMALMAP: boolean;
  20855. PARALLAX: boolean;
  20856. PARALLAXOCCLUSION: boolean;
  20857. NORMALXYSCALE: boolean;
  20858. LIGHTMAP: boolean;
  20859. LIGHTMAPDIRECTUV: number;
  20860. USELIGHTMAPASSHADOWMAP: boolean;
  20861. GAMMALIGHTMAP: boolean;
  20862. RGBDLIGHTMAP: boolean;
  20863. REFLECTION: boolean;
  20864. REFLECTIONMAP_3D: boolean;
  20865. REFLECTIONMAP_SPHERICAL: boolean;
  20866. REFLECTIONMAP_PLANAR: boolean;
  20867. REFLECTIONMAP_CUBIC: boolean;
  20868. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20869. REFLECTIONMAP_PROJECTION: boolean;
  20870. REFLECTIONMAP_SKYBOX: boolean;
  20871. REFLECTIONMAP_EXPLICIT: boolean;
  20872. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20873. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20874. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20875. INVERTCUBICMAP: boolean;
  20876. USESPHERICALFROMREFLECTIONMAP: boolean;
  20877. USEIRRADIANCEMAP: boolean;
  20878. SPHERICAL_HARMONICS: boolean;
  20879. USESPHERICALINVERTEX: boolean;
  20880. REFLECTIONMAP_OPPOSITEZ: boolean;
  20881. LODINREFLECTIONALPHA: boolean;
  20882. GAMMAREFLECTION: boolean;
  20883. RGBDREFLECTION: boolean;
  20884. LINEARSPECULARREFLECTION: boolean;
  20885. RADIANCEOCCLUSION: boolean;
  20886. HORIZONOCCLUSION: boolean;
  20887. INSTANCES: boolean;
  20888. THIN_INSTANCES: boolean;
  20889. PREPASS: boolean;
  20890. PREPASS_IRRADIANCE: boolean;
  20891. PREPASS_IRRADIANCE_INDEX: number;
  20892. PREPASS_ALBEDO: boolean;
  20893. PREPASS_ALBEDO_INDEX: number;
  20894. PREPASS_DEPTHNORMAL: boolean;
  20895. PREPASS_DEPTHNORMAL_INDEX: number;
  20896. PREPASS_POSITION: boolean;
  20897. PREPASS_POSITION_INDEX: number;
  20898. PREPASS_VELOCITY: boolean;
  20899. PREPASS_VELOCITY_INDEX: number;
  20900. PREPASS_REFLECTIVITY: boolean;
  20901. PREPASS_REFLECTIVITY_INDEX: number;
  20902. SCENE_MRT_COUNT: number;
  20903. NUM_BONE_INFLUENCERS: number;
  20904. BonesPerMesh: number;
  20905. BONETEXTURE: boolean;
  20906. BONES_VELOCITY_ENABLED: boolean;
  20907. NONUNIFORMSCALING: boolean;
  20908. MORPHTARGETS: boolean;
  20909. MORPHTARGETS_NORMAL: boolean;
  20910. MORPHTARGETS_TANGENT: boolean;
  20911. MORPHTARGETS_UV: boolean;
  20912. NUM_MORPH_INFLUENCERS: number;
  20913. IMAGEPROCESSING: boolean;
  20914. VIGNETTE: boolean;
  20915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20916. VIGNETTEBLENDMODEOPAQUE: boolean;
  20917. TONEMAPPING: boolean;
  20918. TONEMAPPING_ACES: boolean;
  20919. CONTRAST: boolean;
  20920. COLORCURVES: boolean;
  20921. COLORGRADING: boolean;
  20922. COLORGRADING3D: boolean;
  20923. SAMPLER3DGREENDEPTH: boolean;
  20924. SAMPLER3DBGRMAP: boolean;
  20925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20926. EXPOSURE: boolean;
  20927. MULTIVIEW: boolean;
  20928. USEPHYSICALLIGHTFALLOFF: boolean;
  20929. USEGLTFLIGHTFALLOFF: boolean;
  20930. TWOSIDEDLIGHTING: boolean;
  20931. SHADOWFLOAT: boolean;
  20932. CLIPPLANE: boolean;
  20933. CLIPPLANE2: boolean;
  20934. CLIPPLANE3: boolean;
  20935. CLIPPLANE4: boolean;
  20936. CLIPPLANE5: boolean;
  20937. CLIPPLANE6: boolean;
  20938. POINTSIZE: boolean;
  20939. FOG: boolean;
  20940. LOGARITHMICDEPTH: boolean;
  20941. FORCENORMALFORWARD: boolean;
  20942. SPECULARAA: boolean;
  20943. CLEARCOAT: boolean;
  20944. CLEARCOAT_DEFAULTIOR: boolean;
  20945. CLEARCOAT_TEXTURE: boolean;
  20946. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20947. CLEARCOAT_TEXTUREDIRECTUV: number;
  20948. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20949. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20950. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20951. CLEARCOAT_BUMP: boolean;
  20952. CLEARCOAT_BUMPDIRECTUV: number;
  20953. CLEARCOAT_REMAP_F0: boolean;
  20954. CLEARCOAT_TINT: boolean;
  20955. CLEARCOAT_TINT_TEXTURE: boolean;
  20956. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20957. ANISOTROPIC: boolean;
  20958. ANISOTROPIC_TEXTURE: boolean;
  20959. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20960. BRDF_V_HEIGHT_CORRELATED: boolean;
  20961. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20962. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20963. SHEEN: boolean;
  20964. SHEEN_TEXTURE: boolean;
  20965. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20966. SHEEN_TEXTUREDIRECTUV: number;
  20967. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20968. SHEEN_LINKWITHALBEDO: boolean;
  20969. SHEEN_ROUGHNESS: boolean;
  20970. SHEEN_ALBEDOSCALING: boolean;
  20971. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20972. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20973. SUBSURFACE: boolean;
  20974. SS_REFRACTION: boolean;
  20975. SS_TRANSLUCENCY: boolean;
  20976. SS_SCATTERING: boolean;
  20977. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20978. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20979. SS_REFRACTIONMAP_3D: boolean;
  20980. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20981. SS_LODINREFRACTIONALPHA: boolean;
  20982. SS_GAMMAREFRACTION: boolean;
  20983. SS_RGBDREFRACTION: boolean;
  20984. SS_LINEARSPECULARREFRACTION: boolean;
  20985. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20986. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20987. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20988. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20989. UNLIT: boolean;
  20990. DEBUGMODE: number;
  20991. /**
  20992. * Initializes the PBR Material defines.
  20993. */
  20994. constructor();
  20995. /**
  20996. * Resets the PBR Material defines.
  20997. */
  20998. reset(): void;
  20999. }
  21000. /**
  21001. * The Physically based material base class of BJS.
  21002. *
  21003. * This offers the main features of a standard PBR material.
  21004. * For more information, please refer to the documentation :
  21005. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21006. */
  21007. export abstract class PBRBaseMaterial extends PushMaterial {
  21008. /**
  21009. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21010. */
  21011. static readonly PBRMATERIAL_OPAQUE: number;
  21012. /**
  21013. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21014. */
  21015. static readonly PBRMATERIAL_ALPHATEST: number;
  21016. /**
  21017. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21018. */
  21019. static readonly PBRMATERIAL_ALPHABLEND: number;
  21020. /**
  21021. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21022. * They are also discarded below the alpha cutoff threshold to improve performances.
  21023. */
  21024. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21025. /**
  21026. * Defines the default value of how much AO map is occluding the analytical lights
  21027. * (point spot...).
  21028. */
  21029. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21030. /**
  21031. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21032. */
  21033. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21034. /**
  21035. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21036. * to enhance interoperability with other engines.
  21037. */
  21038. static readonly LIGHTFALLOFF_GLTF: number;
  21039. /**
  21040. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21041. * to enhance interoperability with other materials.
  21042. */
  21043. static readonly LIGHTFALLOFF_STANDARD: number;
  21044. /**
  21045. * Intensity of the direct lights e.g. the four lights available in your scene.
  21046. * This impacts both the direct diffuse and specular highlights.
  21047. */
  21048. protected _directIntensity: number;
  21049. /**
  21050. * Intensity of the emissive part of the material.
  21051. * This helps controlling the emissive effect without modifying the emissive color.
  21052. */
  21053. protected _emissiveIntensity: number;
  21054. /**
  21055. * Intensity of the environment e.g. how much the environment will light the object
  21056. * either through harmonics for rough material or through the refelction for shiny ones.
  21057. */
  21058. protected _environmentIntensity: number;
  21059. /**
  21060. * This is a special control allowing the reduction of the specular highlights coming from the
  21061. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21062. */
  21063. protected _specularIntensity: number;
  21064. /**
  21065. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21066. */
  21067. private _lightingInfos;
  21068. /**
  21069. * Debug Control allowing disabling the bump map on this material.
  21070. */
  21071. protected _disableBumpMap: boolean;
  21072. /**
  21073. * AKA Diffuse Texture in standard nomenclature.
  21074. */
  21075. protected _albedoTexture: Nullable<BaseTexture>;
  21076. /**
  21077. * AKA Occlusion Texture in other nomenclature.
  21078. */
  21079. protected _ambientTexture: Nullable<BaseTexture>;
  21080. /**
  21081. * AKA Occlusion Texture Intensity in other nomenclature.
  21082. */
  21083. protected _ambientTextureStrength: number;
  21084. /**
  21085. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21086. * 1 means it completely occludes it
  21087. * 0 mean it has no impact
  21088. */
  21089. protected _ambientTextureImpactOnAnalyticalLights: number;
  21090. /**
  21091. * Stores the alpha values in a texture.
  21092. */
  21093. protected _opacityTexture: Nullable<BaseTexture>;
  21094. /**
  21095. * Stores the reflection values in a texture.
  21096. */
  21097. protected _reflectionTexture: Nullable<BaseTexture>;
  21098. /**
  21099. * Stores the emissive values in a texture.
  21100. */
  21101. protected _emissiveTexture: Nullable<BaseTexture>;
  21102. /**
  21103. * AKA Specular texture in other nomenclature.
  21104. */
  21105. protected _reflectivityTexture: Nullable<BaseTexture>;
  21106. /**
  21107. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21108. */
  21109. protected _metallicTexture: Nullable<BaseTexture>;
  21110. /**
  21111. * Specifies the metallic scalar of the metallic/roughness workflow.
  21112. * Can also be used to scale the metalness values of the metallic texture.
  21113. */
  21114. protected _metallic: Nullable<number>;
  21115. /**
  21116. * Specifies the roughness scalar of the metallic/roughness workflow.
  21117. * Can also be used to scale the roughness values of the metallic texture.
  21118. */
  21119. protected _roughness: Nullable<number>;
  21120. /**
  21121. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21122. * By default the indexOfrefraction is used to compute F0;
  21123. *
  21124. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21125. *
  21126. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21127. * F90 = metallicReflectanceColor;
  21128. */
  21129. protected _metallicF0Factor: number;
  21130. /**
  21131. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21132. * By default the F90 is always 1;
  21133. *
  21134. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21135. *
  21136. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21137. * F90 = metallicReflectanceColor;
  21138. */
  21139. protected _metallicReflectanceColor: Color3;
  21140. /**
  21141. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21142. * This is multiply against the scalar values defined in the material.
  21143. */
  21144. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21145. /**
  21146. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21147. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21148. */
  21149. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21150. /**
  21151. * Stores surface normal data used to displace a mesh in a texture.
  21152. */
  21153. protected _bumpTexture: Nullable<BaseTexture>;
  21154. /**
  21155. * Stores the pre-calculated light information of a mesh in a texture.
  21156. */
  21157. protected _lightmapTexture: Nullable<BaseTexture>;
  21158. /**
  21159. * The color of a material in ambient lighting.
  21160. */
  21161. protected _ambientColor: Color3;
  21162. /**
  21163. * AKA Diffuse Color in other nomenclature.
  21164. */
  21165. protected _albedoColor: Color3;
  21166. /**
  21167. * AKA Specular Color in other nomenclature.
  21168. */
  21169. protected _reflectivityColor: Color3;
  21170. /**
  21171. * The color applied when light is reflected from a material.
  21172. */
  21173. protected _reflectionColor: Color3;
  21174. /**
  21175. * The color applied when light is emitted from a material.
  21176. */
  21177. protected _emissiveColor: Color3;
  21178. /**
  21179. * AKA Glossiness in other nomenclature.
  21180. */
  21181. protected _microSurface: number;
  21182. /**
  21183. * Specifies that the material will use the light map as a show map.
  21184. */
  21185. protected _useLightmapAsShadowmap: boolean;
  21186. /**
  21187. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21188. * makes the reflect vector face the model (under horizon).
  21189. */
  21190. protected _useHorizonOcclusion: boolean;
  21191. /**
  21192. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21193. * too much the area relying on ambient texture to define their ambient occlusion.
  21194. */
  21195. protected _useRadianceOcclusion: boolean;
  21196. /**
  21197. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21198. */
  21199. protected _useAlphaFromAlbedoTexture: boolean;
  21200. /**
  21201. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21202. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21203. */
  21204. protected _useSpecularOverAlpha: boolean;
  21205. /**
  21206. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21207. */
  21208. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21209. /**
  21210. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21211. */
  21212. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21213. /**
  21214. * Specifies if the metallic texture contains the roughness information in its green channel.
  21215. */
  21216. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21217. /**
  21218. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21219. */
  21220. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21221. /**
  21222. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21223. */
  21224. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21225. /**
  21226. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21227. */
  21228. protected _useAmbientInGrayScale: boolean;
  21229. /**
  21230. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21231. * The material will try to infer what glossiness each pixel should be.
  21232. */
  21233. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21234. /**
  21235. * Defines the falloff type used in this material.
  21236. * It by default is Physical.
  21237. */
  21238. protected _lightFalloff: number;
  21239. /**
  21240. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21241. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21242. */
  21243. protected _useRadianceOverAlpha: boolean;
  21244. /**
  21245. * Allows using an object space normal map (instead of tangent space).
  21246. */
  21247. protected _useObjectSpaceNormalMap: boolean;
  21248. /**
  21249. * Allows using the bump map in parallax mode.
  21250. */
  21251. protected _useParallax: boolean;
  21252. /**
  21253. * Allows using the bump map in parallax occlusion mode.
  21254. */
  21255. protected _useParallaxOcclusion: boolean;
  21256. /**
  21257. * Controls the scale bias of the parallax mode.
  21258. */
  21259. protected _parallaxScaleBias: number;
  21260. /**
  21261. * If sets to true, disables all the lights affecting the material.
  21262. */
  21263. protected _disableLighting: boolean;
  21264. /**
  21265. * Number of Simultaneous lights allowed on the material.
  21266. */
  21267. protected _maxSimultaneousLights: number;
  21268. /**
  21269. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21270. */
  21271. protected _invertNormalMapX: boolean;
  21272. /**
  21273. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21274. */
  21275. protected _invertNormalMapY: boolean;
  21276. /**
  21277. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21278. */
  21279. protected _twoSidedLighting: boolean;
  21280. /**
  21281. * Defines the alpha limits in alpha test mode.
  21282. */
  21283. protected _alphaCutOff: number;
  21284. /**
  21285. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21286. */
  21287. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  21291. */
  21292. protected _useAlphaFresnel: boolean;
  21293. /**
  21294. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21295. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21296. */
  21297. protected _useLinearAlphaFresnel: boolean;
  21298. /**
  21299. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21300. * from cos thetav and roughness:
  21301. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21302. */
  21303. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21304. /**
  21305. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21306. */
  21307. protected _forceIrradianceInFragment: boolean;
  21308. private _realTimeFiltering;
  21309. /**
  21310. * Enables realtime filtering on the texture.
  21311. */
  21312. get realTimeFiltering(): boolean;
  21313. set realTimeFiltering(b: boolean);
  21314. private _realTimeFilteringQuality;
  21315. /**
  21316. * Quality switch for realtime filtering
  21317. */
  21318. get realTimeFilteringQuality(): number;
  21319. set realTimeFilteringQuality(n: number);
  21320. /**
  21321. * Can this material render to several textures at once
  21322. */
  21323. get canRenderToMRT(): boolean;
  21324. /**
  21325. * Force normal to face away from face.
  21326. */
  21327. protected _forceNormalForward: boolean;
  21328. /**
  21329. * Enables specular anti aliasing in the PBR shader.
  21330. * It will both interacts on the Geometry for analytical and IBL lighting.
  21331. * It also prefilter the roughness map based on the bump values.
  21332. */
  21333. protected _enableSpecularAntiAliasing: boolean;
  21334. /**
  21335. * Default configuration related to image processing available in the PBR Material.
  21336. */
  21337. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21338. /**
  21339. * Keep track of the image processing observer to allow dispose and replace.
  21340. */
  21341. private _imageProcessingObserver;
  21342. /**
  21343. * Attaches a new image processing configuration to the PBR Material.
  21344. * @param configuration
  21345. */
  21346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21347. /**
  21348. * Stores the available render targets.
  21349. */
  21350. private _renderTargets;
  21351. /**
  21352. * Sets the global ambient color for the material used in lighting calculations.
  21353. */
  21354. private _globalAmbientColor;
  21355. /**
  21356. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21357. */
  21358. private _useLogarithmicDepth;
  21359. /**
  21360. * If set to true, no lighting calculations will be applied.
  21361. */
  21362. private _unlit;
  21363. private _debugMode;
  21364. /**
  21365. * @hidden
  21366. * This is reserved for the inspector.
  21367. * Defines the material debug mode.
  21368. * It helps seeing only some components of the material while troubleshooting.
  21369. */
  21370. debugMode: number;
  21371. /**
  21372. * @hidden
  21373. * This is reserved for the inspector.
  21374. * Specify from where on screen the debug mode should start.
  21375. * The value goes from -1 (full screen) to 1 (not visible)
  21376. * It helps with side by side comparison against the final render
  21377. * This defaults to -1
  21378. */
  21379. private debugLimit;
  21380. /**
  21381. * @hidden
  21382. * This is reserved for the inspector.
  21383. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21384. * You can use the factor to better multiply the final value.
  21385. */
  21386. private debugFactor;
  21387. /**
  21388. * Defines the clear coat layer parameters for the material.
  21389. */
  21390. readonly clearCoat: PBRClearCoatConfiguration;
  21391. /**
  21392. * Defines the anisotropic parameters for the material.
  21393. */
  21394. readonly anisotropy: PBRAnisotropicConfiguration;
  21395. /**
  21396. * Defines the BRDF parameters for the material.
  21397. */
  21398. readonly brdf: PBRBRDFConfiguration;
  21399. /**
  21400. * Defines the Sheen parameters for the material.
  21401. */
  21402. readonly sheen: PBRSheenConfiguration;
  21403. /**
  21404. * Defines the SubSurface parameters for the material.
  21405. */
  21406. readonly subSurface: PBRSubSurfaceConfiguration;
  21407. /**
  21408. * Defines additionnal PrePass parameters for the material.
  21409. */
  21410. readonly prePassConfiguration: PrePassConfiguration;
  21411. /**
  21412. * Defines the detail map parameters for the material.
  21413. */
  21414. readonly detailMap: DetailMapConfiguration;
  21415. protected _rebuildInParallel: boolean;
  21416. /**
  21417. * Instantiates a new PBRMaterial instance.
  21418. *
  21419. * @param name The material name
  21420. * @param scene The scene the material will be use in.
  21421. */
  21422. constructor(name: string, scene: Scene);
  21423. /**
  21424. * Gets a boolean indicating that current material needs to register RTT
  21425. */
  21426. get hasRenderTargetTextures(): boolean;
  21427. /**
  21428. * Gets the name of the material class.
  21429. */
  21430. getClassName(): string;
  21431. /**
  21432. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21433. */
  21434. get useLogarithmicDepth(): boolean;
  21435. /**
  21436. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21437. */
  21438. set useLogarithmicDepth(value: boolean);
  21439. /**
  21440. * Returns true if alpha blending should be disabled.
  21441. */
  21442. protected get _disableAlphaBlending(): boolean;
  21443. /**
  21444. * Specifies whether or not this material should be rendered in alpha blend mode.
  21445. */
  21446. needAlphaBlending(): boolean;
  21447. /**
  21448. * Specifies whether or not this material should be rendered in alpha test mode.
  21449. */
  21450. needAlphaTesting(): boolean;
  21451. /**
  21452. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21453. */
  21454. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21455. /**
  21456. * Specifies whether or not there is a usable alpha channel for transparency.
  21457. */
  21458. protected _hasAlphaChannel(): boolean;
  21459. /**
  21460. * Gets the texture used for the alpha test.
  21461. */
  21462. getAlphaTestTexture(): Nullable<BaseTexture>;
  21463. /**
  21464. * Specifies that the submesh is ready to be used.
  21465. * @param mesh - BJS mesh.
  21466. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21467. * @param useInstances - Specifies that instances should be used.
  21468. * @returns - boolean indicating that the submesh is ready or not.
  21469. */
  21470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21471. /**
  21472. * Specifies if the material uses metallic roughness workflow.
  21473. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21474. */
  21475. isMetallicWorkflow(): boolean;
  21476. private _prepareEffect;
  21477. private _prepareDefines;
  21478. /**
  21479. * Force shader compilation
  21480. */
  21481. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21482. /**
  21483. * Initializes the uniform buffer layout for the shader.
  21484. */
  21485. buildUniformLayout(): void;
  21486. /**
  21487. * Unbinds the material from the mesh
  21488. */
  21489. unbind(): void;
  21490. /**
  21491. * Binds the submesh data.
  21492. * @param world - The world matrix.
  21493. * @param mesh - The BJS mesh.
  21494. * @param subMesh - A submesh of the BJS mesh.
  21495. */
  21496. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21497. /**
  21498. * Returns the animatable textures.
  21499. * @returns - Array of animatable textures.
  21500. */
  21501. getAnimatables(): IAnimatable[];
  21502. /**
  21503. * Returns the texture used for reflections.
  21504. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21505. */
  21506. private _getReflectionTexture;
  21507. /**
  21508. * Returns an array of the actively used textures.
  21509. * @returns - Array of BaseTextures
  21510. */
  21511. getActiveTextures(): BaseTexture[];
  21512. /**
  21513. * Checks to see if a texture is used in the material.
  21514. * @param texture - Base texture to use.
  21515. * @returns - Boolean specifying if a texture is used in the material.
  21516. */
  21517. hasTexture(texture: BaseTexture): boolean;
  21518. /**
  21519. * Sets the required values to the prepass renderer.
  21520. * @param prePassRenderer defines the prepass renderer to setup
  21521. */
  21522. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21523. /**
  21524. * Disposes the resources of the material.
  21525. * @param forceDisposeEffect - Forces the disposal of effects.
  21526. * @param forceDisposeTextures - Forces the disposal of all textures.
  21527. */
  21528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * The Physically based material of BJS.
  21534. *
  21535. * This offers the main features of a standard PBR material.
  21536. * For more information, please refer to the documentation :
  21537. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21538. */
  21539. export class PBRMaterial extends PBRBaseMaterial {
  21540. /**
  21541. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21542. */
  21543. static readonly PBRMATERIAL_OPAQUE: number;
  21544. /**
  21545. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21546. */
  21547. static readonly PBRMATERIAL_ALPHATEST: number;
  21548. /**
  21549. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21550. */
  21551. static readonly PBRMATERIAL_ALPHABLEND: number;
  21552. /**
  21553. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21554. * They are also discarded below the alpha cutoff threshold to improve performances.
  21555. */
  21556. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21557. /**
  21558. * Defines the default value of how much AO map is occluding the analytical lights
  21559. * (point spot...).
  21560. */
  21561. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21562. /**
  21563. * Intensity of the direct lights e.g. the four lights available in your scene.
  21564. * This impacts both the direct diffuse and specular highlights.
  21565. */
  21566. directIntensity: number;
  21567. /**
  21568. * Intensity of the emissive part of the material.
  21569. * This helps controlling the emissive effect without modifying the emissive color.
  21570. */
  21571. emissiveIntensity: number;
  21572. /**
  21573. * Intensity of the environment e.g. how much the environment will light the object
  21574. * either through harmonics for rough material or through the refelction for shiny ones.
  21575. */
  21576. environmentIntensity: number;
  21577. /**
  21578. * This is a special control allowing the reduction of the specular highlights coming from the
  21579. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21580. */
  21581. specularIntensity: number;
  21582. /**
  21583. * Debug Control allowing disabling the bump map on this material.
  21584. */
  21585. disableBumpMap: boolean;
  21586. /**
  21587. * AKA Diffuse Texture in standard nomenclature.
  21588. */
  21589. albedoTexture: BaseTexture;
  21590. /**
  21591. * AKA Occlusion Texture in other nomenclature.
  21592. */
  21593. ambientTexture: BaseTexture;
  21594. /**
  21595. * AKA Occlusion Texture Intensity in other nomenclature.
  21596. */
  21597. ambientTextureStrength: number;
  21598. /**
  21599. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21600. * 1 means it completely occludes it
  21601. * 0 mean it has no impact
  21602. */
  21603. ambientTextureImpactOnAnalyticalLights: number;
  21604. /**
  21605. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21606. */
  21607. opacityTexture: BaseTexture;
  21608. /**
  21609. * Stores the reflection values in a texture.
  21610. */
  21611. reflectionTexture: Nullable<BaseTexture>;
  21612. /**
  21613. * Stores the emissive values in a texture.
  21614. */
  21615. emissiveTexture: BaseTexture;
  21616. /**
  21617. * AKA Specular texture in other nomenclature.
  21618. */
  21619. reflectivityTexture: BaseTexture;
  21620. /**
  21621. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21622. */
  21623. metallicTexture: BaseTexture;
  21624. /**
  21625. * Specifies the metallic scalar of the metallic/roughness workflow.
  21626. * Can also be used to scale the metalness values of the metallic texture.
  21627. */
  21628. metallic: Nullable<number>;
  21629. /**
  21630. * Specifies the roughness scalar of the metallic/roughness workflow.
  21631. * Can also be used to scale the roughness values of the metallic texture.
  21632. */
  21633. roughness: Nullable<number>;
  21634. /**
  21635. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21636. * By default the indexOfrefraction is used to compute F0;
  21637. *
  21638. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21639. *
  21640. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21641. * F90 = metallicReflectanceColor;
  21642. */
  21643. metallicF0Factor: number;
  21644. /**
  21645. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21646. * By default the F90 is always 1;
  21647. *
  21648. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21649. *
  21650. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21651. * F90 = metallicReflectanceColor;
  21652. */
  21653. metallicReflectanceColor: Color3;
  21654. /**
  21655. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21656. * This is multiply against the scalar values defined in the material.
  21657. */
  21658. metallicReflectanceTexture: Nullable<BaseTexture>;
  21659. /**
  21660. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21661. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21662. */
  21663. microSurfaceTexture: BaseTexture;
  21664. /**
  21665. * Stores surface normal data used to displace a mesh in a texture.
  21666. */
  21667. bumpTexture: BaseTexture;
  21668. /**
  21669. * Stores the pre-calculated light information of a mesh in a texture.
  21670. */
  21671. lightmapTexture: BaseTexture;
  21672. /**
  21673. * Stores the refracted light information in a texture.
  21674. */
  21675. get refractionTexture(): Nullable<BaseTexture>;
  21676. set refractionTexture(value: Nullable<BaseTexture>);
  21677. /**
  21678. * The color of a material in ambient lighting.
  21679. */
  21680. ambientColor: Color3;
  21681. /**
  21682. * AKA Diffuse Color in other nomenclature.
  21683. */
  21684. albedoColor: Color3;
  21685. /**
  21686. * AKA Specular Color in other nomenclature.
  21687. */
  21688. reflectivityColor: Color3;
  21689. /**
  21690. * The color reflected from the material.
  21691. */
  21692. reflectionColor: Color3;
  21693. /**
  21694. * The color emitted from the material.
  21695. */
  21696. emissiveColor: Color3;
  21697. /**
  21698. * AKA Glossiness in other nomenclature.
  21699. */
  21700. microSurface: number;
  21701. /**
  21702. * Index of refraction of the material base layer.
  21703. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21704. *
  21705. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21706. *
  21707. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21708. */
  21709. get indexOfRefraction(): number;
  21710. set indexOfRefraction(value: number);
  21711. /**
  21712. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21713. */
  21714. get invertRefractionY(): boolean;
  21715. set invertRefractionY(value: boolean);
  21716. /**
  21717. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21718. * Materials half opaque for instance using refraction could benefit from this control.
  21719. */
  21720. get linkRefractionWithTransparency(): boolean;
  21721. set linkRefractionWithTransparency(value: boolean);
  21722. /**
  21723. * If true, the light map contains occlusion information instead of lighting info.
  21724. */
  21725. useLightmapAsShadowmap: boolean;
  21726. /**
  21727. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21728. */
  21729. useAlphaFromAlbedoTexture: boolean;
  21730. /**
  21731. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21732. */
  21733. forceAlphaTest: boolean;
  21734. /**
  21735. * Defines the alpha limits in alpha test mode.
  21736. */
  21737. alphaCutOff: number;
  21738. /**
  21739. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21740. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21741. */
  21742. useSpecularOverAlpha: boolean;
  21743. /**
  21744. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21745. */
  21746. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21747. /**
  21748. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21749. */
  21750. useRoughnessFromMetallicTextureAlpha: boolean;
  21751. /**
  21752. * Specifies if the metallic texture contains the roughness information in its green channel.
  21753. */
  21754. useRoughnessFromMetallicTextureGreen: boolean;
  21755. /**
  21756. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21757. */
  21758. useMetallnessFromMetallicTextureBlue: boolean;
  21759. /**
  21760. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21761. */
  21762. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21763. /**
  21764. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21765. */
  21766. useAmbientInGrayScale: boolean;
  21767. /**
  21768. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21769. * The material will try to infer what glossiness each pixel should be.
  21770. */
  21771. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21772. /**
  21773. * BJS is using an harcoded light falloff based on a manually sets up range.
  21774. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21775. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21776. */
  21777. get usePhysicalLightFalloff(): boolean;
  21778. /**
  21779. * BJS is using an harcoded light falloff based on a manually sets up range.
  21780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21782. */
  21783. set usePhysicalLightFalloff(value: 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. get useGLTFLightFalloff(): boolean;
  21789. /**
  21790. * In order to support the falloff compatibility with gltf, a special mode has been added
  21791. * to reproduce the gltf light falloff.
  21792. */
  21793. set useGLTFLightFalloff(value: boolean);
  21794. /**
  21795. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21796. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21797. */
  21798. useRadianceOverAlpha: boolean;
  21799. /**
  21800. * Allows using an object space normal map (instead of tangent space).
  21801. */
  21802. useObjectSpaceNormalMap: boolean;
  21803. /**
  21804. * Allows using the bump map in parallax mode.
  21805. */
  21806. useParallax: boolean;
  21807. /**
  21808. * Allows using the bump map in parallax occlusion mode.
  21809. */
  21810. useParallaxOcclusion: boolean;
  21811. /**
  21812. * Controls the scale bias of the parallax mode.
  21813. */
  21814. parallaxScaleBias: number;
  21815. /**
  21816. * If sets to true, disables all the lights affecting the material.
  21817. */
  21818. disableLighting: boolean;
  21819. /**
  21820. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21821. */
  21822. forceIrradianceInFragment: boolean;
  21823. /**
  21824. * Number of Simultaneous lights allowed on the material.
  21825. */
  21826. maxSimultaneousLights: number;
  21827. /**
  21828. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21829. */
  21830. invertNormalMapX: boolean;
  21831. /**
  21832. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21833. */
  21834. invertNormalMapY: boolean;
  21835. /**
  21836. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21837. */
  21838. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  21842. */
  21843. useAlphaFresnel: boolean;
  21844. /**
  21845. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21846. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21847. */
  21848. useLinearAlphaFresnel: boolean;
  21849. /**
  21850. * Let user defines the brdf lookup texture used for IBL.
  21851. * A default 8bit version is embedded but you could point at :
  21852. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21853. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21854. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21855. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21856. */
  21857. environmentBRDFTexture: Nullable<BaseTexture>;
  21858. /**
  21859. * Force normal to face away from face.
  21860. */
  21861. forceNormalForward: boolean;
  21862. /**
  21863. * Enables specular anti aliasing in the PBR shader.
  21864. * It will both interacts on the Geometry for analytical and IBL lighting.
  21865. * It also prefilter the roughness map based on the bump values.
  21866. */
  21867. enableSpecularAntiAliasing: boolean;
  21868. /**
  21869. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21870. * makes the reflect vector face the model (under horizon).
  21871. */
  21872. useHorizonOcclusion: boolean;
  21873. /**
  21874. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21875. * too much the area relying on ambient texture to define their ambient occlusion.
  21876. */
  21877. useRadianceOcclusion: boolean;
  21878. /**
  21879. * If set to true, no lighting calculations will be applied.
  21880. */
  21881. unlit: boolean;
  21882. /**
  21883. * Gets the image processing configuration used either in this material.
  21884. */
  21885. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21886. /**
  21887. * Sets the Default image processing configuration used either in the this material.
  21888. *
  21889. * If sets to null, the scene one is in use.
  21890. */
  21891. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21892. /**
  21893. * Gets wether the color curves effect is enabled.
  21894. */
  21895. get cameraColorCurvesEnabled(): boolean;
  21896. /**
  21897. * Sets wether the color curves effect is enabled.
  21898. */
  21899. set cameraColorCurvesEnabled(value: boolean);
  21900. /**
  21901. * Gets wether the color grading effect is enabled.
  21902. */
  21903. get cameraColorGradingEnabled(): boolean;
  21904. /**
  21905. * Gets wether the color grading effect is enabled.
  21906. */
  21907. set cameraColorGradingEnabled(value: boolean);
  21908. /**
  21909. * Gets wether tonemapping is enabled or not.
  21910. */
  21911. get cameraToneMappingEnabled(): boolean;
  21912. /**
  21913. * Sets wether tonemapping is enabled or not
  21914. */
  21915. set cameraToneMappingEnabled(value: boolean);
  21916. /**
  21917. * The camera exposure used on this material.
  21918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21919. * This corresponds to a photographic exposure.
  21920. */
  21921. get cameraExposure(): number;
  21922. /**
  21923. * The camera exposure used on this material.
  21924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21925. * This corresponds to a photographic exposure.
  21926. */
  21927. set cameraExposure(value: number);
  21928. /**
  21929. * Gets The camera contrast used on this material.
  21930. */
  21931. get cameraContrast(): number;
  21932. /**
  21933. * Sets The camera contrast used on this material.
  21934. */
  21935. set cameraContrast(value: number);
  21936. /**
  21937. * Gets the Color Grading 2D Lookup Texture.
  21938. */
  21939. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21940. /**
  21941. * Sets the Color Grading 2D Lookup Texture.
  21942. */
  21943. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21944. /**
  21945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21947. * 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;
  21948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21949. */
  21950. get cameraColorCurves(): Nullable<ColorCurves>;
  21951. /**
  21952. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21953. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21954. * 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;
  21955. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21956. */
  21957. set cameraColorCurves(value: Nullable<ColorCurves>);
  21958. /**
  21959. * Instantiates a new PBRMaterial instance.
  21960. *
  21961. * @param name The material name
  21962. * @param scene The scene the material will be use in.
  21963. */
  21964. constructor(name: string, scene: Scene);
  21965. /**
  21966. * Returns the name of this material class.
  21967. */
  21968. getClassName(): string;
  21969. /**
  21970. * Makes a duplicate of the current material.
  21971. * @param name - name to use for the new material.
  21972. */
  21973. clone(name: string): PBRMaterial;
  21974. /**
  21975. * Serializes this PBR Material.
  21976. * @returns - An object with the serialized material.
  21977. */
  21978. serialize(): any;
  21979. /**
  21980. * Parses a PBR Material from a serialized object.
  21981. * @param source - Serialized object.
  21982. * @param scene - BJS scene instance.
  21983. * @param rootUrl - url for the scene object
  21984. * @returns - PBRMaterial
  21985. */
  21986. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /** @hidden */
  21991. export var mrtFragmentDeclaration: {
  21992. name: string;
  21993. shader: string;
  21994. };
  21995. }
  21996. declare module BABYLON {
  21997. /** @hidden */
  21998. export var geometryPixelShader: {
  21999. name: string;
  22000. shader: string;
  22001. };
  22002. }
  22003. declare module BABYLON {
  22004. /** @hidden */
  22005. export var geometryVertexShader: {
  22006. name: string;
  22007. shader: string;
  22008. };
  22009. }
  22010. declare module BABYLON {
  22011. /** @hidden */
  22012. interface ISavedTransformationMatrix {
  22013. world: Matrix;
  22014. viewProjection: Matrix;
  22015. }
  22016. /**
  22017. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22018. */
  22019. export class GeometryBufferRenderer {
  22020. /**
  22021. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22022. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22023. */
  22024. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22025. /**
  22026. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22027. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22028. */
  22029. static readonly POSITION_TEXTURE_TYPE: number;
  22030. /**
  22031. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22032. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22033. */
  22034. static readonly VELOCITY_TEXTURE_TYPE: number;
  22035. /**
  22036. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22037. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22038. */
  22039. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22040. /**
  22041. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22042. * in order to compute objects velocities when enableVelocity is set to "true"
  22043. * @hidden
  22044. */
  22045. _previousTransformationMatrices: {
  22046. [index: number]: ISavedTransformationMatrix;
  22047. };
  22048. /**
  22049. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22050. * in order to compute objects velocities when enableVelocity is set to "true"
  22051. * @hidden
  22052. */
  22053. _previousBonesTransformationMatrices: {
  22054. [index: number]: Float32Array;
  22055. };
  22056. /**
  22057. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22058. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22059. */
  22060. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22061. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22062. renderTransparentMeshes: boolean;
  22063. private _scene;
  22064. private _resizeObserver;
  22065. private _multiRenderTarget;
  22066. private _ratio;
  22067. private _enablePosition;
  22068. private _enableVelocity;
  22069. private _enableReflectivity;
  22070. private _positionIndex;
  22071. private _velocityIndex;
  22072. private _reflectivityIndex;
  22073. private _depthNormalIndex;
  22074. private _linkedWithPrePass;
  22075. private _prePassRenderer;
  22076. private _attachments;
  22077. protected _effect: Effect;
  22078. protected _cachedDefines: string;
  22079. /**
  22080. * @hidden
  22081. * Sets up internal structures to share outputs with PrePassRenderer
  22082. * This method should only be called by the PrePassRenderer itself
  22083. */
  22084. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22085. /**
  22086. * @hidden
  22087. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22088. * This method should only be called by the PrePassRenderer itself
  22089. */
  22090. _unlinkPrePassRenderer(): void;
  22091. /**
  22092. * @hidden
  22093. * Resets the geometry buffer layout
  22094. */
  22095. _resetLayout(): void;
  22096. /**
  22097. * @hidden
  22098. * Replaces a texture in the geometry buffer renderer
  22099. * Useful when linking textures of the prepass renderer
  22100. */
  22101. _forceTextureType(geometryBufferType: number, index: number): void;
  22102. /**
  22103. * @hidden
  22104. * Sets texture attachments
  22105. * Useful when linking textures of the prepass renderer
  22106. */
  22107. _setAttachments(attachments: number[]): void;
  22108. /**
  22109. * @hidden
  22110. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22111. * Useful when linking textures of the prepass renderer
  22112. */
  22113. _linkInternalTexture(internalTexture: InternalTexture): void;
  22114. /**
  22115. * Gets the render list (meshes to be rendered) used in the G buffer.
  22116. */
  22117. get renderList(): Nullable<AbstractMesh[]>;
  22118. /**
  22119. * Set the render list (meshes to be rendered) used in the G buffer.
  22120. */
  22121. set renderList(meshes: Nullable<AbstractMesh[]>);
  22122. /**
  22123. * Gets wether or not G buffer are supported by the running hardware.
  22124. * This requires draw buffer supports
  22125. */
  22126. get isSupported(): boolean;
  22127. /**
  22128. * Returns the index of the given texture type in the G-Buffer textures array
  22129. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22130. * @returns the index of the given texture type in the G-Buffer textures array
  22131. */
  22132. getTextureIndex(textureType: number): number;
  22133. /**
  22134. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22135. */
  22136. get enablePosition(): boolean;
  22137. /**
  22138. * Sets whether or not objects positions are enabled for the G buffer.
  22139. */
  22140. set enablePosition(enable: boolean);
  22141. /**
  22142. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22143. */
  22144. get enableVelocity(): boolean;
  22145. /**
  22146. * Sets wether or not objects velocities are enabled for the G buffer.
  22147. */
  22148. set enableVelocity(enable: boolean);
  22149. /**
  22150. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22151. */
  22152. get enableReflectivity(): boolean;
  22153. /**
  22154. * Sets wether or not objects roughness are enabled for the G buffer.
  22155. */
  22156. set enableReflectivity(enable: boolean);
  22157. /**
  22158. * Gets the scene associated with the buffer.
  22159. */
  22160. get scene(): Scene;
  22161. /**
  22162. * Gets the ratio used by the buffer during its creation.
  22163. * How big is the buffer related to the main canvas.
  22164. */
  22165. get ratio(): number;
  22166. /** @hidden */
  22167. static _SceneComponentInitialization: (scene: Scene) => void;
  22168. /**
  22169. * Creates a new G Buffer for the scene
  22170. * @param scene The scene the buffer belongs to
  22171. * @param ratio How big is the buffer related to the main canvas.
  22172. */
  22173. constructor(scene: Scene, ratio?: number);
  22174. /**
  22175. * Checks wether everything is ready to render a submesh to the G buffer.
  22176. * @param subMesh the submesh to check readiness for
  22177. * @param useInstances is the mesh drawn using instance or not
  22178. * @returns true if ready otherwise false
  22179. */
  22180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22181. /**
  22182. * Gets the current underlying G Buffer.
  22183. * @returns the buffer
  22184. */
  22185. getGBuffer(): MultiRenderTarget;
  22186. /**
  22187. * Gets the number of samples used to render the buffer (anti aliasing).
  22188. */
  22189. get samples(): number;
  22190. /**
  22191. * Sets the number of samples used to render the buffer (anti aliasing).
  22192. */
  22193. set samples(value: number);
  22194. /**
  22195. * Disposes the renderer and frees up associated resources.
  22196. */
  22197. dispose(): void;
  22198. private _assignRenderTargetIndices;
  22199. protected _createRenderTargets(): void;
  22200. private _copyBonesTransformationMatrices;
  22201. }
  22202. }
  22203. declare module BABYLON {
  22204. /**
  22205. * Renders a pre pass of the scene
  22206. * This means every mesh in the scene will be rendered to a render target texture
  22207. * And then this texture will be composited to the rendering canvas with post processes
  22208. * It is necessary for effects like subsurface scattering or deferred shading
  22209. */
  22210. export class PrePassRenderer {
  22211. /** @hidden */
  22212. static _SceneComponentInitialization: (scene: Scene) => void;
  22213. private _textureFormats;
  22214. /**
  22215. * To save performance, we can excluded skinned meshes from the prepass
  22216. */
  22217. excludedSkinnedMesh: AbstractMesh[];
  22218. /**
  22219. * Force material to be excluded from the prepass
  22220. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22221. * and you don't want a material to show in the effect.
  22222. */
  22223. excludedMaterials: Material[];
  22224. private _textureIndices;
  22225. private _scene;
  22226. private _engine;
  22227. private _isDirty;
  22228. /**
  22229. * Number of textures in the multi render target texture where the scene is directly rendered
  22230. */
  22231. mrtCount: number;
  22232. /**
  22233. * The render target where the scene is directly rendered
  22234. */
  22235. prePassRT: MultiRenderTarget;
  22236. private _multiRenderAttachments;
  22237. private _defaultAttachments;
  22238. private _clearAttachments;
  22239. private _postProcesses;
  22240. private readonly _clearColor;
  22241. /**
  22242. * Image processing post process for composition
  22243. */
  22244. imageProcessingPostProcess: ImageProcessingPostProcess;
  22245. /**
  22246. * Configuration for prepass effects
  22247. */
  22248. private _effectConfigurations;
  22249. private _mrtFormats;
  22250. private _mrtLayout;
  22251. private _enabled;
  22252. /**
  22253. * Indicates if the prepass is enabled
  22254. */
  22255. get enabled(): boolean;
  22256. /**
  22257. * How many samples are used for MSAA of the scene render target
  22258. */
  22259. get samples(): number;
  22260. set samples(n: number);
  22261. private _geometryBuffer;
  22262. private _useGeometryBufferFallback;
  22263. /**
  22264. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22265. */
  22266. get useGeometryBufferFallback(): boolean;
  22267. set useGeometryBufferFallback(value: boolean);
  22268. /**
  22269. * Set to true to disable gamma transform in PrePass.
  22270. * Can be useful in case you already proceed to gamma transform on a material level
  22271. * and your post processes don't need to be in linear color space.
  22272. */
  22273. disableGammaTransform: boolean;
  22274. /**
  22275. * Instanciates a prepass renderer
  22276. * @param scene The scene
  22277. */
  22278. constructor(scene: Scene);
  22279. private _initializeAttachments;
  22280. private _createCompositionEffect;
  22281. /**
  22282. * Indicates if rendering a prepass is supported
  22283. */
  22284. get isSupported(): boolean;
  22285. /**
  22286. * Sets the proper output textures to draw in the engine.
  22287. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22288. * @param subMesh Submesh on which the effect is applied
  22289. */
  22290. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22291. /**
  22292. * Restores attachments for single texture draw.
  22293. */
  22294. restoreAttachments(): void;
  22295. /**
  22296. * @hidden
  22297. */
  22298. _beforeCameraDraw(): void;
  22299. /**
  22300. * @hidden
  22301. */
  22302. _afterCameraDraw(): void;
  22303. private _checkRTSize;
  22304. private _bindFrameBuffer;
  22305. /**
  22306. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22307. */
  22308. clear(): void;
  22309. private _setState;
  22310. private _updateGeometryBufferLayout;
  22311. /**
  22312. * Adds an effect configuration to the prepass.
  22313. * If an effect has already been added, it won't add it twice and will return the configuration
  22314. * already present.
  22315. * @param cfg the effect configuration
  22316. * @return the effect configuration now used by the prepass
  22317. */
  22318. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22319. /**
  22320. * Returns the index of a texture in the multi render target texture array.
  22321. * @param type Texture type
  22322. * @return The index
  22323. */
  22324. getIndex(type: number): number;
  22325. private _enable;
  22326. private _disable;
  22327. private _resetLayout;
  22328. private _resetPostProcessChain;
  22329. private _bindPostProcessChain;
  22330. /**
  22331. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22332. */
  22333. markAsDirty(): void;
  22334. /**
  22335. * Enables a texture on the MultiRenderTarget for prepass
  22336. */
  22337. private _enableTextures;
  22338. private _update;
  22339. private _markAllMaterialsAsPrePassDirty;
  22340. /**
  22341. * Disposes the prepass renderer.
  22342. */
  22343. dispose(): void;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Size options for a post process
  22349. */
  22350. export type PostProcessOptions = {
  22351. width: number;
  22352. height: number;
  22353. };
  22354. /**
  22355. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22356. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22357. */
  22358. export class PostProcess {
  22359. /**
  22360. * Gets or sets the unique id of the post process
  22361. */
  22362. uniqueId: number;
  22363. /** Name of the PostProcess. */
  22364. name: string;
  22365. /**
  22366. * Width of the texture to apply the post process on
  22367. */
  22368. width: number;
  22369. /**
  22370. * Height of the texture to apply the post process on
  22371. */
  22372. height: number;
  22373. /**
  22374. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22375. */
  22376. nodeMaterialSource: Nullable<NodeMaterial>;
  22377. /**
  22378. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22379. * @hidden
  22380. */
  22381. _outputTexture: Nullable<InternalTexture>;
  22382. /**
  22383. * Sampling mode used by the shader
  22384. * See https://doc.babylonjs.com/classes/3.1/texture
  22385. */
  22386. renderTargetSamplingMode: number;
  22387. /**
  22388. * Clear color to use when screen clearing
  22389. */
  22390. clearColor: Color4;
  22391. /**
  22392. * If the buffer needs to be cleared before applying the post process. (default: true)
  22393. * Should be set to false if shader will overwrite all previous pixels.
  22394. */
  22395. autoClear: boolean;
  22396. /**
  22397. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22398. */
  22399. alphaMode: number;
  22400. /**
  22401. * Sets the setAlphaBlendConstants of the babylon engine
  22402. */
  22403. alphaConstants: Color4;
  22404. /**
  22405. * Animations to be used for the post processing
  22406. */
  22407. animations: Animation[];
  22408. /**
  22409. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22410. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22411. */
  22412. enablePixelPerfectMode: boolean;
  22413. /**
  22414. * Force the postprocess to be applied without taking in account viewport
  22415. */
  22416. forceFullscreenViewport: boolean;
  22417. /**
  22418. * List of inspectable custom properties (used by the Inspector)
  22419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22420. */
  22421. inspectableCustomProperties: IInspectable[];
  22422. /**
  22423. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22424. *
  22425. * | Value | Type | Description |
  22426. * | ----- | ----------------------------------- | ----------- |
  22427. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22428. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22429. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22430. *
  22431. */
  22432. scaleMode: number;
  22433. /**
  22434. * Force textures to be a power of two (default: false)
  22435. */
  22436. alwaysForcePOT: boolean;
  22437. private _samples;
  22438. /**
  22439. * Number of sample textures (default: 1)
  22440. */
  22441. get samples(): number;
  22442. set samples(n: number);
  22443. /**
  22444. * Modify the scale of the post process to be the same as the viewport (default: false)
  22445. */
  22446. adaptScaleToCurrentViewport: boolean;
  22447. private _camera;
  22448. protected _scene: Scene;
  22449. private _engine;
  22450. private _options;
  22451. private _reusable;
  22452. private _textureType;
  22453. private _textureFormat;
  22454. /**
  22455. * Smart array of input and output textures for the post process.
  22456. * @hidden
  22457. */
  22458. _textures: SmartArray<InternalTexture>;
  22459. /**
  22460. * The index in _textures that corresponds to the output texture.
  22461. * @hidden
  22462. */
  22463. _currentRenderTextureInd: number;
  22464. private _effect;
  22465. private _samplers;
  22466. private _fragmentUrl;
  22467. private _vertexUrl;
  22468. private _parameters;
  22469. private _scaleRatio;
  22470. protected _indexParameters: any;
  22471. private _shareOutputWithPostProcess;
  22472. private _texelSize;
  22473. private _forcedOutputTexture;
  22474. /**
  22475. * Prepass configuration in case this post process needs a texture from prepass
  22476. * @hidden
  22477. */
  22478. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22479. /**
  22480. * Returns the fragment url or shader name used in the post process.
  22481. * @returns the fragment url or name in the shader store.
  22482. */
  22483. getEffectName(): string;
  22484. /**
  22485. * An event triggered when the postprocess is activated.
  22486. */
  22487. onActivateObservable: Observable<Camera>;
  22488. private _onActivateObserver;
  22489. /**
  22490. * A function that is added to the onActivateObservable
  22491. */
  22492. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22493. /**
  22494. * An event triggered when the postprocess changes its size.
  22495. */
  22496. onSizeChangedObservable: Observable<PostProcess>;
  22497. private _onSizeChangedObserver;
  22498. /**
  22499. * A function that is added to the onSizeChangedObservable
  22500. */
  22501. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22502. /**
  22503. * An event triggered when the postprocess applies its effect.
  22504. */
  22505. onApplyObservable: Observable<Effect>;
  22506. private _onApplyObserver;
  22507. /**
  22508. * A function that is added to the onApplyObservable
  22509. */
  22510. set onApply(callback: (effect: Effect) => void);
  22511. /**
  22512. * An event triggered before rendering the postprocess
  22513. */
  22514. onBeforeRenderObservable: Observable<Effect>;
  22515. private _onBeforeRenderObserver;
  22516. /**
  22517. * A function that is added to the onBeforeRenderObservable
  22518. */
  22519. set onBeforeRender(callback: (effect: Effect) => void);
  22520. /**
  22521. * An event triggered after rendering the postprocess
  22522. */
  22523. onAfterRenderObservable: Observable<Effect>;
  22524. private _onAfterRenderObserver;
  22525. /**
  22526. * A function that is added to the onAfterRenderObservable
  22527. */
  22528. set onAfterRender(callback: (efect: Effect) => void);
  22529. /**
  22530. * 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
  22531. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22532. */
  22533. get inputTexture(): InternalTexture;
  22534. set inputTexture(value: InternalTexture);
  22535. /**
  22536. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22537. * the only way to unset it is to use this function to restore its internal state
  22538. */
  22539. restoreDefaultInputTexture(): void;
  22540. /**
  22541. * Gets the camera which post process is applied to.
  22542. * @returns The camera the post process is applied to.
  22543. */
  22544. getCamera(): Camera;
  22545. /**
  22546. * Gets the texel size of the postprocess.
  22547. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22548. */
  22549. get texelSize(): Vector2;
  22550. /**
  22551. * Creates a new instance PostProcess
  22552. * @param name The name of the PostProcess.
  22553. * @param fragmentUrl The url of the fragment shader to be used.
  22554. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22555. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22556. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22557. * @param camera The camera to apply the render pass to.
  22558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22559. * @param engine The engine which the post process will be applied. (default: current engine)
  22560. * @param reusable If the post process can be reused on the same frame. (default: false)
  22561. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22562. * @param textureType Type of textures used when performing the post process. (default: 0)
  22563. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22564. * @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
  22565. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22566. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22567. */
  22568. 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);
  22569. /**
  22570. * Gets a string identifying the name of the class
  22571. * @returns "PostProcess" string
  22572. */
  22573. getClassName(): string;
  22574. /**
  22575. * Gets the engine which this post process belongs to.
  22576. * @returns The engine the post process was enabled with.
  22577. */
  22578. getEngine(): Engine;
  22579. /**
  22580. * The effect that is created when initializing the post process.
  22581. * @returns The created effect corresponding the the postprocess.
  22582. */
  22583. getEffect(): Effect;
  22584. /**
  22585. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22586. * @param postProcess The post process to share the output with.
  22587. * @returns This post process.
  22588. */
  22589. shareOutputWith(postProcess: PostProcess): PostProcess;
  22590. /**
  22591. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22592. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22593. */
  22594. useOwnOutput(): void;
  22595. /**
  22596. * Updates the effect with the current post process compile time values and recompiles the shader.
  22597. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22598. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22599. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22600. * @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
  22601. * @param onCompiled Called when the shader has been compiled.
  22602. * @param onError Called if there is an error when compiling a shader.
  22603. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22604. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22605. */
  22606. 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;
  22607. /**
  22608. * The post process is reusable if it can be used multiple times within one frame.
  22609. * @returns If the post process is reusable
  22610. */
  22611. isReusable(): boolean;
  22612. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22613. markTextureDirty(): void;
  22614. /**
  22615. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22616. * 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.
  22617. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22618. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22619. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22620. * @returns The target texture that was bound to be written to.
  22621. */
  22622. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22623. /**
  22624. * If the post process is supported.
  22625. */
  22626. get isSupported(): boolean;
  22627. /**
  22628. * The aspect ratio of the output texture.
  22629. */
  22630. get aspectRatio(): number;
  22631. /**
  22632. * Get a value indicating if the post-process is ready to be used
  22633. * @returns true if the post-process is ready (shader is compiled)
  22634. */
  22635. isReady(): boolean;
  22636. /**
  22637. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22638. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22639. */
  22640. apply(): Nullable<Effect>;
  22641. private _disposeTextures;
  22642. /**
  22643. * Sets the required values to the prepass renderer.
  22644. * @param prePassRenderer defines the prepass renderer to setup.
  22645. * @returns true if the pre pass is needed.
  22646. */
  22647. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22648. /**
  22649. * Disposes the post process.
  22650. * @param camera The camera to dispose the post process on.
  22651. */
  22652. dispose(camera?: Camera): void;
  22653. /**
  22654. * Serializes the particle system to a JSON object
  22655. * @returns the JSON object
  22656. */
  22657. serialize(): any;
  22658. /**
  22659. * Creates a material from parsed material data
  22660. * @param parsedPostProcess defines parsed post process data
  22661. * @param scene defines the hosting scene
  22662. * @param rootUrl defines the root URL to use to load textures
  22663. * @returns a new post process
  22664. */
  22665. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22666. }
  22667. }
  22668. declare module BABYLON {
  22669. /** @hidden */
  22670. export var kernelBlurVaryingDeclaration: {
  22671. name: string;
  22672. shader: string;
  22673. };
  22674. }
  22675. declare module BABYLON {
  22676. /** @hidden */
  22677. export var packingFunctions: {
  22678. name: string;
  22679. shader: string;
  22680. };
  22681. }
  22682. declare module BABYLON {
  22683. /** @hidden */
  22684. export var kernelBlurFragment: {
  22685. name: string;
  22686. shader: string;
  22687. };
  22688. }
  22689. declare module BABYLON {
  22690. /** @hidden */
  22691. export var kernelBlurFragment2: {
  22692. name: string;
  22693. shader: string;
  22694. };
  22695. }
  22696. declare module BABYLON {
  22697. /** @hidden */
  22698. export var kernelBlurPixelShader: {
  22699. name: string;
  22700. shader: string;
  22701. };
  22702. }
  22703. declare module BABYLON {
  22704. /** @hidden */
  22705. export var kernelBlurVertex: {
  22706. name: string;
  22707. shader: string;
  22708. };
  22709. }
  22710. declare module BABYLON {
  22711. /** @hidden */
  22712. export var kernelBlurVertexShader: {
  22713. name: string;
  22714. shader: string;
  22715. };
  22716. }
  22717. declare module BABYLON {
  22718. /**
  22719. * The Blur Post Process which blurs an image based on a kernel and direction.
  22720. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22721. */
  22722. export class BlurPostProcess extends PostProcess {
  22723. private blockCompilation;
  22724. protected _kernel: number;
  22725. protected _idealKernel: number;
  22726. protected _packedFloat: boolean;
  22727. private _staticDefines;
  22728. /** The direction in which to blur the image. */
  22729. direction: Vector2;
  22730. /**
  22731. * Sets the length in pixels of the blur sample region
  22732. */
  22733. set kernel(v: number);
  22734. /**
  22735. * Gets the length in pixels of the blur sample region
  22736. */
  22737. get kernel(): number;
  22738. /**
  22739. * Sets wether or not the blur needs to unpack/repack floats
  22740. */
  22741. set packedFloat(v: boolean);
  22742. /**
  22743. * Gets wether or not the blur is unpacking/repacking floats
  22744. */
  22745. get packedFloat(): boolean;
  22746. /**
  22747. * Gets a string identifying the name of the class
  22748. * @returns "BlurPostProcess" string
  22749. */
  22750. getClassName(): string;
  22751. /**
  22752. * Creates a new instance BlurPostProcess
  22753. * @param name The name of the effect.
  22754. * @param direction The direction in which to blur the image.
  22755. * @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.
  22756. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22757. * @param camera The camera to apply the render pass to.
  22758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22759. * @param engine The engine which the post process will be applied. (default: current engine)
  22760. * @param reusable If the post process can be reused on the same frame. (default: false)
  22761. * @param textureType Type of textures used when performing the post process. (default: 0)
  22762. * @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)
  22763. */
  22764. 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);
  22765. /**
  22766. * Updates the effect with the current post process compile time values and recompiles the shader.
  22767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22770. * @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
  22771. * @param onCompiled Called when the shader has been compiled.
  22772. * @param onError Called if there is an error when compiling a shader.
  22773. */
  22774. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22775. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22776. /**
  22777. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22778. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22779. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22780. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22781. * The gaps between physical kernels are compensated for in the weighting of the samples
  22782. * @param idealKernel Ideal blur kernel.
  22783. * @return Nearest best kernel.
  22784. */
  22785. protected _nearestBestKernel(idealKernel: number): number;
  22786. /**
  22787. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22788. * @param x The point on the Gaussian distribution to sample.
  22789. * @return the value of the Gaussian function at x.
  22790. */
  22791. protected _gaussianWeight(x: number): number;
  22792. /**
  22793. * Generates a string that can be used as a floating point number in GLSL.
  22794. * @param x Value to print.
  22795. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22796. * @return GLSL float string.
  22797. */
  22798. protected _glslFloat(x: number, decimalFigures?: number): string;
  22799. /** @hidden */
  22800. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22801. }
  22802. }
  22803. declare module BABYLON {
  22804. /**
  22805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22807. * You can then easily use it as a reflectionTexture on a flat surface.
  22808. * In case the surface is not a plane, please consider relying on reflection probes.
  22809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22810. */
  22811. export class MirrorTexture extends RenderTargetTexture {
  22812. private scene;
  22813. /**
  22814. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22815. * 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.
  22816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22817. */
  22818. mirrorPlane: Plane;
  22819. /**
  22820. * Define the blur ratio used to blur the reflection if needed.
  22821. */
  22822. set blurRatio(value: number);
  22823. get blurRatio(): number;
  22824. /**
  22825. * Define the adaptive blur kernel used to blur the reflection if needed.
  22826. * This will autocompute the closest best match for the `blurKernel`
  22827. */
  22828. set adaptiveBlurKernel(value: number);
  22829. /**
  22830. * Define the blur kernel 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 blurKernel(value: number);
  22834. /**
  22835. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22837. */
  22838. set blurKernelX(value: number);
  22839. get blurKernelX(): number;
  22840. /**
  22841. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22843. */
  22844. set blurKernelY(value: number);
  22845. get blurKernelY(): number;
  22846. private _autoComputeBlurKernel;
  22847. protected _onRatioRescale(): void;
  22848. private _updateGammaSpace;
  22849. private _imageProcessingConfigChangeObserver;
  22850. private _transformMatrix;
  22851. private _mirrorMatrix;
  22852. private _savedViewMatrix;
  22853. private _blurX;
  22854. private _blurY;
  22855. private _adaptiveBlurKernel;
  22856. private _blurKernelX;
  22857. private _blurKernelY;
  22858. private _blurRatio;
  22859. /**
  22860. * Instantiates a Mirror Texture.
  22861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22863. * You can then easily use it as a reflectionTexture on a flat surface.
  22864. * In case the surface is not a plane, please consider relying on reflection probes.
  22865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22866. * @param name
  22867. * @param size
  22868. * @param scene
  22869. * @param generateMipMaps
  22870. * @param type
  22871. * @param samplingMode
  22872. * @param generateDepthBuffer
  22873. */
  22874. constructor(name: string, size: number | {
  22875. width: number;
  22876. height: number;
  22877. } | {
  22878. ratio: number;
  22879. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22880. private _preparePostProcesses;
  22881. /**
  22882. * Clone the mirror texture.
  22883. * @returns the cloned texture
  22884. */
  22885. clone(): MirrorTexture;
  22886. /**
  22887. * Serialize the texture to a JSON representation you could use in Parse later on
  22888. * @returns the serialized JSON representation
  22889. */
  22890. serialize(): any;
  22891. /**
  22892. * Dispose the texture and release its associated resources.
  22893. */
  22894. dispose(): void;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22900. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22901. */
  22902. export class Texture extends BaseTexture {
  22903. /**
  22904. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22905. */
  22906. static SerializeBuffers: boolean;
  22907. /**
  22908. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22909. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22910. */
  22911. static ForceSerializeBuffers: boolean;
  22912. /** @hidden */
  22913. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22914. /** @hidden */
  22915. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22916. /** @hidden */
  22917. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22918. /** nearest is mag = nearest and min = nearest and mip = linear */
  22919. static readonly NEAREST_SAMPLINGMODE: number;
  22920. /** nearest is mag = nearest and min = nearest and mip = linear */
  22921. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22923. static readonly BILINEAR_SAMPLINGMODE: number;
  22924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22925. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22926. /** Trilinear is mag = linear and min = linear and mip = linear */
  22927. static readonly TRILINEAR_SAMPLINGMODE: number;
  22928. /** Trilinear is mag = linear and min = linear and mip = linear */
  22929. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22930. /** mag = nearest and min = nearest and mip = nearest */
  22931. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22932. /** mag = nearest and min = linear and mip = nearest */
  22933. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22934. /** mag = nearest and min = linear and mip = linear */
  22935. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22936. /** mag = nearest and min = linear and mip = none */
  22937. static readonly NEAREST_LINEAR: number;
  22938. /** mag = nearest and min = nearest and mip = none */
  22939. static readonly NEAREST_NEAREST: number;
  22940. /** mag = linear and min = nearest and mip = nearest */
  22941. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22942. /** mag = linear and min = nearest and mip = linear */
  22943. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22944. /** mag = linear and min = linear and mip = none */
  22945. static readonly LINEAR_LINEAR: number;
  22946. /** mag = linear and min = nearest and mip = none */
  22947. static readonly LINEAR_NEAREST: number;
  22948. /** Explicit coordinates mode */
  22949. static readonly EXPLICIT_MODE: number;
  22950. /** Spherical coordinates mode */
  22951. static readonly SPHERICAL_MODE: number;
  22952. /** Planar coordinates mode */
  22953. static readonly PLANAR_MODE: number;
  22954. /** Cubic coordinates mode */
  22955. static readonly CUBIC_MODE: number;
  22956. /** Projection coordinates mode */
  22957. static readonly PROJECTION_MODE: number;
  22958. /** Inverse Cubic coordinates mode */
  22959. static readonly SKYBOX_MODE: number;
  22960. /** Inverse Cubic coordinates mode */
  22961. static readonly INVCUBIC_MODE: number;
  22962. /** Equirectangular coordinates mode */
  22963. static readonly EQUIRECTANGULAR_MODE: number;
  22964. /** Equirectangular Fixed coordinates mode */
  22965. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22966. /** Equirectangular Fixed Mirrored coordinates mode */
  22967. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22968. /** Texture is not repeating outside of 0..1 UVs */
  22969. static readonly CLAMP_ADDRESSMODE: number;
  22970. /** Texture is repeating outside of 0..1 UVs */
  22971. static readonly WRAP_ADDRESSMODE: number;
  22972. /** Texture is repeating and mirrored */
  22973. static readonly MIRROR_ADDRESSMODE: number;
  22974. /**
  22975. * 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
  22976. */
  22977. static UseSerializedUrlIfAny: boolean;
  22978. /**
  22979. * Define the url of the texture.
  22980. */
  22981. url: Nullable<string>;
  22982. /**
  22983. * Define an offset on the texture to offset the u coordinates of the UVs
  22984. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. uOffset: number;
  22987. /**
  22988. * Define an offset on the texture to offset the v coordinates of the UVs
  22989. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22990. */
  22991. vOffset: number;
  22992. /**
  22993. * Define an offset on the texture to scale the u coordinates of the UVs
  22994. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. uScale: number;
  22997. /**
  22998. * Define an offset on the texture to scale the v coordinates of the UVs
  22999. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23000. */
  23001. vScale: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23004. * @see https://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. uAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23009. * @see https://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. vAng: number;
  23012. /**
  23013. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23014. * @see https://doc.babylonjs.com/how_to/more_materials
  23015. */
  23016. wAng: number;
  23017. /**
  23018. * Defines the center of rotation (U)
  23019. */
  23020. uRotationCenter: number;
  23021. /**
  23022. * Defines the center of rotation (V)
  23023. */
  23024. vRotationCenter: number;
  23025. /**
  23026. * Defines the center of rotation (W)
  23027. */
  23028. wRotationCenter: number;
  23029. /**
  23030. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23031. */
  23032. homogeneousRotationInUVTransform: boolean;
  23033. /**
  23034. * Are mip maps generated for this texture or not.
  23035. */
  23036. get noMipmap(): boolean;
  23037. /**
  23038. * List of inspectable custom properties (used by the Inspector)
  23039. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23040. */
  23041. inspectableCustomProperties: Nullable<IInspectable[]>;
  23042. private _noMipmap;
  23043. /** @hidden */
  23044. _invertY: boolean;
  23045. private _rowGenerationMatrix;
  23046. private _cachedTextureMatrix;
  23047. private _projectionModeMatrix;
  23048. private _t0;
  23049. private _t1;
  23050. private _t2;
  23051. private _cachedUOffset;
  23052. private _cachedVOffset;
  23053. private _cachedUScale;
  23054. private _cachedVScale;
  23055. private _cachedUAng;
  23056. private _cachedVAng;
  23057. private _cachedWAng;
  23058. private _cachedProjectionMatrixId;
  23059. private _cachedURotationCenter;
  23060. private _cachedVRotationCenter;
  23061. private _cachedWRotationCenter;
  23062. private _cachedHomogeneousRotationInUVTransform;
  23063. private _cachedCoordinatesMode;
  23064. /** @hidden */
  23065. protected _initialSamplingMode: number;
  23066. /** @hidden */
  23067. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23068. private _deleteBuffer;
  23069. protected _format: Nullable<number>;
  23070. private _delayedOnLoad;
  23071. private _delayedOnError;
  23072. private _mimeType?;
  23073. private _loaderOptions?;
  23074. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23075. get mimeType(): string | undefined;
  23076. /**
  23077. * Observable triggered once the texture has been loaded.
  23078. */
  23079. onLoadObservable: Observable<Texture>;
  23080. protected _isBlocking: boolean;
  23081. /**
  23082. * Is the texture preventing material to render while loading.
  23083. * If false, a default texture will be used instead of the loading one during the preparation step.
  23084. */
  23085. set isBlocking(value: boolean);
  23086. get isBlocking(): boolean;
  23087. /**
  23088. * Get the current sampling mode associated with the texture.
  23089. */
  23090. get samplingMode(): number;
  23091. /**
  23092. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23093. */
  23094. get invertY(): boolean;
  23095. /**
  23096. * Instantiates a new texture.
  23097. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23098. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23099. * @param url defines the url of the picture to load as a texture
  23100. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23101. * @param noMipmap defines if the texture will require mip maps or not
  23102. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23103. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23104. * @param onLoad defines a callback triggered when the texture has been loaded
  23105. * @param onError defines a callback triggered when an error occurred during the loading session
  23106. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23107. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23108. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23109. * @param mimeType defines an optional mime type information
  23110. * @param loaderOptions options to be passed to the loader
  23111. */
  23112. 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);
  23113. /**
  23114. * Update the url (and optional buffer) of this texture if url was null during construction.
  23115. * @param url the url of the texture
  23116. * @param buffer the buffer of the texture (defaults to null)
  23117. * @param onLoad callback called when the texture is loaded (defaults to null)
  23118. */
  23119. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23120. /**
  23121. * Finish the loading sequence of a texture flagged as delayed load.
  23122. * @hidden
  23123. */
  23124. delayLoad(): void;
  23125. private _prepareRowForTextureGeneration;
  23126. /**
  23127. * Checks if the texture has the same transform matrix than another texture
  23128. * @param texture texture to check against
  23129. * @returns true if the transforms are the same, else false
  23130. */
  23131. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23132. /**
  23133. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23134. * @returns the transform matrix of the texture.
  23135. */
  23136. getTextureMatrix(uBase?: number): Matrix;
  23137. /**
  23138. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23139. * @returns The reflection texture transform
  23140. */
  23141. getReflectionTextureMatrix(): Matrix;
  23142. /**
  23143. * Clones the texture.
  23144. * @returns the cloned texture
  23145. */
  23146. clone(): Texture;
  23147. /**
  23148. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23149. * @returns The JSON representation of the texture
  23150. */
  23151. serialize(): any;
  23152. /**
  23153. * Get the current class name of the texture useful for serialization or dynamic coding.
  23154. * @returns "Texture"
  23155. */
  23156. getClassName(): string;
  23157. /**
  23158. * Dispose the texture and release its associated resources.
  23159. */
  23160. dispose(): void;
  23161. /**
  23162. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23163. * @param parsedTexture Define the JSON representation of the texture
  23164. * @param scene Define the scene the parsed texture should be instantiated in
  23165. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23166. * @returns The parsed texture if successful
  23167. */
  23168. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23169. /**
  23170. * Creates a texture from its base 64 representation.
  23171. * @param data Define the base64 payload without the data: prefix
  23172. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23173. * @param scene Define the scene the texture should belong to
  23174. * @param noMipmap Forces the texture to not create mip map information if true
  23175. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23176. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23177. * @param onLoad define a callback triggered when the texture has been loaded
  23178. * @param onError define a callback triggered when an error occurred during the loading session
  23179. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23180. * @returns the created texture
  23181. */
  23182. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23183. /**
  23184. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23185. * @param data Define the base64 payload without the data: prefix
  23186. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23187. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23188. * @param scene Define the scene the texture should belong to
  23189. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23190. * @param noMipmap Forces the texture to not create mip map information if true
  23191. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23192. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23193. * @param onLoad define a callback triggered when the texture has been loaded
  23194. * @param onError define a callback triggered when an error occurred during the loading session
  23195. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23196. * @returns the created texture
  23197. */
  23198. 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;
  23199. }
  23200. }
  23201. declare module BABYLON {
  23202. /**
  23203. * ThinSprite Class used to represent a thin sprite
  23204. * This is the base class for sprites but can also directly be used with ThinEngine
  23205. * @see https://doc.babylonjs.com/babylon101/sprites
  23206. */
  23207. export class ThinSprite {
  23208. /** Gets or sets the cell index in the sprite sheet */
  23209. cellIndex: number;
  23210. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23211. cellRef: string;
  23212. /** Gets or sets the current world position */
  23213. position: IVector3Like;
  23214. /** Gets or sets the main color */
  23215. color: IColor4Like;
  23216. /** Gets or sets the width */
  23217. width: number;
  23218. /** Gets or sets the height */
  23219. height: number;
  23220. /** Gets or sets rotation angle */
  23221. angle: number;
  23222. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23223. invertU: boolean;
  23224. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23225. invertV: boolean;
  23226. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23227. isVisible: boolean;
  23228. /**
  23229. * Returns a boolean indicating if the animation is started
  23230. */
  23231. get animationStarted(): boolean;
  23232. /** Gets the initial key for the animation (setting it will restart the animation) */
  23233. get fromIndex(): number;
  23234. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23235. get toIndex(): number;
  23236. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23237. get loopAnimation(): boolean;
  23238. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23239. get delay(): number;
  23240. /** @hidden */
  23241. _xOffset: number;
  23242. /** @hidden */
  23243. _yOffset: number;
  23244. /** @hidden */
  23245. _xSize: number;
  23246. /** @hidden */
  23247. _ySize: number;
  23248. private _animationStarted;
  23249. protected _loopAnimation: boolean;
  23250. protected _fromIndex: number;
  23251. protected _toIndex: number;
  23252. protected _delay: number;
  23253. private _direction;
  23254. private _time;
  23255. private _onBaseAnimationEnd;
  23256. /**
  23257. * Creates a new Thin Sprite
  23258. */
  23259. constructor();
  23260. /**
  23261. * Starts an animation
  23262. * @param from defines the initial key
  23263. * @param to defines the end key
  23264. * @param loop defines if the animation must loop
  23265. * @param delay defines the start delay (in ms)
  23266. * @param onAnimationEnd defines a callback for when the animation ends
  23267. */
  23268. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23269. /** Stops current animation (if any) */
  23270. stopAnimation(): void;
  23271. /** @hidden */
  23272. _animate(deltaTime: number): void;
  23273. }
  23274. }
  23275. declare module BABYLON {
  23276. /** @hidden */
  23277. export var imageProcessingCompatibility: {
  23278. name: string;
  23279. shader: string;
  23280. };
  23281. }
  23282. declare module BABYLON {
  23283. /** @hidden */
  23284. export var spritesPixelShader: {
  23285. name: string;
  23286. shader: string;
  23287. };
  23288. }
  23289. declare module BABYLON {
  23290. /** @hidden */
  23291. export var spritesVertexShader: {
  23292. name: string;
  23293. shader: string;
  23294. };
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * Class used to render sprites.
  23299. *
  23300. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23301. */
  23302. export class SpriteRenderer {
  23303. /**
  23304. * Defines the texture of the spritesheet
  23305. */
  23306. texture: Nullable<ThinTexture>;
  23307. /**
  23308. * Defines the default width of a cell in the spritesheet
  23309. */
  23310. cellWidth: number;
  23311. /**
  23312. * Defines the default height of a cell in the spritesheet
  23313. */
  23314. cellHeight: number;
  23315. /**
  23316. * Blend mode use to render the particle, it can be any of
  23317. * the static Constants.ALPHA_x properties provided in this class.
  23318. * Default value is Constants.ALPHA_COMBINE
  23319. */
  23320. blendMode: number;
  23321. /**
  23322. * Gets or sets a boolean indicating if alpha mode is automatically
  23323. * reset.
  23324. */
  23325. autoResetAlpha: boolean;
  23326. /**
  23327. * Disables writing to the depth buffer when rendering the sprites.
  23328. * It can be handy to disable depth writing when using textures without alpha channel
  23329. * and setting some specific blend modes.
  23330. */
  23331. disableDepthWrite: boolean;
  23332. /**
  23333. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23334. */
  23335. fogEnabled: boolean;
  23336. /**
  23337. * Gets the capacity of the manager
  23338. */
  23339. get capacity(): number;
  23340. private readonly _engine;
  23341. private readonly _useVAO;
  23342. private readonly _useInstancing;
  23343. private readonly _scene;
  23344. private readonly _capacity;
  23345. private readonly _epsilon;
  23346. private _vertexBufferSize;
  23347. private _vertexData;
  23348. private _buffer;
  23349. private _vertexBuffers;
  23350. private _spriteBuffer;
  23351. private _indexBuffer;
  23352. private _effectBase;
  23353. private _effectFog;
  23354. private _vertexArrayObject;
  23355. /**
  23356. * Creates a new sprite Renderer
  23357. * @param engine defines the engine the renderer works with
  23358. * @param capacity defines the maximum allowed number of sprites
  23359. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23360. * @param scene defines the hosting scene
  23361. */
  23362. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23363. /**
  23364. * Render all child sprites
  23365. * @param sprites defines the list of sprites to render
  23366. * @param deltaTime defines the time since last frame
  23367. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23368. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23369. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23370. */
  23371. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23372. private _appendSpriteVertex;
  23373. /**
  23374. * Release associated resources
  23375. */
  23376. dispose(): void;
  23377. }
  23378. }
  23379. declare module BABYLON {
  23380. /**
  23381. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23382. */
  23383. export interface ISpriteManager extends IDisposable {
  23384. /**
  23385. * Gets manager's name
  23386. */
  23387. name: string;
  23388. /**
  23389. * Restricts the camera to viewing objects with the same layerMask.
  23390. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23391. */
  23392. layerMask: number;
  23393. /**
  23394. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23395. */
  23396. isPickable: boolean;
  23397. /**
  23398. * Gets the hosting scene
  23399. */
  23400. scene: Scene;
  23401. /**
  23402. * Specifies the rendering group id for this mesh (0 by default)
  23403. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23404. */
  23405. renderingGroupId: number;
  23406. /**
  23407. * Defines the list of sprites managed by the manager.
  23408. */
  23409. sprites: Array<Sprite>;
  23410. /**
  23411. * Gets or sets the spritesheet texture
  23412. */
  23413. texture: Texture;
  23414. /** Defines the default width of a cell in the spritesheet */
  23415. cellWidth: number;
  23416. /** Defines the default height of a cell in the spritesheet */
  23417. cellHeight: number;
  23418. /**
  23419. * Tests the intersection of a sprite with a specific ray.
  23420. * @param ray The ray we are sending to test the collision
  23421. * @param camera The camera space we are sending rays in
  23422. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23423. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23424. * @returns picking info or null.
  23425. */
  23426. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23427. /**
  23428. * Intersects the sprites with a ray
  23429. * @param ray defines the ray to intersect with
  23430. * @param camera defines the current active camera
  23431. * @param predicate defines a predicate used to select candidate sprites
  23432. * @returns null if no hit or a PickingInfo array
  23433. */
  23434. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23435. /**
  23436. * Renders the list of sprites on screen.
  23437. */
  23438. render(): void;
  23439. }
  23440. /**
  23441. * Class used to manage multiple sprites on the same spritesheet
  23442. * @see https://doc.babylonjs.com/babylon101/sprites
  23443. */
  23444. export class SpriteManager implements ISpriteManager {
  23445. /** defines the manager's name */
  23446. name: string;
  23447. /** Define the Url to load snippets */
  23448. static SnippetUrl: string;
  23449. /** Snippet ID if the manager was created from the snippet server */
  23450. snippetId: string;
  23451. /** Gets the list of sprites */
  23452. sprites: Sprite[];
  23453. /** Gets or sets the rendering group id (0 by default) */
  23454. renderingGroupId: number;
  23455. /** Gets or sets camera layer mask */
  23456. layerMask: number;
  23457. /** Gets or sets a boolean indicating if the sprites are pickable */
  23458. isPickable: boolean;
  23459. /**
  23460. * An event triggered when the manager is disposed.
  23461. */
  23462. onDisposeObservable: Observable<SpriteManager>;
  23463. /**
  23464. * Callback called when the manager is disposed
  23465. */
  23466. set onDispose(callback: () => void);
  23467. /**
  23468. * Gets or sets the unique id of the sprite
  23469. */
  23470. uniqueId: number;
  23471. /**
  23472. * Gets the array of sprites
  23473. */
  23474. get children(): Sprite[];
  23475. /**
  23476. * Gets the hosting scene
  23477. */
  23478. get scene(): Scene;
  23479. /**
  23480. * Gets the capacity of the manager
  23481. */
  23482. get capacity(): number;
  23483. /**
  23484. * Gets or sets the spritesheet texture
  23485. */
  23486. get texture(): Texture;
  23487. set texture(value: Texture);
  23488. /** Defines the default width of a cell in the spritesheet */
  23489. get cellWidth(): number;
  23490. set cellWidth(value: number);
  23491. /** Defines the default height of a cell in the spritesheet */
  23492. get cellHeight(): number;
  23493. set cellHeight(value: number);
  23494. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23495. get fogEnabled(): boolean;
  23496. set fogEnabled(value: boolean);
  23497. /**
  23498. * Blend mode use to render the particle, it can be any of
  23499. * the static Constants.ALPHA_x properties provided in this class.
  23500. * Default value is Constants.ALPHA_COMBINE
  23501. */
  23502. get blendMode(): number;
  23503. set blendMode(blendMode: number);
  23504. /** Disables writing to the depth buffer when rendering the sprites.
  23505. * It can be handy to disable depth writing when using textures without alpha channel
  23506. * and setting some specific blend modes.
  23507. */
  23508. disableDepthWrite: boolean;
  23509. private _spriteRenderer;
  23510. /** Associative array from JSON sprite data file */
  23511. private _cellData;
  23512. /** Array of sprite names from JSON sprite data file */
  23513. private _spriteMap;
  23514. /** True when packed cell data from JSON file is ready*/
  23515. private _packedAndReady;
  23516. private _textureContent;
  23517. private _onDisposeObserver;
  23518. private _fromPacked;
  23519. private _scene;
  23520. /**
  23521. * Creates a new sprite manager
  23522. * @param name defines the manager's name
  23523. * @param imgUrl defines the sprite sheet url
  23524. * @param capacity defines the maximum allowed number of sprites
  23525. * @param cellSize defines the size of a sprite cell
  23526. * @param scene defines the hosting scene
  23527. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23528. * @param samplingMode defines the smapling mode to use with spritesheet
  23529. * @param fromPacked set to false; do not alter
  23530. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23531. */
  23532. constructor(
  23533. /** defines the manager's name */
  23534. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23535. /**
  23536. * Returns the string "SpriteManager"
  23537. * @returns "SpriteManager"
  23538. */
  23539. getClassName(): string;
  23540. private _makePacked;
  23541. private _checkTextureAlpha;
  23542. /**
  23543. * Intersects the sprites with a ray
  23544. * @param ray defines the ray to intersect with
  23545. * @param camera defines the current active camera
  23546. * @param predicate defines a predicate used to select candidate sprites
  23547. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23548. * @returns null if no hit or a PickingInfo
  23549. */
  23550. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23551. /**
  23552. * Intersects the sprites with a ray
  23553. * @param ray defines the ray to intersect with
  23554. * @param camera defines the current active camera
  23555. * @param predicate defines a predicate used to select candidate sprites
  23556. * @returns null if no hit or a PickingInfo array
  23557. */
  23558. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23559. /**
  23560. * Render all child sprites
  23561. */
  23562. render(): void;
  23563. private _customUpdate;
  23564. /**
  23565. * Release associated resources
  23566. */
  23567. dispose(): void;
  23568. /**
  23569. * Serializes the sprite manager to a JSON object
  23570. * @param serializeTexture defines if the texture must be serialized as well
  23571. * @returns the JSON object
  23572. */
  23573. serialize(serializeTexture?: boolean): any;
  23574. /**
  23575. * Parses a JSON object to create a new sprite manager.
  23576. * @param parsedManager The JSON object to parse
  23577. * @param scene The scene to create the sprite managerin
  23578. * @param rootUrl The root url to use to load external dependencies like texture
  23579. * @returns the new sprite manager
  23580. */
  23581. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23582. /**
  23583. * Creates a sprite manager from a snippet saved in a remote file
  23584. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23585. * @param url defines the url to load from
  23586. * @param scene defines the hosting scene
  23587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23588. * @returns a promise that will resolve to the new sprite manager
  23589. */
  23590. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23591. /**
  23592. * Creates a sprite manager from a snippet saved by the sprite editor
  23593. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23594. * @param scene defines the hosting scene
  23595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23596. * @returns a promise that will resolve to the new sprite manager
  23597. */
  23598. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23599. }
  23600. }
  23601. declare module BABYLON {
  23602. /**
  23603. * Class used to represent a sprite
  23604. * @see https://doc.babylonjs.com/babylon101/sprites
  23605. */
  23606. export class Sprite extends ThinSprite implements IAnimatable {
  23607. /** defines the name */
  23608. name: string;
  23609. /** Gets or sets the current world position */
  23610. position: Vector3;
  23611. /** Gets or sets the main color */
  23612. color: Color4;
  23613. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23614. disposeWhenFinishedAnimating: boolean;
  23615. /** Gets the list of attached animations */
  23616. animations: Nullable<Array<Animation>>;
  23617. /** Gets or sets a boolean indicating if the sprite can be picked */
  23618. isPickable: boolean;
  23619. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23620. useAlphaForPicking: boolean;
  23621. /**
  23622. * Gets or sets the associated action manager
  23623. */
  23624. actionManager: Nullable<ActionManager>;
  23625. /**
  23626. * An event triggered when the control has been disposed
  23627. */
  23628. onDisposeObservable: Observable<Sprite>;
  23629. private _manager;
  23630. private _onAnimationEnd;
  23631. /**
  23632. * Gets or sets the sprite size
  23633. */
  23634. get size(): number;
  23635. set size(value: number);
  23636. /**
  23637. * Gets or sets the unique id of the sprite
  23638. */
  23639. uniqueId: number;
  23640. /**
  23641. * Gets the manager of this sprite
  23642. */
  23643. get manager(): ISpriteManager;
  23644. /**
  23645. * Creates a new Sprite
  23646. * @param name defines the name
  23647. * @param manager defines the manager
  23648. */
  23649. constructor(
  23650. /** defines the name */
  23651. name: string, manager: ISpriteManager);
  23652. /**
  23653. * Returns the string "Sprite"
  23654. * @returns "Sprite"
  23655. */
  23656. getClassName(): string;
  23657. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23658. get fromIndex(): number;
  23659. set fromIndex(value: number);
  23660. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23661. get toIndex(): number;
  23662. set toIndex(value: number);
  23663. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23664. get loopAnimation(): boolean;
  23665. set loopAnimation(value: boolean);
  23666. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23667. get delay(): number;
  23668. set delay(value: number);
  23669. /**
  23670. * Starts an animation
  23671. * @param from defines the initial key
  23672. * @param to defines the end key
  23673. * @param loop defines if the animation must loop
  23674. * @param delay defines the start delay (in ms)
  23675. * @param onAnimationEnd defines a callback to call when animation ends
  23676. */
  23677. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23678. private _endAnimation;
  23679. /** Release associated resources */
  23680. dispose(): void;
  23681. /**
  23682. * Serializes the sprite to a JSON object
  23683. * @returns the JSON object
  23684. */
  23685. serialize(): any;
  23686. /**
  23687. * Parses a JSON object to create a new sprite
  23688. * @param parsedSprite The JSON object to parse
  23689. * @param manager defines the hosting manager
  23690. * @returns the new sprite
  23691. */
  23692. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23693. }
  23694. }
  23695. declare module BABYLON {
  23696. /**
  23697. * Information about the result of picking within a scene
  23698. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23699. */
  23700. export class PickingInfo {
  23701. /** @hidden */
  23702. _pickingUnavailable: boolean;
  23703. /**
  23704. * If the pick collided with an object
  23705. */
  23706. hit: boolean;
  23707. /**
  23708. * Distance away where the pick collided
  23709. */
  23710. distance: number;
  23711. /**
  23712. * The location of pick collision
  23713. */
  23714. pickedPoint: Nullable<Vector3>;
  23715. /**
  23716. * The mesh corresponding the the pick collision
  23717. */
  23718. pickedMesh: Nullable<AbstractMesh>;
  23719. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23720. bu: number;
  23721. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23722. bv: number;
  23723. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23724. faceId: number;
  23725. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23726. subMeshFaceId: number;
  23727. /** Id of the the submesh that was picked */
  23728. subMeshId: number;
  23729. /** If a sprite was picked, this will be the sprite the pick collided with */
  23730. pickedSprite: Nullable<Sprite>;
  23731. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23732. thinInstanceIndex: number;
  23733. /**
  23734. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23735. */
  23736. originMesh: Nullable<AbstractMesh>;
  23737. /**
  23738. * The ray that was used to perform the picking.
  23739. */
  23740. ray: Nullable<Ray>;
  23741. /**
  23742. * Gets the normal correspodning to the face the pick collided with
  23743. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23744. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23745. * @returns The normal correspodning to the face the pick collided with
  23746. */
  23747. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23748. /**
  23749. * Gets the texture coordinates of where the pick occured
  23750. * @returns the vector containing the coordnates of the texture
  23751. */
  23752. getTextureCoordinates(): Nullable<Vector2>;
  23753. }
  23754. }
  23755. declare module BABYLON {
  23756. /**
  23757. * Gather the list of pointer event types as constants.
  23758. */
  23759. export class PointerEventTypes {
  23760. /**
  23761. * 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.
  23762. */
  23763. static readonly POINTERDOWN: number;
  23764. /**
  23765. * The pointerup event is fired when a pointer is no longer active.
  23766. */
  23767. static readonly POINTERUP: number;
  23768. /**
  23769. * The pointermove event is fired when a pointer changes coordinates.
  23770. */
  23771. static readonly POINTERMOVE: number;
  23772. /**
  23773. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23774. */
  23775. static readonly POINTERWHEEL: number;
  23776. /**
  23777. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23778. */
  23779. static readonly POINTERPICK: number;
  23780. /**
  23781. * The pointertap event is fired when a the object has been touched and released without drag.
  23782. */
  23783. static readonly POINTERTAP: number;
  23784. /**
  23785. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23786. */
  23787. static readonly POINTERDOUBLETAP: number;
  23788. }
  23789. /**
  23790. * Base class of pointer info types.
  23791. */
  23792. export class PointerInfoBase {
  23793. /**
  23794. * Defines the type of event (PointerEventTypes)
  23795. */
  23796. type: number;
  23797. /**
  23798. * Defines the related dom event
  23799. */
  23800. event: PointerEvent | MouseWheelEvent;
  23801. /**
  23802. * Instantiates the base class of pointers info.
  23803. * @param type Defines the type of event (PointerEventTypes)
  23804. * @param event Defines the related dom event
  23805. */
  23806. constructor(
  23807. /**
  23808. * Defines the type of event (PointerEventTypes)
  23809. */
  23810. type: number,
  23811. /**
  23812. * Defines the related dom event
  23813. */
  23814. event: PointerEvent | MouseWheelEvent);
  23815. }
  23816. /**
  23817. * This class is used to store pointer related info for the onPrePointerObservable event.
  23818. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23819. */
  23820. export class PointerInfoPre extends PointerInfoBase {
  23821. /**
  23822. * Ray from a pointer if availible (eg. 6dof controller)
  23823. */
  23824. ray: Nullable<Ray>;
  23825. /**
  23826. * Defines the local position of the pointer on the canvas.
  23827. */
  23828. localPosition: Vector2;
  23829. /**
  23830. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23831. */
  23832. skipOnPointerObservable: boolean;
  23833. /**
  23834. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23835. * @param type Defines the type of event (PointerEventTypes)
  23836. * @param event Defines the related dom event
  23837. * @param localX Defines the local x coordinates of the pointer when the event occured
  23838. * @param localY Defines the local y coordinates of the pointer when the event occured
  23839. */
  23840. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23841. }
  23842. /**
  23843. * This type contains all the data related to a pointer event in Babylon.js.
  23844. * 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.
  23845. */
  23846. export class PointerInfo extends PointerInfoBase {
  23847. /**
  23848. * Defines the picking info associated to the info (if any)\
  23849. */
  23850. pickInfo: Nullable<PickingInfo>;
  23851. /**
  23852. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23853. * @param type Defines the type of event (PointerEventTypes)
  23854. * @param event Defines the related dom event
  23855. * @param pickInfo Defines the picking info associated to the info (if any)\
  23856. */
  23857. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23858. /**
  23859. * Defines the picking info associated to the info (if any)\
  23860. */
  23861. pickInfo: Nullable<PickingInfo>);
  23862. }
  23863. /**
  23864. * Data relating to a touch event on the screen.
  23865. */
  23866. export interface PointerTouch {
  23867. /**
  23868. * X coordinate of touch.
  23869. */
  23870. x: number;
  23871. /**
  23872. * Y coordinate of touch.
  23873. */
  23874. y: number;
  23875. /**
  23876. * Id of touch. Unique for each finger.
  23877. */
  23878. pointerId: number;
  23879. /**
  23880. * Event type passed from DOM.
  23881. */
  23882. type: any;
  23883. }
  23884. }
  23885. declare module BABYLON {
  23886. /**
  23887. * Manage the mouse inputs to control the movement of a free camera.
  23888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23889. */
  23890. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23891. /**
  23892. * Define if touch is enabled in the mouse input
  23893. */
  23894. touchEnabled: boolean;
  23895. /**
  23896. * Defines the camera the input is attached to.
  23897. */
  23898. camera: FreeCamera;
  23899. /**
  23900. * Defines the buttons associated with the input to handle camera move.
  23901. */
  23902. buttons: number[];
  23903. /**
  23904. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23905. */
  23906. angularSensibility: number;
  23907. private _pointerInput;
  23908. private _onMouseMove;
  23909. private _observer;
  23910. private previousPosition;
  23911. /**
  23912. * Observable for when a pointer move event occurs containing the move offset
  23913. */
  23914. onPointerMovedObservable: Observable<{
  23915. offsetX: number;
  23916. offsetY: number;
  23917. }>;
  23918. /**
  23919. * @hidden
  23920. * If the camera should be rotated automatically based on pointer movement
  23921. */
  23922. _allowCameraRotation: boolean;
  23923. /**
  23924. * Manage the mouse inputs to control the movement of a free camera.
  23925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23926. * @param touchEnabled Defines if touch is enabled or not
  23927. */
  23928. constructor(
  23929. /**
  23930. * Define if touch is enabled in the mouse input
  23931. */
  23932. touchEnabled?: boolean);
  23933. /**
  23934. * Attach the input controls to a specific dom element to get the input from.
  23935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23936. */
  23937. attachControl(noPreventDefault?: boolean): void;
  23938. /**
  23939. * Called on JS contextmenu event.
  23940. * Override this method to provide functionality.
  23941. */
  23942. protected onContextMenu(evt: PointerEvent): void;
  23943. /**
  23944. * Detach the current controls from the specified dom element.
  23945. */
  23946. detachControl(): void;
  23947. /**
  23948. * Gets the class name of the current intput.
  23949. * @returns the class name
  23950. */
  23951. getClassName(): string;
  23952. /**
  23953. * Get the friendly name associated with the input class.
  23954. * @returns the input friendly name
  23955. */
  23956. getSimpleName(): string;
  23957. }
  23958. }
  23959. declare module BABYLON {
  23960. /**
  23961. * Base class for mouse wheel input..
  23962. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23963. * for example usage.
  23964. */
  23965. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23966. /**
  23967. * Defines the camera the input is attached to.
  23968. */
  23969. abstract camera: Camera;
  23970. /**
  23971. * How fast is the camera moves in relation to X axis mouseWheel events.
  23972. * Use negative value to reverse direction.
  23973. */
  23974. wheelPrecisionX: number;
  23975. /**
  23976. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23977. * Use negative value to reverse direction.
  23978. */
  23979. wheelPrecisionY: number;
  23980. /**
  23981. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23982. * Use negative value to reverse direction.
  23983. */
  23984. wheelPrecisionZ: number;
  23985. /**
  23986. * Observable for when a mouse wheel move event occurs.
  23987. */
  23988. onChangedObservable: Observable<{
  23989. wheelDeltaX: number;
  23990. wheelDeltaY: number;
  23991. wheelDeltaZ: number;
  23992. }>;
  23993. private _wheel;
  23994. private _observer;
  23995. /**
  23996. * Attach the input controls to a specific dom element to get the input from.
  23997. * @param noPreventDefault Defines whether event caught by the controls
  23998. * should call preventdefault().
  23999. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24000. */
  24001. attachControl(noPreventDefault?: boolean): void;
  24002. /**
  24003. * Detach the current controls from the specified dom element.
  24004. */
  24005. detachControl(): void;
  24006. /**
  24007. * Called for each rendered frame.
  24008. */
  24009. checkInputs(): void;
  24010. /**
  24011. * Gets the class name of the current intput.
  24012. * @returns the class name
  24013. */
  24014. getClassName(): string;
  24015. /**
  24016. * Get the friendly name associated with the input class.
  24017. * @returns the input friendly name
  24018. */
  24019. getSimpleName(): string;
  24020. /**
  24021. * Incremental value of multiple mouse wheel movements of the X axis.
  24022. * Should be zero-ed when read.
  24023. */
  24024. protected _wheelDeltaX: number;
  24025. /**
  24026. * Incremental value of multiple mouse wheel movements of the Y axis.
  24027. * Should be zero-ed when read.
  24028. */
  24029. protected _wheelDeltaY: number;
  24030. /**
  24031. * Incremental value of multiple mouse wheel movements of the Z axis.
  24032. * Should be zero-ed when read.
  24033. */
  24034. protected _wheelDeltaZ: number;
  24035. /**
  24036. * Firefox uses a different scheme to report scroll distances to other
  24037. * browsers. Rather than use complicated methods to calculate the exact
  24038. * multiple we need to apply, let's just cheat and use a constant.
  24039. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24040. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24041. */
  24042. private readonly _ffMultiplier;
  24043. /**
  24044. * Different event attributes for wheel data fall into a few set ranges.
  24045. * Some relevant but dated date here:
  24046. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24047. */
  24048. private readonly _normalize;
  24049. }
  24050. }
  24051. declare module BABYLON {
  24052. /**
  24053. * Manage the mouse wheel inputs to control a free camera.
  24054. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24055. */
  24056. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24057. /**
  24058. * Defines the camera the input is attached to.
  24059. */
  24060. camera: FreeCamera;
  24061. /**
  24062. * Gets the class name of the current input.
  24063. * @returns the class name
  24064. */
  24065. getClassName(): string;
  24066. /**
  24067. * Set which movement axis (relative to camera's orientation) the mouse
  24068. * wheel's X axis controls.
  24069. * @param axis The axis to be moved. Set null to clear.
  24070. */
  24071. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24072. /**
  24073. * Get the configured movement axis (relative to camera's orientation) the
  24074. * mouse wheel's X axis controls.
  24075. * @returns The configured axis or null if none.
  24076. */
  24077. get wheelXMoveRelative(): Nullable<Coordinate>;
  24078. /**
  24079. * Set which movement axis (relative to camera's orientation) the mouse
  24080. * wheel's Y axis controls.
  24081. * @param axis The axis to be moved. Set null to clear.
  24082. */
  24083. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24084. /**
  24085. * Get the configured movement axis (relative to camera's orientation) the
  24086. * mouse wheel's Y axis controls.
  24087. * @returns The configured axis or null if none.
  24088. */
  24089. get wheelYMoveRelative(): Nullable<Coordinate>;
  24090. /**
  24091. * Set which movement axis (relative to camera's orientation) the mouse
  24092. * wheel's Z axis controls.
  24093. * @param axis The axis to be moved. Set null to clear.
  24094. */
  24095. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24096. /**
  24097. * Get the configured movement axis (relative to camera's orientation) the
  24098. * mouse wheel's Z axis controls.
  24099. * @returns The configured axis or null if none.
  24100. */
  24101. get wheelZMoveRelative(): Nullable<Coordinate>;
  24102. /**
  24103. * Set which rotation axis (relative to camera's orientation) the mouse
  24104. * wheel's X axis controls.
  24105. * @param axis The axis to be moved. Set null to clear.
  24106. */
  24107. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24108. /**
  24109. * Get the configured rotation axis (relative to camera's orientation) the
  24110. * mouse wheel's X axis controls.
  24111. * @returns The configured axis or null if none.
  24112. */
  24113. get wheelXRotateRelative(): Nullable<Coordinate>;
  24114. /**
  24115. * Set which rotation axis (relative to camera's orientation) the mouse
  24116. * wheel's Y axis controls.
  24117. * @param axis The axis to be moved. Set null to clear.
  24118. */
  24119. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24120. /**
  24121. * Get the configured rotation axis (relative to camera's orientation) the
  24122. * mouse wheel's Y axis controls.
  24123. * @returns The configured axis or null if none.
  24124. */
  24125. get wheelYRotateRelative(): Nullable<Coordinate>;
  24126. /**
  24127. * Set which rotation axis (relative to camera's orientation) the mouse
  24128. * wheel's Z axis controls.
  24129. * @param axis The axis to be moved. Set null to clear.
  24130. */
  24131. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24132. /**
  24133. * Get the configured rotation axis (relative to camera's orientation) the
  24134. * mouse wheel's Z axis controls.
  24135. * @returns The configured axis or null if none.
  24136. */
  24137. get wheelZRotateRelative(): Nullable<Coordinate>;
  24138. /**
  24139. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24140. * controls.
  24141. * @param axis The axis to be moved. Set null to clear.
  24142. */
  24143. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24144. /**
  24145. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24146. * X axis controls.
  24147. * @returns The configured axis or null if none.
  24148. */
  24149. get wheelXMoveScene(): Nullable<Coordinate>;
  24150. /**
  24151. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24152. * controls.
  24153. * @param axis The axis to be moved. Set null to clear.
  24154. */
  24155. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24156. /**
  24157. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24158. * Y axis controls.
  24159. * @returns The configured axis or null if none.
  24160. */
  24161. get wheelYMoveScene(): Nullable<Coordinate>;
  24162. /**
  24163. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24164. * controls.
  24165. * @param axis The axis to be moved. Set null to clear.
  24166. */
  24167. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24168. /**
  24169. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24170. * Z axis controls.
  24171. * @returns The configured axis or null if none.
  24172. */
  24173. get wheelZMoveScene(): Nullable<Coordinate>;
  24174. /**
  24175. * Called for each rendered frame.
  24176. */
  24177. checkInputs(): void;
  24178. private _moveRelative;
  24179. private _rotateRelative;
  24180. private _moveScene;
  24181. /**
  24182. * These are set to the desired default behaviour.
  24183. */
  24184. private _wheelXAction;
  24185. private _wheelXActionCoordinate;
  24186. private _wheelYAction;
  24187. private _wheelYActionCoordinate;
  24188. private _wheelZAction;
  24189. private _wheelZActionCoordinate;
  24190. /**
  24191. * Update the camera according to any configured properties for the 3
  24192. * mouse-wheel axis.
  24193. */
  24194. private _updateCamera;
  24195. }
  24196. }
  24197. declare module BABYLON {
  24198. /**
  24199. * Manage the touch inputs to control the movement of a free camera.
  24200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24201. */
  24202. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24203. /**
  24204. * Define if mouse events can be treated as touch events
  24205. */
  24206. allowMouse: boolean;
  24207. /**
  24208. * Defines the camera the input is attached to.
  24209. */
  24210. camera: FreeCamera;
  24211. /**
  24212. * Defines the touch sensibility for rotation.
  24213. * The higher the faster.
  24214. */
  24215. touchAngularSensibility: number;
  24216. /**
  24217. * Defines the touch sensibility for move.
  24218. * The higher the faster.
  24219. */
  24220. touchMoveSensibility: number;
  24221. private _offsetX;
  24222. private _offsetY;
  24223. private _pointerPressed;
  24224. private _pointerInput?;
  24225. private _observer;
  24226. private _onLostFocus;
  24227. /**
  24228. * Manage the touch inputs to control the movement of a free camera.
  24229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24230. * @param allowMouse Defines if mouse events can be treated as touch events
  24231. */
  24232. constructor(
  24233. /**
  24234. * Define if mouse events can be treated as touch events
  24235. */
  24236. allowMouse?: boolean);
  24237. /**
  24238. * Attach the input controls to a specific dom element to get the input from.
  24239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24240. */
  24241. attachControl(noPreventDefault?: boolean): void;
  24242. /**
  24243. * Detach the current controls from the specified dom element.
  24244. */
  24245. detachControl(): void;
  24246. /**
  24247. * Update the current camera state depending on the inputs that have been used this frame.
  24248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24249. */
  24250. checkInputs(): void;
  24251. /**
  24252. * Gets the class name of the current intput.
  24253. * @returns the class name
  24254. */
  24255. getClassName(): string;
  24256. /**
  24257. * Get the friendly name associated with the input class.
  24258. * @returns the input friendly name
  24259. */
  24260. getSimpleName(): string;
  24261. }
  24262. }
  24263. declare module BABYLON {
  24264. /**
  24265. * Default Inputs manager for the FreeCamera.
  24266. * It groups all the default supported inputs for ease of use.
  24267. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24268. */
  24269. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24270. /**
  24271. * @hidden
  24272. */
  24273. _mouseInput: Nullable<FreeCameraMouseInput>;
  24274. /**
  24275. * @hidden
  24276. */
  24277. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24278. /**
  24279. * Instantiates a new FreeCameraInputsManager.
  24280. * @param camera Defines the camera the inputs belong to
  24281. */
  24282. constructor(camera: FreeCamera);
  24283. /**
  24284. * Add keyboard input support to the input manager.
  24285. * @returns the current input manager
  24286. */
  24287. addKeyboard(): FreeCameraInputsManager;
  24288. /**
  24289. * Add mouse input support to the input manager.
  24290. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24291. * @returns the current input manager
  24292. */
  24293. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24294. /**
  24295. * Removes the mouse input support from the manager
  24296. * @returns the current input manager
  24297. */
  24298. removeMouse(): FreeCameraInputsManager;
  24299. /**
  24300. * Add mouse wheel input support to the input manager.
  24301. * @returns the current input manager
  24302. */
  24303. addMouseWheel(): FreeCameraInputsManager;
  24304. /**
  24305. * Removes the mouse wheel input support from the manager
  24306. * @returns the current input manager
  24307. */
  24308. removeMouseWheel(): FreeCameraInputsManager;
  24309. /**
  24310. * Add touch input support to the input manager.
  24311. * @returns the current input manager
  24312. */
  24313. addTouch(): FreeCameraInputsManager;
  24314. /**
  24315. * Remove all attached input methods from a camera
  24316. */
  24317. clear(): void;
  24318. }
  24319. }
  24320. declare module BABYLON {
  24321. /**
  24322. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24323. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24324. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24325. */
  24326. export class FreeCamera extends TargetCamera {
  24327. /**
  24328. * Define the collision ellipsoid of the camera.
  24329. * This is helpful to simulate a camera body like the player body around the camera
  24330. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24331. */
  24332. ellipsoid: Vector3;
  24333. /**
  24334. * Define an offset for the position of the ellipsoid around the camera.
  24335. * This can be helpful to determine the center of the body near the gravity center of the body
  24336. * instead of its head.
  24337. */
  24338. ellipsoidOffset: Vector3;
  24339. /**
  24340. * Enable or disable collisions of the camera with the rest of the scene objects.
  24341. */
  24342. checkCollisions: boolean;
  24343. /**
  24344. * Enable or disable gravity on the camera.
  24345. */
  24346. applyGravity: boolean;
  24347. /**
  24348. * Define the input manager associated to the camera.
  24349. */
  24350. inputs: FreeCameraInputsManager;
  24351. /**
  24352. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24353. * Higher values reduce sensitivity.
  24354. */
  24355. get angularSensibility(): number;
  24356. /**
  24357. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24358. * Higher values reduce sensitivity.
  24359. */
  24360. set angularSensibility(value: number);
  24361. /**
  24362. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24363. */
  24364. get keysUp(): number[];
  24365. set keysUp(value: number[]);
  24366. /**
  24367. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24368. */
  24369. get keysUpward(): number[];
  24370. set keysUpward(value: number[]);
  24371. /**
  24372. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24373. */
  24374. get keysDown(): number[];
  24375. set keysDown(value: number[]);
  24376. /**
  24377. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24378. */
  24379. get keysDownward(): number[];
  24380. set keysDownward(value: number[]);
  24381. /**
  24382. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24383. */
  24384. get keysLeft(): number[];
  24385. set keysLeft(value: number[]);
  24386. /**
  24387. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24388. */
  24389. get keysRight(): number[];
  24390. set keysRight(value: number[]);
  24391. /**
  24392. * Event raised when the camera collide with a mesh in the scene.
  24393. */
  24394. onCollide: (collidedMesh: AbstractMesh) => void;
  24395. private _collider;
  24396. private _needMoveForGravity;
  24397. private _oldPosition;
  24398. private _diffPosition;
  24399. private _newPosition;
  24400. /** @hidden */
  24401. _localDirection: Vector3;
  24402. /** @hidden */
  24403. _transformedDirection: Vector3;
  24404. /**
  24405. * Instantiates a Free Camera.
  24406. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24407. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24408. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24409. * @param name Define the name of the camera in the scene
  24410. * @param position Define the start position of the camera in the scene
  24411. * @param scene Define the scene the camera belongs to
  24412. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24413. */
  24414. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24415. /**
  24416. * Attach the input controls to a specific dom element to get the input from.
  24417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24418. */
  24419. attachControl(noPreventDefault?: boolean): void;
  24420. /**
  24421. * Attach the input controls to a specific dom element to get the input from.
  24422. * @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
  24423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24424. * BACK COMPAT SIGNATURE ONLY.
  24425. */
  24426. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24427. /**
  24428. * Detach the current controls from the specified dom element.
  24429. */
  24430. detachControl(): void;
  24431. /**
  24432. * Detach the current controls from the specified dom element.
  24433. * @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
  24434. */
  24435. detachControl(ignored: any): void;
  24436. private _collisionMask;
  24437. /**
  24438. * Define a collision mask to limit the list of object the camera can collide with
  24439. */
  24440. get collisionMask(): number;
  24441. set collisionMask(mask: number);
  24442. /** @hidden */
  24443. _collideWithWorld(displacement: Vector3): void;
  24444. private _onCollisionPositionChange;
  24445. /** @hidden */
  24446. _checkInputs(): void;
  24447. /** @hidden */
  24448. _decideIfNeedsToMove(): boolean;
  24449. /** @hidden */
  24450. _updatePosition(): void;
  24451. /**
  24452. * Destroy the camera and release the current resources hold by it.
  24453. */
  24454. dispose(): void;
  24455. /**
  24456. * Gets the current object class name.
  24457. * @return the class name
  24458. */
  24459. getClassName(): string;
  24460. }
  24461. }
  24462. declare module BABYLON {
  24463. /**
  24464. * Represents a gamepad control stick position
  24465. */
  24466. export class StickValues {
  24467. /**
  24468. * The x component of the control stick
  24469. */
  24470. x: number;
  24471. /**
  24472. * The y component of the control stick
  24473. */
  24474. y: number;
  24475. /**
  24476. * Initializes the gamepad x and y control stick values
  24477. * @param x The x component of the gamepad control stick value
  24478. * @param y The y component of the gamepad control stick value
  24479. */
  24480. constructor(
  24481. /**
  24482. * The x component of the control stick
  24483. */
  24484. x: number,
  24485. /**
  24486. * The y component of the control stick
  24487. */
  24488. y: number);
  24489. }
  24490. /**
  24491. * An interface which manages callbacks for gamepad button changes
  24492. */
  24493. export interface GamepadButtonChanges {
  24494. /**
  24495. * Called when a gamepad has been changed
  24496. */
  24497. changed: boolean;
  24498. /**
  24499. * Called when a gamepad press event has been triggered
  24500. */
  24501. pressChanged: boolean;
  24502. /**
  24503. * Called when a touch event has been triggered
  24504. */
  24505. touchChanged: boolean;
  24506. /**
  24507. * Called when a value has changed
  24508. */
  24509. valueChanged: boolean;
  24510. }
  24511. /**
  24512. * Represents a gamepad
  24513. */
  24514. export class Gamepad {
  24515. /**
  24516. * The id of the gamepad
  24517. */
  24518. id: string;
  24519. /**
  24520. * The index of the gamepad
  24521. */
  24522. index: number;
  24523. /**
  24524. * The browser gamepad
  24525. */
  24526. browserGamepad: any;
  24527. /**
  24528. * Specifies what type of gamepad this represents
  24529. */
  24530. type: number;
  24531. private _leftStick;
  24532. private _rightStick;
  24533. /** @hidden */
  24534. _isConnected: boolean;
  24535. private _leftStickAxisX;
  24536. private _leftStickAxisY;
  24537. private _rightStickAxisX;
  24538. private _rightStickAxisY;
  24539. /**
  24540. * Triggered when the left control stick has been changed
  24541. */
  24542. private _onleftstickchanged;
  24543. /**
  24544. * Triggered when the right control stick has been changed
  24545. */
  24546. private _onrightstickchanged;
  24547. /**
  24548. * Represents a gamepad controller
  24549. */
  24550. static GAMEPAD: number;
  24551. /**
  24552. * Represents a generic controller
  24553. */
  24554. static GENERIC: number;
  24555. /**
  24556. * Represents an XBox controller
  24557. */
  24558. static XBOX: number;
  24559. /**
  24560. * Represents a pose-enabled controller
  24561. */
  24562. static POSE_ENABLED: number;
  24563. /**
  24564. * Represents an Dual Shock controller
  24565. */
  24566. static DUALSHOCK: number;
  24567. /**
  24568. * Specifies whether the left control stick should be Y-inverted
  24569. */
  24570. protected _invertLeftStickY: boolean;
  24571. /**
  24572. * Specifies if the gamepad has been connected
  24573. */
  24574. get isConnected(): boolean;
  24575. /**
  24576. * Initializes the gamepad
  24577. * @param id The id of the gamepad
  24578. * @param index The index of the gamepad
  24579. * @param browserGamepad The browser gamepad
  24580. * @param leftStickX The x component of the left joystick
  24581. * @param leftStickY The y component of the left joystick
  24582. * @param rightStickX The x component of the right joystick
  24583. * @param rightStickY The y component of the right joystick
  24584. */
  24585. constructor(
  24586. /**
  24587. * The id of the gamepad
  24588. */
  24589. id: string,
  24590. /**
  24591. * The index of the gamepad
  24592. */
  24593. index: number,
  24594. /**
  24595. * The browser gamepad
  24596. */
  24597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24598. /**
  24599. * Callback triggered when the left joystick has changed
  24600. * @param callback
  24601. */
  24602. onleftstickchanged(callback: (values: StickValues) => void): void;
  24603. /**
  24604. * Callback triggered when the right joystick has changed
  24605. * @param callback
  24606. */
  24607. onrightstickchanged(callback: (values: StickValues) => void): void;
  24608. /**
  24609. * Gets the left joystick
  24610. */
  24611. get leftStick(): StickValues;
  24612. /**
  24613. * Sets the left joystick values
  24614. */
  24615. set leftStick(newValues: StickValues);
  24616. /**
  24617. * Gets the right joystick
  24618. */
  24619. get rightStick(): StickValues;
  24620. /**
  24621. * Sets the right joystick value
  24622. */
  24623. set rightStick(newValues: StickValues);
  24624. /**
  24625. * Updates the gamepad joystick positions
  24626. */
  24627. update(): void;
  24628. /**
  24629. * Disposes the gamepad
  24630. */
  24631. dispose(): void;
  24632. }
  24633. /**
  24634. * Represents a generic gamepad
  24635. */
  24636. export class GenericPad extends Gamepad {
  24637. private _buttons;
  24638. private _onbuttondown;
  24639. private _onbuttonup;
  24640. /**
  24641. * Observable triggered when a button has been pressed
  24642. */
  24643. onButtonDownObservable: Observable<number>;
  24644. /**
  24645. * Observable triggered when a button has been released
  24646. */
  24647. onButtonUpObservable: Observable<number>;
  24648. /**
  24649. * Callback triggered when a button has been pressed
  24650. * @param callback Called when a button has been pressed
  24651. */
  24652. onbuttondown(callback: (buttonPressed: number) => void): void;
  24653. /**
  24654. * Callback triggered when a button has been released
  24655. * @param callback Called when a button has been released
  24656. */
  24657. onbuttonup(callback: (buttonReleased: number) => void): void;
  24658. /**
  24659. * Initializes the generic gamepad
  24660. * @param id The id of the generic gamepad
  24661. * @param index The index of the generic gamepad
  24662. * @param browserGamepad The browser gamepad
  24663. */
  24664. constructor(id: string, index: number, browserGamepad: any);
  24665. private _setButtonValue;
  24666. /**
  24667. * Updates the generic gamepad
  24668. */
  24669. update(): void;
  24670. /**
  24671. * Disposes the generic gamepad
  24672. */
  24673. dispose(): void;
  24674. }
  24675. }
  24676. declare module BABYLON {
  24677. /**
  24678. * Defines a runtime animation
  24679. */
  24680. export class RuntimeAnimation {
  24681. private _events;
  24682. /**
  24683. * The current frame of the runtime animation
  24684. */
  24685. private _currentFrame;
  24686. /**
  24687. * The animation used by the runtime animation
  24688. */
  24689. private _animation;
  24690. /**
  24691. * The target of the runtime animation
  24692. */
  24693. private _target;
  24694. /**
  24695. * The initiating animatable
  24696. */
  24697. private _host;
  24698. /**
  24699. * The original value of the runtime animation
  24700. */
  24701. private _originalValue;
  24702. /**
  24703. * The original blend value of the runtime animation
  24704. */
  24705. private _originalBlendValue;
  24706. /**
  24707. * The offsets cache of the runtime animation
  24708. */
  24709. private _offsetsCache;
  24710. /**
  24711. * The high limits cache of the runtime animation
  24712. */
  24713. private _highLimitsCache;
  24714. /**
  24715. * Specifies if the runtime animation has been stopped
  24716. */
  24717. private _stopped;
  24718. /**
  24719. * The blending factor of the runtime animation
  24720. */
  24721. private _blendingFactor;
  24722. /**
  24723. * The BabylonJS scene
  24724. */
  24725. private _scene;
  24726. /**
  24727. * The current value of the runtime animation
  24728. */
  24729. private _currentValue;
  24730. /** @hidden */
  24731. _animationState: _IAnimationState;
  24732. /**
  24733. * The active target of the runtime animation
  24734. */
  24735. private _activeTargets;
  24736. private _currentActiveTarget;
  24737. private _directTarget;
  24738. /**
  24739. * The target path of the runtime animation
  24740. */
  24741. private _targetPath;
  24742. /**
  24743. * The weight of the runtime animation
  24744. */
  24745. private _weight;
  24746. /**
  24747. * The ratio offset of the runtime animation
  24748. */
  24749. private _ratioOffset;
  24750. /**
  24751. * The previous delay of the runtime animation
  24752. */
  24753. private _previousDelay;
  24754. /**
  24755. * The previous ratio of the runtime animation
  24756. */
  24757. private _previousRatio;
  24758. private _enableBlending;
  24759. private _keys;
  24760. private _minFrame;
  24761. private _maxFrame;
  24762. private _minValue;
  24763. private _maxValue;
  24764. private _targetIsArray;
  24765. /**
  24766. * Gets the current frame of the runtime animation
  24767. */
  24768. get currentFrame(): number;
  24769. /**
  24770. * Gets the weight of the runtime animation
  24771. */
  24772. get weight(): number;
  24773. /**
  24774. * Gets the current value of the runtime animation
  24775. */
  24776. get currentValue(): any;
  24777. /**
  24778. * Gets the target path of the runtime animation
  24779. */
  24780. get targetPath(): string;
  24781. /**
  24782. * Gets the actual target of the runtime animation
  24783. */
  24784. get target(): any;
  24785. /**
  24786. * Gets the additive state of the runtime animation
  24787. */
  24788. get isAdditive(): boolean;
  24789. /** @hidden */
  24790. _onLoop: () => void;
  24791. /**
  24792. * Create a new RuntimeAnimation object
  24793. * @param target defines the target of the animation
  24794. * @param animation defines the source animation object
  24795. * @param scene defines the hosting scene
  24796. * @param host defines the initiating Animatable
  24797. */
  24798. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24799. private _preparePath;
  24800. /**
  24801. * Gets the animation from the runtime animation
  24802. */
  24803. get animation(): Animation;
  24804. /**
  24805. * Resets the runtime animation to the beginning
  24806. * @param restoreOriginal defines whether to restore the target property to the original value
  24807. */
  24808. reset(restoreOriginal?: boolean): void;
  24809. /**
  24810. * Specifies if the runtime animation is stopped
  24811. * @returns Boolean specifying if the runtime animation is stopped
  24812. */
  24813. isStopped(): boolean;
  24814. /**
  24815. * Disposes of the runtime animation
  24816. */
  24817. dispose(): void;
  24818. /**
  24819. * Apply the interpolated value to the target
  24820. * @param currentValue defines the value computed by the animation
  24821. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24822. */
  24823. setValue(currentValue: any, weight: number): void;
  24824. private _getOriginalValues;
  24825. private _setValue;
  24826. /**
  24827. * Gets the loop pmode of the runtime animation
  24828. * @returns Loop Mode
  24829. */
  24830. private _getCorrectLoopMode;
  24831. /**
  24832. * Move the current animation to a given frame
  24833. * @param frame defines the frame to move to
  24834. */
  24835. goToFrame(frame: number): void;
  24836. /**
  24837. * @hidden Internal use only
  24838. */
  24839. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24840. /**
  24841. * Execute the current animation
  24842. * @param delay defines the delay to add to the current frame
  24843. * @param from defines the lower bound of the animation range
  24844. * @param to defines the upper bound of the animation range
  24845. * @param loop defines if the current animation must loop
  24846. * @param speedRatio defines the current speed ratio
  24847. * @param weight defines the weight of the animation (default is -1 so no weight)
  24848. * @param onLoop optional callback called when animation loops
  24849. * @returns a boolean indicating if the animation is running
  24850. */
  24851. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24852. }
  24853. }
  24854. declare module BABYLON {
  24855. /**
  24856. * Class used to store an actual running animation
  24857. */
  24858. export class Animatable {
  24859. /** defines the target object */
  24860. target: any;
  24861. /** defines the starting frame number (default is 0) */
  24862. fromFrame: number;
  24863. /** defines the ending frame number (default is 100) */
  24864. toFrame: number;
  24865. /** defines if the animation must loop (default is false) */
  24866. loopAnimation: boolean;
  24867. /** defines a callback to call when animation ends if it is not looping */
  24868. onAnimationEnd?: (() => void) | null | undefined;
  24869. /** defines a callback to call when animation loops */
  24870. onAnimationLoop?: (() => void) | null | undefined;
  24871. /** defines whether the animation should be evaluated additively */
  24872. isAdditive: boolean;
  24873. private _localDelayOffset;
  24874. private _pausedDelay;
  24875. private _runtimeAnimations;
  24876. private _paused;
  24877. private _scene;
  24878. private _speedRatio;
  24879. private _weight;
  24880. private _syncRoot;
  24881. /**
  24882. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24883. * This will only apply for non looping animation (default is true)
  24884. */
  24885. disposeOnEnd: boolean;
  24886. /**
  24887. * Gets a boolean indicating if the animation has started
  24888. */
  24889. animationStarted: boolean;
  24890. /**
  24891. * Observer raised when the animation ends
  24892. */
  24893. onAnimationEndObservable: Observable<Animatable>;
  24894. /**
  24895. * Observer raised when the animation loops
  24896. */
  24897. onAnimationLoopObservable: Observable<Animatable>;
  24898. /**
  24899. * Gets the root Animatable used to synchronize and normalize animations
  24900. */
  24901. get syncRoot(): Nullable<Animatable>;
  24902. /**
  24903. * Gets the current frame of the first RuntimeAnimation
  24904. * Used to synchronize Animatables
  24905. */
  24906. get masterFrame(): number;
  24907. /**
  24908. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24909. */
  24910. get weight(): number;
  24911. set weight(value: number);
  24912. /**
  24913. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24914. */
  24915. get speedRatio(): number;
  24916. set speedRatio(value: number);
  24917. /**
  24918. * Creates a new Animatable
  24919. * @param scene defines the hosting scene
  24920. * @param target defines the target object
  24921. * @param fromFrame defines the starting frame number (default is 0)
  24922. * @param toFrame defines the ending frame number (default is 100)
  24923. * @param loopAnimation defines if the animation must loop (default is false)
  24924. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24925. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24926. * @param animations defines a group of animation to add to the new Animatable
  24927. * @param onAnimationLoop defines a callback to call when animation loops
  24928. * @param isAdditive defines whether the animation should be evaluated additively
  24929. */
  24930. constructor(scene: Scene,
  24931. /** defines the target object */
  24932. target: any,
  24933. /** defines the starting frame number (default is 0) */
  24934. fromFrame?: number,
  24935. /** defines the ending frame number (default is 100) */
  24936. toFrame?: number,
  24937. /** defines if the animation must loop (default is false) */
  24938. loopAnimation?: boolean, speedRatio?: number,
  24939. /** defines a callback to call when animation ends if it is not looping */
  24940. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24941. /** defines a callback to call when animation loops */
  24942. onAnimationLoop?: (() => void) | null | undefined,
  24943. /** defines whether the animation should be evaluated additively */
  24944. isAdditive?: boolean);
  24945. /**
  24946. * Synchronize and normalize current Animatable with a source Animatable
  24947. * This is useful when using animation weights and when animations are not of the same length
  24948. * @param root defines the root Animatable to synchronize with
  24949. * @returns the current Animatable
  24950. */
  24951. syncWith(root: Animatable): Animatable;
  24952. /**
  24953. * Gets the list of runtime animations
  24954. * @returns an array of RuntimeAnimation
  24955. */
  24956. getAnimations(): RuntimeAnimation[];
  24957. /**
  24958. * Adds more animations to the current animatable
  24959. * @param target defines the target of the animations
  24960. * @param animations defines the new animations to add
  24961. */
  24962. appendAnimations(target: any, animations: Animation[]): void;
  24963. /**
  24964. * Gets the source animation for a specific property
  24965. * @param property defines the propertyu to look for
  24966. * @returns null or the source animation for the given property
  24967. */
  24968. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24969. /**
  24970. * Gets the runtime animation for a specific property
  24971. * @param property defines the propertyu to look for
  24972. * @returns null or the runtime animation for the given property
  24973. */
  24974. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24975. /**
  24976. * Resets the animatable to its original state
  24977. */
  24978. reset(): void;
  24979. /**
  24980. * Allows the animatable to blend with current running animations
  24981. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24982. * @param blendingSpeed defines the blending speed to use
  24983. */
  24984. enableBlending(blendingSpeed: number): void;
  24985. /**
  24986. * Disable animation blending
  24987. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24988. */
  24989. disableBlending(): void;
  24990. /**
  24991. * Jump directly to a given frame
  24992. * @param frame defines the frame to jump to
  24993. */
  24994. goToFrame(frame: number): void;
  24995. /**
  24996. * Pause the animation
  24997. */
  24998. pause(): void;
  24999. /**
  25000. * Restart the animation
  25001. */
  25002. restart(): void;
  25003. private _raiseOnAnimationEnd;
  25004. /**
  25005. * Stop and delete the current animation
  25006. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25007. * @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)
  25008. */
  25009. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25010. /**
  25011. * Wait asynchronously for the animation to end
  25012. * @returns a promise which will be fullfilled when the animation ends
  25013. */
  25014. waitAsync(): Promise<Animatable>;
  25015. /** @hidden */
  25016. _animate(delay: number): boolean;
  25017. }
  25018. interface Scene {
  25019. /** @hidden */
  25020. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25021. /** @hidden */
  25022. _processLateAnimationBindingsForMatrices(holder: {
  25023. totalWeight: number;
  25024. totalAdditiveWeight: number;
  25025. animations: RuntimeAnimation[];
  25026. additiveAnimations: RuntimeAnimation[];
  25027. originalValue: Matrix;
  25028. }): any;
  25029. /** @hidden */
  25030. _processLateAnimationBindingsForQuaternions(holder: {
  25031. totalWeight: number;
  25032. totalAdditiveWeight: number;
  25033. animations: RuntimeAnimation[];
  25034. additiveAnimations: RuntimeAnimation[];
  25035. originalValue: Quaternion;
  25036. }, refQuaternion: Quaternion): Quaternion;
  25037. /** @hidden */
  25038. _processLateAnimationBindings(): void;
  25039. /**
  25040. * Will start the animation sequence of a given target
  25041. * @param target defines the target
  25042. * @param from defines from which frame should animation start
  25043. * @param to defines until which frame should animation run.
  25044. * @param weight defines the weight to apply to the animation (1.0 by default)
  25045. * @param loop defines if the animation loops
  25046. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25047. * @param onAnimationEnd defines the function to be executed when the animation ends
  25048. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25049. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25050. * @param onAnimationLoop defines the callback to call when an animation loops
  25051. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25052. * @returns the animatable object created for this animation
  25053. */
  25054. 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;
  25055. /**
  25056. * Will start the animation sequence of a given target
  25057. * @param target defines the target
  25058. * @param from defines from which frame should animation start
  25059. * @param to defines until which frame should animation run.
  25060. * @param loop defines if the animation loops
  25061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25062. * @param onAnimationEnd defines the function to be executed when the animation ends
  25063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25065. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25066. * @param onAnimationLoop defines the callback to call when an animation loops
  25067. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25068. * @returns the animatable object created for this animation
  25069. */
  25070. 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;
  25071. /**
  25072. * Will start the animation sequence of a given target and its hierarchy
  25073. * @param target defines the target
  25074. * @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.
  25075. * @param from defines from which frame should animation start
  25076. * @param to defines until which frame should animation run.
  25077. * @param loop defines if the animation loops
  25078. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25079. * @param onAnimationEnd defines the function to be executed when the animation ends
  25080. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25081. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25082. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25083. * @param onAnimationLoop defines the callback to call when an animation loops
  25084. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25085. * @returns the list of created animatables
  25086. */
  25087. 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[];
  25088. /**
  25089. * Begin a new animation on a given node
  25090. * @param target defines the target where the animation will take place
  25091. * @param animations defines the list of animations to start
  25092. * @param from defines the initial value
  25093. * @param to defines the final value
  25094. * @param loop defines if you want animation to loop (off by default)
  25095. * @param speedRatio defines the speed ratio to apply to all animations
  25096. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25097. * @param onAnimationLoop defines the callback to call when an animation loops
  25098. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25099. * @returns the list of created animatables
  25100. */
  25101. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25102. /**
  25103. * Begin a new animation on a given node and its hierarchy
  25104. * @param target defines the root node where the animation will take place
  25105. * @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.
  25106. * @param animations defines the list of animations to start
  25107. * @param from defines the initial value
  25108. * @param to defines the final value
  25109. * @param loop defines if you want animation to loop (off by default)
  25110. * @param speedRatio defines the speed ratio to apply to all animations
  25111. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25112. * @param onAnimationLoop defines the callback to call when an animation loops
  25113. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25114. * @returns the list of animatables created for all nodes
  25115. */
  25116. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25117. /**
  25118. * Gets the animatable associated with a specific target
  25119. * @param target defines the target of the animatable
  25120. * @returns the required animatable if found
  25121. */
  25122. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25123. /**
  25124. * Gets all animatables associated with a given target
  25125. * @param target defines the target to look animatables for
  25126. * @returns an array of Animatables
  25127. */
  25128. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25129. /**
  25130. * Stops and removes all animations that have been applied to the scene
  25131. */
  25132. stopAllAnimations(): void;
  25133. /**
  25134. * Gets the current delta time used by animation engine
  25135. */
  25136. deltaTime: number;
  25137. }
  25138. interface Bone {
  25139. /**
  25140. * Copy an animation range from another bone
  25141. * @param source defines the source bone
  25142. * @param rangeName defines the range name to copy
  25143. * @param frameOffset defines the frame offset
  25144. * @param rescaleAsRequired defines if rescaling must be applied if required
  25145. * @param skelDimensionsRatio defines the scaling ratio
  25146. * @returns true if operation was successful
  25147. */
  25148. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25149. }
  25150. }
  25151. declare module BABYLON {
  25152. /**
  25153. * Class used to override all child animations of a given target
  25154. */
  25155. export class AnimationPropertiesOverride {
  25156. /**
  25157. * Gets or sets a value indicating if animation blending must be used
  25158. */
  25159. enableBlending: boolean;
  25160. /**
  25161. * Gets or sets the blending speed to use when enableBlending is true
  25162. */
  25163. blendingSpeed: number;
  25164. /**
  25165. * Gets or sets the default loop mode to use
  25166. */
  25167. loopMode: number;
  25168. }
  25169. }
  25170. declare module BABYLON {
  25171. /**
  25172. * Class used to handle skinning animations
  25173. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25174. */
  25175. export class Skeleton implements IAnimatable {
  25176. /** defines the skeleton name */
  25177. name: string;
  25178. /** defines the skeleton Id */
  25179. id: string;
  25180. /**
  25181. * Defines the list of child bones
  25182. */
  25183. bones: Bone[];
  25184. /**
  25185. * Defines an estimate of the dimension of the skeleton at rest
  25186. */
  25187. dimensionsAtRest: Vector3;
  25188. /**
  25189. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25190. */
  25191. needInitialSkinMatrix: boolean;
  25192. /**
  25193. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25194. */
  25195. overrideMesh: Nullable<AbstractMesh>;
  25196. /**
  25197. * Gets the list of animations attached to this skeleton
  25198. */
  25199. animations: Array<Animation>;
  25200. private _scene;
  25201. private _isDirty;
  25202. private _transformMatrices;
  25203. private _transformMatrixTexture;
  25204. private _meshesWithPoseMatrix;
  25205. private _animatables;
  25206. private _identity;
  25207. private _synchronizedWithMesh;
  25208. private _ranges;
  25209. private _lastAbsoluteTransformsUpdateId;
  25210. private _canUseTextureForBones;
  25211. private _uniqueId;
  25212. /** @hidden */
  25213. _numBonesWithLinkedTransformNode: number;
  25214. /** @hidden */
  25215. _hasWaitingData: Nullable<boolean>;
  25216. /** @hidden */
  25217. _waitingOverrideMeshId: Nullable<string>;
  25218. /**
  25219. * Specifies if the skeleton should be serialized
  25220. */
  25221. doNotSerialize: boolean;
  25222. private _useTextureToStoreBoneMatrices;
  25223. /**
  25224. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25225. * Please note that this option is not available if the hardware does not support it
  25226. */
  25227. get useTextureToStoreBoneMatrices(): boolean;
  25228. set useTextureToStoreBoneMatrices(value: boolean);
  25229. private _animationPropertiesOverride;
  25230. /**
  25231. * Gets or sets the animation properties override
  25232. */
  25233. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25234. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25235. /**
  25236. * List of inspectable custom properties (used by the Inspector)
  25237. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25238. */
  25239. inspectableCustomProperties: IInspectable[];
  25240. /**
  25241. * An observable triggered before computing the skeleton's matrices
  25242. */
  25243. onBeforeComputeObservable: Observable<Skeleton>;
  25244. /**
  25245. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25246. */
  25247. get isUsingTextureForMatrices(): boolean;
  25248. /**
  25249. * Gets the unique ID of this skeleton
  25250. */
  25251. get uniqueId(): number;
  25252. /**
  25253. * Creates a new skeleton
  25254. * @param name defines the skeleton name
  25255. * @param id defines the skeleton Id
  25256. * @param scene defines the hosting scene
  25257. */
  25258. constructor(
  25259. /** defines the skeleton name */
  25260. name: string,
  25261. /** defines the skeleton Id */
  25262. id: string, scene: Scene);
  25263. /**
  25264. * Gets the current object class name.
  25265. * @return the class name
  25266. */
  25267. getClassName(): string;
  25268. /**
  25269. * Returns an array containing the root bones
  25270. * @returns an array containing the root bones
  25271. */
  25272. getChildren(): Array<Bone>;
  25273. /**
  25274. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25276. * @returns a Float32Array containing matrices data
  25277. */
  25278. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25279. /**
  25280. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25281. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25282. * @returns a raw texture containing the data
  25283. */
  25284. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25285. /**
  25286. * Gets the current hosting scene
  25287. * @returns a scene object
  25288. */
  25289. getScene(): Scene;
  25290. /**
  25291. * Gets a string representing the current skeleton data
  25292. * @param fullDetails defines a boolean indicating if we want a verbose version
  25293. * @returns a string representing the current skeleton data
  25294. */
  25295. toString(fullDetails?: boolean): string;
  25296. /**
  25297. * Get bone's index searching by name
  25298. * @param name defines bone's name to search for
  25299. * @return the indice of the bone. Returns -1 if not found
  25300. */
  25301. getBoneIndexByName(name: string): number;
  25302. /**
  25303. * Creater a new animation range
  25304. * @param name defines the name of the range
  25305. * @param from defines the start key
  25306. * @param to defines the end key
  25307. */
  25308. createAnimationRange(name: string, from: number, to: number): void;
  25309. /**
  25310. * Delete a specific animation range
  25311. * @param name defines the name of the range
  25312. * @param deleteFrames defines if frames must be removed as well
  25313. */
  25314. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25315. /**
  25316. * Gets a specific animation range
  25317. * @param name defines the name of the range to look for
  25318. * @returns the requested animation range or null if not found
  25319. */
  25320. getAnimationRange(name: string): Nullable<AnimationRange>;
  25321. /**
  25322. * Gets the list of all animation ranges defined on this skeleton
  25323. * @returns an array
  25324. */
  25325. getAnimationRanges(): Nullable<AnimationRange>[];
  25326. /**
  25327. * Copy animation range from a source skeleton.
  25328. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25329. * @param source defines the source skeleton
  25330. * @param name defines the name of the range to copy
  25331. * @param rescaleAsRequired defines if rescaling must be applied if required
  25332. * @returns true if operation was successful
  25333. */
  25334. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25335. /**
  25336. * Forces the skeleton to go to rest pose
  25337. */
  25338. returnToRest(): void;
  25339. private _getHighestAnimationFrame;
  25340. /**
  25341. * Begin a specific animation range
  25342. * @param name defines the name of the range to start
  25343. * @param loop defines if looping must be turned on (false by default)
  25344. * @param speedRatio defines the speed ratio to apply (1 by default)
  25345. * @param onAnimationEnd defines a callback which will be called when animation will end
  25346. * @returns a new animatable
  25347. */
  25348. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25349. /**
  25350. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25351. * @param skeleton defines the Skeleton containing the animation range to convert
  25352. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25353. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25354. * @returns the original skeleton
  25355. */
  25356. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25357. /** @hidden */
  25358. _markAsDirty(): void;
  25359. /** @hidden */
  25360. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25361. /** @hidden */
  25362. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25363. private _computeTransformMatrices;
  25364. /**
  25365. * Build all resources required to render a skeleton
  25366. */
  25367. prepare(): void;
  25368. /**
  25369. * Gets the list of animatables currently running for this skeleton
  25370. * @returns an array of animatables
  25371. */
  25372. getAnimatables(): IAnimatable[];
  25373. /**
  25374. * Clone the current skeleton
  25375. * @param name defines the name of the new skeleton
  25376. * @param id defines the id of the new skeleton
  25377. * @returns the new skeleton
  25378. */
  25379. clone(name: string, id?: string): Skeleton;
  25380. /**
  25381. * Enable animation blending for this skeleton
  25382. * @param blendingSpeed defines the blending speed to apply
  25383. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25384. */
  25385. enableBlending(blendingSpeed?: number): void;
  25386. /**
  25387. * Releases all resources associated with the current skeleton
  25388. */
  25389. dispose(): void;
  25390. /**
  25391. * Serialize the skeleton in a JSON object
  25392. * @returns a JSON object
  25393. */
  25394. serialize(): any;
  25395. /**
  25396. * Creates a new skeleton from serialized data
  25397. * @param parsedSkeleton defines the serialized data
  25398. * @param scene defines the hosting scene
  25399. * @returns a new skeleton
  25400. */
  25401. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25402. /**
  25403. * Compute all node absolute transforms
  25404. * @param forceUpdate defines if computation must be done even if cache is up to date
  25405. */
  25406. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25407. /**
  25408. * Gets the root pose matrix
  25409. * @returns a matrix
  25410. */
  25411. getPoseMatrix(): Nullable<Matrix>;
  25412. /**
  25413. * Sorts bones per internal index
  25414. */
  25415. sortBones(): void;
  25416. private _sortBones;
  25417. /**
  25418. * Set the current local matrix as the restPose for all bones in the skeleton.
  25419. */
  25420. setCurrentPoseAsRest(): void;
  25421. }
  25422. }
  25423. declare module BABYLON {
  25424. /**
  25425. * Class used to store bone information
  25426. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25427. */
  25428. export class Bone extends Node {
  25429. /**
  25430. * defines the bone name
  25431. */
  25432. name: string;
  25433. private static _tmpVecs;
  25434. private static _tmpQuat;
  25435. private static _tmpMats;
  25436. /**
  25437. * Gets the list of child bones
  25438. */
  25439. children: Bone[];
  25440. /** Gets the animations associated with this bone */
  25441. animations: Animation[];
  25442. /**
  25443. * Gets or sets bone length
  25444. */
  25445. length: number;
  25446. /**
  25447. * @hidden Internal only
  25448. * Set this value to map this bone to a different index in the transform matrices
  25449. * Set this value to -1 to exclude the bone from the transform matrices
  25450. */
  25451. _index: Nullable<number>;
  25452. private _skeleton;
  25453. private _localMatrix;
  25454. private _restPose;
  25455. private _bindPose;
  25456. private _baseMatrix;
  25457. private _absoluteTransform;
  25458. private _invertedAbsoluteTransform;
  25459. private _parent;
  25460. private _scalingDeterminant;
  25461. private _worldTransform;
  25462. private _localScaling;
  25463. private _localRotation;
  25464. private _localPosition;
  25465. private _needToDecompose;
  25466. private _needToCompose;
  25467. /** @hidden */
  25468. _linkedTransformNode: Nullable<TransformNode>;
  25469. /** @hidden */
  25470. _waitingTransformNodeId: Nullable<string>;
  25471. /** @hidden */
  25472. get _matrix(): Matrix;
  25473. /** @hidden */
  25474. set _matrix(value: Matrix);
  25475. /**
  25476. * Create a new bone
  25477. * @param name defines the bone name
  25478. * @param skeleton defines the parent skeleton
  25479. * @param parentBone defines the parent (can be null if the bone is the root)
  25480. * @param localMatrix defines the local matrix
  25481. * @param restPose defines the rest pose matrix
  25482. * @param baseMatrix defines the base matrix
  25483. * @param index defines index of the bone in the hiearchy
  25484. */
  25485. constructor(
  25486. /**
  25487. * defines the bone name
  25488. */
  25489. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25490. /**
  25491. * Gets the current object class name.
  25492. * @return the class name
  25493. */
  25494. getClassName(): string;
  25495. /**
  25496. * Gets the parent skeleton
  25497. * @returns a skeleton
  25498. */
  25499. getSkeleton(): Skeleton;
  25500. /**
  25501. * Gets parent bone
  25502. * @returns a bone or null if the bone is the root of the bone hierarchy
  25503. */
  25504. getParent(): Nullable<Bone>;
  25505. /**
  25506. * Returns an array containing the root bones
  25507. * @returns an array containing the root bones
  25508. */
  25509. getChildren(): Array<Bone>;
  25510. /**
  25511. * Gets the node index in matrix array generated for rendering
  25512. * @returns the node index
  25513. */
  25514. getIndex(): number;
  25515. /**
  25516. * Sets the parent bone
  25517. * @param parent defines the parent (can be null if the bone is the root)
  25518. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25519. */
  25520. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25521. /**
  25522. * Gets the local matrix
  25523. * @returns a matrix
  25524. */
  25525. getLocalMatrix(): Matrix;
  25526. /**
  25527. * Gets the base matrix (initial matrix which remains unchanged)
  25528. * @returns a matrix
  25529. */
  25530. getBaseMatrix(): Matrix;
  25531. /**
  25532. * Gets the rest pose matrix
  25533. * @returns a matrix
  25534. */
  25535. getRestPose(): Matrix;
  25536. /**
  25537. * Sets the rest pose matrix
  25538. * @param matrix the local-space rest pose to set for this bone
  25539. */
  25540. setRestPose(matrix: Matrix): void;
  25541. /**
  25542. * Gets the bind pose matrix
  25543. * @returns the bind pose matrix
  25544. */
  25545. getBindPose(): Matrix;
  25546. /**
  25547. * Sets the bind pose matrix
  25548. * @param matrix the local-space bind pose to set for this bone
  25549. */
  25550. setBindPose(matrix: Matrix): void;
  25551. /**
  25552. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25553. */
  25554. getWorldMatrix(): Matrix;
  25555. /**
  25556. * Sets the local matrix to rest pose matrix
  25557. */
  25558. returnToRest(): void;
  25559. /**
  25560. * Gets the inverse of the absolute transform matrix.
  25561. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25562. * @returns a matrix
  25563. */
  25564. getInvertedAbsoluteTransform(): Matrix;
  25565. /**
  25566. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25567. * @returns a matrix
  25568. */
  25569. getAbsoluteTransform(): Matrix;
  25570. /**
  25571. * Links with the given transform node.
  25572. * The local matrix of this bone is copied from the transform node every frame.
  25573. * @param transformNode defines the transform node to link to
  25574. */
  25575. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25576. /**
  25577. * Gets the node used to drive the bone's transformation
  25578. * @returns a transform node or null
  25579. */
  25580. getTransformNode(): Nullable<TransformNode>;
  25581. /** Gets or sets current position (in local space) */
  25582. get position(): Vector3;
  25583. set position(newPosition: Vector3);
  25584. /** Gets or sets current rotation (in local space) */
  25585. get rotation(): Vector3;
  25586. set rotation(newRotation: Vector3);
  25587. /** Gets or sets current rotation quaternion (in local space) */
  25588. get rotationQuaternion(): Quaternion;
  25589. set rotationQuaternion(newRotation: Quaternion);
  25590. /** Gets or sets current scaling (in local space) */
  25591. get scaling(): Vector3;
  25592. set scaling(newScaling: Vector3);
  25593. /**
  25594. * Gets the animation properties override
  25595. */
  25596. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25597. private _decompose;
  25598. private _compose;
  25599. /**
  25600. * Update the base and local matrices
  25601. * @param matrix defines the new base or local matrix
  25602. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25603. * @param updateLocalMatrix defines if the local matrix should be updated
  25604. */
  25605. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25606. /** @hidden */
  25607. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25608. /**
  25609. * Flag the bone as dirty (Forcing it to update everything)
  25610. */
  25611. markAsDirty(): void;
  25612. /** @hidden */
  25613. _markAsDirtyAndCompose(): void;
  25614. private _markAsDirtyAndDecompose;
  25615. /**
  25616. * Translate the bone in local or world space
  25617. * @param vec The amount to translate the bone
  25618. * @param space The space that the translation is in
  25619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25620. */
  25621. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25622. /**
  25623. * Set the postion of the bone in local or world space
  25624. * @param position The position to set the bone
  25625. * @param space The space that the position is in
  25626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25627. */
  25628. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25629. /**
  25630. * Set the absolute position of the bone (world space)
  25631. * @param position The position to set the bone
  25632. * @param mesh The mesh that this bone is attached to
  25633. */
  25634. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25635. /**
  25636. * Scale the bone on the x, y and z axes (in local space)
  25637. * @param x The amount to scale the bone on the x axis
  25638. * @param y The amount to scale the bone on the y axis
  25639. * @param z The amount to scale the bone on the z axis
  25640. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25641. */
  25642. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25643. /**
  25644. * Set the bone scaling in local space
  25645. * @param scale defines the scaling vector
  25646. */
  25647. setScale(scale: Vector3): void;
  25648. /**
  25649. * Gets the current scaling in local space
  25650. * @returns the current scaling vector
  25651. */
  25652. getScale(): Vector3;
  25653. /**
  25654. * Gets the current scaling in local space and stores it in a target vector
  25655. * @param result defines the target vector
  25656. */
  25657. getScaleToRef(result: Vector3): void;
  25658. /**
  25659. * Set the yaw, pitch, and roll of the bone in local or world space
  25660. * @param yaw The rotation of the bone on the y axis
  25661. * @param pitch The rotation of the bone on the x axis
  25662. * @param roll The rotation of the bone on the z axis
  25663. * @param space The space that the axes of rotation are in
  25664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25665. */
  25666. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25667. /**
  25668. * Add a rotation to the bone on an axis in local or world space
  25669. * @param axis The axis to rotate the bone on
  25670. * @param amount The amount to rotate the bone
  25671. * @param space The space that the axis is in
  25672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25673. */
  25674. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25675. /**
  25676. * Set the rotation of the bone to a particular axis angle in local or world space
  25677. * @param axis The axis to rotate the bone on
  25678. * @param angle The angle that the bone should be rotated to
  25679. * @param space The space that the axis is in
  25680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25681. */
  25682. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25683. /**
  25684. * Set the euler rotation of the bone in local or world space
  25685. * @param rotation The euler rotation that the bone should be set to
  25686. * @param space The space that the rotation is in
  25687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25688. */
  25689. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25690. /**
  25691. * Set the quaternion rotation of the bone in local or world space
  25692. * @param quat The quaternion rotation that the bone should be set to
  25693. * @param space The space that the rotation is in
  25694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25695. */
  25696. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25697. /**
  25698. * Set the rotation matrix of the bone in local or world space
  25699. * @param rotMat The rotation matrix that the bone should be set to
  25700. * @param space The space that the rotation is in
  25701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25702. */
  25703. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25704. private _rotateWithMatrix;
  25705. private _getNegativeRotationToRef;
  25706. /**
  25707. * Get the position of the bone in local or world space
  25708. * @param space The space that the returned position is in
  25709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25710. * @returns The position of the bone
  25711. */
  25712. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25713. /**
  25714. * Copy the position of the bone to a vector3 in local or world space
  25715. * @param space The space that the returned position is in
  25716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25717. * @param result The vector3 to copy the position to
  25718. */
  25719. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25720. /**
  25721. * Get the absolute position of the bone (world space)
  25722. * @param mesh The mesh that this bone is attached to
  25723. * @returns The absolute position of the bone
  25724. */
  25725. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25726. /**
  25727. * Copy the absolute position of the bone (world space) to the result param
  25728. * @param mesh The mesh that this bone is attached to
  25729. * @param result The vector3 to copy the absolute position to
  25730. */
  25731. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25732. /**
  25733. * Compute the absolute transforms of this bone and its children
  25734. */
  25735. computeAbsoluteTransforms(): void;
  25736. /**
  25737. * Get the world direction from an axis that is in the local space of the bone
  25738. * @param localAxis The local direction that is used to compute the world direction
  25739. * @param mesh The mesh that this bone is attached to
  25740. * @returns The world direction
  25741. */
  25742. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25743. /**
  25744. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25745. * @param localAxis The local direction that is used to compute the world direction
  25746. * @param mesh The mesh that this bone is attached to
  25747. * @param result The vector3 that the world direction will be copied to
  25748. */
  25749. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25750. /**
  25751. * Get the euler rotation of the bone in local or world space
  25752. * @param space The space that the rotation should be in
  25753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25754. * @returns The euler rotation
  25755. */
  25756. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25757. /**
  25758. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25759. * @param space The space that the rotation should be in
  25760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25761. * @param result The vector3 that the rotation should be copied to
  25762. */
  25763. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25764. /**
  25765. * Get the quaternion rotation of the bone in either local or world space
  25766. * @param space The space that the rotation should be in
  25767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25768. * @returns The quaternion rotation
  25769. */
  25770. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25771. /**
  25772. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25773. * @param space The space that the rotation should be in
  25774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25775. * @param result The quaternion that the rotation should be copied to
  25776. */
  25777. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25778. /**
  25779. * Get the rotation matrix of the bone in local or world space
  25780. * @param space The space that the rotation should be in
  25781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25782. * @returns The rotation matrix
  25783. */
  25784. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25785. /**
  25786. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25787. * @param space The space that the rotation should be in
  25788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25789. * @param result The quaternion that the rotation should be copied to
  25790. */
  25791. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25792. /**
  25793. * Get the world position of a point that is in the local space of the bone
  25794. * @param position The local position
  25795. * @param mesh The mesh that this bone is attached to
  25796. * @returns The world position
  25797. */
  25798. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25799. /**
  25800. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25801. * @param position The local position
  25802. * @param mesh The mesh that this bone is attached to
  25803. * @param result The vector3 that the world position should be copied to
  25804. */
  25805. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25806. /**
  25807. * Get the local position of a point that is in world space
  25808. * @param position The world position
  25809. * @param mesh The mesh that this bone is attached to
  25810. * @returns The local position
  25811. */
  25812. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25813. /**
  25814. * Get the local position of a point that is in world space and copy it to the result param
  25815. * @param position The world position
  25816. * @param mesh The mesh that this bone is attached to
  25817. * @param result The vector3 that the local position should be copied to
  25818. */
  25819. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25820. /**
  25821. * Set the current local matrix as the restPose for this bone.
  25822. */
  25823. setCurrentPoseAsRest(): void;
  25824. }
  25825. }
  25826. declare module BABYLON {
  25827. /**
  25828. * 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.
  25829. * @see https://doc.babylonjs.com/how_to/transformnode
  25830. */
  25831. export class TransformNode extends Node {
  25832. /**
  25833. * Object will not rotate to face the camera
  25834. */
  25835. static BILLBOARDMODE_NONE: number;
  25836. /**
  25837. * Object will rotate to face the camera but only on the x axis
  25838. */
  25839. static BILLBOARDMODE_X: number;
  25840. /**
  25841. * Object will rotate to face the camera but only on the y axis
  25842. */
  25843. static BILLBOARDMODE_Y: number;
  25844. /**
  25845. * Object will rotate to face the camera but only on the z axis
  25846. */
  25847. static BILLBOARDMODE_Z: number;
  25848. /**
  25849. * Object will rotate to face the camera
  25850. */
  25851. static BILLBOARDMODE_ALL: number;
  25852. /**
  25853. * Object will rotate to face the camera's position instead of orientation
  25854. */
  25855. static BILLBOARDMODE_USE_POSITION: number;
  25856. private static _TmpRotation;
  25857. private static _TmpScaling;
  25858. private static _TmpTranslation;
  25859. private _forward;
  25860. private _forwardInverted;
  25861. private _up;
  25862. private _right;
  25863. private _rightInverted;
  25864. private _position;
  25865. private _rotation;
  25866. private _rotationQuaternion;
  25867. protected _scaling: Vector3;
  25868. protected _isDirty: boolean;
  25869. private _transformToBoneReferal;
  25870. private _isAbsoluteSynced;
  25871. private _billboardMode;
  25872. /**
  25873. * Gets or sets the billboard mode. Default is 0.
  25874. *
  25875. * | Value | Type | Description |
  25876. * | --- | --- | --- |
  25877. * | 0 | BILLBOARDMODE_NONE | |
  25878. * | 1 | BILLBOARDMODE_X | |
  25879. * | 2 | BILLBOARDMODE_Y | |
  25880. * | 4 | BILLBOARDMODE_Z | |
  25881. * | 7 | BILLBOARDMODE_ALL | |
  25882. *
  25883. */
  25884. get billboardMode(): number;
  25885. set billboardMode(value: number);
  25886. private _preserveParentRotationForBillboard;
  25887. /**
  25888. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25889. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25890. */
  25891. get preserveParentRotationForBillboard(): boolean;
  25892. set preserveParentRotationForBillboard(value: boolean);
  25893. /**
  25894. * 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
  25895. */
  25896. scalingDeterminant: number;
  25897. private _infiniteDistance;
  25898. /**
  25899. * Gets or sets the distance of the object to max, often used by skybox
  25900. */
  25901. get infiniteDistance(): boolean;
  25902. set infiniteDistance(value: boolean);
  25903. /**
  25904. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25905. * By default the system will update normals to compensate
  25906. */
  25907. ignoreNonUniformScaling: boolean;
  25908. /**
  25909. * 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
  25910. */
  25911. reIntegrateRotationIntoRotationQuaternion: boolean;
  25912. /** @hidden */
  25913. _poseMatrix: Nullable<Matrix>;
  25914. /** @hidden */
  25915. _localMatrix: Matrix;
  25916. private _usePivotMatrix;
  25917. private _absolutePosition;
  25918. private _absoluteScaling;
  25919. private _absoluteRotationQuaternion;
  25920. private _pivotMatrix;
  25921. private _pivotMatrixInverse;
  25922. /** @hidden */
  25923. _postMultiplyPivotMatrix: boolean;
  25924. protected _isWorldMatrixFrozen: boolean;
  25925. /** @hidden */
  25926. _indexInSceneTransformNodesArray: number;
  25927. /**
  25928. * An event triggered after the world matrix is updated
  25929. */
  25930. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25931. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25932. /**
  25933. * Gets a string identifying the name of the class
  25934. * @returns "TransformNode" string
  25935. */
  25936. getClassName(): string;
  25937. /**
  25938. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25939. */
  25940. get position(): Vector3;
  25941. set position(newPosition: Vector3);
  25942. /**
  25943. * 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)).
  25944. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25945. */
  25946. get rotation(): Vector3;
  25947. set rotation(newRotation: Vector3);
  25948. /**
  25949. * 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)).
  25950. */
  25951. get scaling(): Vector3;
  25952. set scaling(newScaling: Vector3);
  25953. /**
  25954. * 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).
  25955. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25956. */
  25957. get rotationQuaternion(): Nullable<Quaternion>;
  25958. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25959. /**
  25960. * The forward direction of that transform in world space.
  25961. */
  25962. get forward(): Vector3;
  25963. /**
  25964. * The up direction of that transform in world space.
  25965. */
  25966. get up(): Vector3;
  25967. /**
  25968. * The right direction of that transform in world space.
  25969. */
  25970. get right(): Vector3;
  25971. /**
  25972. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25973. * @param matrix the matrix to copy the pose from
  25974. * @returns this TransformNode.
  25975. */
  25976. updatePoseMatrix(matrix: Matrix): TransformNode;
  25977. /**
  25978. * Returns the mesh Pose matrix.
  25979. * @returns the pose matrix
  25980. */
  25981. getPoseMatrix(): Matrix;
  25982. /** @hidden */
  25983. _isSynchronized(): boolean;
  25984. /** @hidden */
  25985. _initCache(): void;
  25986. /**
  25987. * Flag the transform node as dirty (Forcing it to update everything)
  25988. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25989. * @returns this transform node
  25990. */
  25991. markAsDirty(property: string): TransformNode;
  25992. /**
  25993. * Returns the current mesh absolute position.
  25994. * Returns a Vector3.
  25995. */
  25996. get absolutePosition(): Vector3;
  25997. /**
  25998. * Returns the current mesh absolute scaling.
  25999. * Returns a Vector3.
  26000. */
  26001. get absoluteScaling(): Vector3;
  26002. /**
  26003. * Returns the current mesh absolute rotation.
  26004. * Returns a Quaternion.
  26005. */
  26006. get absoluteRotationQuaternion(): Quaternion;
  26007. /**
  26008. * Sets a new matrix to apply before all other transformation
  26009. * @param matrix defines the transform matrix
  26010. * @returns the current TransformNode
  26011. */
  26012. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26013. /**
  26014. * Sets a new pivot matrix to the current node
  26015. * @param matrix defines the new pivot matrix to use
  26016. * @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
  26017. * @returns the current TransformNode
  26018. */
  26019. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26020. /**
  26021. * Returns the mesh pivot matrix.
  26022. * Default : Identity.
  26023. * @returns the matrix
  26024. */
  26025. getPivotMatrix(): Matrix;
  26026. /**
  26027. * Instantiate (when possible) or clone that node with its hierarchy
  26028. * @param newParent defines the new parent to use for the instance (or clone)
  26029. * @param options defines options to configure how copy is done
  26030. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26031. * @returns an instance (or a clone) of the current node with its hiearchy
  26032. */
  26033. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26034. doNotInstantiate: boolean;
  26035. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26036. /**
  26037. * Prevents the World matrix to be computed any longer
  26038. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26039. * @returns the TransformNode.
  26040. */
  26041. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26042. /**
  26043. * Allows back the World matrix computation.
  26044. * @returns the TransformNode.
  26045. */
  26046. unfreezeWorldMatrix(): this;
  26047. /**
  26048. * True if the World matrix has been frozen.
  26049. */
  26050. get isWorldMatrixFrozen(): boolean;
  26051. /**
  26052. * Retuns the mesh absolute position in the World.
  26053. * @returns a Vector3.
  26054. */
  26055. getAbsolutePosition(): Vector3;
  26056. /**
  26057. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26058. * @param absolutePosition the absolute position to set
  26059. * @returns the TransformNode.
  26060. */
  26061. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26062. /**
  26063. * Sets the mesh position in its local space.
  26064. * @param vector3 the position to set in localspace
  26065. * @returns the TransformNode.
  26066. */
  26067. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26068. /**
  26069. * Returns the mesh position in the local space from the current World matrix values.
  26070. * @returns a new Vector3.
  26071. */
  26072. getPositionExpressedInLocalSpace(): Vector3;
  26073. /**
  26074. * Translates the mesh along the passed Vector3 in its local space.
  26075. * @param vector3 the distance to translate in localspace
  26076. * @returns the TransformNode.
  26077. */
  26078. locallyTranslate(vector3: Vector3): TransformNode;
  26079. private static _lookAtVectorCache;
  26080. /**
  26081. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26082. * @param targetPoint the position (must be in same space as current mesh) to look at
  26083. * @param yawCor optional yaw (y-axis) correction in radians
  26084. * @param pitchCor optional pitch (x-axis) correction in radians
  26085. * @param rollCor optional roll (z-axis) correction in radians
  26086. * @param space the choosen space of the target
  26087. * @returns the TransformNode.
  26088. */
  26089. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26090. /**
  26091. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26092. * This Vector3 is expressed in the World space.
  26093. * @param localAxis axis to rotate
  26094. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26095. */
  26096. getDirection(localAxis: Vector3): Vector3;
  26097. /**
  26098. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26099. * localAxis is expressed in the mesh local space.
  26100. * result is computed in the Wordl space from the mesh World matrix.
  26101. * @param localAxis axis to rotate
  26102. * @param result the resulting transformnode
  26103. * @returns this TransformNode.
  26104. */
  26105. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26106. /**
  26107. * Sets this transform node rotation to the given local axis.
  26108. * @param localAxis the axis in local space
  26109. * @param yawCor optional yaw (y-axis) correction in radians
  26110. * @param pitchCor optional pitch (x-axis) correction in radians
  26111. * @param rollCor optional roll (z-axis) correction in radians
  26112. * @returns this TransformNode
  26113. */
  26114. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26115. /**
  26116. * Sets a new pivot point to the current node
  26117. * @param point defines the new pivot point to use
  26118. * @param space defines if the point is in world or local space (local by default)
  26119. * @returns the current TransformNode
  26120. */
  26121. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26122. /**
  26123. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26124. * @returns the pivot point
  26125. */
  26126. getPivotPoint(): Vector3;
  26127. /**
  26128. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26129. * @param result the vector3 to store the result
  26130. * @returns this TransformNode.
  26131. */
  26132. getPivotPointToRef(result: Vector3): TransformNode;
  26133. /**
  26134. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26135. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26136. */
  26137. getAbsolutePivotPoint(): Vector3;
  26138. /**
  26139. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26140. * @param result vector3 to store the result
  26141. * @returns this TransformNode.
  26142. */
  26143. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26144. /**
  26145. * Defines the passed node as the parent of the current node.
  26146. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26147. * @see https://doc.babylonjs.com/how_to/parenting
  26148. * @param node the node ot set as the parent
  26149. * @returns this TransformNode.
  26150. */
  26151. setParent(node: Nullable<Node>): TransformNode;
  26152. private _nonUniformScaling;
  26153. /**
  26154. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26155. */
  26156. get nonUniformScaling(): boolean;
  26157. /** @hidden */
  26158. _updateNonUniformScalingState(value: boolean): boolean;
  26159. /**
  26160. * Attach the current TransformNode to another TransformNode associated with a bone
  26161. * @param bone Bone affecting the TransformNode
  26162. * @param affectedTransformNode TransformNode associated with the bone
  26163. * @returns this object
  26164. */
  26165. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26166. /**
  26167. * Detach the transform node if its associated with a bone
  26168. * @returns this object
  26169. */
  26170. detachFromBone(): TransformNode;
  26171. private static _rotationAxisCache;
  26172. /**
  26173. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26174. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26175. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26176. * The passed axis is also normalized.
  26177. * @param axis the axis to rotate around
  26178. * @param amount the amount to rotate in radians
  26179. * @param space Space to rotate in (Default: local)
  26180. * @returns the TransformNode.
  26181. */
  26182. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26183. /**
  26184. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26185. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26186. * The passed axis is also normalized. .
  26187. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26188. * @param point the point to rotate around
  26189. * @param axis the axis to rotate around
  26190. * @param amount the amount to rotate in radians
  26191. * @returns the TransformNode
  26192. */
  26193. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26194. /**
  26195. * Translates the mesh along the axis vector for the passed distance in the given space.
  26196. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26197. * @param axis the axis to translate in
  26198. * @param distance the distance to translate
  26199. * @param space Space to rotate in (Default: local)
  26200. * @returns the TransformNode.
  26201. */
  26202. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26203. /**
  26204. * Adds a rotation step to the mesh current rotation.
  26205. * x, y, z are Euler angles expressed in radians.
  26206. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26207. * This means this rotation is made in the mesh local space only.
  26208. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26209. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26210. * ```javascript
  26211. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26212. * ```
  26213. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26214. * 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.
  26215. * @param x Rotation to add
  26216. * @param y Rotation to add
  26217. * @param z Rotation to add
  26218. * @returns the TransformNode.
  26219. */
  26220. addRotation(x: number, y: number, z: number): TransformNode;
  26221. /**
  26222. * @hidden
  26223. */
  26224. protected _getEffectiveParent(): Nullable<Node>;
  26225. /**
  26226. * Computes the world matrix of the node
  26227. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26228. * @returns the world matrix
  26229. */
  26230. computeWorldMatrix(force?: boolean): Matrix;
  26231. /**
  26232. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26233. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26234. */
  26235. resetLocalMatrix(independentOfChildren?: boolean): void;
  26236. protected _afterComputeWorldMatrix(): void;
  26237. /**
  26238. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26239. * @param func callback function to add
  26240. *
  26241. * @returns the TransformNode.
  26242. */
  26243. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26244. /**
  26245. * Removes a registered callback function.
  26246. * @param func callback function to remove
  26247. * @returns the TransformNode.
  26248. */
  26249. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26250. /**
  26251. * Gets the position of the current mesh in camera space
  26252. * @param camera defines the camera to use
  26253. * @returns a position
  26254. */
  26255. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26256. /**
  26257. * Returns the distance from the mesh to the active camera
  26258. * @param camera defines the camera to use
  26259. * @returns the distance
  26260. */
  26261. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26262. /**
  26263. * Clone the current transform node
  26264. * @param name Name of the new clone
  26265. * @param newParent New parent for the clone
  26266. * @param doNotCloneChildren Do not clone children hierarchy
  26267. * @returns the new transform node
  26268. */
  26269. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26270. /**
  26271. * Serializes the objects information.
  26272. * @param currentSerializationObject defines the object to serialize in
  26273. * @returns the serialized object
  26274. */
  26275. serialize(currentSerializationObject?: any): any;
  26276. /**
  26277. * Returns a new TransformNode object parsed from the source provided.
  26278. * @param parsedTransformNode is the source.
  26279. * @param scene the scne the object belongs to
  26280. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26281. * @returns a new TransformNode object parsed from the source provided.
  26282. */
  26283. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26284. /**
  26285. * Get all child-transformNodes of this node
  26286. * @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
  26287. * @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
  26288. * @returns an array of TransformNode
  26289. */
  26290. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26291. /**
  26292. * Releases resources associated with this transform node.
  26293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26295. */
  26296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26297. /**
  26298. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26299. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26300. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26301. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26302. * @returns the current mesh
  26303. */
  26304. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26305. private _syncAbsoluteScalingAndRotation;
  26306. }
  26307. }
  26308. declare module BABYLON {
  26309. /**
  26310. * Defines the types of pose enabled controllers that are supported
  26311. */
  26312. export enum PoseEnabledControllerType {
  26313. /**
  26314. * HTC Vive
  26315. */
  26316. VIVE = 0,
  26317. /**
  26318. * Oculus Rift
  26319. */
  26320. OCULUS = 1,
  26321. /**
  26322. * Windows mixed reality
  26323. */
  26324. WINDOWS = 2,
  26325. /**
  26326. * Samsung gear VR
  26327. */
  26328. GEAR_VR = 3,
  26329. /**
  26330. * Google Daydream
  26331. */
  26332. DAYDREAM = 4,
  26333. /**
  26334. * Generic
  26335. */
  26336. GENERIC = 5
  26337. }
  26338. /**
  26339. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26340. */
  26341. export interface MutableGamepadButton {
  26342. /**
  26343. * Value of the button/trigger
  26344. */
  26345. value: number;
  26346. /**
  26347. * If the button/trigger is currently touched
  26348. */
  26349. touched: boolean;
  26350. /**
  26351. * If the button/trigger is currently pressed
  26352. */
  26353. pressed: boolean;
  26354. }
  26355. /**
  26356. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26357. * @hidden
  26358. */
  26359. export interface ExtendedGamepadButton extends GamepadButton {
  26360. /**
  26361. * If the button/trigger is currently pressed
  26362. */
  26363. readonly pressed: boolean;
  26364. /**
  26365. * If the button/trigger is currently touched
  26366. */
  26367. readonly touched: boolean;
  26368. /**
  26369. * Value of the button/trigger
  26370. */
  26371. readonly value: number;
  26372. }
  26373. /** @hidden */
  26374. export interface _GamePadFactory {
  26375. /**
  26376. * Returns whether or not the current gamepad can be created for this type of controller.
  26377. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26378. * @returns true if it can be created, otherwise false
  26379. */
  26380. canCreate(gamepadInfo: any): boolean;
  26381. /**
  26382. * Creates a new instance of the Gamepad.
  26383. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26384. * @returns the new gamepad instance
  26385. */
  26386. create(gamepadInfo: any): Gamepad;
  26387. }
  26388. /**
  26389. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26390. */
  26391. export class PoseEnabledControllerHelper {
  26392. /** @hidden */
  26393. static _ControllerFactories: _GamePadFactory[];
  26394. /** @hidden */
  26395. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26396. /**
  26397. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26398. * @param vrGamepad the gamepad to initialized
  26399. * @returns a vr controller of the type the gamepad identified as
  26400. */
  26401. static InitiateController(vrGamepad: any): Gamepad;
  26402. }
  26403. /**
  26404. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26405. */
  26406. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26407. /**
  26408. * If the controller is used in a webXR session
  26409. */
  26410. isXR: boolean;
  26411. private _deviceRoomPosition;
  26412. private _deviceRoomRotationQuaternion;
  26413. /**
  26414. * The device position in babylon space
  26415. */
  26416. devicePosition: Vector3;
  26417. /**
  26418. * The device rotation in babylon space
  26419. */
  26420. deviceRotationQuaternion: Quaternion;
  26421. /**
  26422. * The scale factor of the device in babylon space
  26423. */
  26424. deviceScaleFactor: number;
  26425. /**
  26426. * (Likely devicePosition should be used instead) The device position in its room space
  26427. */
  26428. position: Vector3;
  26429. /**
  26430. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26431. */
  26432. rotationQuaternion: Quaternion;
  26433. /**
  26434. * The type of controller (Eg. Windows mixed reality)
  26435. */
  26436. controllerType: PoseEnabledControllerType;
  26437. protected _calculatedPosition: Vector3;
  26438. private _calculatedRotation;
  26439. /**
  26440. * The raw pose from the device
  26441. */
  26442. rawPose: DevicePose;
  26443. private _trackPosition;
  26444. private _maxRotationDistFromHeadset;
  26445. private _draggedRoomRotation;
  26446. /**
  26447. * @hidden
  26448. */
  26449. _disableTrackPosition(fixedPosition: Vector3): void;
  26450. /**
  26451. * Internal, the mesh attached to the controller
  26452. * @hidden
  26453. */
  26454. _mesh: Nullable<AbstractMesh>;
  26455. private _poseControlledCamera;
  26456. private _leftHandSystemQuaternion;
  26457. /**
  26458. * Internal, matrix used to convert room space to babylon space
  26459. * @hidden
  26460. */
  26461. _deviceToWorld: Matrix;
  26462. /**
  26463. * Node to be used when casting a ray from the controller
  26464. * @hidden
  26465. */
  26466. _pointingPoseNode: Nullable<TransformNode>;
  26467. /**
  26468. * Name of the child mesh that can be used to cast a ray from the controller
  26469. */
  26470. static readonly POINTING_POSE: string;
  26471. /**
  26472. * Creates a new PoseEnabledController from a gamepad
  26473. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26474. */
  26475. constructor(browserGamepad: any);
  26476. private _workingMatrix;
  26477. /**
  26478. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26479. */
  26480. update(): void;
  26481. /**
  26482. * Updates only the pose device and mesh without doing any button event checking
  26483. */
  26484. protected _updatePoseAndMesh(): void;
  26485. /**
  26486. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26487. * @param poseData raw pose fromthe device
  26488. */
  26489. updateFromDevice(poseData: DevicePose): void;
  26490. /**
  26491. * @hidden
  26492. */
  26493. _meshAttachedObservable: Observable<AbstractMesh>;
  26494. /**
  26495. * Attaches a mesh to the controller
  26496. * @param mesh the mesh to be attached
  26497. */
  26498. attachToMesh(mesh: AbstractMesh): void;
  26499. /**
  26500. * Attaches the controllers mesh to a camera
  26501. * @param camera the camera the mesh should be attached to
  26502. */
  26503. attachToPoseControlledCamera(camera: TargetCamera): void;
  26504. /**
  26505. * Disposes of the controller
  26506. */
  26507. dispose(): void;
  26508. /**
  26509. * The mesh that is attached to the controller
  26510. */
  26511. get mesh(): Nullable<AbstractMesh>;
  26512. /**
  26513. * Gets the ray of the controller in the direction the controller is pointing
  26514. * @param length the length the resulting ray should be
  26515. * @returns a ray in the direction the controller is pointing
  26516. */
  26517. getForwardRay(length?: number): Ray;
  26518. }
  26519. }
  26520. declare module BABYLON {
  26521. /**
  26522. * Defines the WebVRController object that represents controllers tracked in 3D space
  26523. */
  26524. export abstract class WebVRController extends PoseEnabledController {
  26525. /**
  26526. * Internal, the default controller model for the controller
  26527. */
  26528. protected _defaultModel: Nullable<AbstractMesh>;
  26529. /**
  26530. * Fired when the trigger state has changed
  26531. */
  26532. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26533. /**
  26534. * Fired when the main button state has changed
  26535. */
  26536. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26537. /**
  26538. * Fired when the secondary button state has changed
  26539. */
  26540. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26541. /**
  26542. * Fired when the pad state has changed
  26543. */
  26544. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26545. /**
  26546. * Fired when controllers stick values have changed
  26547. */
  26548. onPadValuesChangedObservable: Observable<StickValues>;
  26549. /**
  26550. * Array of button availible on the controller
  26551. */
  26552. protected _buttons: Array<MutableGamepadButton>;
  26553. private _onButtonStateChange;
  26554. /**
  26555. * Fired when a controller button's state has changed
  26556. * @param callback the callback containing the button that was modified
  26557. */
  26558. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26559. /**
  26560. * X and Y axis corresponding to the controllers joystick
  26561. */
  26562. pad: StickValues;
  26563. /**
  26564. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26565. */
  26566. hand: string;
  26567. /**
  26568. * The default controller model for the controller
  26569. */
  26570. get defaultModel(): Nullable<AbstractMesh>;
  26571. /**
  26572. * Creates a new WebVRController from a gamepad
  26573. * @param vrGamepad the gamepad that the WebVRController should be created from
  26574. */
  26575. constructor(vrGamepad: any);
  26576. /**
  26577. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26578. */
  26579. update(): void;
  26580. /**
  26581. * Function to be called when a button is modified
  26582. */
  26583. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26584. /**
  26585. * Loads a mesh and attaches it to the controller
  26586. * @param scene the scene the mesh should be added to
  26587. * @param meshLoaded callback for when the mesh has been loaded
  26588. */
  26589. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26590. private _setButtonValue;
  26591. private _changes;
  26592. private _checkChanges;
  26593. /**
  26594. * Disposes of th webVRCOntroller
  26595. */
  26596. dispose(): void;
  26597. }
  26598. }
  26599. declare module BABYLON {
  26600. /**
  26601. * The HemisphericLight simulates the ambient environment light,
  26602. * so the passed direction is the light reflection direction, not the incoming direction.
  26603. */
  26604. export class HemisphericLight extends Light {
  26605. /**
  26606. * The groundColor is the light in the opposite direction to the one specified during creation.
  26607. * 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.
  26608. */
  26609. groundColor: Color3;
  26610. /**
  26611. * The light reflection direction, not the incoming direction.
  26612. */
  26613. direction: Vector3;
  26614. /**
  26615. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26616. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26617. * The HemisphericLight can't cast shadows.
  26618. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26619. * @param name The friendly name of the light
  26620. * @param direction The direction of the light reflection
  26621. * @param scene The scene the light belongs to
  26622. */
  26623. constructor(name: string, direction: Vector3, scene: Scene);
  26624. protected _buildUniformLayout(): void;
  26625. /**
  26626. * Returns the string "HemisphericLight".
  26627. * @return The class name
  26628. */
  26629. getClassName(): string;
  26630. /**
  26631. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26632. * Returns the updated direction.
  26633. * @param target The target the direction should point to
  26634. * @return The computed direction
  26635. */
  26636. setDirectionToTarget(target: Vector3): Vector3;
  26637. /**
  26638. * Returns the shadow generator associated to the light.
  26639. * @returns Always null for hemispheric lights because it does not support shadows.
  26640. */
  26641. getShadowGenerator(): Nullable<IShadowGenerator>;
  26642. /**
  26643. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26644. * @param effect The effect to update
  26645. * @param lightIndex The index of the light in the effect to update
  26646. * @returns The hemispheric light
  26647. */
  26648. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26649. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26650. /**
  26651. * Computes the world matrix of the node
  26652. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26653. * @param useWasUpdatedFlag defines a reserved property
  26654. * @returns the world matrix
  26655. */
  26656. computeWorldMatrix(): Matrix;
  26657. /**
  26658. * Returns the integer 3.
  26659. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26660. */
  26661. getTypeID(): number;
  26662. /**
  26663. * Prepares the list of defines specific to the light type.
  26664. * @param defines the list of defines
  26665. * @param lightIndex defines the index of the light for the effect
  26666. */
  26667. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26668. }
  26669. }
  26670. declare module BABYLON {
  26671. /** @hidden */
  26672. export var vrMultiviewToSingleviewPixelShader: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module BABYLON {
  26678. /**
  26679. * Renders to multiple views with a single draw call
  26680. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26681. */
  26682. export class MultiviewRenderTarget extends RenderTargetTexture {
  26683. /**
  26684. * Creates a multiview render target
  26685. * @param scene scene used with the render target
  26686. * @param size the size of the render target (used for each view)
  26687. */
  26688. constructor(scene: Scene, size?: number | {
  26689. width: number;
  26690. height: number;
  26691. } | {
  26692. ratio: number;
  26693. });
  26694. /**
  26695. * @hidden
  26696. * @param faceIndex the face index, if its a cube texture
  26697. */
  26698. _bindFrameBuffer(faceIndex?: number): void;
  26699. /**
  26700. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26701. * @returns the view count
  26702. */
  26703. getViewCount(): number;
  26704. }
  26705. }
  26706. declare module BABYLON {
  26707. interface Engine {
  26708. /**
  26709. * Creates a new multiview render target
  26710. * @param width defines the width of the texture
  26711. * @param height defines the height of the texture
  26712. * @returns the created multiview texture
  26713. */
  26714. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26715. /**
  26716. * Binds a multiview framebuffer to be drawn to
  26717. * @param multiviewTexture texture to bind
  26718. */
  26719. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26720. }
  26721. interface Camera {
  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. _useMultiviewToSingleView: boolean;
  26727. /**
  26728. * @hidden
  26729. * 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)
  26730. */
  26731. _multiviewTexture: Nullable<RenderTargetTexture>;
  26732. /**
  26733. * @hidden
  26734. * ensures the multiview texture of the camera exists and has the specified width/height
  26735. * @param width height to set on the multiview texture
  26736. * @param height width to set on the multiview texture
  26737. */
  26738. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26739. }
  26740. interface Scene {
  26741. /** @hidden */
  26742. _transformMatrixR: Matrix;
  26743. /** @hidden */
  26744. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26745. /** @hidden */
  26746. _createMultiviewUbo(): void;
  26747. /** @hidden */
  26748. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26749. /** @hidden */
  26750. _renderMultiviewToSingleView(camera: Camera): void;
  26751. }
  26752. }
  26753. declare module BABYLON {
  26754. /**
  26755. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26756. * This will not be used for webXR as it supports displaying texture arrays directly
  26757. */
  26758. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26759. /**
  26760. * Gets a string identifying the name of the class
  26761. * @returns "VRMultiviewToSingleviewPostProcess" string
  26762. */
  26763. getClassName(): string;
  26764. /**
  26765. * Initializes a VRMultiviewToSingleview
  26766. * @param name name of the post process
  26767. * @param camera camera to be applied to
  26768. * @param scaleFactor scaling factor to the size of the output texture
  26769. */
  26770. constructor(name: string, camera: Camera, scaleFactor: number);
  26771. }
  26772. }
  26773. declare module BABYLON {
  26774. /**
  26775. * Interface used to define additional presentation attributes
  26776. */
  26777. export interface IVRPresentationAttributes {
  26778. /**
  26779. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26780. */
  26781. highRefreshRate: boolean;
  26782. /**
  26783. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26784. */
  26785. foveationLevel: number;
  26786. }
  26787. interface Engine {
  26788. /** @hidden */
  26789. _vrDisplay: any;
  26790. /** @hidden */
  26791. _vrSupported: boolean;
  26792. /** @hidden */
  26793. _oldSize: Size;
  26794. /** @hidden */
  26795. _oldHardwareScaleFactor: number;
  26796. /** @hidden */
  26797. _vrExclusivePointerMode: boolean;
  26798. /** @hidden */
  26799. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26800. /** @hidden */
  26801. _onVRDisplayPointerRestricted: () => void;
  26802. /** @hidden */
  26803. _onVRDisplayPointerUnrestricted: () => void;
  26804. /** @hidden */
  26805. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26806. /** @hidden */
  26807. _onVrDisplayDisconnect: Nullable<() => void>;
  26808. /** @hidden */
  26809. _onVrDisplayPresentChange: Nullable<() => void>;
  26810. /**
  26811. * Observable signaled when VR display mode changes
  26812. */
  26813. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26814. /**
  26815. * Observable signaled when VR request present is complete
  26816. */
  26817. onVRRequestPresentComplete: Observable<boolean>;
  26818. /**
  26819. * Observable signaled when VR request present starts
  26820. */
  26821. onVRRequestPresentStart: Observable<Engine>;
  26822. /**
  26823. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26824. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26825. */
  26826. isInVRExclusivePointerMode: boolean;
  26827. /**
  26828. * Gets a boolean indicating if a webVR device was detected
  26829. * @returns true if a webVR device was detected
  26830. */
  26831. isVRDevicePresent(): boolean;
  26832. /**
  26833. * Gets the current webVR device
  26834. * @returns the current webVR device (or null)
  26835. */
  26836. getVRDevice(): any;
  26837. /**
  26838. * Initializes a webVR display and starts listening to display change events
  26839. * The onVRDisplayChangedObservable will be notified upon these changes
  26840. * @returns A promise containing a VRDisplay and if vr is supported
  26841. */
  26842. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26843. /** @hidden */
  26844. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26845. /**
  26846. * Gets or sets the presentation attributes used to configure VR rendering
  26847. */
  26848. vrPresentationAttributes?: IVRPresentationAttributes;
  26849. /**
  26850. * Call this function to switch to webVR mode
  26851. * Will do nothing if webVR is not supported or if there is no webVR device
  26852. * @param options the webvr options provided to the camera. mainly used for multiview
  26853. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26854. */
  26855. enableVR(options: WebVROptions): void;
  26856. /** @hidden */
  26857. _onVRFullScreenTriggered(): void;
  26858. }
  26859. }
  26860. declare module BABYLON {
  26861. /**
  26862. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26863. * IMPORTANT!! The data is right-hand data.
  26864. * @export
  26865. * @interface DevicePose
  26866. */
  26867. export interface DevicePose {
  26868. /**
  26869. * The position of the device, values in array are [x,y,z].
  26870. */
  26871. readonly position: Nullable<Float32Array>;
  26872. /**
  26873. * The linearVelocity of the device, values in array are [x,y,z].
  26874. */
  26875. readonly linearVelocity: Nullable<Float32Array>;
  26876. /**
  26877. * The linearAcceleration of the device, values in array are [x,y,z].
  26878. */
  26879. readonly linearAcceleration: Nullable<Float32Array>;
  26880. /**
  26881. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26882. */
  26883. readonly orientation: Nullable<Float32Array>;
  26884. /**
  26885. * The angularVelocity of the device, values in array are [x,y,z].
  26886. */
  26887. readonly angularVelocity: Nullable<Float32Array>;
  26888. /**
  26889. * The angularAcceleration of the device, values in array are [x,y,z].
  26890. */
  26891. readonly angularAcceleration: Nullable<Float32Array>;
  26892. }
  26893. /**
  26894. * Interface representing a pose controlled object in Babylon.
  26895. * A pose controlled object has both regular pose values as well as pose values
  26896. * from an external device such as a VR head mounted display
  26897. */
  26898. export interface PoseControlled {
  26899. /**
  26900. * The position of the object in babylon space.
  26901. */
  26902. position: Vector3;
  26903. /**
  26904. * The rotation quaternion of the object in babylon space.
  26905. */
  26906. rotationQuaternion: Quaternion;
  26907. /**
  26908. * The position of the device in babylon space.
  26909. */
  26910. devicePosition?: Vector3;
  26911. /**
  26912. * The rotation quaternion of the device in babylon space.
  26913. */
  26914. deviceRotationQuaternion: Quaternion;
  26915. /**
  26916. * The raw pose coming from the device.
  26917. */
  26918. rawPose: Nullable<DevicePose>;
  26919. /**
  26920. * The scale of the device to be used when translating from device space to babylon space.
  26921. */
  26922. deviceScaleFactor: number;
  26923. /**
  26924. * Updates the poseControlled values based on the input device pose.
  26925. * @param poseData the pose data to update the object with
  26926. */
  26927. updateFromDevice(poseData: DevicePose): void;
  26928. }
  26929. /**
  26930. * Set of options to customize the webVRCamera
  26931. */
  26932. export interface WebVROptions {
  26933. /**
  26934. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26935. */
  26936. trackPosition?: boolean;
  26937. /**
  26938. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26939. */
  26940. positionScale?: number;
  26941. /**
  26942. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26943. */
  26944. displayName?: string;
  26945. /**
  26946. * Should the native controller meshes be initialized. (default: true)
  26947. */
  26948. controllerMeshes?: boolean;
  26949. /**
  26950. * Creating a default HemiLight only on controllers. (default: true)
  26951. */
  26952. defaultLightingOnControllers?: boolean;
  26953. /**
  26954. * If you don't want to use the default VR button of the helper. (default: false)
  26955. */
  26956. useCustomVRButton?: boolean;
  26957. /**
  26958. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26959. */
  26960. customVRButton?: HTMLButtonElement;
  26961. /**
  26962. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26963. */
  26964. rayLength?: number;
  26965. /**
  26966. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26967. */
  26968. defaultHeight?: number;
  26969. /**
  26970. * If multiview should be used if availible (default: false)
  26971. */
  26972. useMultiview?: boolean;
  26973. }
  26974. /**
  26975. * This represents a WebVR camera.
  26976. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26977. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26978. */
  26979. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26980. private webVROptions;
  26981. /**
  26982. * @hidden
  26983. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26984. */
  26985. _vrDevice: any;
  26986. /**
  26987. * The rawPose of the vrDevice.
  26988. */
  26989. rawPose: Nullable<DevicePose>;
  26990. private _onVREnabled;
  26991. private _specsVersion;
  26992. private _attached;
  26993. private _frameData;
  26994. protected _descendants: Array<Node>;
  26995. private _deviceRoomPosition;
  26996. /** @hidden */
  26997. _deviceRoomRotationQuaternion: Quaternion;
  26998. private _standingMatrix;
  26999. /**
  27000. * Represents device position in babylon space.
  27001. */
  27002. devicePosition: Vector3;
  27003. /**
  27004. * Represents device rotation in babylon space.
  27005. */
  27006. deviceRotationQuaternion: Quaternion;
  27007. /**
  27008. * The scale of the device to be used when translating from device space to babylon space.
  27009. */
  27010. deviceScaleFactor: number;
  27011. private _deviceToWorld;
  27012. private _worldToDevice;
  27013. /**
  27014. * References to the webVR controllers for the vrDevice.
  27015. */
  27016. controllers: Array<WebVRController>;
  27017. /**
  27018. * Emits an event when a controller is attached.
  27019. */
  27020. onControllersAttachedObservable: Observable<WebVRController[]>;
  27021. /**
  27022. * Emits an event when a controller's mesh has been loaded;
  27023. */
  27024. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27025. /**
  27026. * Emits an event when the HMD's pose has been updated.
  27027. */
  27028. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27029. private _poseSet;
  27030. /**
  27031. * If the rig cameras be used as parent instead of this camera.
  27032. */
  27033. rigParenting: boolean;
  27034. private _lightOnControllers;
  27035. private _defaultHeight?;
  27036. /**
  27037. * Instantiates a WebVRFreeCamera.
  27038. * @param name The name of the WebVRFreeCamera
  27039. * @param position The starting anchor position for the camera
  27040. * @param scene The scene the camera belongs to
  27041. * @param webVROptions a set of customizable options for the webVRCamera
  27042. */
  27043. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27044. /**
  27045. * Gets the device distance from the ground in meters.
  27046. * @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.
  27047. */
  27048. deviceDistanceToRoomGround(): number;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27052. */
  27053. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27054. /**
  27055. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27056. * @returns A promise with a boolean set to if the standing matrix is supported.
  27057. */
  27058. useStandingMatrixAsync(): Promise<boolean>;
  27059. /**
  27060. * Disposes the camera
  27061. */
  27062. dispose(): void;
  27063. /**
  27064. * Gets a vrController by name.
  27065. * @param name The name of the controller to retreive
  27066. * @returns the controller matching the name specified or null if not found
  27067. */
  27068. getControllerByName(name: string): Nullable<WebVRController>;
  27069. private _leftController;
  27070. /**
  27071. * The controller corresponding to the users left hand.
  27072. */
  27073. get leftController(): Nullable<WebVRController>;
  27074. private _rightController;
  27075. /**
  27076. * The controller corresponding to the users right hand.
  27077. */
  27078. get rightController(): Nullable<WebVRController>;
  27079. /**
  27080. * Casts a ray forward from the vrCamera's gaze.
  27081. * @param length Length of the ray (default: 100)
  27082. * @returns the ray corresponding to the gaze
  27083. */
  27084. getForwardRay(length?: number): Ray;
  27085. /**
  27086. * @hidden
  27087. * Updates the camera based on device's frame data
  27088. */
  27089. _checkInputs(): void;
  27090. /**
  27091. * Updates the poseControlled values based on the input device pose.
  27092. * @param poseData Pose coming from the device
  27093. */
  27094. updateFromDevice(poseData: DevicePose): void;
  27095. private _detachIfAttached;
  27096. /**
  27097. * WebVR's attach control will start broadcasting frames to the device.
  27098. * Note that in certain browsers (chrome for example) this function must be called
  27099. * within a user-interaction callback. Example:
  27100. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27101. *
  27102. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27103. */
  27104. attachControl(noPreventDefault?: boolean): void;
  27105. /**
  27106. * Detach the current controls from the specified dom element.
  27107. */
  27108. detachControl(): void;
  27109. /**
  27110. * @returns the name of this class
  27111. */
  27112. getClassName(): string;
  27113. /**
  27114. * Calls resetPose on the vrDisplay
  27115. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27116. */
  27117. resetToCurrentRotation(): void;
  27118. /**
  27119. * @hidden
  27120. * Updates the rig cameras (left and right eye)
  27121. */
  27122. _updateRigCameras(): void;
  27123. private _workingVector;
  27124. private _oneVector;
  27125. private _workingMatrix;
  27126. private updateCacheCalled;
  27127. private _correctPositionIfNotTrackPosition;
  27128. /**
  27129. * @hidden
  27130. * Updates the cached values of the camera
  27131. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27132. */
  27133. _updateCache(ignoreParentClass?: boolean): void;
  27134. /**
  27135. * @hidden
  27136. * Get current device position in babylon world
  27137. */
  27138. _computeDevicePosition(): void;
  27139. /**
  27140. * Updates the current device position and rotation in the babylon world
  27141. */
  27142. update(): void;
  27143. /**
  27144. * @hidden
  27145. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27146. * @returns an identity matrix
  27147. */
  27148. _getViewMatrix(): Matrix;
  27149. private _tmpMatrix;
  27150. /**
  27151. * This function is called by the two RIG cameras.
  27152. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27153. * @hidden
  27154. */
  27155. _getWebVRViewMatrix(): Matrix;
  27156. /** @hidden */
  27157. _getWebVRProjectionMatrix(): Matrix;
  27158. private _onGamepadConnectedObserver;
  27159. private _onGamepadDisconnectedObserver;
  27160. private _updateCacheWhenTrackingDisabledObserver;
  27161. /**
  27162. * Initializes the controllers and their meshes
  27163. */
  27164. initControllers(): void;
  27165. }
  27166. }
  27167. declare module BABYLON {
  27168. /**
  27169. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27170. *
  27171. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27172. *
  27173. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27174. */
  27175. export class MaterialHelper {
  27176. /**
  27177. * Bind the current view position to an effect.
  27178. * @param effect The effect to be bound
  27179. * @param scene The scene the eyes position is used from
  27180. * @param variableName name of the shader variable that will hold the eye position
  27181. */
  27182. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27183. /**
  27184. * Helps preparing the defines values about the UVs in used in the effect.
  27185. * UVs are shared as much as we can accross channels in the shaders.
  27186. * @param texture The texture we are preparing the UVs for
  27187. * @param defines The defines to update
  27188. * @param key The channel key "diffuse", "specular"... used in the shader
  27189. */
  27190. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27191. /**
  27192. * Binds a texture matrix value to its corrsponding uniform
  27193. * @param texture The texture to bind the matrix for
  27194. * @param uniformBuffer The uniform buffer receivin the data
  27195. * @param key The channel key "diffuse", "specular"... used in the shader
  27196. */
  27197. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27198. /**
  27199. * Gets the current status of the fog (should it be enabled?)
  27200. * @param mesh defines the mesh to evaluate for fog support
  27201. * @param scene defines the hosting scene
  27202. * @returns true if fog must be enabled
  27203. */
  27204. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27205. /**
  27206. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27207. * @param mesh defines the current mesh
  27208. * @param scene defines the current scene
  27209. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27210. * @param pointsCloud defines if point cloud rendering has to be turned on
  27211. * @param fogEnabled defines if fog has to be turned on
  27212. * @param alphaTest defines if alpha testing has to be turned on
  27213. * @param defines defines the current list of defines
  27214. */
  27215. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27216. /**
  27217. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27218. * @param scene defines the current scene
  27219. * @param engine defines the current engine
  27220. * @param defines specifies the list of active defines
  27221. * @param useInstances defines if instances have to be turned on
  27222. * @param useClipPlane defines if clip plane have to be turned on
  27223. * @param useInstances defines if instances have to be turned on
  27224. * @param useThinInstances defines if thin instances have to be turned on
  27225. */
  27226. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27227. /**
  27228. * Prepares the defines for bones
  27229. * @param mesh The mesh containing the geometry data we will draw
  27230. * @param defines The defines to update
  27231. */
  27232. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27233. /**
  27234. * Prepares the defines for morph targets
  27235. * @param mesh The mesh containing the geometry data we will draw
  27236. * @param defines The defines to update
  27237. */
  27238. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27239. /**
  27240. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27241. * @param mesh The mesh containing the geometry data we will draw
  27242. * @param defines The defines to update
  27243. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27244. * @param useBones Precise whether bones should be used or not (override mesh info)
  27245. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27246. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27247. * @returns false if defines are considered not dirty and have not been checked
  27248. */
  27249. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27250. /**
  27251. * Prepares the defines related to multiview
  27252. * @param scene The scene we are intending to draw
  27253. * @param defines The defines to update
  27254. */
  27255. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27256. /**
  27257. * Prepares the defines related to the prepass
  27258. * @param scene The scene we are intending to draw
  27259. * @param defines The defines to update
  27260. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27261. */
  27262. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27263. /**
  27264. * Prepares the defines related to the light information passed in parameter
  27265. * @param scene The scene we are intending to draw
  27266. * @param mesh The mesh the effect is compiling for
  27267. * @param light The light the effect is compiling for
  27268. * @param lightIndex The index of the light
  27269. * @param defines The defines to update
  27270. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27271. * @param state Defines the current state regarding what is needed (normals, etc...)
  27272. */
  27273. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27274. needNormals: boolean;
  27275. needRebuild: boolean;
  27276. shadowEnabled: boolean;
  27277. specularEnabled: boolean;
  27278. lightmapMode: boolean;
  27279. }): void;
  27280. /**
  27281. * Prepares the defines related to the light information passed in parameter
  27282. * @param scene The scene we are intending to draw
  27283. * @param mesh The mesh the effect is compiling for
  27284. * @param defines The defines to update
  27285. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27286. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27287. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27288. * @returns true if normals will be required for the rest of the effect
  27289. */
  27290. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27291. /**
  27292. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27293. * @param lightIndex defines the light index
  27294. * @param uniformsList The uniform list
  27295. * @param samplersList The sampler list
  27296. * @param projectedLightTexture defines if projected texture must be used
  27297. * @param uniformBuffersList defines an optional list of uniform buffers
  27298. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27299. */
  27300. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27301. /**
  27302. * Prepares the uniforms and samplers list to be used in the effect
  27303. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27304. * @param samplersList The sampler list
  27305. * @param defines The defines helping in the list generation
  27306. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27307. */
  27308. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27309. /**
  27310. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27311. * @param defines The defines to update while falling back
  27312. * @param fallbacks The authorized effect fallbacks
  27313. * @param maxSimultaneousLights The maximum number of lights allowed
  27314. * @param rank the current rank of the Effect
  27315. * @returns The newly affected rank
  27316. */
  27317. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27318. private static _TmpMorphInfluencers;
  27319. /**
  27320. * Prepares the list of attributes required for morph targets according to the effect defines.
  27321. * @param attribs The current list of supported attribs
  27322. * @param mesh The mesh to prepare the morph targets attributes for
  27323. * @param influencers The number of influencers
  27324. */
  27325. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27326. /**
  27327. * Prepares the list of attributes required for morph targets according to the effect defines.
  27328. * @param attribs The current list of supported attribs
  27329. * @param mesh The mesh to prepare the morph targets attributes for
  27330. * @param defines The current Defines of the effect
  27331. */
  27332. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27333. /**
  27334. * Prepares the list of attributes required for bones according to the effect defines.
  27335. * @param attribs The current list of supported attribs
  27336. * @param mesh The mesh to prepare the bones attributes for
  27337. * @param defines The current Defines of the effect
  27338. * @param fallbacks The current efffect fallback strategy
  27339. */
  27340. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27341. /**
  27342. * Check and prepare the list of attributes required for instances according to the effect defines.
  27343. * @param attribs The current list of supported attribs
  27344. * @param defines The current MaterialDefines of the effect
  27345. */
  27346. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27347. /**
  27348. * Add the list of attributes required for instances to the attribs array.
  27349. * @param attribs The current list of supported attribs
  27350. */
  27351. static PushAttributesForInstances(attribs: string[]): void;
  27352. /**
  27353. * Binds the light information to the effect.
  27354. * @param light The light containing the generator
  27355. * @param effect The effect we are binding the data to
  27356. * @param lightIndex The light index in the effect used to render
  27357. */
  27358. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27359. /**
  27360. * Binds the lights information from the scene to the effect for the given mesh.
  27361. * @param light Light to bind
  27362. * @param lightIndex Light index
  27363. * @param scene The scene where the light belongs to
  27364. * @param effect The effect we are binding the data to
  27365. * @param useSpecular Defines if specular is supported
  27366. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27367. */
  27368. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27369. /**
  27370. * Binds the lights information from the scene to the effect for the given mesh.
  27371. * @param scene The scene the lights belongs to
  27372. * @param mesh The mesh we are binding the information to render
  27373. * @param effect The effect we are binding the data to
  27374. * @param defines The generated defines for the effect
  27375. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27376. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27377. */
  27378. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27379. private static _tempFogColor;
  27380. /**
  27381. * Binds the fog information from the scene to the effect for the given mesh.
  27382. * @param scene The scene the lights belongs to
  27383. * @param mesh The mesh we are binding the information to render
  27384. * @param effect The effect we are binding the data to
  27385. * @param linearSpace Defines if the fog effect is applied in linear space
  27386. */
  27387. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27388. /**
  27389. * Binds the bones information from the mesh to the effect.
  27390. * @param mesh The mesh we are binding the information to render
  27391. * @param effect The effect we are binding the data to
  27392. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27393. */
  27394. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27395. private static _CopyBonesTransformationMatrices;
  27396. /**
  27397. * Binds the morph targets information from the mesh to the effect.
  27398. * @param abstractMesh The mesh we are binding the information to render
  27399. * @param effect The effect we are binding the data to
  27400. */
  27401. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27402. /**
  27403. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27404. * @param defines The generated defines used in the effect
  27405. * @param effect The effect we are binding the data to
  27406. * @param scene The scene we are willing to render with logarithmic scale for
  27407. */
  27408. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27409. /**
  27410. * Binds the clip plane information from the scene to the effect.
  27411. * @param scene The scene the clip plane information are extracted from
  27412. * @param effect The effect we are binding the data to
  27413. */
  27414. static BindClipPlane(effect: Effect, scene: Scene): void;
  27415. }
  27416. }
  27417. declare module BABYLON {
  27418. /** @hidden */
  27419. export var bayerDitherFunctions: {
  27420. name: string;
  27421. shader: string;
  27422. };
  27423. }
  27424. declare module BABYLON {
  27425. /** @hidden */
  27426. export var shadowMapFragmentDeclaration: {
  27427. name: string;
  27428. shader: string;
  27429. };
  27430. }
  27431. declare module BABYLON {
  27432. /** @hidden */
  27433. export var shadowMapFragment: {
  27434. name: string;
  27435. shader: string;
  27436. };
  27437. }
  27438. declare module BABYLON {
  27439. /** @hidden */
  27440. export var shadowMapPixelShader: {
  27441. name: string;
  27442. shader: string;
  27443. };
  27444. }
  27445. declare module BABYLON {
  27446. /** @hidden */
  27447. export var shadowMapVertexDeclaration: {
  27448. name: string;
  27449. shader: string;
  27450. };
  27451. }
  27452. declare module BABYLON {
  27453. /** @hidden */
  27454. export var shadowMapVertexNormalBias: {
  27455. name: string;
  27456. shader: string;
  27457. };
  27458. }
  27459. declare module BABYLON {
  27460. /** @hidden */
  27461. export var shadowMapVertexMetric: {
  27462. name: string;
  27463. shader: string;
  27464. };
  27465. }
  27466. declare module BABYLON {
  27467. /** @hidden */
  27468. export var shadowMapVertexShader: {
  27469. name: string;
  27470. shader: string;
  27471. };
  27472. }
  27473. declare module BABYLON {
  27474. /** @hidden */
  27475. export var depthBoxBlurPixelShader: {
  27476. name: string;
  27477. shader: string;
  27478. };
  27479. }
  27480. declare module BABYLON {
  27481. /** @hidden */
  27482. export var shadowMapFragmentSoftTransparentShadow: {
  27483. name: string;
  27484. shader: string;
  27485. };
  27486. }
  27487. declare module BABYLON {
  27488. /**
  27489. * Creates an instance based on a source mesh.
  27490. */
  27491. export class InstancedMesh extends AbstractMesh {
  27492. private _sourceMesh;
  27493. private _currentLOD;
  27494. /** @hidden */
  27495. _indexInSourceMeshInstanceArray: number;
  27496. constructor(name: string, source: Mesh);
  27497. /**
  27498. * Returns the string "InstancedMesh".
  27499. */
  27500. getClassName(): string;
  27501. /** Gets the list of lights affecting that mesh */
  27502. get lightSources(): Light[];
  27503. _resyncLightSources(): void;
  27504. _resyncLightSource(light: Light): void;
  27505. _removeLightSource(light: Light, dispose: boolean): void;
  27506. /**
  27507. * If the source mesh receives shadows
  27508. */
  27509. get receiveShadows(): boolean;
  27510. /**
  27511. * The material of the source mesh
  27512. */
  27513. get material(): Nullable<Material>;
  27514. /**
  27515. * Visibility of the source mesh
  27516. */
  27517. get visibility(): number;
  27518. /**
  27519. * Skeleton of the source mesh
  27520. */
  27521. get skeleton(): Nullable<Skeleton>;
  27522. /**
  27523. * Rendering ground id of the source mesh
  27524. */
  27525. get renderingGroupId(): number;
  27526. set renderingGroupId(value: number);
  27527. /**
  27528. * Returns the total number of vertices (integer).
  27529. */
  27530. getTotalVertices(): number;
  27531. /**
  27532. * Returns a positive integer : the total number of indices in this mesh geometry.
  27533. * @returns the numner of indices or zero if the mesh has no geometry.
  27534. */
  27535. getTotalIndices(): number;
  27536. /**
  27537. * The source mesh of the instance
  27538. */
  27539. get sourceMesh(): Mesh;
  27540. /**
  27541. * Creates a new InstancedMesh object from the mesh model.
  27542. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27543. * @param name defines the name of the new instance
  27544. * @returns a new InstancedMesh
  27545. */
  27546. createInstance(name: string): InstancedMesh;
  27547. /**
  27548. * Is this node ready to be used/rendered
  27549. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27550. * @return {boolean} is it ready
  27551. */
  27552. isReady(completeCheck?: boolean): boolean;
  27553. /**
  27554. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27555. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27556. * @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.
  27557. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27558. */
  27559. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27560. /**
  27561. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27562. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27563. * The `data` are either a numeric array either a Float32Array.
  27564. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27565. * 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).
  27566. * Note that a new underlying VertexBuffer object is created each call.
  27567. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27568. *
  27569. * Possible `kind` values :
  27570. * - VertexBuffer.PositionKind
  27571. * - VertexBuffer.UVKind
  27572. * - VertexBuffer.UV2Kind
  27573. * - VertexBuffer.UV3Kind
  27574. * - VertexBuffer.UV4Kind
  27575. * - VertexBuffer.UV5Kind
  27576. * - VertexBuffer.UV6Kind
  27577. * - VertexBuffer.ColorKind
  27578. * - VertexBuffer.MatricesIndicesKind
  27579. * - VertexBuffer.MatricesIndicesExtraKind
  27580. * - VertexBuffer.MatricesWeightsKind
  27581. * - VertexBuffer.MatricesWeightsExtraKind
  27582. *
  27583. * Returns the Mesh.
  27584. */
  27585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27586. /**
  27587. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27588. * If the mesh has no geometry, it is simply returned as it is.
  27589. * The `data` are either a numeric array either a Float32Array.
  27590. * No new underlying VertexBuffer object is created.
  27591. * 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.
  27592. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27593. *
  27594. * Possible `kind` values :
  27595. * - VertexBuffer.PositionKind
  27596. * - VertexBuffer.UVKind
  27597. * - VertexBuffer.UV2Kind
  27598. * - VertexBuffer.UV3Kind
  27599. * - VertexBuffer.UV4Kind
  27600. * - VertexBuffer.UV5Kind
  27601. * - VertexBuffer.UV6Kind
  27602. * - VertexBuffer.ColorKind
  27603. * - VertexBuffer.MatricesIndicesKind
  27604. * - VertexBuffer.MatricesIndicesExtraKind
  27605. * - VertexBuffer.MatricesWeightsKind
  27606. * - VertexBuffer.MatricesWeightsExtraKind
  27607. *
  27608. * Returns the Mesh.
  27609. */
  27610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27611. /**
  27612. * Sets the mesh indices.
  27613. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27614. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27615. * This method creates a new index buffer each call.
  27616. * Returns the Mesh.
  27617. */
  27618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27619. /**
  27620. * Boolean : True if the mesh owns the requested kind of data.
  27621. */
  27622. isVerticesDataPresent(kind: string): boolean;
  27623. /**
  27624. * Returns an array of indices (IndicesArray).
  27625. */
  27626. getIndices(): Nullable<IndicesArray>;
  27627. get _positions(): Nullable<Vector3[]>;
  27628. /**
  27629. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27630. * This means the mesh underlying bounding box and sphere are recomputed.
  27631. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27632. * @returns the current mesh
  27633. */
  27634. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27635. /** @hidden */
  27636. _preActivate(): InstancedMesh;
  27637. /** @hidden */
  27638. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27639. /** @hidden */
  27640. _postActivate(): void;
  27641. getWorldMatrix(): Matrix;
  27642. get isAnInstance(): boolean;
  27643. /**
  27644. * Returns the current associated LOD AbstractMesh.
  27645. */
  27646. getLOD(camera: Camera): AbstractMesh;
  27647. /** @hidden */
  27648. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27649. /** @hidden */
  27650. _syncSubMeshes(): InstancedMesh;
  27651. /** @hidden */
  27652. _generatePointsArray(): boolean;
  27653. /** @hidden */
  27654. _updateBoundingInfo(): AbstractMesh;
  27655. /**
  27656. * Creates a new InstancedMesh from the current mesh.
  27657. * - name (string) : the cloned mesh name
  27658. * - newParent (optional Node) : the optional Node to parent the clone to.
  27659. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27660. *
  27661. * Returns the clone.
  27662. */
  27663. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27664. /**
  27665. * Disposes the InstancedMesh.
  27666. * Returns nothing.
  27667. */
  27668. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27669. }
  27670. interface Mesh {
  27671. /**
  27672. * Register a custom buffer that will be instanced
  27673. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27674. * @param kind defines the buffer kind
  27675. * @param stride defines the stride in floats
  27676. */
  27677. registerInstancedBuffer(kind: string, stride: number): void;
  27678. /**
  27679. * true to use the edge renderer for all instances of this mesh
  27680. */
  27681. edgesShareWithInstances: boolean;
  27682. /** @hidden */
  27683. _userInstancedBuffersStorage: {
  27684. data: {
  27685. [key: string]: Float32Array;
  27686. };
  27687. sizes: {
  27688. [key: string]: number;
  27689. };
  27690. vertexBuffers: {
  27691. [key: string]: Nullable<VertexBuffer>;
  27692. };
  27693. strides: {
  27694. [key: string]: number;
  27695. };
  27696. };
  27697. }
  27698. interface AbstractMesh {
  27699. /**
  27700. * Object used to store instanced buffers defined by user
  27701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27702. */
  27703. instancedBuffers: {
  27704. [key: string]: any;
  27705. };
  27706. }
  27707. }
  27708. declare module BABYLON {
  27709. /**
  27710. * Defines the options associated with the creation of a shader material.
  27711. */
  27712. export interface IShaderMaterialOptions {
  27713. /**
  27714. * Does the material work in alpha blend mode
  27715. */
  27716. needAlphaBlending: boolean;
  27717. /**
  27718. * Does the material work in alpha test mode
  27719. */
  27720. needAlphaTesting: boolean;
  27721. /**
  27722. * The list of attribute names used in the shader
  27723. */
  27724. attributes: string[];
  27725. /**
  27726. * The list of unifrom names used in the shader
  27727. */
  27728. uniforms: string[];
  27729. /**
  27730. * The list of UBO names used in the shader
  27731. */
  27732. uniformBuffers: string[];
  27733. /**
  27734. * The list of sampler names used in the shader
  27735. */
  27736. samplers: string[];
  27737. /**
  27738. * The list of defines used in the shader
  27739. */
  27740. defines: string[];
  27741. }
  27742. /**
  27743. * 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.
  27744. *
  27745. * This returned material effects how the mesh will look based on the code in the shaders.
  27746. *
  27747. * @see https://doc.babylonjs.com/how_to/shader_material
  27748. */
  27749. export class ShaderMaterial extends Material {
  27750. private _shaderPath;
  27751. private _options;
  27752. private _textures;
  27753. private _textureArrays;
  27754. private _floats;
  27755. private _ints;
  27756. private _floatsArrays;
  27757. private _colors3;
  27758. private _colors3Arrays;
  27759. private _colors4;
  27760. private _colors4Arrays;
  27761. private _vectors2;
  27762. private _vectors3;
  27763. private _vectors4;
  27764. private _matrices;
  27765. private _matrixArrays;
  27766. private _matrices3x3;
  27767. private _matrices2x2;
  27768. private _vectors2Arrays;
  27769. private _vectors3Arrays;
  27770. private _vectors4Arrays;
  27771. private _cachedWorldViewMatrix;
  27772. private _cachedWorldViewProjectionMatrix;
  27773. private _renderId;
  27774. private _multiview;
  27775. private _cachedDefines;
  27776. /** Define the Url to load snippets */
  27777. static SnippetUrl: string;
  27778. /** Snippet ID if the material was created from the snippet server */
  27779. snippetId: string;
  27780. /**
  27781. * Instantiate a new shader material.
  27782. * 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.
  27783. * This returned material effects how the mesh will look based on the code in the shaders.
  27784. * @see https://doc.babylonjs.com/how_to/shader_material
  27785. * @param name Define the name of the material in the scene
  27786. * @param scene Define the scene the material belongs to
  27787. * @param shaderPath Defines the route to the shader code in one of three ways:
  27788. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27789. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27790. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27791. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27792. * @param options Define the options used to create the shader
  27793. */
  27794. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27795. /**
  27796. * Gets the shader path used to define the shader code
  27797. * It can be modified to trigger a new compilation
  27798. */
  27799. get shaderPath(): any;
  27800. /**
  27801. * Sets the shader path used to define the shader code
  27802. * It can be modified to trigger a new compilation
  27803. */
  27804. set shaderPath(shaderPath: any);
  27805. /**
  27806. * Gets the options used to compile the shader.
  27807. * They can be modified to trigger a new compilation
  27808. */
  27809. get options(): IShaderMaterialOptions;
  27810. /**
  27811. * Gets the current class name of the material e.g. "ShaderMaterial"
  27812. * Mainly use in serialization.
  27813. * @returns the class name
  27814. */
  27815. getClassName(): string;
  27816. /**
  27817. * Specifies if the material will require alpha blending
  27818. * @returns a boolean specifying if alpha blending is needed
  27819. */
  27820. needAlphaBlending(): boolean;
  27821. /**
  27822. * Specifies if this material should be rendered in alpha test mode
  27823. * @returns a boolean specifying if an alpha test is needed.
  27824. */
  27825. needAlphaTesting(): boolean;
  27826. private _checkUniform;
  27827. /**
  27828. * Set a texture in the shader.
  27829. * @param name Define the name of the uniform samplers as defined in the shader
  27830. * @param texture Define the texture to bind to this sampler
  27831. * @return the material itself allowing "fluent" like uniform updates
  27832. */
  27833. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27834. /**
  27835. * Set a texture array in the shader.
  27836. * @param name Define the name of the uniform sampler array as defined in the shader
  27837. * @param textures Define the list of textures to bind to this sampler
  27838. * @return the material itself allowing "fluent" like uniform updates
  27839. */
  27840. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27841. /**
  27842. * Set a float in the shader.
  27843. * @param name Define the name of the uniform as defined in the shader
  27844. * @param value Define the value to give to the uniform
  27845. * @return the material itself allowing "fluent" like uniform updates
  27846. */
  27847. setFloat(name: string, value: number): ShaderMaterial;
  27848. /**
  27849. * Set a int in the shader.
  27850. * @param name Define the name of the uniform as defined in the shader
  27851. * @param value Define the value to give to the uniform
  27852. * @return the material itself allowing "fluent" like uniform updates
  27853. */
  27854. setInt(name: string, value: number): ShaderMaterial;
  27855. /**
  27856. * Set an array of floats in the shader.
  27857. * @param name Define the name of the uniform as defined in the shader
  27858. * @param value Define the value to give to the uniform
  27859. * @return the material itself allowing "fluent" like uniform updates
  27860. */
  27861. setFloats(name: string, value: number[]): ShaderMaterial;
  27862. /**
  27863. * Set a vec3 in the shader from a Color3.
  27864. * @param name Define the name of the uniform as defined in the shader
  27865. * @param value Define the value to give to the uniform
  27866. * @return the material itself allowing "fluent" like uniform updates
  27867. */
  27868. setColor3(name: string, value: Color3): ShaderMaterial;
  27869. /**
  27870. * Set a vec3 array in the shader from a Color3 array.
  27871. * @param name Define the name of the uniform as defined in the shader
  27872. * @param value Define the value to give to the uniform
  27873. * @return the material itself allowing "fluent" like uniform updates
  27874. */
  27875. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27876. /**
  27877. * Set a vec4 in the shader from a Color4.
  27878. * @param name Define the name of the uniform as defined in the shader
  27879. * @param value Define the value to give to the uniform
  27880. * @return the material itself allowing "fluent" like uniform updates
  27881. */
  27882. setColor4(name: string, value: Color4): ShaderMaterial;
  27883. /**
  27884. * Set a vec4 array in the shader from a Color4 array.
  27885. * @param name Define the name of the uniform as defined in the shader
  27886. * @param value Define the value to give to the uniform
  27887. * @return the material itself allowing "fluent" like uniform updates
  27888. */
  27889. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27890. /**
  27891. * Set a vec2 in the shader from a Vector2.
  27892. * @param name Define the name of the uniform as defined in the shader
  27893. * @param value Define the value to give to the uniform
  27894. * @return the material itself allowing "fluent" like uniform updates
  27895. */
  27896. setVector2(name: string, value: Vector2): ShaderMaterial;
  27897. /**
  27898. * Set a vec3 in the shader from a Vector3.
  27899. * @param name Define the name of the uniform as defined in the shader
  27900. * @param value Define the value to give to the uniform
  27901. * @return the material itself allowing "fluent" like uniform updates
  27902. */
  27903. setVector3(name: string, value: Vector3): ShaderMaterial;
  27904. /**
  27905. * Set a vec4 in the shader from a Vector4.
  27906. * @param name Define the name of the uniform as defined in the shader
  27907. * @param value Define the value to give to the uniform
  27908. * @return the material itself allowing "fluent" like uniform updates
  27909. */
  27910. setVector4(name: string, value: Vector4): ShaderMaterial;
  27911. /**
  27912. * Set a mat4 in the shader from a Matrix.
  27913. * @param name Define the name of the uniform as defined in the shader
  27914. * @param value Define the value to give to the uniform
  27915. * @return the material itself allowing "fluent" like uniform updates
  27916. */
  27917. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27918. /**
  27919. * Set a float32Array in the shader from a matrix array.
  27920. * @param name Define the name of the uniform as defined in the shader
  27921. * @param value Define the value to give to the uniform
  27922. * @return the material itself allowing "fluent" like uniform updates
  27923. */
  27924. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27925. /**
  27926. * Set a mat3 in the shader from a Float32Array.
  27927. * @param name Define the name of the uniform as defined in the shader
  27928. * @param value Define the value to give to the uniform
  27929. * @return the material itself allowing "fluent" like uniform updates
  27930. */
  27931. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27932. /**
  27933. * Set a mat2 in the shader from a Float32Array.
  27934. * @param name Define the name of the uniform as defined in the shader
  27935. * @param value Define the value to give to the uniform
  27936. * @return the material itself allowing "fluent" like uniform updates
  27937. */
  27938. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27939. /**
  27940. * Set a vec2 array in the shader from a number array.
  27941. * @param name Define the name of the uniform as defined in the shader
  27942. * @param value Define the value to give to the uniform
  27943. * @return the material itself allowing "fluent" like uniform updates
  27944. */
  27945. setArray2(name: string, value: number[]): ShaderMaterial;
  27946. /**
  27947. * Set a vec3 array in the shader from a number array.
  27948. * @param name Define the name of the uniform as defined in the shader
  27949. * @param value Define the value to give to the uniform
  27950. * @return the material itself allowing "fluent" like uniform updates
  27951. */
  27952. setArray3(name: string, value: number[]): ShaderMaterial;
  27953. /**
  27954. * Set a vec4 array in the shader from a number array.
  27955. * @param name Define the name of the uniform as defined in the shader
  27956. * @param value Define the value to give to the uniform
  27957. * @return the material itself allowing "fluent" like uniform updates
  27958. */
  27959. setArray4(name: string, value: number[]): ShaderMaterial;
  27960. private _checkCache;
  27961. /**
  27962. * Specifies that the submesh is ready to be used
  27963. * @param mesh defines the mesh to check
  27964. * @param subMesh defines which submesh to check
  27965. * @param useInstances specifies that instances should be used
  27966. * @returns a boolean indicating that the submesh is ready or not
  27967. */
  27968. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27969. /**
  27970. * Checks if the material is ready to render the requested mesh
  27971. * @param mesh Define the mesh to render
  27972. * @param useInstances Define whether or not the material is used with instances
  27973. * @returns true if ready, otherwise false
  27974. */
  27975. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27976. /**
  27977. * Binds the world matrix to the material
  27978. * @param world defines the world transformation matrix
  27979. * @param effectOverride - If provided, use this effect instead of internal effect
  27980. */
  27981. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27982. /**
  27983. * Binds the submesh to this material by preparing the effect and shader to draw
  27984. * @param world defines the world transformation matrix
  27985. * @param mesh defines the mesh containing the submesh
  27986. * @param subMesh defines the submesh to bind the material to
  27987. */
  27988. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27989. /**
  27990. * Binds the material to the mesh
  27991. * @param world defines the world transformation matrix
  27992. * @param mesh defines the mesh to bind the material to
  27993. * @param effectOverride - If provided, use this effect instead of internal effect
  27994. */
  27995. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27996. protected _afterBind(mesh?: Mesh): void;
  27997. /**
  27998. * Gets the active textures from the material
  27999. * @returns an array of textures
  28000. */
  28001. getActiveTextures(): BaseTexture[];
  28002. /**
  28003. * Specifies if the material uses a texture
  28004. * @param texture defines the texture to check against the material
  28005. * @returns a boolean specifying if the material uses the texture
  28006. */
  28007. hasTexture(texture: BaseTexture): boolean;
  28008. /**
  28009. * Makes a duplicate of the material, and gives it a new name
  28010. * @param name defines the new name for the duplicated material
  28011. * @returns the cloned material
  28012. */
  28013. clone(name: string): ShaderMaterial;
  28014. /**
  28015. * Disposes the material
  28016. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28017. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28018. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28019. */
  28020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28021. /**
  28022. * Serializes this material in a JSON representation
  28023. * @returns the serialized material object
  28024. */
  28025. serialize(): any;
  28026. /**
  28027. * Creates a shader material from parsed shader material data
  28028. * @param source defines the JSON represnetation of the material
  28029. * @param scene defines the hosting scene
  28030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28031. * @returns a new material
  28032. */
  28033. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28034. /**
  28035. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28036. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28037. * @param url defines the url to load from
  28038. * @param scene defines the hosting scene
  28039. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28040. * @returns a promise that will resolve to the new ShaderMaterial
  28041. */
  28042. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28043. /**
  28044. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28045. * @param snippetId defines the snippet to load
  28046. * @param scene defines the hosting scene
  28047. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28048. * @returns a promise that will resolve to the new ShaderMaterial
  28049. */
  28050. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28051. }
  28052. }
  28053. declare module BABYLON {
  28054. /** @hidden */
  28055. export var colorPixelShader: {
  28056. name: string;
  28057. shader: string;
  28058. };
  28059. }
  28060. declare module BABYLON {
  28061. /** @hidden */
  28062. export var colorVertexShader: {
  28063. name: string;
  28064. shader: string;
  28065. };
  28066. }
  28067. declare module BABYLON {
  28068. /**
  28069. * Line mesh
  28070. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28071. */
  28072. export class LinesMesh extends Mesh {
  28073. /**
  28074. * If vertex color should be applied to the mesh
  28075. */
  28076. readonly useVertexColor?: boolean | undefined;
  28077. /**
  28078. * If vertex alpha should be applied to the mesh
  28079. */
  28080. readonly useVertexAlpha?: boolean | undefined;
  28081. /**
  28082. * Color of the line (Default: White)
  28083. */
  28084. color: Color3;
  28085. /**
  28086. * Alpha of the line (Default: 1)
  28087. */
  28088. alpha: number;
  28089. /**
  28090. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28091. * This margin is expressed in world space coordinates, so its value may vary.
  28092. * Default value is 0.1
  28093. */
  28094. intersectionThreshold: number;
  28095. private _colorShader;
  28096. private color4;
  28097. /**
  28098. * Creates a new LinesMesh
  28099. * @param name defines the name
  28100. * @param scene defines the hosting scene
  28101. * @param parent defines the parent mesh if any
  28102. * @param source defines the optional source LinesMesh used to clone data from
  28103. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28104. * When false, achieved by calling a clone(), also passing False.
  28105. * This will make creation of children, recursive.
  28106. * @param useVertexColor defines if this LinesMesh supports vertex color
  28107. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28108. */
  28109. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28110. /**
  28111. * If vertex color should be applied to the mesh
  28112. */
  28113. useVertexColor?: boolean | undefined,
  28114. /**
  28115. * If vertex alpha should be applied to the mesh
  28116. */
  28117. useVertexAlpha?: boolean | undefined);
  28118. private _addClipPlaneDefine;
  28119. private _removeClipPlaneDefine;
  28120. isReady(): boolean;
  28121. /**
  28122. * Returns the string "LineMesh"
  28123. */
  28124. getClassName(): string;
  28125. /**
  28126. * @hidden
  28127. */
  28128. get material(): Material;
  28129. /**
  28130. * @hidden
  28131. */
  28132. set material(value: Material);
  28133. /**
  28134. * @hidden
  28135. */
  28136. get checkCollisions(): boolean;
  28137. set checkCollisions(value: boolean);
  28138. /** @hidden */
  28139. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28140. /** @hidden */
  28141. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28142. /**
  28143. * Disposes of the line mesh
  28144. * @param doNotRecurse If children should be disposed
  28145. */
  28146. dispose(doNotRecurse?: boolean): void;
  28147. /**
  28148. * Returns a new LineMesh object cloned from the current one.
  28149. */
  28150. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28151. /**
  28152. * Creates a new InstancedLinesMesh object from the mesh model.
  28153. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28154. * @param name defines the name of the new instance
  28155. * @returns a new InstancedLinesMesh
  28156. */
  28157. createInstance(name: string): InstancedLinesMesh;
  28158. }
  28159. /**
  28160. * Creates an instance based on a source LinesMesh
  28161. */
  28162. export class InstancedLinesMesh extends InstancedMesh {
  28163. /**
  28164. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28165. * This margin is expressed in world space coordinates, so its value may vary.
  28166. * Initilized with the intersectionThreshold value of the source LinesMesh
  28167. */
  28168. intersectionThreshold: number;
  28169. constructor(name: string, source: LinesMesh);
  28170. /**
  28171. * Returns the string "InstancedLinesMesh".
  28172. */
  28173. getClassName(): string;
  28174. }
  28175. }
  28176. declare module BABYLON {
  28177. /** @hidden */
  28178. export var linePixelShader: {
  28179. name: string;
  28180. shader: string;
  28181. };
  28182. }
  28183. declare module BABYLON {
  28184. /** @hidden */
  28185. export var lineVertexShader: {
  28186. name: string;
  28187. shader: string;
  28188. };
  28189. }
  28190. declare module BABYLON {
  28191. interface Scene {
  28192. /** @hidden */
  28193. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28194. }
  28195. interface AbstractMesh {
  28196. /**
  28197. * Gets the edgesRenderer associated with the mesh
  28198. */
  28199. edgesRenderer: Nullable<EdgesRenderer>;
  28200. }
  28201. interface LinesMesh {
  28202. /**
  28203. * Enables the edge rendering mode on the mesh.
  28204. * This mode makes the mesh edges visible
  28205. * @param epsilon defines the maximal distance between two angles to detect a face
  28206. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28207. * @returns the currentAbstractMesh
  28208. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28209. */
  28210. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28211. }
  28212. interface InstancedLinesMesh {
  28213. /**
  28214. * Enables the edge rendering mode on the mesh.
  28215. * This mode makes the mesh edges visible
  28216. * @param epsilon defines the maximal distance between two angles to detect a face
  28217. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28218. * @returns the current InstancedLinesMesh
  28219. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28220. */
  28221. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28222. }
  28223. /**
  28224. * Defines the minimum contract an Edges renderer should follow.
  28225. */
  28226. export interface IEdgesRenderer extends IDisposable {
  28227. /**
  28228. * Gets or sets a boolean indicating if the edgesRenderer is active
  28229. */
  28230. isEnabled: boolean;
  28231. /**
  28232. * Renders the edges of the attached mesh,
  28233. */
  28234. render(): void;
  28235. /**
  28236. * Checks wether or not the edges renderer is ready to render.
  28237. * @return true if ready, otherwise false.
  28238. */
  28239. isReady(): boolean;
  28240. /**
  28241. * List of instances to render in case the source mesh has instances
  28242. */
  28243. customInstances: SmartArray<Matrix>;
  28244. }
  28245. /**
  28246. * Defines the additional options of the edges renderer
  28247. */
  28248. export interface IEdgesRendererOptions {
  28249. /**
  28250. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28251. * If not defined, the default value is true
  28252. */
  28253. useAlternateEdgeFinder?: boolean;
  28254. /**
  28255. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28256. * If not defined, the default value is true.
  28257. * 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)
  28258. * This option is used only if useAlternateEdgeFinder = true
  28259. */
  28260. useFastVertexMerger?: boolean;
  28261. /**
  28262. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28263. * The default value is 1e-6
  28264. * This option is used only if useAlternateEdgeFinder = true
  28265. */
  28266. epsilonVertexMerge?: number;
  28267. /**
  28268. * 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
  28269. * 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.
  28270. * This option is used only if useAlternateEdgeFinder = true
  28271. */
  28272. applyTessellation?: boolean;
  28273. /**
  28274. * 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
  28275. * The default value is 1e-6
  28276. * This option is used only if useAlternateEdgeFinder = true
  28277. */
  28278. epsilonVertexAligned?: number;
  28279. }
  28280. /**
  28281. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28282. */
  28283. export class EdgesRenderer implements IEdgesRenderer {
  28284. /**
  28285. * Define the size of the edges with an orthographic camera
  28286. */
  28287. edgesWidthScalerForOrthographic: number;
  28288. /**
  28289. * Define the size of the edges with a perspective camera
  28290. */
  28291. edgesWidthScalerForPerspective: number;
  28292. protected _source: AbstractMesh;
  28293. protected _linesPositions: number[];
  28294. protected _linesNormals: number[];
  28295. protected _linesIndices: number[];
  28296. protected _epsilon: number;
  28297. protected _indicesCount: number;
  28298. protected _lineShader: ShaderMaterial;
  28299. protected _ib: DataBuffer;
  28300. protected _buffers: {
  28301. [key: string]: Nullable<VertexBuffer>;
  28302. };
  28303. protected _buffersForInstances: {
  28304. [key: string]: Nullable<VertexBuffer>;
  28305. };
  28306. protected _checkVerticesInsteadOfIndices: boolean;
  28307. protected _options: Nullable<IEdgesRendererOptions>;
  28308. private _meshRebuildObserver;
  28309. private _meshDisposeObserver;
  28310. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28311. isEnabled: boolean;
  28312. /** Gets the vertices generated by the edge renderer */
  28313. get linesPositions(): Immutable<Array<number>>;
  28314. /** Gets the normals generated by the edge renderer */
  28315. get linesNormals(): Immutable<Array<number>>;
  28316. /** Gets the indices generated by the edge renderer */
  28317. get linesIndices(): Immutable<Array<number>>;
  28318. /**
  28319. * List of instances to render in case the source mesh has instances
  28320. */
  28321. customInstances: SmartArray<Matrix>;
  28322. private static GetShader;
  28323. /**
  28324. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28325. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28326. * @param source Mesh used to create edges
  28327. * @param epsilon sum of angles in adjacency to check for edge
  28328. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28329. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28330. * @param options The options to apply when generating the edges
  28331. */
  28332. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28333. protected _prepareRessources(): void;
  28334. /** @hidden */
  28335. _rebuild(): void;
  28336. /**
  28337. * Releases the required resources for the edges renderer
  28338. */
  28339. dispose(): void;
  28340. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28341. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28342. /**
  28343. * Checks if the pair of p0 and p1 is en edge
  28344. * @param faceIndex
  28345. * @param edge
  28346. * @param faceNormals
  28347. * @param p0
  28348. * @param p1
  28349. * @private
  28350. */
  28351. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28352. /**
  28353. * push line into the position, normal and index buffer
  28354. * @protected
  28355. */
  28356. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28357. /**
  28358. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28359. */
  28360. private _tessellateTriangle;
  28361. private _generateEdgesLinesAlternate;
  28362. /**
  28363. * Generates lines edges from adjacencjes
  28364. * @private
  28365. */
  28366. _generateEdgesLines(): void;
  28367. /**
  28368. * Checks wether or not the edges renderer is ready to render.
  28369. * @return true if ready, otherwise false.
  28370. */
  28371. isReady(): boolean;
  28372. /**
  28373. * Renders the edges of the attached mesh,
  28374. */
  28375. render(): void;
  28376. }
  28377. /**
  28378. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28379. */
  28380. export class LineEdgesRenderer extends EdgesRenderer {
  28381. /**
  28382. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28383. * @param source LineMesh used to generate edges
  28384. * @param epsilon not important (specified angle for edge detection)
  28385. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28386. */
  28387. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28388. /**
  28389. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28390. */
  28391. _generateEdgesLines(): void;
  28392. }
  28393. }
  28394. declare module BABYLON {
  28395. /**
  28396. * This represents the object necessary to create a rendering group.
  28397. * This is exclusively used and created by the rendering manager.
  28398. * To modify the behavior, you use the available helpers in your scene or meshes.
  28399. * @hidden
  28400. */
  28401. export class RenderingGroup {
  28402. index: number;
  28403. private static _zeroVector;
  28404. private _scene;
  28405. private _opaqueSubMeshes;
  28406. private _transparentSubMeshes;
  28407. private _alphaTestSubMeshes;
  28408. private _depthOnlySubMeshes;
  28409. private _particleSystems;
  28410. private _spriteManagers;
  28411. private _opaqueSortCompareFn;
  28412. private _alphaTestSortCompareFn;
  28413. private _transparentSortCompareFn;
  28414. private _renderOpaque;
  28415. private _renderAlphaTest;
  28416. private _renderTransparent;
  28417. /** @hidden */
  28418. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28419. onBeforeTransparentRendering: () => void;
  28420. /**
  28421. * Set the opaque sort comparison function.
  28422. * If null the sub meshes will be render in the order they were created
  28423. */
  28424. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28425. /**
  28426. * Set the alpha test sort comparison function.
  28427. * If null the sub meshes will be render in the order they were created
  28428. */
  28429. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28430. /**
  28431. * Set the transparent sort comparison function.
  28432. * If null the sub meshes will be render in the order they were created
  28433. */
  28434. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28435. /**
  28436. * Creates a new rendering group.
  28437. * @param index The rendering group index
  28438. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28439. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28440. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28441. */
  28442. 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>);
  28443. /**
  28444. * Render all the sub meshes contained in the group.
  28445. * @param customRenderFunction Used to override the default render behaviour of the group.
  28446. * @returns true if rendered some submeshes.
  28447. */
  28448. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28449. /**
  28450. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28451. * @param subMeshes The submeshes to render
  28452. */
  28453. private renderOpaqueSorted;
  28454. /**
  28455. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28456. * @param subMeshes The submeshes to render
  28457. */
  28458. private renderAlphaTestSorted;
  28459. /**
  28460. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28461. * @param subMeshes The submeshes to render
  28462. */
  28463. private renderTransparentSorted;
  28464. /**
  28465. * Renders the submeshes in a specified order.
  28466. * @param subMeshes The submeshes to sort before render
  28467. * @param sortCompareFn The comparison function use to sort
  28468. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28469. * @param transparent Specifies to activate blending if true
  28470. */
  28471. private static renderSorted;
  28472. /**
  28473. * Renders the submeshes in the order they were dispatched (no sort applied).
  28474. * @param subMeshes The submeshes to render
  28475. */
  28476. private static renderUnsorted;
  28477. /**
  28478. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28479. * are rendered back to front if in the same alpha index.
  28480. *
  28481. * @param a The first submesh
  28482. * @param b The second submesh
  28483. * @returns The result of the comparison
  28484. */
  28485. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28486. /**
  28487. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28488. * are rendered back to front.
  28489. *
  28490. * @param a The first submesh
  28491. * @param b The second submesh
  28492. * @returns The result of the comparison
  28493. */
  28494. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28495. /**
  28496. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28497. * are rendered front to back (prevent overdraw).
  28498. *
  28499. * @param a The first submesh
  28500. * @param b The second submesh
  28501. * @returns The result of the comparison
  28502. */
  28503. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28504. /**
  28505. * Resets the different lists of submeshes to prepare a new frame.
  28506. */
  28507. prepare(): void;
  28508. dispose(): void;
  28509. /**
  28510. * Inserts the submesh in its correct queue depending on its material.
  28511. * @param subMesh The submesh to dispatch
  28512. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28513. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28514. */
  28515. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28516. dispatchSprites(spriteManager: ISpriteManager): void;
  28517. dispatchParticles(particleSystem: IParticleSystem): void;
  28518. private _renderParticles;
  28519. private _renderSprites;
  28520. }
  28521. }
  28522. declare module BABYLON {
  28523. /**
  28524. * Interface describing the different options available in the rendering manager
  28525. * regarding Auto Clear between groups.
  28526. */
  28527. export interface IRenderingManagerAutoClearSetup {
  28528. /**
  28529. * Defines whether or not autoclear is enable.
  28530. */
  28531. autoClear: boolean;
  28532. /**
  28533. * Defines whether or not to autoclear the depth buffer.
  28534. */
  28535. depth: boolean;
  28536. /**
  28537. * Defines whether or not to autoclear the stencil buffer.
  28538. */
  28539. stencil: boolean;
  28540. }
  28541. /**
  28542. * This class is used by the onRenderingGroupObservable
  28543. */
  28544. export class RenderingGroupInfo {
  28545. /**
  28546. * The Scene that being rendered
  28547. */
  28548. scene: Scene;
  28549. /**
  28550. * The camera currently used for the rendering pass
  28551. */
  28552. camera: Nullable<Camera>;
  28553. /**
  28554. * The ID of the renderingGroup being processed
  28555. */
  28556. renderingGroupId: number;
  28557. }
  28558. /**
  28559. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28560. * It is enable to manage the different groups as well as the different necessary sort functions.
  28561. * This should not be used directly aside of the few static configurations
  28562. */
  28563. export class RenderingManager {
  28564. /**
  28565. * The max id used for rendering groups (not included)
  28566. */
  28567. static MAX_RENDERINGGROUPS: number;
  28568. /**
  28569. * The min id used for rendering groups (included)
  28570. */
  28571. static MIN_RENDERINGGROUPS: number;
  28572. /**
  28573. * Used to globally prevent autoclearing scenes.
  28574. */
  28575. static AUTOCLEAR: boolean;
  28576. /**
  28577. * @hidden
  28578. */
  28579. _useSceneAutoClearSetup: boolean;
  28580. private _scene;
  28581. private _renderingGroups;
  28582. private _depthStencilBufferAlreadyCleaned;
  28583. private _autoClearDepthStencil;
  28584. private _customOpaqueSortCompareFn;
  28585. private _customAlphaTestSortCompareFn;
  28586. private _customTransparentSortCompareFn;
  28587. private _renderingGroupInfo;
  28588. /**
  28589. * Instantiates a new rendering group for a particular scene
  28590. * @param scene Defines the scene the groups belongs to
  28591. */
  28592. constructor(scene: Scene);
  28593. private _clearDepthStencilBuffer;
  28594. /**
  28595. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28596. * @hidden
  28597. */
  28598. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28599. /**
  28600. * Resets the different information of the group to prepare a new frame
  28601. * @hidden
  28602. */
  28603. reset(): void;
  28604. /**
  28605. * Dispose and release the group and its associated resources.
  28606. * @hidden
  28607. */
  28608. dispose(): void;
  28609. /**
  28610. * Clear the info related to rendering groups preventing retention points during dispose.
  28611. */
  28612. freeRenderingGroups(): void;
  28613. private _prepareRenderingGroup;
  28614. /**
  28615. * Add a sprite manager to the rendering manager in order to render it this frame.
  28616. * @param spriteManager Define the sprite manager to render
  28617. */
  28618. dispatchSprites(spriteManager: ISpriteManager): void;
  28619. /**
  28620. * Add a particle system to the rendering manager in order to render it this frame.
  28621. * @param particleSystem Define the particle system to render
  28622. */
  28623. dispatchParticles(particleSystem: IParticleSystem): void;
  28624. /**
  28625. * Add a submesh to the manager in order to render it this frame
  28626. * @param subMesh The submesh to dispatch
  28627. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28628. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28629. */
  28630. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28631. /**
  28632. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28633. * This allowed control for front to back rendering or reversly depending of the special needs.
  28634. *
  28635. * @param renderingGroupId The rendering group id corresponding to its index
  28636. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28637. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28638. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28639. */
  28640. 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;
  28641. /**
  28642. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28643. *
  28644. * @param renderingGroupId The rendering group id corresponding to its index
  28645. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28646. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28647. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28648. */
  28649. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28650. /**
  28651. * Gets the current auto clear configuration for one rendering group of the rendering
  28652. * manager.
  28653. * @param index the rendering group index to get the information for
  28654. * @returns The auto clear setup for the requested rendering group
  28655. */
  28656. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28662. */
  28663. export interface ICustomShaderOptions {
  28664. /**
  28665. * Gets or sets the custom shader name to use
  28666. */
  28667. shaderName: string;
  28668. /**
  28669. * The list of attribute names used in the shader
  28670. */
  28671. attributes?: string[];
  28672. /**
  28673. * The list of unifrom names used in the shader
  28674. */
  28675. uniforms?: string[];
  28676. /**
  28677. * The list of sampler names used in the shader
  28678. */
  28679. samplers?: string[];
  28680. /**
  28681. * The list of defines used in the shader
  28682. */
  28683. defines?: string[];
  28684. }
  28685. /**
  28686. * Interface to implement to create a shadow generator compatible with BJS.
  28687. */
  28688. export interface IShadowGenerator {
  28689. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28690. id: string;
  28691. /**
  28692. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28693. * @returns The render target texture if present otherwise, null
  28694. */
  28695. getShadowMap(): Nullable<RenderTargetTexture>;
  28696. /**
  28697. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28698. * @param subMesh The submesh we want to render in the shadow map
  28699. * @param useInstances Defines wether will draw in the map using instances
  28700. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28701. * @returns true if ready otherwise, false
  28702. */
  28703. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28704. /**
  28705. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28706. * @param defines Defines of the material we want to update
  28707. * @param lightIndex Index of the light in the enabled light list of the material
  28708. */
  28709. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28710. /**
  28711. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28712. * defined in the generator but impacting the effect).
  28713. * It implies the unifroms available on the materials are the standard BJS ones.
  28714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28715. * @param effect The effect we are binfing the information for
  28716. */
  28717. bindShadowLight(lightIndex: string, effect: Effect): void;
  28718. /**
  28719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28720. * (eq to shadow prjection matrix * light transform matrix)
  28721. * @returns The transform matrix used to create the shadow map
  28722. */
  28723. getTransformMatrix(): Matrix;
  28724. /**
  28725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28726. * Cube and 2D textures for instance.
  28727. */
  28728. recreateShadowMap(): void;
  28729. /**
  28730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28731. * @param onCompiled Callback triggered at the and of the effects compilation
  28732. * @param options Sets of optional options forcing the compilation with different modes
  28733. */
  28734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28735. useInstances: boolean;
  28736. }>): void;
  28737. /**
  28738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28739. * @param options Sets of optional options forcing the compilation with different modes
  28740. * @returns A promise that resolves when the compilation completes
  28741. */
  28742. forceCompilationAsync(options?: Partial<{
  28743. useInstances: boolean;
  28744. }>): Promise<void>;
  28745. /**
  28746. * Serializes the shadow generator setup to a json object.
  28747. * @returns The serialized JSON object
  28748. */
  28749. serialize(): any;
  28750. /**
  28751. * Disposes the Shadow map and related Textures and effects.
  28752. */
  28753. dispose(): void;
  28754. }
  28755. /**
  28756. * Default implementation IShadowGenerator.
  28757. * This is the main object responsible of generating shadows in the framework.
  28758. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28759. */
  28760. export class ShadowGenerator implements IShadowGenerator {
  28761. /**
  28762. * Name of the shadow generator class
  28763. */
  28764. static CLASSNAME: string;
  28765. /**
  28766. * Shadow generator mode None: no filtering applied.
  28767. */
  28768. static readonly FILTER_NONE: number;
  28769. /**
  28770. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28771. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28772. */
  28773. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28774. /**
  28775. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28776. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28777. */
  28778. static readonly FILTER_POISSONSAMPLING: number;
  28779. /**
  28780. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28781. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28782. */
  28783. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28784. /**
  28785. * Shadow generator mode ESM: 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_CLOSEEXPONENTIALSHADOWMAP: number;
  28790. /**
  28791. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28792. * edge artifacts on steep falloff.
  28793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28794. */
  28795. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28796. /**
  28797. * Shadow generator mode PCF: Percentage Closer Filtering
  28798. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28799. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28800. */
  28801. static readonly FILTER_PCF: number;
  28802. /**
  28803. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28805. * Contact Hardening
  28806. */
  28807. static readonly FILTER_PCSS: number;
  28808. /**
  28809. * Reserved for PCF and PCSS
  28810. * Highest Quality.
  28811. *
  28812. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28813. *
  28814. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28815. */
  28816. static readonly QUALITY_HIGH: number;
  28817. /**
  28818. * Reserved for PCF and PCSS
  28819. * Good tradeoff for quality/perf cross devices
  28820. *
  28821. * Execute PCF on a 3*3 kernel.
  28822. *
  28823. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28824. */
  28825. static readonly QUALITY_MEDIUM: number;
  28826. /**
  28827. * Reserved for PCF and PCSS
  28828. * The lowest quality but the fastest.
  28829. *
  28830. * Execute PCF on a 1*1 kernel.
  28831. *
  28832. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28833. */
  28834. static readonly QUALITY_LOW: number;
  28835. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28836. id: string;
  28837. /** Gets or sets the custom shader name to use */
  28838. customShaderOptions: ICustomShaderOptions;
  28839. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28840. customAllowRendering: (subMesh: SubMesh) => boolean;
  28841. /**
  28842. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28843. */
  28844. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28845. /**
  28846. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28847. */
  28848. onAfterShadowMapRenderObservable: Observable<Effect>;
  28849. /**
  28850. * Observable triggered before a mesh is rendered in the shadow map.
  28851. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28852. */
  28853. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28854. /**
  28855. * Observable triggered after a mesh is rendered in the shadow map.
  28856. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28857. */
  28858. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28859. protected _bias: number;
  28860. /**
  28861. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28862. */
  28863. get bias(): number;
  28864. /**
  28865. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28866. */
  28867. set bias(bias: number);
  28868. protected _normalBias: number;
  28869. /**
  28870. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28871. */
  28872. get normalBias(): number;
  28873. /**
  28874. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28875. */
  28876. set normalBias(normalBias: number);
  28877. protected _blurBoxOffset: number;
  28878. /**
  28879. * Gets the blur box offset: offset applied during the blur pass.
  28880. * Only useful if useKernelBlur = false
  28881. */
  28882. get blurBoxOffset(): number;
  28883. /**
  28884. * Sets the blur box offset: offset applied during the blur pass.
  28885. * Only useful if useKernelBlur = false
  28886. */
  28887. set blurBoxOffset(value: number);
  28888. protected _blurScale: number;
  28889. /**
  28890. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28891. * 2 means half of the size.
  28892. */
  28893. get blurScale(): number;
  28894. /**
  28895. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28896. * 2 means half of the size.
  28897. */
  28898. set blurScale(value: number);
  28899. protected _blurKernel: number;
  28900. /**
  28901. * Gets the blur kernel: kernel size of the blur pass.
  28902. * Only useful if useKernelBlur = true
  28903. */
  28904. get blurKernel(): number;
  28905. /**
  28906. * Sets the blur kernel: kernel size of the blur pass.
  28907. * Only useful if useKernelBlur = true
  28908. */
  28909. set blurKernel(value: number);
  28910. protected _useKernelBlur: boolean;
  28911. /**
  28912. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28913. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28914. */
  28915. get useKernelBlur(): boolean;
  28916. /**
  28917. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28918. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28919. */
  28920. set useKernelBlur(value: boolean);
  28921. protected _depthScale: number;
  28922. /**
  28923. * Gets the depth scale used in ESM mode.
  28924. */
  28925. get depthScale(): number;
  28926. /**
  28927. * Sets the depth scale used in ESM mode.
  28928. * This can override the scale stored on the light.
  28929. */
  28930. set depthScale(value: number);
  28931. protected _validateFilter(filter: number): number;
  28932. protected _filter: number;
  28933. /**
  28934. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28935. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28936. */
  28937. get filter(): number;
  28938. /**
  28939. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28940. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28941. */
  28942. set filter(value: number);
  28943. /**
  28944. * Gets if the current filter is set to Poisson Sampling.
  28945. */
  28946. get usePoissonSampling(): boolean;
  28947. /**
  28948. * Sets the current filter to Poisson Sampling.
  28949. */
  28950. set usePoissonSampling(value: boolean);
  28951. /**
  28952. * Gets if the current filter is set to ESM.
  28953. */
  28954. get useExponentialShadowMap(): boolean;
  28955. /**
  28956. * Sets the current filter is to ESM.
  28957. */
  28958. set useExponentialShadowMap(value: boolean);
  28959. /**
  28960. * Gets if the current filter is set to filtered ESM.
  28961. */
  28962. get useBlurExponentialShadowMap(): boolean;
  28963. /**
  28964. * Gets if the current filter is set to filtered ESM.
  28965. */
  28966. set useBlurExponentialShadowMap(value: boolean);
  28967. /**
  28968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28969. * exponential to prevent steep falloff artifacts).
  28970. */
  28971. get useCloseExponentialShadowMap(): boolean;
  28972. /**
  28973. * Sets the current filter to "close ESM" (using the inverse of the
  28974. * exponential to prevent steep falloff artifacts).
  28975. */
  28976. set useCloseExponentialShadowMap(value: boolean);
  28977. /**
  28978. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28979. * exponential to prevent steep falloff artifacts).
  28980. */
  28981. get useBlurCloseExponentialShadowMap(): boolean;
  28982. /**
  28983. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28984. * exponential to prevent steep falloff artifacts).
  28985. */
  28986. set useBlurCloseExponentialShadowMap(value: boolean);
  28987. /**
  28988. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28989. */
  28990. get usePercentageCloserFiltering(): boolean;
  28991. /**
  28992. * Sets the current filter to "PCF" (percentage closer filtering).
  28993. */
  28994. set usePercentageCloserFiltering(value: boolean);
  28995. protected _filteringQuality: number;
  28996. /**
  28997. * Gets the PCF or PCSS Quality.
  28998. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28999. */
  29000. get filteringQuality(): number;
  29001. /**
  29002. * Sets the PCF or PCSS Quality.
  29003. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29004. */
  29005. set filteringQuality(filteringQuality: number);
  29006. /**
  29007. * Gets if the current filter is set to "PCSS" (contact hardening).
  29008. */
  29009. get useContactHardeningShadow(): boolean;
  29010. /**
  29011. * Sets the current filter to "PCSS" (contact hardening).
  29012. */
  29013. set useContactHardeningShadow(value: boolean);
  29014. protected _contactHardeningLightSizeUVRatio: number;
  29015. /**
  29016. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29017. * Using a ratio helps keeping shape stability independently of the map size.
  29018. *
  29019. * It does not account for the light projection as it was having too much
  29020. * instability during the light setup or during light position changes.
  29021. *
  29022. * Only valid if useContactHardeningShadow is true.
  29023. */
  29024. get contactHardeningLightSizeUVRatio(): number;
  29025. /**
  29026. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29027. * Using a ratio helps keeping shape stability independently of the map size.
  29028. *
  29029. * It does not account for the light projection as it was having too much
  29030. * instability during the light setup or during light position changes.
  29031. *
  29032. * Only valid if useContactHardeningShadow is true.
  29033. */
  29034. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29035. protected _darkness: number;
  29036. /** Gets or sets the actual darkness of a shadow */
  29037. get darkness(): number;
  29038. set darkness(value: number);
  29039. /**
  29040. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29041. * 0 means strongest and 1 would means no shadow.
  29042. * @returns the darkness.
  29043. */
  29044. getDarkness(): number;
  29045. /**
  29046. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29047. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29048. * @returns the shadow generator allowing fluent coding.
  29049. */
  29050. setDarkness(darkness: number): ShadowGenerator;
  29051. protected _transparencyShadow: boolean;
  29052. /** Gets or sets the ability to have transparent shadow */
  29053. get transparencyShadow(): boolean;
  29054. set transparencyShadow(value: boolean);
  29055. /**
  29056. * Sets the ability to have transparent shadow (boolean).
  29057. * @param transparent True if transparent else False
  29058. * @returns the shadow generator allowing fluent coding
  29059. */
  29060. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29061. /**
  29062. * Enables or disables shadows with varying strength based on the transparency
  29063. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29064. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29065. * mesh.visibility * alphaTexture.a
  29066. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29067. */
  29068. enableSoftTransparentShadow: boolean;
  29069. protected _shadowMap: Nullable<RenderTargetTexture>;
  29070. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29071. /**
  29072. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29073. * @returns The render target texture if present otherwise, null
  29074. */
  29075. getShadowMap(): Nullable<RenderTargetTexture>;
  29076. /**
  29077. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29078. * @returns The render target texture if the shadow map is present otherwise, null
  29079. */
  29080. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29081. /**
  29082. * Gets the class name of that object
  29083. * @returns "ShadowGenerator"
  29084. */
  29085. getClassName(): string;
  29086. /**
  29087. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29088. * @param mesh Mesh to add
  29089. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29090. * @returns the Shadow Generator itself
  29091. */
  29092. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29093. /**
  29094. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29095. * @param mesh Mesh to remove
  29096. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29097. * @returns the Shadow Generator itself
  29098. */
  29099. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29100. /**
  29101. * Controls the extent to which the shadows fade out at the edge of the frustum
  29102. */
  29103. frustumEdgeFalloff: number;
  29104. protected _light: IShadowLight;
  29105. /**
  29106. * Returns the associated light object.
  29107. * @returns the light generating the shadow
  29108. */
  29109. getLight(): IShadowLight;
  29110. /**
  29111. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29112. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29113. * It might on the other hand introduce peter panning.
  29114. */
  29115. forceBackFacesOnly: boolean;
  29116. protected _scene: Scene;
  29117. protected _lightDirection: Vector3;
  29118. protected _effect: Effect;
  29119. protected _viewMatrix: Matrix;
  29120. protected _projectionMatrix: Matrix;
  29121. protected _transformMatrix: Matrix;
  29122. protected _cachedPosition: Vector3;
  29123. protected _cachedDirection: Vector3;
  29124. protected _cachedDefines: string;
  29125. protected _currentRenderID: number;
  29126. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29127. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29128. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29129. protected _blurPostProcesses: PostProcess[];
  29130. protected _mapSize: number;
  29131. protected _currentFaceIndex: number;
  29132. protected _currentFaceIndexCache: number;
  29133. protected _textureType: number;
  29134. protected _defaultTextureMatrix: Matrix;
  29135. protected _storedUniqueId: Nullable<number>;
  29136. /** @hidden */
  29137. static _SceneComponentInitialization: (scene: Scene) => void;
  29138. /**
  29139. * Gets or sets the size of the texture what stores the shadows
  29140. */
  29141. get mapSize(): number;
  29142. set mapSize(size: number);
  29143. /**
  29144. * Creates a ShadowGenerator object.
  29145. * A ShadowGenerator is the required tool to use the shadows.
  29146. * Each light casting shadows needs to use its own ShadowGenerator.
  29147. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29148. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29149. * @param light The light object generating the shadows.
  29150. * @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.
  29151. */
  29152. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29153. protected _initializeGenerator(): void;
  29154. protected _createTargetRenderTexture(): void;
  29155. protected _initializeShadowMap(): void;
  29156. protected _initializeBlurRTTAndPostProcesses(): void;
  29157. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29158. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29159. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29160. protected _applyFilterValues(): void;
  29161. /**
  29162. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29163. * @param onCompiled Callback triggered at the and of the effects compilation
  29164. * @param options Sets of optional options forcing the compilation with different modes
  29165. */
  29166. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29167. useInstances: boolean;
  29168. }>): void;
  29169. /**
  29170. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29171. * @param options Sets of optional options forcing the compilation with different modes
  29172. * @returns A promise that resolves when the compilation completes
  29173. */
  29174. forceCompilationAsync(options?: Partial<{
  29175. useInstances: boolean;
  29176. }>): Promise<void>;
  29177. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29178. private _prepareShadowDefines;
  29179. /**
  29180. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29181. * @param subMesh The submesh we want to render in the shadow map
  29182. * @param useInstances Defines wether will draw in the map using instances
  29183. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29184. * @returns true if ready otherwise, false
  29185. */
  29186. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29187. /**
  29188. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29189. * @param defines Defines of the material we want to update
  29190. * @param lightIndex Index of the light in the enabled light list of the material
  29191. */
  29192. prepareDefines(defines: any, lightIndex: number): void;
  29193. /**
  29194. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29195. * defined in the generator but impacting the effect).
  29196. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29197. * @param effect The effect we are binfing the information for
  29198. */
  29199. bindShadowLight(lightIndex: string, effect: Effect): void;
  29200. /**
  29201. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29202. * (eq to shadow prjection matrix * light transform matrix)
  29203. * @returns The transform matrix used to create the shadow map
  29204. */
  29205. getTransformMatrix(): Matrix;
  29206. /**
  29207. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29208. * Cube and 2D textures for instance.
  29209. */
  29210. recreateShadowMap(): void;
  29211. protected _disposeBlurPostProcesses(): void;
  29212. protected _disposeRTTandPostProcesses(): void;
  29213. /**
  29214. * Disposes the ShadowGenerator.
  29215. * Returns nothing.
  29216. */
  29217. dispose(): void;
  29218. /**
  29219. * Serializes the shadow generator setup to a json object.
  29220. * @returns The serialized JSON object
  29221. */
  29222. serialize(): any;
  29223. /**
  29224. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29225. * @param parsedShadowGenerator The JSON object to parse
  29226. * @param scene The scene to create the shadow map for
  29227. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29228. * @returns The parsed shadow generator
  29229. */
  29230. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29231. }
  29232. }
  29233. declare module BABYLON {
  29234. /**
  29235. * Options to be used when creating a shadow depth material
  29236. */
  29237. export interface IIOptionShadowDepthMaterial {
  29238. /** Variables in the vertex shader code that need to have their names remapped.
  29239. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29240. * "var_name" should be either: worldPos or vNormalW
  29241. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29242. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29243. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29244. */
  29245. remappedVariables?: string[];
  29246. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29247. standalone?: boolean;
  29248. }
  29249. /**
  29250. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29251. */
  29252. export class ShadowDepthWrapper {
  29253. private _scene;
  29254. private _options?;
  29255. private _baseMaterial;
  29256. private _onEffectCreatedObserver;
  29257. private _subMeshToEffect;
  29258. private _subMeshToDepthEffect;
  29259. private _meshes;
  29260. /** @hidden */
  29261. _matriceNames: any;
  29262. /** Gets the standalone status of the wrapper */
  29263. get standalone(): boolean;
  29264. /** Gets the base material the wrapper is built upon */
  29265. get baseMaterial(): Material;
  29266. /**
  29267. * Instantiate a new shadow depth wrapper.
  29268. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29269. * generate the shadow depth map. For more information, please refer to the documentation:
  29270. * https://doc.babylonjs.com/babylon101/shadows
  29271. * @param baseMaterial Material to wrap
  29272. * @param scene Define the scene the material belongs to
  29273. * @param options Options used to create the wrapper
  29274. */
  29275. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29276. /**
  29277. * Gets the effect to use to generate the depth map
  29278. * @param subMesh subMesh to get the effect for
  29279. * @param shadowGenerator shadow generator to get the effect for
  29280. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29281. */
  29282. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29283. /**
  29284. * Specifies that the submesh is ready to be used for depth rendering
  29285. * @param subMesh submesh to check
  29286. * @param defines the list of defines to take into account when checking the effect
  29287. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29288. * @param useInstances specifies that instances should be used
  29289. * @returns a boolean indicating that the submesh is ready or not
  29290. */
  29291. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29292. /**
  29293. * Disposes the resources
  29294. */
  29295. dispose(): void;
  29296. private _makeEffect;
  29297. }
  29298. }
  29299. declare module BABYLON {
  29300. /**
  29301. * Options for compiling materials.
  29302. */
  29303. export interface IMaterialCompilationOptions {
  29304. /**
  29305. * Defines whether clip planes are enabled.
  29306. */
  29307. clipPlane: boolean;
  29308. /**
  29309. * Defines whether instances are enabled.
  29310. */
  29311. useInstances: boolean;
  29312. }
  29313. /**
  29314. * Options passed when calling customShaderNameResolve
  29315. */
  29316. export interface ICustomShaderNameResolveOptions {
  29317. /**
  29318. * 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
  29319. */
  29320. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29321. }
  29322. /**
  29323. * Base class for the main features of a material in Babylon.js
  29324. */
  29325. export class Material implements IAnimatable {
  29326. /**
  29327. * Returns the triangle fill mode
  29328. */
  29329. static readonly TriangleFillMode: number;
  29330. /**
  29331. * Returns the wireframe mode
  29332. */
  29333. static readonly WireFrameFillMode: number;
  29334. /**
  29335. * Returns the point fill mode
  29336. */
  29337. static readonly PointFillMode: number;
  29338. /**
  29339. * Returns the point list draw mode
  29340. */
  29341. static readonly PointListDrawMode: number;
  29342. /**
  29343. * Returns the line list draw mode
  29344. */
  29345. static readonly LineListDrawMode: number;
  29346. /**
  29347. * Returns the line loop draw mode
  29348. */
  29349. static readonly LineLoopDrawMode: number;
  29350. /**
  29351. * Returns the line strip draw mode
  29352. */
  29353. static readonly LineStripDrawMode: number;
  29354. /**
  29355. * Returns the triangle strip draw mode
  29356. */
  29357. static readonly TriangleStripDrawMode: number;
  29358. /**
  29359. * Returns the triangle fan draw mode
  29360. */
  29361. static readonly TriangleFanDrawMode: number;
  29362. /**
  29363. * Stores the clock-wise side orientation
  29364. */
  29365. static readonly ClockWiseSideOrientation: number;
  29366. /**
  29367. * Stores the counter clock-wise side orientation
  29368. */
  29369. static readonly CounterClockWiseSideOrientation: number;
  29370. /**
  29371. * The dirty texture flag value
  29372. */
  29373. static readonly TextureDirtyFlag: number;
  29374. /**
  29375. * The dirty light flag value
  29376. */
  29377. static readonly LightDirtyFlag: number;
  29378. /**
  29379. * The dirty fresnel flag value
  29380. */
  29381. static readonly FresnelDirtyFlag: number;
  29382. /**
  29383. * The dirty attribute flag value
  29384. */
  29385. static readonly AttributesDirtyFlag: number;
  29386. /**
  29387. * The dirty misc flag value
  29388. */
  29389. static readonly MiscDirtyFlag: number;
  29390. /**
  29391. * The dirty prepass flag value
  29392. */
  29393. static readonly PrePassDirtyFlag: number;
  29394. /**
  29395. * The all dirty flag value
  29396. */
  29397. static readonly AllDirtyFlag: number;
  29398. /**
  29399. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29400. */
  29401. static readonly MATERIAL_OPAQUE: number;
  29402. /**
  29403. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29404. */
  29405. static readonly MATERIAL_ALPHATEST: number;
  29406. /**
  29407. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29408. */
  29409. static readonly MATERIAL_ALPHABLEND: number;
  29410. /**
  29411. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29412. * They are also discarded below the alpha cutoff threshold to improve performances.
  29413. */
  29414. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29415. /**
  29416. * The Whiteout method is used to blend normals.
  29417. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29418. */
  29419. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29420. /**
  29421. * The Reoriented Normal Mapping method is used to blend normals.
  29422. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29423. */
  29424. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29425. /**
  29426. * Custom callback helping to override the default shader used in the material.
  29427. */
  29428. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29429. /**
  29430. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29431. */
  29432. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29433. /**
  29434. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29435. * This means that the material can keep using a previous shader while a new one is being compiled.
  29436. * This is mostly used when shader parallel compilation is supported (true by default)
  29437. */
  29438. allowShaderHotSwapping: boolean;
  29439. /**
  29440. * The ID of the material
  29441. */
  29442. id: string;
  29443. /**
  29444. * Gets or sets the unique id of the material
  29445. */
  29446. uniqueId: number;
  29447. /**
  29448. * The name of the material
  29449. */
  29450. name: string;
  29451. /**
  29452. * Gets or sets user defined metadata
  29453. */
  29454. metadata: any;
  29455. /**
  29456. * For internal use only. Please do not use.
  29457. */
  29458. reservedDataStore: any;
  29459. /**
  29460. * Specifies if the ready state should be checked on each call
  29461. */
  29462. checkReadyOnEveryCall: boolean;
  29463. /**
  29464. * Specifies if the ready state should be checked once
  29465. */
  29466. checkReadyOnlyOnce: boolean;
  29467. /**
  29468. * The state of the material
  29469. */
  29470. state: string;
  29471. /**
  29472. * If the material can be rendered to several textures with MRT extension
  29473. */
  29474. get canRenderToMRT(): boolean;
  29475. /**
  29476. * The alpha value of the material
  29477. */
  29478. protected _alpha: number;
  29479. /**
  29480. * List of inspectable custom properties (used by the Inspector)
  29481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29482. */
  29483. inspectableCustomProperties: IInspectable[];
  29484. /**
  29485. * Sets the alpha value of the material
  29486. */
  29487. set alpha(value: number);
  29488. /**
  29489. * Gets the alpha value of the material
  29490. */
  29491. get alpha(): number;
  29492. /**
  29493. * Specifies if back face culling is enabled
  29494. */
  29495. protected _backFaceCulling: boolean;
  29496. /**
  29497. * Sets the back-face culling state
  29498. */
  29499. set backFaceCulling(value: boolean);
  29500. /**
  29501. * Gets the back-face culling state
  29502. */
  29503. get backFaceCulling(): boolean;
  29504. /**
  29505. * Stores the value for side orientation
  29506. */
  29507. sideOrientation: number;
  29508. /**
  29509. * Callback triggered when the material is compiled
  29510. */
  29511. onCompiled: Nullable<(effect: Effect) => void>;
  29512. /**
  29513. * Callback triggered when an error occurs
  29514. */
  29515. onError: Nullable<(effect: Effect, errors: string) => void>;
  29516. /**
  29517. * Callback triggered to get the render target textures
  29518. */
  29519. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29520. /**
  29521. * Gets a boolean indicating that current material needs to register RTT
  29522. */
  29523. get hasRenderTargetTextures(): boolean;
  29524. /**
  29525. * Specifies if the material should be serialized
  29526. */
  29527. doNotSerialize: boolean;
  29528. /**
  29529. * @hidden
  29530. */
  29531. _storeEffectOnSubMeshes: boolean;
  29532. /**
  29533. * Stores the animations for the material
  29534. */
  29535. animations: Nullable<Array<Animation>>;
  29536. /**
  29537. * An event triggered when the material is disposed
  29538. */
  29539. onDisposeObservable: Observable<Material>;
  29540. /**
  29541. * An observer which watches for dispose events
  29542. */
  29543. private _onDisposeObserver;
  29544. private _onUnBindObservable;
  29545. /**
  29546. * Called during a dispose event
  29547. */
  29548. set onDispose(callback: () => void);
  29549. private _onBindObservable;
  29550. /**
  29551. * An event triggered when the material is bound
  29552. */
  29553. get onBindObservable(): Observable<AbstractMesh>;
  29554. /**
  29555. * An observer which watches for bind events
  29556. */
  29557. private _onBindObserver;
  29558. /**
  29559. * Called during a bind event
  29560. */
  29561. set onBind(callback: (Mesh: AbstractMesh) => void);
  29562. /**
  29563. * An event triggered when the material is unbound
  29564. */
  29565. get onUnBindObservable(): Observable<Material>;
  29566. protected _onEffectCreatedObservable: Nullable<Observable<{
  29567. effect: Effect;
  29568. subMesh: Nullable<SubMesh>;
  29569. }>>;
  29570. /**
  29571. * An event triggered when the effect is (re)created
  29572. */
  29573. get onEffectCreatedObservable(): Observable<{
  29574. effect: Effect;
  29575. subMesh: Nullable<SubMesh>;
  29576. }>;
  29577. /**
  29578. * Stores the value of the alpha mode
  29579. */
  29580. private _alphaMode;
  29581. /**
  29582. * Sets the value of the alpha mode.
  29583. *
  29584. * | Value | Type | Description |
  29585. * | --- | --- | --- |
  29586. * | 0 | ALPHA_DISABLE | |
  29587. * | 1 | ALPHA_ADD | |
  29588. * | 2 | ALPHA_COMBINE | |
  29589. * | 3 | ALPHA_SUBTRACT | |
  29590. * | 4 | ALPHA_MULTIPLY | |
  29591. * | 5 | ALPHA_MAXIMIZED | |
  29592. * | 6 | ALPHA_ONEONE | |
  29593. * | 7 | ALPHA_PREMULTIPLIED | |
  29594. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29595. * | 9 | ALPHA_INTERPOLATE | |
  29596. * | 10 | ALPHA_SCREENMODE | |
  29597. *
  29598. */
  29599. set alphaMode(value: number);
  29600. /**
  29601. * Gets the value of the alpha mode
  29602. */
  29603. get alphaMode(): number;
  29604. /**
  29605. * Stores the state of the need depth pre-pass value
  29606. */
  29607. private _needDepthPrePass;
  29608. /**
  29609. * Sets the need depth pre-pass value
  29610. */
  29611. set needDepthPrePass(value: boolean);
  29612. /**
  29613. * Gets the depth pre-pass value
  29614. */
  29615. get needDepthPrePass(): boolean;
  29616. /**
  29617. * Specifies if depth writing should be disabled
  29618. */
  29619. disableDepthWrite: boolean;
  29620. /**
  29621. * Specifies if color writing should be disabled
  29622. */
  29623. disableColorWrite: boolean;
  29624. /**
  29625. * Specifies if depth writing should be forced
  29626. */
  29627. forceDepthWrite: boolean;
  29628. /**
  29629. * Specifies the depth function that should be used. 0 means the default engine function
  29630. */
  29631. depthFunction: number;
  29632. /**
  29633. * Specifies if there should be a separate pass for culling
  29634. */
  29635. separateCullingPass: boolean;
  29636. /**
  29637. * Stores the state specifing if fog should be enabled
  29638. */
  29639. private _fogEnabled;
  29640. /**
  29641. * Sets the state for enabling fog
  29642. */
  29643. set fogEnabled(value: boolean);
  29644. /**
  29645. * Gets the value of the fog enabled state
  29646. */
  29647. get fogEnabled(): boolean;
  29648. /**
  29649. * Stores the size of points
  29650. */
  29651. pointSize: number;
  29652. /**
  29653. * Stores the z offset value
  29654. */
  29655. zOffset: number;
  29656. get wireframe(): boolean;
  29657. /**
  29658. * Sets the state of wireframe mode
  29659. */
  29660. set wireframe(value: boolean);
  29661. /**
  29662. * Gets the value specifying if point clouds are enabled
  29663. */
  29664. get pointsCloud(): boolean;
  29665. /**
  29666. * Sets the state of point cloud mode
  29667. */
  29668. set pointsCloud(value: boolean);
  29669. /**
  29670. * Gets the material fill mode
  29671. */
  29672. get fillMode(): number;
  29673. /**
  29674. * Sets the material fill mode
  29675. */
  29676. set fillMode(value: number);
  29677. /**
  29678. * @hidden
  29679. * Stores the effects for the material
  29680. */
  29681. _effect: Nullable<Effect>;
  29682. /**
  29683. * Specifies if uniform buffers should be used
  29684. */
  29685. private _useUBO;
  29686. /**
  29687. * Stores a reference to the scene
  29688. */
  29689. private _scene;
  29690. /**
  29691. * Stores the fill mode state
  29692. */
  29693. private _fillMode;
  29694. /**
  29695. * Specifies if the depth write state should be cached
  29696. */
  29697. private _cachedDepthWriteState;
  29698. /**
  29699. * Specifies if the color write state should be cached
  29700. */
  29701. private _cachedColorWriteState;
  29702. /**
  29703. * Specifies if the depth function state should be cached
  29704. */
  29705. private _cachedDepthFunctionState;
  29706. /**
  29707. * Stores the uniform buffer
  29708. */
  29709. protected _uniformBuffer: UniformBuffer;
  29710. /** @hidden */
  29711. _indexInSceneMaterialArray: number;
  29712. /** @hidden */
  29713. meshMap: Nullable<{
  29714. [id: string]: AbstractMesh | undefined;
  29715. }>;
  29716. /**
  29717. * Creates a material instance
  29718. * @param name defines the name of the material
  29719. * @param scene defines the scene to reference
  29720. * @param doNotAdd specifies if the material should be added to the scene
  29721. */
  29722. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29723. /**
  29724. * Returns a string representation of the current material
  29725. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29726. * @returns a string with material information
  29727. */
  29728. toString(fullDetails?: boolean): string;
  29729. /**
  29730. * Gets the class name of the material
  29731. * @returns a string with the class name of the material
  29732. */
  29733. getClassName(): string;
  29734. /**
  29735. * Specifies if updates for the material been locked
  29736. */
  29737. get isFrozen(): boolean;
  29738. /**
  29739. * Locks updates for the material
  29740. */
  29741. freeze(): void;
  29742. /**
  29743. * Unlocks updates for the material
  29744. */
  29745. unfreeze(): void;
  29746. /**
  29747. * Specifies if the material is ready to be used
  29748. * @param mesh defines the mesh to check
  29749. * @param useInstances specifies if instances should be used
  29750. * @returns a boolean indicating if the material is ready to be used
  29751. */
  29752. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29753. /**
  29754. * Specifies that the submesh is ready to be used
  29755. * @param mesh defines the mesh to check
  29756. * @param subMesh defines which submesh to check
  29757. * @param useInstances specifies that instances should be used
  29758. * @returns a boolean indicating that the submesh is ready or not
  29759. */
  29760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29761. /**
  29762. * Returns the material effect
  29763. * @returns the effect associated with the material
  29764. */
  29765. getEffect(): Nullable<Effect>;
  29766. /**
  29767. * Returns the current scene
  29768. * @returns a Scene
  29769. */
  29770. getScene(): Scene;
  29771. /**
  29772. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29773. */
  29774. protected _forceAlphaTest: boolean;
  29775. /**
  29776. * The transparency mode of the material.
  29777. */
  29778. protected _transparencyMode: Nullable<number>;
  29779. /**
  29780. * Gets the current transparency mode.
  29781. */
  29782. get transparencyMode(): Nullable<number>;
  29783. /**
  29784. * Sets the transparency mode of the material.
  29785. *
  29786. * | Value | Type | Description |
  29787. * | ----- | ----------------------------------- | ----------- |
  29788. * | 0 | OPAQUE | |
  29789. * | 1 | ALPHATEST | |
  29790. * | 2 | ALPHABLEND | |
  29791. * | 3 | ALPHATESTANDBLEND | |
  29792. *
  29793. */
  29794. set transparencyMode(value: Nullable<number>);
  29795. /**
  29796. * Returns true if alpha blending should be disabled.
  29797. */
  29798. protected get _disableAlphaBlending(): boolean;
  29799. /**
  29800. * Specifies whether or not this material should be rendered in alpha blend mode.
  29801. * @returns a boolean specifying if alpha blending is needed
  29802. */
  29803. needAlphaBlending(): boolean;
  29804. /**
  29805. * Specifies if the mesh will require alpha blending
  29806. * @param mesh defines the mesh to check
  29807. * @returns a boolean specifying if alpha blending is needed for the mesh
  29808. */
  29809. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29810. /**
  29811. * Specifies whether or not this material should be rendered in alpha test mode.
  29812. * @returns a boolean specifying if an alpha test is needed.
  29813. */
  29814. needAlphaTesting(): boolean;
  29815. /**
  29816. * Specifies if material alpha testing should be turned on for the mesh
  29817. * @param mesh defines the mesh to check
  29818. */
  29819. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29820. /**
  29821. * Gets the texture used for the alpha test
  29822. * @returns the texture to use for alpha testing
  29823. */
  29824. getAlphaTestTexture(): Nullable<BaseTexture>;
  29825. /**
  29826. * Marks the material to indicate that it needs to be re-calculated
  29827. */
  29828. markDirty(): void;
  29829. /** @hidden */
  29830. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29831. /**
  29832. * Binds the material to the mesh
  29833. * @param world defines the world transformation matrix
  29834. * @param mesh defines the mesh to bind the material to
  29835. */
  29836. bind(world: Matrix, mesh?: Mesh): void;
  29837. /**
  29838. * Binds the submesh to the material
  29839. * @param world defines the world transformation matrix
  29840. * @param mesh defines the mesh containing the submesh
  29841. * @param subMesh defines the submesh to bind the material to
  29842. */
  29843. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29844. /**
  29845. * Binds the world matrix to the material
  29846. * @param world defines the world transformation matrix
  29847. */
  29848. bindOnlyWorldMatrix(world: Matrix): void;
  29849. /**
  29850. * Binds the scene's uniform buffer to the effect.
  29851. * @param effect defines the effect to bind to the scene uniform buffer
  29852. * @param sceneUbo defines the uniform buffer storing scene data
  29853. */
  29854. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29855. /**
  29856. * Binds the view matrix to the effect
  29857. * @param effect defines the effect to bind the view matrix to
  29858. */
  29859. bindView(effect: Effect): void;
  29860. /**
  29861. * Binds the view projection matrix to the effect
  29862. * @param effect defines the effect to bind the view projection matrix to
  29863. */
  29864. bindViewProjection(effect: Effect): void;
  29865. /**
  29866. * Processes to execute after binding the material to a mesh
  29867. * @param mesh defines the rendered mesh
  29868. */
  29869. protected _afterBind(mesh?: Mesh): void;
  29870. /**
  29871. * Unbinds the material from the mesh
  29872. */
  29873. unbind(): void;
  29874. /**
  29875. * Gets the active textures from the material
  29876. * @returns an array of textures
  29877. */
  29878. getActiveTextures(): BaseTexture[];
  29879. /**
  29880. * Specifies if the material uses a texture
  29881. * @param texture defines the texture to check against the material
  29882. * @returns a boolean specifying if the material uses the texture
  29883. */
  29884. hasTexture(texture: BaseTexture): boolean;
  29885. /**
  29886. * Makes a duplicate of the material, and gives it a new name
  29887. * @param name defines the new name for the duplicated material
  29888. * @returns the cloned material
  29889. */
  29890. clone(name: string): Nullable<Material>;
  29891. /**
  29892. * Gets the meshes bound to the material
  29893. * @returns an array of meshes bound to the material
  29894. */
  29895. getBindedMeshes(): AbstractMesh[];
  29896. /**
  29897. * Force shader compilation
  29898. * @param mesh defines the mesh associated with this material
  29899. * @param onCompiled defines a function to execute once the material is compiled
  29900. * @param options defines the options to configure the compilation
  29901. * @param onError defines a function to execute if the material fails compiling
  29902. */
  29903. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29904. /**
  29905. * Force shader compilation
  29906. * @param mesh defines the mesh that will use this material
  29907. * @param options defines additional options for compiling the shaders
  29908. * @returns a promise that resolves when the compilation completes
  29909. */
  29910. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29911. private static readonly _AllDirtyCallBack;
  29912. private static readonly _ImageProcessingDirtyCallBack;
  29913. private static readonly _TextureDirtyCallBack;
  29914. private static readonly _FresnelDirtyCallBack;
  29915. private static readonly _MiscDirtyCallBack;
  29916. private static readonly _PrePassDirtyCallBack;
  29917. private static readonly _LightsDirtyCallBack;
  29918. private static readonly _AttributeDirtyCallBack;
  29919. private static _FresnelAndMiscDirtyCallBack;
  29920. private static _TextureAndMiscDirtyCallBack;
  29921. private static readonly _DirtyCallbackArray;
  29922. private static readonly _RunDirtyCallBacks;
  29923. /**
  29924. * Marks a define in the material to indicate that it needs to be re-computed
  29925. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29926. */
  29927. markAsDirty(flag: number): void;
  29928. /**
  29929. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29930. * @param func defines a function which checks material defines against the submeshes
  29931. */
  29932. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29933. /**
  29934. * Indicates that the scene should check if the rendering now needs a prepass
  29935. */
  29936. protected _markScenePrePassDirty(): void;
  29937. /**
  29938. * Indicates that we need to re-calculated for all submeshes
  29939. */
  29940. protected _markAllSubMeshesAsAllDirty(): void;
  29941. /**
  29942. * Indicates that image processing needs to be re-calculated for all submeshes
  29943. */
  29944. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29945. /**
  29946. * Indicates that textures need to be re-calculated for all submeshes
  29947. */
  29948. protected _markAllSubMeshesAsTexturesDirty(): void;
  29949. /**
  29950. * Indicates that fresnel needs to be re-calculated for all submeshes
  29951. */
  29952. protected _markAllSubMeshesAsFresnelDirty(): void;
  29953. /**
  29954. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29955. */
  29956. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29957. /**
  29958. * Indicates that lights need to be re-calculated for all submeshes
  29959. */
  29960. protected _markAllSubMeshesAsLightsDirty(): void;
  29961. /**
  29962. * Indicates that attributes need to be re-calculated for all submeshes
  29963. */
  29964. protected _markAllSubMeshesAsAttributesDirty(): void;
  29965. /**
  29966. * Indicates that misc needs to be re-calculated for all submeshes
  29967. */
  29968. protected _markAllSubMeshesAsMiscDirty(): void;
  29969. /**
  29970. * Indicates that prepass needs to be re-calculated for all submeshes
  29971. */
  29972. protected _markAllSubMeshesAsPrePassDirty(): void;
  29973. /**
  29974. * Indicates that textures and misc need to be re-calculated for all submeshes
  29975. */
  29976. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29977. /**
  29978. * Sets the required values to the prepass renderer.
  29979. * @param prePassRenderer defines the prepass renderer to setup.
  29980. * @returns true if the pre pass is needed.
  29981. */
  29982. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29983. /**
  29984. * Disposes the material
  29985. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29986. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29987. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29988. */
  29989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29990. /** @hidden */
  29991. private releaseVertexArrayObject;
  29992. /**
  29993. * Serializes this material
  29994. * @returns the serialized material object
  29995. */
  29996. serialize(): any;
  29997. /**
  29998. * Creates a material from parsed material data
  29999. * @param parsedMaterial defines parsed material data
  30000. * @param scene defines the hosting scene
  30001. * @param rootUrl defines the root URL to use to load textures
  30002. * @returns a new material
  30003. */
  30004. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30005. }
  30006. }
  30007. declare module BABYLON {
  30008. /**
  30009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30010. * separate meshes. This can be use to improve performances.
  30011. * @see https://doc.babylonjs.com/how_to/multi_materials
  30012. */
  30013. export class MultiMaterial extends Material {
  30014. private _subMaterials;
  30015. /**
  30016. * Gets or Sets the list of Materials used within the multi material.
  30017. * They need to be ordered according to the submeshes order in the associated mesh
  30018. */
  30019. get subMaterials(): Nullable<Material>[];
  30020. set subMaterials(value: Nullable<Material>[]);
  30021. /**
  30022. * Function used to align with Node.getChildren()
  30023. * @returns the list of Materials used within the multi material
  30024. */
  30025. getChildren(): Nullable<Material>[];
  30026. /**
  30027. * Instantiates a new Multi Material
  30028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30029. * separate meshes. This can be use to improve performances.
  30030. * @see https://doc.babylonjs.com/how_to/multi_materials
  30031. * @param name Define the name in the scene
  30032. * @param scene Define the scene the material belongs to
  30033. */
  30034. constructor(name: string, scene: Scene);
  30035. private _hookArray;
  30036. /**
  30037. * Get one of the submaterial by its index in the submaterials array
  30038. * @param index The index to look the sub material at
  30039. * @returns The Material if the index has been defined
  30040. */
  30041. getSubMaterial(index: number): Nullable<Material>;
  30042. /**
  30043. * Get the list of active textures for the whole sub materials list.
  30044. * @returns All the textures that will be used during the rendering
  30045. */
  30046. getActiveTextures(): BaseTexture[];
  30047. /**
  30048. * Specifies if any sub-materials of this multi-material use a given texture.
  30049. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30050. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30051. */
  30052. hasTexture(texture: BaseTexture): boolean;
  30053. /**
  30054. * Gets the current class name of the material e.g. "MultiMaterial"
  30055. * Mainly use in serialization.
  30056. * @returns the class name
  30057. */
  30058. getClassName(): string;
  30059. /**
  30060. * Checks if the material is ready to render the requested sub mesh
  30061. * @param mesh Define the mesh the submesh belongs to
  30062. * @param subMesh Define the sub mesh to look readyness for
  30063. * @param useInstances Define whether or not the material is used with instances
  30064. * @returns true if ready, otherwise false
  30065. */
  30066. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30067. /**
  30068. * Clones the current material and its related sub materials
  30069. * @param name Define the name of the newly cloned material
  30070. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30071. * @returns the cloned material
  30072. */
  30073. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30074. /**
  30075. * Serializes the materials into a JSON representation.
  30076. * @returns the JSON representation
  30077. */
  30078. serialize(): any;
  30079. /**
  30080. * Dispose the material and release its associated resources
  30081. * @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)
  30082. * @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)
  30083. * @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)
  30084. */
  30085. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30086. /**
  30087. * Creates a MultiMaterial from parsed MultiMaterial data.
  30088. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30089. * @param scene defines the hosting scene
  30090. * @returns a new MultiMaterial
  30091. */
  30092. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30093. }
  30094. }
  30095. declare module BABYLON {
  30096. /**
  30097. * Defines a subdivision inside a mesh
  30098. */
  30099. export class SubMesh implements ICullable {
  30100. /** the material index to use */
  30101. materialIndex: number;
  30102. /** vertex index start */
  30103. verticesStart: number;
  30104. /** vertices count */
  30105. verticesCount: number;
  30106. /** index start */
  30107. indexStart: number;
  30108. /** indices count */
  30109. indexCount: number;
  30110. /** @hidden */
  30111. _materialDefines: Nullable<MaterialDefines>;
  30112. /** @hidden */
  30113. _materialEffect: Nullable<Effect>;
  30114. /** @hidden */
  30115. _effectOverride: Nullable<Effect>;
  30116. /**
  30117. * Gets material defines used by the effect associated to the sub mesh
  30118. */
  30119. get materialDefines(): Nullable<MaterialDefines>;
  30120. /**
  30121. * Sets material defines used by the effect associated to the sub mesh
  30122. */
  30123. set materialDefines(defines: Nullable<MaterialDefines>);
  30124. /**
  30125. * Gets associated effect
  30126. */
  30127. get effect(): Nullable<Effect>;
  30128. /**
  30129. * Sets associated effect (effect used to render this submesh)
  30130. * @param effect defines the effect to associate with
  30131. * @param defines defines the set of defines used to compile this effect
  30132. */
  30133. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30134. /** @hidden */
  30135. _linesIndexCount: number;
  30136. private _mesh;
  30137. private _renderingMesh;
  30138. private _boundingInfo;
  30139. private _linesIndexBuffer;
  30140. /** @hidden */
  30141. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30142. /** @hidden */
  30143. _trianglePlanes: Plane[];
  30144. /** @hidden */
  30145. _lastColliderTransformMatrix: Nullable<Matrix>;
  30146. /** @hidden */
  30147. _renderId: number;
  30148. /** @hidden */
  30149. _alphaIndex: number;
  30150. /** @hidden */
  30151. _distanceToCamera: number;
  30152. /** @hidden */
  30153. _id: number;
  30154. private _currentMaterial;
  30155. /**
  30156. * Add a new submesh to a mesh
  30157. * @param materialIndex defines the material index to use
  30158. * @param verticesStart defines vertex index start
  30159. * @param verticesCount defines vertices count
  30160. * @param indexStart defines index start
  30161. * @param indexCount defines indices count
  30162. * @param mesh defines the parent mesh
  30163. * @param renderingMesh defines an optional rendering mesh
  30164. * @param createBoundingBox defines if bounding box should be created for this submesh
  30165. * @returns the new submesh
  30166. */
  30167. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30168. /**
  30169. * Creates a new submesh
  30170. * @param materialIndex defines the material index to use
  30171. * @param verticesStart defines vertex index start
  30172. * @param verticesCount defines vertices count
  30173. * @param indexStart defines index start
  30174. * @param indexCount defines indices count
  30175. * @param mesh defines the parent mesh
  30176. * @param renderingMesh defines an optional rendering mesh
  30177. * @param createBoundingBox defines if bounding box should be created for this submesh
  30178. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30179. */
  30180. constructor(
  30181. /** the material index to use */
  30182. materialIndex: number,
  30183. /** vertex index start */
  30184. verticesStart: number,
  30185. /** vertices count */
  30186. verticesCount: number,
  30187. /** index start */
  30188. indexStart: number,
  30189. /** indices count */
  30190. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30191. /**
  30192. * Returns true if this submesh covers the entire parent mesh
  30193. * @ignorenaming
  30194. */
  30195. get IsGlobal(): boolean;
  30196. /**
  30197. * Returns the submesh BoudingInfo object
  30198. * @returns current bounding info (or mesh's one if the submesh is global)
  30199. */
  30200. getBoundingInfo(): BoundingInfo;
  30201. /**
  30202. * Sets the submesh BoundingInfo
  30203. * @param boundingInfo defines the new bounding info to use
  30204. * @returns the SubMesh
  30205. */
  30206. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30207. /**
  30208. * Returns the mesh of the current submesh
  30209. * @return the parent mesh
  30210. */
  30211. getMesh(): AbstractMesh;
  30212. /**
  30213. * Returns the rendering mesh of the submesh
  30214. * @returns the rendering mesh (could be different from parent mesh)
  30215. */
  30216. getRenderingMesh(): Mesh;
  30217. /**
  30218. * Returns the replacement mesh of the submesh
  30219. * @returns the replacement mesh (could be different from parent mesh)
  30220. */
  30221. getReplacementMesh(): Nullable<AbstractMesh>;
  30222. /**
  30223. * Returns the effective mesh of the submesh
  30224. * @returns the effective mesh (could be different from parent mesh)
  30225. */
  30226. getEffectiveMesh(): AbstractMesh;
  30227. /**
  30228. * Returns the submesh material
  30229. * @returns null or the current material
  30230. */
  30231. getMaterial(): Nullable<Material>;
  30232. private _IsMultiMaterial;
  30233. /**
  30234. * Sets a new updated BoundingInfo object to the submesh
  30235. * @param data defines an optional position array to use to determine the bounding info
  30236. * @returns the SubMesh
  30237. */
  30238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30239. /** @hidden */
  30240. _checkCollision(collider: Collider): boolean;
  30241. /**
  30242. * Updates the submesh BoundingInfo
  30243. * @param world defines the world matrix to use to update the bounding info
  30244. * @returns the submesh
  30245. */
  30246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30247. /**
  30248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30249. * @param frustumPlanes defines the frustum planes
  30250. * @returns true if the submesh is intersecting with the frustum
  30251. */
  30252. isInFrustum(frustumPlanes: Plane[]): boolean;
  30253. /**
  30254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30255. * @param frustumPlanes defines the frustum planes
  30256. * @returns true if the submesh is inside the frustum
  30257. */
  30258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30259. /**
  30260. * Renders the submesh
  30261. * @param enableAlphaMode defines if alpha needs to be used
  30262. * @returns the submesh
  30263. */
  30264. render(enableAlphaMode: boolean): SubMesh;
  30265. /**
  30266. * @hidden
  30267. */
  30268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30269. /**
  30270. * Checks if the submesh intersects with a ray
  30271. * @param ray defines the ray to test
  30272. * @returns true is the passed ray intersects the submesh bounding box
  30273. */
  30274. canIntersects(ray: Ray): boolean;
  30275. /**
  30276. * Intersects current submesh with a ray
  30277. * @param ray defines the ray to test
  30278. * @param positions defines mesh's positions array
  30279. * @param indices defines mesh's indices array
  30280. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30282. * @returns intersection info or null if no intersection
  30283. */
  30284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30285. /** @hidden */
  30286. private _intersectLines;
  30287. /** @hidden */
  30288. private _intersectUnIndexedLines;
  30289. /** @hidden */
  30290. private _intersectTriangles;
  30291. /** @hidden */
  30292. private _intersectUnIndexedTriangles;
  30293. /** @hidden */
  30294. _rebuild(): void;
  30295. /**
  30296. * Creates a new submesh from the passed mesh
  30297. * @param newMesh defines the new hosting mesh
  30298. * @param newRenderingMesh defines an optional rendering mesh
  30299. * @returns the new submesh
  30300. */
  30301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30302. /**
  30303. * Release associated resources
  30304. */
  30305. dispose(): void;
  30306. /**
  30307. * Gets the class name
  30308. * @returns the string "SubMesh".
  30309. */
  30310. getClassName(): string;
  30311. /**
  30312. * Creates a new submesh from indices data
  30313. * @param materialIndex the index of the main mesh material
  30314. * @param startIndex the index where to start the copy in the mesh indices array
  30315. * @param indexCount the number of indices to copy then from the startIndex
  30316. * @param mesh the main mesh to create the submesh from
  30317. * @param renderingMesh the optional rendering mesh
  30318. * @returns a new submesh
  30319. */
  30320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30321. }
  30322. }
  30323. declare module BABYLON {
  30324. /**
  30325. * Class used to represent data loading progression
  30326. */
  30327. export class SceneLoaderFlags {
  30328. private static _ForceFullSceneLoadingForIncremental;
  30329. private static _ShowLoadingScreen;
  30330. private static _CleanBoneMatrixWeights;
  30331. private static _loggingLevel;
  30332. /**
  30333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30334. */
  30335. static get ForceFullSceneLoadingForIncremental(): boolean;
  30336. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30337. /**
  30338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30339. */
  30340. static get ShowLoadingScreen(): boolean;
  30341. static set ShowLoadingScreen(value: boolean);
  30342. /**
  30343. * Defines the current logging level (while loading the scene)
  30344. * @ignorenaming
  30345. */
  30346. static get loggingLevel(): number;
  30347. static set loggingLevel(value: number);
  30348. /**
  30349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30350. */
  30351. static get CleanBoneMatrixWeights(): boolean;
  30352. static set CleanBoneMatrixWeights(value: boolean);
  30353. }
  30354. }
  30355. declare module BABYLON {
  30356. /**
  30357. * Class used to store geometry data (vertex buffers + index buffer)
  30358. */
  30359. export class Geometry implements IGetSetVerticesData {
  30360. /**
  30361. * Gets or sets the ID of the geometry
  30362. */
  30363. id: string;
  30364. /**
  30365. * Gets or sets the unique ID of the geometry
  30366. */
  30367. uniqueId: number;
  30368. /**
  30369. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30370. */
  30371. delayLoadState: number;
  30372. /**
  30373. * Gets the file containing the data to load when running in delay load state
  30374. */
  30375. delayLoadingFile: Nullable<string>;
  30376. /**
  30377. * Callback called when the geometry is updated
  30378. */
  30379. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30380. private _scene;
  30381. private _engine;
  30382. private _meshes;
  30383. private _totalVertices;
  30384. /** @hidden */
  30385. _indices: IndicesArray;
  30386. /** @hidden */
  30387. _vertexBuffers: {
  30388. [key: string]: VertexBuffer;
  30389. };
  30390. private _isDisposed;
  30391. private _extend;
  30392. private _boundingBias;
  30393. /** @hidden */
  30394. _delayInfo: Array<string>;
  30395. private _indexBuffer;
  30396. private _indexBufferIsUpdatable;
  30397. /** @hidden */
  30398. _boundingInfo: Nullable<BoundingInfo>;
  30399. /** @hidden */
  30400. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30401. /** @hidden */
  30402. _softwareSkinningFrameId: number;
  30403. private _vertexArrayObjects;
  30404. private _updatable;
  30405. /** @hidden */
  30406. _positions: Nullable<Vector3[]>;
  30407. private _positionsCache;
  30408. /**
  30409. * 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
  30410. */
  30411. get boundingBias(): Vector2;
  30412. /**
  30413. * 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
  30414. */
  30415. set boundingBias(value: Vector2);
  30416. /**
  30417. * Static function used to attach a new empty geometry to a mesh
  30418. * @param mesh defines the mesh to attach the geometry to
  30419. * @returns the new Geometry
  30420. */
  30421. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30422. /** Get the list of meshes using this geometry */
  30423. get meshes(): Mesh[];
  30424. /**
  30425. * 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
  30426. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30427. */
  30428. useBoundingInfoFromGeometry: boolean;
  30429. /**
  30430. * Creates a new geometry
  30431. * @param id defines the unique ID
  30432. * @param scene defines the hosting scene
  30433. * @param vertexData defines the VertexData used to get geometry data
  30434. * @param updatable defines if geometry must be updatable (false by default)
  30435. * @param mesh defines the mesh that will be associated with the geometry
  30436. */
  30437. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30438. /**
  30439. * Gets the current extend of the geometry
  30440. */
  30441. get extend(): {
  30442. minimum: Vector3;
  30443. maximum: Vector3;
  30444. };
  30445. /**
  30446. * Gets the hosting scene
  30447. * @returns the hosting Scene
  30448. */
  30449. getScene(): Scene;
  30450. /**
  30451. * Gets the hosting engine
  30452. * @returns the hosting Engine
  30453. */
  30454. getEngine(): Engine;
  30455. /**
  30456. * Defines if the geometry is ready to use
  30457. * @returns true if the geometry is ready to be used
  30458. */
  30459. isReady(): boolean;
  30460. /**
  30461. * Gets a value indicating that the geometry should not be serialized
  30462. */
  30463. get doNotSerialize(): boolean;
  30464. /** @hidden */
  30465. _rebuild(): void;
  30466. /**
  30467. * Affects all geometry data in one call
  30468. * @param vertexData defines the geometry data
  30469. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30470. */
  30471. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30472. /**
  30473. * Set specific vertex data
  30474. * @param kind defines the data kind (Position, normal, etc...)
  30475. * @param data defines the vertex data to use
  30476. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30477. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30478. */
  30479. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30480. /**
  30481. * Removes a specific vertex data
  30482. * @param kind defines the data kind (Position, normal, etc...)
  30483. */
  30484. removeVerticesData(kind: string): void;
  30485. /**
  30486. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30487. * @param buffer defines the vertex buffer to use
  30488. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30489. */
  30490. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30491. /**
  30492. * Update a specific vertex buffer
  30493. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30494. * It will do nothing if the buffer is not updatable
  30495. * @param kind defines the data kind (Position, normal, etc...)
  30496. * @param data defines the data to use
  30497. * @param offset defines the offset in the target buffer where to store the data
  30498. * @param useBytes set to true if the offset is in bytes
  30499. */
  30500. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30501. /**
  30502. * Update a specific vertex buffer
  30503. * This function will create a new buffer if the current one is not updatable
  30504. * @param kind defines the data kind (Position, normal, etc...)
  30505. * @param data defines the data to use
  30506. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30507. */
  30508. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30509. private _updateBoundingInfo;
  30510. /** @hidden */
  30511. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30512. /**
  30513. * Gets total number of vertices
  30514. * @returns the total number of vertices
  30515. */
  30516. getTotalVertices(): number;
  30517. /**
  30518. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30519. * @param kind defines the data kind (Position, normal, etc...)
  30520. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30521. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30522. * @returns a float array containing vertex data
  30523. */
  30524. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30525. /**
  30526. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30527. * @param kind defines the data kind (Position, normal, etc...)
  30528. * @returns true if the vertex buffer with the specified kind is updatable
  30529. */
  30530. isVertexBufferUpdatable(kind: string): boolean;
  30531. /**
  30532. * Gets a specific vertex buffer
  30533. * @param kind defines the data kind (Position, normal, etc...)
  30534. * @returns a VertexBuffer
  30535. */
  30536. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30537. /**
  30538. * Returns all vertex buffers
  30539. * @return an object holding all vertex buffers indexed by kind
  30540. */
  30541. getVertexBuffers(): Nullable<{
  30542. [key: string]: VertexBuffer;
  30543. }>;
  30544. /**
  30545. * Gets a boolean indicating if specific vertex buffer is present
  30546. * @param kind defines the data kind (Position, normal, etc...)
  30547. * @returns true if data is present
  30548. */
  30549. isVerticesDataPresent(kind: string): boolean;
  30550. /**
  30551. * Gets a list of all attached data kinds (Position, normal, etc...)
  30552. * @returns a list of string containing all kinds
  30553. */
  30554. getVerticesDataKinds(): string[];
  30555. /**
  30556. * Update index buffer
  30557. * @param indices defines the indices to store in the index buffer
  30558. * @param offset defines the offset in the target buffer where to store the data
  30559. * @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)
  30560. */
  30561. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30562. /**
  30563. * Creates a new index buffer
  30564. * @param indices defines the indices to store in the index buffer
  30565. * @param totalVertices defines the total number of vertices (could be null)
  30566. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30567. */
  30568. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30569. /**
  30570. * Return the total number of indices
  30571. * @returns the total number of indices
  30572. */
  30573. getTotalIndices(): number;
  30574. /**
  30575. * Gets the index buffer array
  30576. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30578. * @returns the index buffer array
  30579. */
  30580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30581. /**
  30582. * Gets the index buffer
  30583. * @return the index buffer
  30584. */
  30585. getIndexBuffer(): Nullable<DataBuffer>;
  30586. /** @hidden */
  30587. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30588. /**
  30589. * Release the associated resources for a specific mesh
  30590. * @param mesh defines the source mesh
  30591. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30592. */
  30593. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30594. /**
  30595. * Apply current geometry to a given mesh
  30596. * @param mesh defines the mesh to apply geometry to
  30597. */
  30598. applyToMesh(mesh: Mesh): void;
  30599. private _updateExtend;
  30600. private _applyToMesh;
  30601. private notifyUpdate;
  30602. /**
  30603. * Load the geometry if it was flagged as delay loaded
  30604. * @param scene defines the hosting scene
  30605. * @param onLoaded defines a callback called when the geometry is loaded
  30606. */
  30607. load(scene: Scene, onLoaded?: () => void): void;
  30608. private _queueLoad;
  30609. /**
  30610. * Invert the geometry to move from a right handed system to a left handed one.
  30611. */
  30612. toLeftHanded(): void;
  30613. /** @hidden */
  30614. _resetPointsArrayCache(): void;
  30615. /** @hidden */
  30616. _generatePointsArray(): boolean;
  30617. /**
  30618. * Gets a value indicating if the geometry is disposed
  30619. * @returns true if the geometry was disposed
  30620. */
  30621. isDisposed(): boolean;
  30622. private _disposeVertexArrayObjects;
  30623. /**
  30624. * Free all associated resources
  30625. */
  30626. dispose(): void;
  30627. /**
  30628. * Clone the current geometry into a new geometry
  30629. * @param id defines the unique ID of the new geometry
  30630. * @returns a new geometry object
  30631. */
  30632. copy(id: string): Geometry;
  30633. /**
  30634. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30635. * @return a JSON representation of the current geometry data (without the vertices data)
  30636. */
  30637. serialize(): any;
  30638. private toNumberArray;
  30639. /**
  30640. * Serialize all vertices data into a JSON oject
  30641. * @returns a JSON representation of the current geometry data
  30642. */
  30643. serializeVerticeData(): any;
  30644. /**
  30645. * Extracts a clone of a mesh geometry
  30646. * @param mesh defines the source mesh
  30647. * @param id defines the unique ID of the new geometry object
  30648. * @returns the new geometry object
  30649. */
  30650. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30651. /**
  30652. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30653. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30654. * Be aware Math.random() could cause collisions, but:
  30655. * "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"
  30656. * @returns a string containing a new GUID
  30657. */
  30658. static RandomId(): string;
  30659. /** @hidden */
  30660. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30661. private static _CleanMatricesWeights;
  30662. /**
  30663. * Create a new geometry from persisted data (Using .babylon file format)
  30664. * @param parsedVertexData defines the persisted data
  30665. * @param scene defines the hosting scene
  30666. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30667. * @returns the new geometry object
  30668. */
  30669. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30670. }
  30671. }
  30672. declare module BABYLON {
  30673. /**
  30674. * Defines a target to use with MorphTargetManager
  30675. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30676. */
  30677. export class MorphTarget implements IAnimatable {
  30678. /** defines the name of the target */
  30679. name: string;
  30680. /**
  30681. * Gets or sets the list of animations
  30682. */
  30683. animations: Animation[];
  30684. private _scene;
  30685. private _positions;
  30686. private _normals;
  30687. private _tangents;
  30688. private _uvs;
  30689. private _influence;
  30690. private _uniqueId;
  30691. /**
  30692. * Observable raised when the influence changes
  30693. */
  30694. onInfluenceChanged: Observable<boolean>;
  30695. /** @hidden */
  30696. _onDataLayoutChanged: Observable<void>;
  30697. /**
  30698. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30699. */
  30700. get influence(): number;
  30701. set influence(influence: number);
  30702. /**
  30703. * Gets or sets the id of the morph Target
  30704. */
  30705. id: string;
  30706. private _animationPropertiesOverride;
  30707. /**
  30708. * Gets or sets the animation properties override
  30709. */
  30710. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30711. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30712. /**
  30713. * Creates a new MorphTarget
  30714. * @param name defines the name of the target
  30715. * @param influence defines the influence to use
  30716. * @param scene defines the scene the morphtarget belongs to
  30717. */
  30718. constructor(
  30719. /** defines the name of the target */
  30720. name: string, influence?: number, scene?: Nullable<Scene>);
  30721. /**
  30722. * Gets the unique ID of this manager
  30723. */
  30724. get uniqueId(): number;
  30725. /**
  30726. * Gets a boolean defining if the target contains position data
  30727. */
  30728. get hasPositions(): boolean;
  30729. /**
  30730. * Gets a boolean defining if the target contains normal data
  30731. */
  30732. get hasNormals(): boolean;
  30733. /**
  30734. * Gets a boolean defining if the target contains tangent data
  30735. */
  30736. get hasTangents(): boolean;
  30737. /**
  30738. * Gets a boolean defining if the target contains texture coordinates data
  30739. */
  30740. get hasUVs(): boolean;
  30741. /**
  30742. * Affects position data to this target
  30743. * @param data defines the position data to use
  30744. */
  30745. setPositions(data: Nullable<FloatArray>): void;
  30746. /**
  30747. * Gets the position data stored in this target
  30748. * @returns a FloatArray containing the position data (or null if not present)
  30749. */
  30750. getPositions(): Nullable<FloatArray>;
  30751. /**
  30752. * Affects normal data to this target
  30753. * @param data defines the normal data to use
  30754. */
  30755. setNormals(data: Nullable<FloatArray>): void;
  30756. /**
  30757. * Gets the normal data stored in this target
  30758. * @returns a FloatArray containing the normal data (or null if not present)
  30759. */
  30760. getNormals(): Nullable<FloatArray>;
  30761. /**
  30762. * Affects tangent data to this target
  30763. * @param data defines the tangent data to use
  30764. */
  30765. setTangents(data: Nullable<FloatArray>): void;
  30766. /**
  30767. * Gets the tangent data stored in this target
  30768. * @returns a FloatArray containing the tangent data (or null if not present)
  30769. */
  30770. getTangents(): Nullable<FloatArray>;
  30771. /**
  30772. * Affects texture coordinates data to this target
  30773. * @param data defines the texture coordinates data to use
  30774. */
  30775. setUVs(data: Nullable<FloatArray>): void;
  30776. /**
  30777. * Gets the texture coordinates data stored in this target
  30778. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30779. */
  30780. getUVs(): Nullable<FloatArray>;
  30781. /**
  30782. * Clone the current target
  30783. * @returns a new MorphTarget
  30784. */
  30785. clone(): MorphTarget;
  30786. /**
  30787. * Serializes the current target into a Serialization object
  30788. * @returns the serialized object
  30789. */
  30790. serialize(): any;
  30791. /**
  30792. * Returns the string "MorphTarget"
  30793. * @returns "MorphTarget"
  30794. */
  30795. getClassName(): string;
  30796. /**
  30797. * Creates a new target from serialized data
  30798. * @param serializationObject defines the serialized data to use
  30799. * @returns a new MorphTarget
  30800. */
  30801. static Parse(serializationObject: any): MorphTarget;
  30802. /**
  30803. * Creates a MorphTarget from mesh data
  30804. * @param mesh defines the source mesh
  30805. * @param name defines the name to use for the new target
  30806. * @param influence defines the influence to attach to the target
  30807. * @returns a new MorphTarget
  30808. */
  30809. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30810. }
  30811. }
  30812. declare module BABYLON {
  30813. /**
  30814. * This class is used to deform meshes using morphing between different targets
  30815. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30816. */
  30817. export class MorphTargetManager {
  30818. private _targets;
  30819. private _targetInfluenceChangedObservers;
  30820. private _targetDataLayoutChangedObservers;
  30821. private _activeTargets;
  30822. private _scene;
  30823. private _influences;
  30824. private _supportsNormals;
  30825. private _supportsTangents;
  30826. private _supportsUVs;
  30827. private _vertexCount;
  30828. private _uniqueId;
  30829. private _tempInfluences;
  30830. /**
  30831. * Gets or sets a boolean indicating if normals must be morphed
  30832. */
  30833. enableNormalMorphing: boolean;
  30834. /**
  30835. * Gets or sets a boolean indicating if tangents must be morphed
  30836. */
  30837. enableTangentMorphing: boolean;
  30838. /**
  30839. * Gets or sets a boolean indicating if UV must be morphed
  30840. */
  30841. enableUVMorphing: boolean;
  30842. /**
  30843. * Creates a new MorphTargetManager
  30844. * @param scene defines the current scene
  30845. */
  30846. constructor(scene?: Nullable<Scene>);
  30847. /**
  30848. * Gets the unique ID of this manager
  30849. */
  30850. get uniqueId(): number;
  30851. /**
  30852. * Gets the number of vertices handled by this manager
  30853. */
  30854. get vertexCount(): number;
  30855. /**
  30856. * Gets a boolean indicating if this manager supports morphing of normals
  30857. */
  30858. get supportsNormals(): boolean;
  30859. /**
  30860. * Gets a boolean indicating if this manager supports morphing of tangents
  30861. */
  30862. get supportsTangents(): boolean;
  30863. /**
  30864. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30865. */
  30866. get supportsUVs(): boolean;
  30867. /**
  30868. * Gets the number of targets stored in this manager
  30869. */
  30870. get numTargets(): number;
  30871. /**
  30872. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30873. */
  30874. get numInfluencers(): number;
  30875. /**
  30876. * Gets the list of influences (one per target)
  30877. */
  30878. get influences(): Float32Array;
  30879. /**
  30880. * Gets the active target at specified index. An active target is a target with an influence > 0
  30881. * @param index defines the index to check
  30882. * @returns the requested target
  30883. */
  30884. getActiveTarget(index: number): MorphTarget;
  30885. /**
  30886. * Gets the target at specified index
  30887. * @param index defines the index to check
  30888. * @returns the requested target
  30889. */
  30890. getTarget(index: number): MorphTarget;
  30891. /**
  30892. * Add a new target to this manager
  30893. * @param target defines the target to add
  30894. */
  30895. addTarget(target: MorphTarget): void;
  30896. /**
  30897. * Removes a target from the manager
  30898. * @param target defines the target to remove
  30899. */
  30900. removeTarget(target: MorphTarget): void;
  30901. /**
  30902. * Clone the current manager
  30903. * @returns a new MorphTargetManager
  30904. */
  30905. clone(): MorphTargetManager;
  30906. /**
  30907. * Serializes the current manager into a Serialization object
  30908. * @returns the serialized object
  30909. */
  30910. serialize(): any;
  30911. private _syncActiveTargets;
  30912. /**
  30913. * Syncrhonize the targets with all the meshes using this morph target manager
  30914. */
  30915. synchronize(): void;
  30916. /**
  30917. * Creates a new MorphTargetManager from serialized data
  30918. * @param serializationObject defines the serialized data
  30919. * @param scene defines the hosting scene
  30920. * @returns the new MorphTargetManager
  30921. */
  30922. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30923. }
  30924. }
  30925. declare module BABYLON {
  30926. /**
  30927. * Class used to represent a specific level of detail of a mesh
  30928. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30929. */
  30930. export class MeshLODLevel {
  30931. /** Defines the distance where this level should start being displayed */
  30932. distance: number;
  30933. /** Defines the mesh to use to render this level */
  30934. mesh: Nullable<Mesh>;
  30935. /**
  30936. * Creates a new LOD level
  30937. * @param distance defines the distance where this level should star being displayed
  30938. * @param mesh defines the mesh to use to render this level
  30939. */
  30940. constructor(
  30941. /** Defines the distance where this level should start being displayed */
  30942. distance: number,
  30943. /** Defines the mesh to use to render this level */
  30944. mesh: Nullable<Mesh>);
  30945. }
  30946. }
  30947. declare module BABYLON {
  30948. /**
  30949. * Helper class used to generate a canvas to manipulate images
  30950. */
  30951. export class CanvasGenerator {
  30952. /**
  30953. * Create a new canvas (or offscreen canvas depending on the context)
  30954. * @param width defines the expected width
  30955. * @param height defines the expected height
  30956. * @return a new canvas or offscreen canvas
  30957. */
  30958. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30959. }
  30960. }
  30961. declare module BABYLON {
  30962. /**
  30963. * Mesh representing the gorund
  30964. */
  30965. export class GroundMesh extends Mesh {
  30966. /** If octree should be generated */
  30967. generateOctree: boolean;
  30968. private _heightQuads;
  30969. /** @hidden */
  30970. _subdivisionsX: number;
  30971. /** @hidden */
  30972. _subdivisionsY: number;
  30973. /** @hidden */
  30974. _width: number;
  30975. /** @hidden */
  30976. _height: number;
  30977. /** @hidden */
  30978. _minX: number;
  30979. /** @hidden */
  30980. _maxX: number;
  30981. /** @hidden */
  30982. _minZ: number;
  30983. /** @hidden */
  30984. _maxZ: number;
  30985. constructor(name: string, scene: Scene);
  30986. /**
  30987. * "GroundMesh"
  30988. * @returns "GroundMesh"
  30989. */
  30990. getClassName(): string;
  30991. /**
  30992. * The minimum of x and y subdivisions
  30993. */
  30994. get subdivisions(): number;
  30995. /**
  30996. * X subdivisions
  30997. */
  30998. get subdivisionsX(): number;
  30999. /**
  31000. * Y subdivisions
  31001. */
  31002. get subdivisionsY(): number;
  31003. /**
  31004. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31005. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31006. * @param chunksCount the number of subdivisions for x and y
  31007. * @param octreeBlocksSize (Default: 32)
  31008. */
  31009. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31010. /**
  31011. * Returns a height (y) value in the Worl system :
  31012. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31013. * @param x x coordinate
  31014. * @param z z coordinate
  31015. * @returns the ground y position if (x, z) are outside the ground surface.
  31016. */
  31017. getHeightAtCoordinates(x: number, z: number): number;
  31018. /**
  31019. * Returns a normalized vector (Vector3) orthogonal to the ground
  31020. * at the ground coordinates (x, z) expressed in the World system.
  31021. * @param x x coordinate
  31022. * @param z z coordinate
  31023. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31024. */
  31025. getNormalAtCoordinates(x: number, z: number): Vector3;
  31026. /**
  31027. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31028. * at the ground coordinates (x, z) expressed in the World system.
  31029. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31030. * @param x x coordinate
  31031. * @param z z coordinate
  31032. * @param ref vector to store the result
  31033. * @returns the GroundMesh.
  31034. */
  31035. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31036. /**
  31037. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31038. * if the ground has been updated.
  31039. * This can be used in the render loop.
  31040. * @returns the GroundMesh.
  31041. */
  31042. updateCoordinateHeights(): GroundMesh;
  31043. private _getFacetAt;
  31044. private _initHeightQuads;
  31045. private _computeHeightQuads;
  31046. /**
  31047. * Serializes this ground mesh
  31048. * @param serializationObject object to write serialization to
  31049. */
  31050. serialize(serializationObject: any): void;
  31051. /**
  31052. * Parses a serialized ground mesh
  31053. * @param parsedMesh the serialized mesh
  31054. * @param scene the scene to create the ground mesh in
  31055. * @returns the created ground mesh
  31056. */
  31057. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31058. }
  31059. }
  31060. declare module BABYLON {
  31061. /**
  31062. * Interface for Physics-Joint data
  31063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31064. */
  31065. export interface PhysicsJointData {
  31066. /**
  31067. * The main pivot of the joint
  31068. */
  31069. mainPivot?: Vector3;
  31070. /**
  31071. * The connected pivot of the joint
  31072. */
  31073. connectedPivot?: Vector3;
  31074. /**
  31075. * The main axis of the joint
  31076. */
  31077. mainAxis?: Vector3;
  31078. /**
  31079. * The connected axis of the joint
  31080. */
  31081. connectedAxis?: Vector3;
  31082. /**
  31083. * The collision of the joint
  31084. */
  31085. collision?: boolean;
  31086. /**
  31087. * Native Oimo/Cannon/Energy data
  31088. */
  31089. nativeParams?: any;
  31090. }
  31091. /**
  31092. * This is a holder class for the physics joint created by the physics plugin
  31093. * It holds a set of functions to control the underlying joint
  31094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31095. */
  31096. export class PhysicsJoint {
  31097. /**
  31098. * The type of the physics joint
  31099. */
  31100. type: number;
  31101. /**
  31102. * The data for the physics joint
  31103. */
  31104. jointData: PhysicsJointData;
  31105. private _physicsJoint;
  31106. protected _physicsPlugin: IPhysicsEnginePlugin;
  31107. /**
  31108. * Initializes the physics joint
  31109. * @param type The type of the physics joint
  31110. * @param jointData The data for the physics joint
  31111. */
  31112. constructor(
  31113. /**
  31114. * The type of the physics joint
  31115. */
  31116. type: number,
  31117. /**
  31118. * The data for the physics joint
  31119. */
  31120. jointData: PhysicsJointData);
  31121. /**
  31122. * Gets the physics joint
  31123. */
  31124. get physicsJoint(): any;
  31125. /**
  31126. * Sets the physics joint
  31127. */
  31128. set physicsJoint(newJoint: any);
  31129. /**
  31130. * Sets the physics plugin
  31131. */
  31132. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31133. /**
  31134. * Execute a function that is physics-plugin specific.
  31135. * @param {Function} func the function that will be executed.
  31136. * It accepts two parameters: the physics world and the physics joint
  31137. */
  31138. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31139. /**
  31140. * Distance-Joint type
  31141. */
  31142. static DistanceJoint: number;
  31143. /**
  31144. * Hinge-Joint type
  31145. */
  31146. static HingeJoint: number;
  31147. /**
  31148. * Ball-and-Socket joint type
  31149. */
  31150. static BallAndSocketJoint: number;
  31151. /**
  31152. * Wheel-Joint type
  31153. */
  31154. static WheelJoint: number;
  31155. /**
  31156. * Slider-Joint type
  31157. */
  31158. static SliderJoint: number;
  31159. /**
  31160. * Prismatic-Joint type
  31161. */
  31162. static PrismaticJoint: number;
  31163. /**
  31164. * Universal-Joint type
  31165. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31166. */
  31167. static UniversalJoint: number;
  31168. /**
  31169. * Hinge-Joint 2 type
  31170. */
  31171. static Hinge2Joint: number;
  31172. /**
  31173. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31174. */
  31175. static PointToPointJoint: number;
  31176. /**
  31177. * Spring-Joint type
  31178. */
  31179. static SpringJoint: number;
  31180. /**
  31181. * Lock-Joint type
  31182. */
  31183. static LockJoint: number;
  31184. }
  31185. /**
  31186. * A class representing a physics distance joint
  31187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31188. */
  31189. export class DistanceJoint extends PhysicsJoint {
  31190. /**
  31191. *
  31192. * @param jointData The data for the Distance-Joint
  31193. */
  31194. constructor(jointData: DistanceJointData);
  31195. /**
  31196. * Update the predefined distance.
  31197. * @param maxDistance The maximum preferred distance
  31198. * @param minDistance The minimum preferred distance
  31199. */
  31200. updateDistance(maxDistance: number, minDistance?: number): void;
  31201. }
  31202. /**
  31203. * Represents a Motor-Enabled Joint
  31204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31205. */
  31206. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31207. /**
  31208. * Initializes the Motor-Enabled Joint
  31209. * @param type The type of the joint
  31210. * @param jointData The physica joint data for the joint
  31211. */
  31212. constructor(type: number, jointData: PhysicsJointData);
  31213. /**
  31214. * Set the motor values.
  31215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31216. * @param force the force to apply
  31217. * @param maxForce max force for this motor.
  31218. */
  31219. setMotor(force?: number, maxForce?: number): void;
  31220. /**
  31221. * Set the motor's limits.
  31222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31223. * @param upperLimit The upper limit of the motor
  31224. * @param lowerLimit The lower limit of the motor
  31225. */
  31226. setLimit(upperLimit: number, lowerLimit?: number): void;
  31227. }
  31228. /**
  31229. * This class represents a single physics Hinge-Joint
  31230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31231. */
  31232. export class HingeJoint extends MotorEnabledJoint {
  31233. /**
  31234. * Initializes the Hinge-Joint
  31235. * @param jointData The joint data for the Hinge-Joint
  31236. */
  31237. constructor(jointData: PhysicsJointData);
  31238. /**
  31239. * Set the motor values.
  31240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31241. * @param {number} force the force to apply
  31242. * @param {number} maxForce max force for this motor.
  31243. */
  31244. setMotor(force?: number, maxForce?: number): void;
  31245. /**
  31246. * Set the motor's limits.
  31247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31248. * @param upperLimit The upper limit of the motor
  31249. * @param lowerLimit The lower limit of the motor
  31250. */
  31251. setLimit(upperLimit: number, lowerLimit?: number): void;
  31252. }
  31253. /**
  31254. * This class represents a dual hinge physics joint (same as wheel joint)
  31255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31256. */
  31257. export class Hinge2Joint extends MotorEnabledJoint {
  31258. /**
  31259. * Initializes the Hinge2-Joint
  31260. * @param jointData The joint data for the Hinge2-Joint
  31261. */
  31262. constructor(jointData: PhysicsJointData);
  31263. /**
  31264. * Set the motor values.
  31265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31266. * @param {number} targetSpeed the speed the motor is to reach
  31267. * @param {number} maxForce max force for this motor.
  31268. * @param {motorIndex} the motor's index, 0 or 1.
  31269. */
  31270. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31271. /**
  31272. * Set the motor limits.
  31273. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31274. * @param {number} upperLimit the upper limit
  31275. * @param {number} lowerLimit lower limit
  31276. * @param {motorIndex} the motor's index, 0 or 1.
  31277. */
  31278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31279. }
  31280. /**
  31281. * Interface for a motor enabled joint
  31282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31283. */
  31284. export interface IMotorEnabledJoint {
  31285. /**
  31286. * Physics joint
  31287. */
  31288. physicsJoint: any;
  31289. /**
  31290. * Sets the motor of the motor-enabled joint
  31291. * @param force The force of the motor
  31292. * @param maxForce The maximum force of the motor
  31293. * @param motorIndex The index of the motor
  31294. */
  31295. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31296. /**
  31297. * Sets the limit of the motor
  31298. * @param upperLimit The upper limit of the motor
  31299. * @param lowerLimit The lower limit of the motor
  31300. * @param motorIndex The index of the motor
  31301. */
  31302. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31303. }
  31304. /**
  31305. * Joint data for a Distance-Joint
  31306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31307. */
  31308. export interface DistanceJointData extends PhysicsJointData {
  31309. /**
  31310. * Max distance the 2 joint objects can be apart
  31311. */
  31312. maxDistance: number;
  31313. }
  31314. /**
  31315. * Joint data from a spring joint
  31316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31317. */
  31318. export interface SpringJointData extends PhysicsJointData {
  31319. /**
  31320. * Length of the spring
  31321. */
  31322. length: number;
  31323. /**
  31324. * Stiffness of the spring
  31325. */
  31326. stiffness: number;
  31327. /**
  31328. * Damping of the spring
  31329. */
  31330. damping: number;
  31331. /** this callback will be called when applying the force to the impostors. */
  31332. forceApplicationCallback: () => void;
  31333. }
  31334. }
  31335. declare module BABYLON {
  31336. /**
  31337. * Holds the data for the raycast result
  31338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31339. */
  31340. export class PhysicsRaycastResult {
  31341. private _hasHit;
  31342. private _hitDistance;
  31343. private _hitNormalWorld;
  31344. private _hitPointWorld;
  31345. private _rayFromWorld;
  31346. private _rayToWorld;
  31347. /**
  31348. * Gets if there was a hit
  31349. */
  31350. get hasHit(): boolean;
  31351. /**
  31352. * Gets the distance from the hit
  31353. */
  31354. get hitDistance(): number;
  31355. /**
  31356. * Gets the hit normal/direction in the world
  31357. */
  31358. get hitNormalWorld(): Vector3;
  31359. /**
  31360. * Gets the hit point in the world
  31361. */
  31362. get hitPointWorld(): Vector3;
  31363. /**
  31364. * Gets the ray "start point" of the ray in the world
  31365. */
  31366. get rayFromWorld(): Vector3;
  31367. /**
  31368. * Gets the ray "end point" of the ray in the world
  31369. */
  31370. get rayToWorld(): Vector3;
  31371. /**
  31372. * Sets the hit data (normal & point in world space)
  31373. * @param hitNormalWorld defines the normal in world space
  31374. * @param hitPointWorld defines the point in world space
  31375. */
  31376. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31377. /**
  31378. * Sets the distance from the start point to the hit point
  31379. * @param distance
  31380. */
  31381. setHitDistance(distance: number): void;
  31382. /**
  31383. * Calculates the distance manually
  31384. */
  31385. calculateHitDistance(): void;
  31386. /**
  31387. * Resets all the values to default
  31388. * @param from The from point on world space
  31389. * @param to The to point on world space
  31390. */
  31391. reset(from?: Vector3, to?: Vector3): void;
  31392. }
  31393. /**
  31394. * Interface for the size containing width and height
  31395. */
  31396. interface IXYZ {
  31397. /**
  31398. * X
  31399. */
  31400. x: number;
  31401. /**
  31402. * Y
  31403. */
  31404. y: number;
  31405. /**
  31406. * Z
  31407. */
  31408. z: number;
  31409. }
  31410. }
  31411. declare module BABYLON {
  31412. /**
  31413. * Interface used to describe a physics joint
  31414. */
  31415. export interface PhysicsImpostorJoint {
  31416. /** Defines the main impostor to which the joint is linked */
  31417. mainImpostor: PhysicsImpostor;
  31418. /** Defines the impostor that is connected to the main impostor using this joint */
  31419. connectedImpostor: PhysicsImpostor;
  31420. /** Defines the joint itself */
  31421. joint: PhysicsJoint;
  31422. }
  31423. /** @hidden */
  31424. export interface IPhysicsEnginePlugin {
  31425. world: any;
  31426. name: string;
  31427. setGravity(gravity: Vector3): void;
  31428. setTimeStep(timeStep: number): void;
  31429. getTimeStep(): number;
  31430. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31431. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31432. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31433. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31434. removePhysicsBody(impostor: PhysicsImpostor): void;
  31435. generateJoint(joint: PhysicsImpostorJoint): void;
  31436. removeJoint(joint: PhysicsImpostorJoint): void;
  31437. isSupported(): boolean;
  31438. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31439. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31440. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31441. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31442. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31443. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31444. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31445. getBodyMass(impostor: PhysicsImpostor): number;
  31446. getBodyFriction(impostor: PhysicsImpostor): number;
  31447. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31448. getBodyRestitution(impostor: PhysicsImpostor): number;
  31449. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31450. getBodyPressure?(impostor: PhysicsImpostor): number;
  31451. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31452. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31453. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31454. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31455. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31456. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31457. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31458. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31459. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31460. sleepBody(impostor: PhysicsImpostor): void;
  31461. wakeUpBody(impostor: PhysicsImpostor): void;
  31462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31463. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31464. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31465. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31466. getRadius(impostor: PhysicsImpostor): number;
  31467. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31468. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31469. dispose(): void;
  31470. }
  31471. /**
  31472. * Interface used to define a physics engine
  31473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31474. */
  31475. export interface IPhysicsEngine {
  31476. /**
  31477. * Gets the gravity vector used by the simulation
  31478. */
  31479. gravity: Vector3;
  31480. /**
  31481. * Sets the gravity vector used by the simulation
  31482. * @param gravity defines the gravity vector to use
  31483. */
  31484. setGravity(gravity: Vector3): void;
  31485. /**
  31486. * Set the time step of the physics engine.
  31487. * Default is 1/60.
  31488. * To slow it down, enter 1/600 for example.
  31489. * To speed it up, 1/30
  31490. * @param newTimeStep the new timestep to apply to this world.
  31491. */
  31492. setTimeStep(newTimeStep: number): void;
  31493. /**
  31494. * Get the time step of the physics engine.
  31495. * @returns the current time step
  31496. */
  31497. getTimeStep(): number;
  31498. /**
  31499. * Set the sub time step of the physics engine.
  31500. * Default is 0 meaning there is no sub steps
  31501. * To increase physics resolution precision, set a small value (like 1 ms)
  31502. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31503. */
  31504. setSubTimeStep(subTimeStep: number): void;
  31505. /**
  31506. * Get the sub time step of the physics engine.
  31507. * @returns the current sub time step
  31508. */
  31509. getSubTimeStep(): number;
  31510. /**
  31511. * Release all resources
  31512. */
  31513. dispose(): void;
  31514. /**
  31515. * Gets the name of the current physics plugin
  31516. * @returns the name of the plugin
  31517. */
  31518. getPhysicsPluginName(): string;
  31519. /**
  31520. * Adding a new impostor for the impostor tracking.
  31521. * This will be done by the impostor itself.
  31522. * @param impostor the impostor to add
  31523. */
  31524. addImpostor(impostor: PhysicsImpostor): void;
  31525. /**
  31526. * Remove an impostor from the engine.
  31527. * This impostor and its mesh will not longer be updated by the physics engine.
  31528. * @param impostor the impostor to remove
  31529. */
  31530. removeImpostor(impostor: PhysicsImpostor): void;
  31531. /**
  31532. * Add a joint to the physics engine
  31533. * @param mainImpostor defines the main impostor to which the joint is added.
  31534. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31535. * @param joint defines the joint that will connect both impostors.
  31536. */
  31537. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31538. /**
  31539. * Removes a joint from the simulation
  31540. * @param mainImpostor defines the impostor used with the joint
  31541. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31542. * @param joint defines the joint to remove
  31543. */
  31544. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31545. /**
  31546. * Gets the current plugin used to run the simulation
  31547. * @returns current plugin
  31548. */
  31549. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31550. /**
  31551. * Gets the list of physic impostors
  31552. * @returns an array of PhysicsImpostor
  31553. */
  31554. getImpostors(): Array<PhysicsImpostor>;
  31555. /**
  31556. * Gets the impostor for a physics enabled object
  31557. * @param object defines the object impersonated by the impostor
  31558. * @returns the PhysicsImpostor or null if not found
  31559. */
  31560. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31561. /**
  31562. * Gets the impostor for a physics body object
  31563. * @param body defines physics body used by the impostor
  31564. * @returns the PhysicsImpostor or null if not found
  31565. */
  31566. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31567. /**
  31568. * Does a raycast in the physics world
  31569. * @param from when should the ray start?
  31570. * @param to when should the ray end?
  31571. * @returns PhysicsRaycastResult
  31572. */
  31573. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31574. /**
  31575. * Called by the scene. No need to call it.
  31576. * @param delta defines the timespam between frames
  31577. */
  31578. _step(delta: number): void;
  31579. }
  31580. }
  31581. declare module BABYLON {
  31582. /**
  31583. * The interface for the physics imposter parameters
  31584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31585. */
  31586. export interface PhysicsImpostorParameters {
  31587. /**
  31588. * The mass of the physics imposter
  31589. */
  31590. mass: number;
  31591. /**
  31592. * The friction of the physics imposter
  31593. */
  31594. friction?: number;
  31595. /**
  31596. * The coefficient of restitution of the physics imposter
  31597. */
  31598. restitution?: number;
  31599. /**
  31600. * The native options of the physics imposter
  31601. */
  31602. nativeOptions?: any;
  31603. /**
  31604. * Specifies if the parent should be ignored
  31605. */
  31606. ignoreParent?: boolean;
  31607. /**
  31608. * Specifies if bi-directional transformations should be disabled
  31609. */
  31610. disableBidirectionalTransformation?: boolean;
  31611. /**
  31612. * The pressure inside the physics imposter, soft object only
  31613. */
  31614. pressure?: number;
  31615. /**
  31616. * The stiffness the physics imposter, soft object only
  31617. */
  31618. stiffness?: number;
  31619. /**
  31620. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31621. */
  31622. velocityIterations?: number;
  31623. /**
  31624. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31625. */
  31626. positionIterations?: number;
  31627. /**
  31628. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31629. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31630. * Add to fix multiple points
  31631. */
  31632. fixedPoints?: number;
  31633. /**
  31634. * The collision margin around a soft object
  31635. */
  31636. margin?: number;
  31637. /**
  31638. * The collision margin around a soft object
  31639. */
  31640. damping?: number;
  31641. /**
  31642. * The path for a rope based on an extrusion
  31643. */
  31644. path?: any;
  31645. /**
  31646. * The shape of an extrusion used for a rope based on an extrusion
  31647. */
  31648. shape?: any;
  31649. }
  31650. /**
  31651. * Interface for a physics-enabled object
  31652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31653. */
  31654. export interface IPhysicsEnabledObject {
  31655. /**
  31656. * The position of the physics-enabled object
  31657. */
  31658. position: Vector3;
  31659. /**
  31660. * The rotation of the physics-enabled object
  31661. */
  31662. rotationQuaternion: Nullable<Quaternion>;
  31663. /**
  31664. * The scale of the physics-enabled object
  31665. */
  31666. scaling: Vector3;
  31667. /**
  31668. * The rotation of the physics-enabled object
  31669. */
  31670. rotation?: Vector3;
  31671. /**
  31672. * The parent of the physics-enabled object
  31673. */
  31674. parent?: any;
  31675. /**
  31676. * The bounding info of the physics-enabled object
  31677. * @returns The bounding info of the physics-enabled object
  31678. */
  31679. getBoundingInfo(): BoundingInfo;
  31680. /**
  31681. * Computes the world matrix
  31682. * @param force Specifies if the world matrix should be computed by force
  31683. * @returns A world matrix
  31684. */
  31685. computeWorldMatrix(force: boolean): Matrix;
  31686. /**
  31687. * Gets the world matrix
  31688. * @returns A world matrix
  31689. */
  31690. getWorldMatrix?(): Matrix;
  31691. /**
  31692. * Gets the child meshes
  31693. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31694. * @returns An array of abstract meshes
  31695. */
  31696. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31697. /**
  31698. * Gets the vertex data
  31699. * @param kind The type of vertex data
  31700. * @returns A nullable array of numbers, or a float32 array
  31701. */
  31702. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31703. /**
  31704. * Gets the indices from the mesh
  31705. * @returns A nullable array of index arrays
  31706. */
  31707. getIndices?(): Nullable<IndicesArray>;
  31708. /**
  31709. * Gets the scene from the mesh
  31710. * @returns the indices array or null
  31711. */
  31712. getScene?(): Scene;
  31713. /**
  31714. * Gets the absolute position from the mesh
  31715. * @returns the absolute position
  31716. */
  31717. getAbsolutePosition(): Vector3;
  31718. /**
  31719. * Gets the absolute pivot point from the mesh
  31720. * @returns the absolute pivot point
  31721. */
  31722. getAbsolutePivotPoint(): Vector3;
  31723. /**
  31724. * Rotates the mesh
  31725. * @param axis The axis of rotation
  31726. * @param amount The amount of rotation
  31727. * @param space The space of the rotation
  31728. * @returns The rotation transform node
  31729. */
  31730. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31731. /**
  31732. * Translates the mesh
  31733. * @param axis The axis of translation
  31734. * @param distance The distance of translation
  31735. * @param space The space of the translation
  31736. * @returns The transform node
  31737. */
  31738. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31739. /**
  31740. * Sets the absolute position of the mesh
  31741. * @param absolutePosition The absolute position of the mesh
  31742. * @returns The transform node
  31743. */
  31744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31745. /**
  31746. * Gets the class name of the mesh
  31747. * @returns The class name
  31748. */
  31749. getClassName(): string;
  31750. }
  31751. /**
  31752. * Represents a physics imposter
  31753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31754. */
  31755. export class PhysicsImpostor {
  31756. /**
  31757. * The physics-enabled object used as the physics imposter
  31758. */
  31759. object: IPhysicsEnabledObject;
  31760. /**
  31761. * The type of the physics imposter
  31762. */
  31763. type: number;
  31764. private _options;
  31765. private _scene?;
  31766. /**
  31767. * The default object size of the imposter
  31768. */
  31769. static DEFAULT_OBJECT_SIZE: Vector3;
  31770. /**
  31771. * The identity quaternion of the imposter
  31772. */
  31773. static IDENTITY_QUATERNION: Quaternion;
  31774. /** @hidden */
  31775. _pluginData: any;
  31776. private _physicsEngine;
  31777. private _physicsBody;
  31778. private _bodyUpdateRequired;
  31779. private _onBeforePhysicsStepCallbacks;
  31780. private _onAfterPhysicsStepCallbacks;
  31781. /** @hidden */
  31782. _onPhysicsCollideCallbacks: Array<{
  31783. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31784. otherImpostors: Array<PhysicsImpostor>;
  31785. }>;
  31786. private _deltaPosition;
  31787. private _deltaRotation;
  31788. private _deltaRotationConjugated;
  31789. /** @hidden */
  31790. _isFromLine: boolean;
  31791. private _parent;
  31792. private _isDisposed;
  31793. private static _tmpVecs;
  31794. private static _tmpQuat;
  31795. /**
  31796. * Specifies if the physics imposter is disposed
  31797. */
  31798. get isDisposed(): boolean;
  31799. /**
  31800. * Gets the mass of the physics imposter
  31801. */
  31802. get mass(): number;
  31803. set mass(value: number);
  31804. /**
  31805. * Gets the coefficient of friction
  31806. */
  31807. get friction(): number;
  31808. /**
  31809. * Sets the coefficient of friction
  31810. */
  31811. set friction(value: number);
  31812. /**
  31813. * Gets the coefficient of restitution
  31814. */
  31815. get restitution(): number;
  31816. /**
  31817. * Sets the coefficient of restitution
  31818. */
  31819. set restitution(value: number);
  31820. /**
  31821. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31822. */
  31823. get pressure(): number;
  31824. /**
  31825. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31826. */
  31827. set pressure(value: number);
  31828. /**
  31829. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31830. */
  31831. get stiffness(): number;
  31832. /**
  31833. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31834. */
  31835. set stiffness(value: number);
  31836. /**
  31837. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31838. */
  31839. get velocityIterations(): number;
  31840. /**
  31841. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31842. */
  31843. set velocityIterations(value: number);
  31844. /**
  31845. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31846. */
  31847. get positionIterations(): number;
  31848. /**
  31849. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31850. */
  31851. set positionIterations(value: number);
  31852. /**
  31853. * The unique id of the physics imposter
  31854. * set by the physics engine when adding this impostor to the array
  31855. */
  31856. uniqueId: number;
  31857. /**
  31858. * @hidden
  31859. */
  31860. soft: boolean;
  31861. /**
  31862. * @hidden
  31863. */
  31864. segments: number;
  31865. private _joints;
  31866. /**
  31867. * Initializes the physics imposter
  31868. * @param object The physics-enabled object used as the physics imposter
  31869. * @param type The type of the physics imposter
  31870. * @param _options The options for the physics imposter
  31871. * @param _scene The Babylon scene
  31872. */
  31873. constructor(
  31874. /**
  31875. * The physics-enabled object used as the physics imposter
  31876. */
  31877. object: IPhysicsEnabledObject,
  31878. /**
  31879. * The type of the physics imposter
  31880. */
  31881. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31882. /**
  31883. * This function will completly initialize this impostor.
  31884. * It will create a new body - but only if this mesh has no parent.
  31885. * If it has, this impostor will not be used other than to define the impostor
  31886. * of the child mesh.
  31887. * @hidden
  31888. */
  31889. _init(): void;
  31890. private _getPhysicsParent;
  31891. /**
  31892. * Should a new body be generated.
  31893. * @returns boolean specifying if body initialization is required
  31894. */
  31895. isBodyInitRequired(): boolean;
  31896. /**
  31897. * Sets the updated scaling
  31898. * @param updated Specifies if the scaling is updated
  31899. */
  31900. setScalingUpdated(): void;
  31901. /**
  31902. * Force a regeneration of this or the parent's impostor's body.
  31903. * Use under cautious - This will remove all joints already implemented.
  31904. */
  31905. forceUpdate(): void;
  31906. /**
  31907. * Gets the body that holds this impostor. Either its own, or its parent.
  31908. */
  31909. get physicsBody(): any;
  31910. /**
  31911. * Get the parent of the physics imposter
  31912. * @returns Physics imposter or null
  31913. */
  31914. get parent(): Nullable<PhysicsImpostor>;
  31915. /**
  31916. * Sets the parent of the physics imposter
  31917. */
  31918. set parent(value: Nullable<PhysicsImpostor>);
  31919. /**
  31920. * Set the physics body. Used mainly by the physics engine/plugin
  31921. */
  31922. set physicsBody(physicsBody: any);
  31923. /**
  31924. * Resets the update flags
  31925. */
  31926. resetUpdateFlags(): void;
  31927. /**
  31928. * Gets the object extend size
  31929. * @returns the object extend size
  31930. */
  31931. getObjectExtendSize(): Vector3;
  31932. /**
  31933. * Gets the object center
  31934. * @returns The object center
  31935. */
  31936. getObjectCenter(): Vector3;
  31937. /**
  31938. * Get a specific parameter from the options parameters
  31939. * @param paramName The object parameter name
  31940. * @returns The object parameter
  31941. */
  31942. getParam(paramName: string): any;
  31943. /**
  31944. * Sets a specific parameter in the options given to the physics plugin
  31945. * @param paramName The parameter name
  31946. * @param value The value of the parameter
  31947. */
  31948. setParam(paramName: string, value: number): void;
  31949. /**
  31950. * Specifically change the body's mass option. Won't recreate the physics body object
  31951. * @param mass The mass of the physics imposter
  31952. */
  31953. setMass(mass: number): void;
  31954. /**
  31955. * Gets the linear velocity
  31956. * @returns linear velocity or null
  31957. */
  31958. getLinearVelocity(): Nullable<Vector3>;
  31959. /**
  31960. * Sets the linear velocity
  31961. * @param velocity linear velocity or null
  31962. */
  31963. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31964. /**
  31965. * Gets the angular velocity
  31966. * @returns angular velocity or null
  31967. */
  31968. getAngularVelocity(): Nullable<Vector3>;
  31969. /**
  31970. * Sets the angular velocity
  31971. * @param velocity The velocity or null
  31972. */
  31973. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31974. /**
  31975. * Execute a function with the physics plugin native code
  31976. * Provide a function the will have two variables - the world object and the physics body object
  31977. * @param func The function to execute with the physics plugin native code
  31978. */
  31979. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31980. /**
  31981. * Register a function that will be executed before the physics world is stepping forward
  31982. * @param func The function to execute before the physics world is stepped forward
  31983. */
  31984. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31985. /**
  31986. * Unregister a function that will be executed before the physics world is stepping forward
  31987. * @param func The function to execute before the physics world is stepped forward
  31988. */
  31989. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31990. /**
  31991. * Register a function that will be executed after the physics step
  31992. * @param func The function to execute after physics step
  31993. */
  31994. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31995. /**
  31996. * Unregisters a function that will be executed after the physics step
  31997. * @param func The function to execute after physics step
  31998. */
  31999. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32000. /**
  32001. * register a function that will be executed when this impostor collides against a different body
  32002. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32003. * @param func Callback that is executed on collision
  32004. */
  32005. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32006. /**
  32007. * Unregisters the physics imposter on contact
  32008. * @param collideAgainst The physics object to collide against
  32009. * @param func Callback to execute on collision
  32010. */
  32011. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32012. private _tmpQuat;
  32013. private _tmpQuat2;
  32014. /**
  32015. * Get the parent rotation
  32016. * @returns The parent rotation
  32017. */
  32018. getParentsRotation(): Quaternion;
  32019. /**
  32020. * this function is executed by the physics engine.
  32021. */
  32022. beforeStep: () => void;
  32023. /**
  32024. * this function is executed by the physics engine
  32025. */
  32026. afterStep: () => void;
  32027. /**
  32028. * Legacy collision detection event support
  32029. */
  32030. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32031. /**
  32032. * event and body object due to cannon's event-based architecture.
  32033. */
  32034. onCollide: (e: {
  32035. body: any;
  32036. point: Nullable<Vector3>;
  32037. }) => void;
  32038. /**
  32039. * Apply a force
  32040. * @param force The force to apply
  32041. * @param contactPoint The contact point for the force
  32042. * @returns The physics imposter
  32043. */
  32044. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32045. /**
  32046. * Apply an impulse
  32047. * @param force The impulse force
  32048. * @param contactPoint The contact point for the impulse force
  32049. * @returns The physics imposter
  32050. */
  32051. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32052. /**
  32053. * A help function to create a joint
  32054. * @param otherImpostor A physics imposter used to create a joint
  32055. * @param jointType The type of joint
  32056. * @param jointData The data for the joint
  32057. * @returns The physics imposter
  32058. */
  32059. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32060. /**
  32061. * Add a joint to this impostor with a different impostor
  32062. * @param otherImpostor A physics imposter used to add a joint
  32063. * @param joint The joint to add
  32064. * @returns The physics imposter
  32065. */
  32066. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32067. /**
  32068. * Add an anchor to a cloth impostor
  32069. * @param otherImpostor rigid impostor to anchor to
  32070. * @param width ratio across width from 0 to 1
  32071. * @param height ratio up height from 0 to 1
  32072. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32073. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32074. * @returns impostor the soft imposter
  32075. */
  32076. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32077. /**
  32078. * Add a hook to a rope impostor
  32079. * @param otherImpostor rigid impostor to anchor to
  32080. * @param length ratio across rope from 0 to 1
  32081. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32082. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32083. * @returns impostor the rope imposter
  32084. */
  32085. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32086. /**
  32087. * Will keep this body still, in a sleep mode.
  32088. * @returns the physics imposter
  32089. */
  32090. sleep(): PhysicsImpostor;
  32091. /**
  32092. * Wake the body up.
  32093. * @returns The physics imposter
  32094. */
  32095. wakeUp(): PhysicsImpostor;
  32096. /**
  32097. * Clones the physics imposter
  32098. * @param newObject The physics imposter clones to this physics-enabled object
  32099. * @returns A nullable physics imposter
  32100. */
  32101. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32102. /**
  32103. * Disposes the physics imposter
  32104. */
  32105. dispose(): void;
  32106. /**
  32107. * Sets the delta position
  32108. * @param position The delta position amount
  32109. */
  32110. setDeltaPosition(position: Vector3): void;
  32111. /**
  32112. * Sets the delta rotation
  32113. * @param rotation The delta rotation amount
  32114. */
  32115. setDeltaRotation(rotation: Quaternion): void;
  32116. /**
  32117. * Gets the box size of the physics imposter and stores the result in the input parameter
  32118. * @param result Stores the box size
  32119. * @returns The physics imposter
  32120. */
  32121. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32122. /**
  32123. * Gets the radius of the physics imposter
  32124. * @returns Radius of the physics imposter
  32125. */
  32126. getRadius(): number;
  32127. /**
  32128. * Sync a bone with this impostor
  32129. * @param bone The bone to sync to the impostor.
  32130. * @param boneMesh The mesh that the bone is influencing.
  32131. * @param jointPivot The pivot of the joint / bone in local space.
  32132. * @param distToJoint Optional distance from the impostor to the joint.
  32133. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32134. */
  32135. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32136. /**
  32137. * Sync impostor to a bone
  32138. * @param bone The bone that the impostor will be synced to.
  32139. * @param boneMesh The mesh that the bone is influencing.
  32140. * @param jointPivot The pivot of the joint / bone in local space.
  32141. * @param distToJoint Optional distance from the impostor to the joint.
  32142. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32143. * @param boneAxis Optional vector3 axis the bone is aligned with
  32144. */
  32145. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32146. /**
  32147. * No-Imposter type
  32148. */
  32149. static NoImpostor: number;
  32150. /**
  32151. * Sphere-Imposter type
  32152. */
  32153. static SphereImpostor: number;
  32154. /**
  32155. * Box-Imposter type
  32156. */
  32157. static BoxImpostor: number;
  32158. /**
  32159. * Plane-Imposter type
  32160. */
  32161. static PlaneImpostor: number;
  32162. /**
  32163. * Mesh-imposter type
  32164. */
  32165. static MeshImpostor: number;
  32166. /**
  32167. * Capsule-Impostor type (Ammo.js plugin only)
  32168. */
  32169. static CapsuleImpostor: number;
  32170. /**
  32171. * Cylinder-Imposter type
  32172. */
  32173. static CylinderImpostor: number;
  32174. /**
  32175. * Particle-Imposter type
  32176. */
  32177. static ParticleImpostor: number;
  32178. /**
  32179. * Heightmap-Imposter type
  32180. */
  32181. static HeightmapImpostor: number;
  32182. /**
  32183. * ConvexHull-Impostor type (Ammo.js plugin only)
  32184. */
  32185. static ConvexHullImpostor: number;
  32186. /**
  32187. * Custom-Imposter type (Ammo.js plugin only)
  32188. */
  32189. static CustomImpostor: number;
  32190. /**
  32191. * Rope-Imposter type
  32192. */
  32193. static RopeImpostor: number;
  32194. /**
  32195. * Cloth-Imposter type
  32196. */
  32197. static ClothImpostor: number;
  32198. /**
  32199. * Softbody-Imposter type
  32200. */
  32201. static SoftbodyImpostor: number;
  32202. }
  32203. }
  32204. declare module BABYLON {
  32205. /**
  32206. * @hidden
  32207. **/
  32208. export class _CreationDataStorage {
  32209. closePath?: boolean;
  32210. closeArray?: boolean;
  32211. idx: number[];
  32212. dashSize: number;
  32213. gapSize: number;
  32214. path3D: Path3D;
  32215. pathArray: Vector3[][];
  32216. arc: number;
  32217. radius: number;
  32218. cap: number;
  32219. tessellation: number;
  32220. }
  32221. /**
  32222. * @hidden
  32223. **/
  32224. class _InstanceDataStorage {
  32225. visibleInstances: any;
  32226. batchCache: _InstancesBatch;
  32227. instancesBufferSize: number;
  32228. instancesBuffer: Nullable<Buffer>;
  32229. instancesData: Float32Array;
  32230. overridenInstanceCount: number;
  32231. isFrozen: boolean;
  32232. previousBatch: Nullable<_InstancesBatch>;
  32233. hardwareInstancedRendering: boolean;
  32234. sideOrientation: number;
  32235. manualUpdate: boolean;
  32236. previousRenderId: number;
  32237. }
  32238. /**
  32239. * @hidden
  32240. **/
  32241. export class _InstancesBatch {
  32242. mustReturn: boolean;
  32243. visibleInstances: Nullable<InstancedMesh[]>[];
  32244. renderSelf: boolean[];
  32245. hardwareInstancedRendering: boolean[];
  32246. }
  32247. /**
  32248. * @hidden
  32249. **/
  32250. class _ThinInstanceDataStorage {
  32251. instancesCount: number;
  32252. matrixBuffer: Nullable<Buffer>;
  32253. matrixBufferSize: number;
  32254. matrixData: Nullable<Float32Array>;
  32255. boundingVectors: Array<Vector3>;
  32256. worldMatrices: Nullable<Matrix[]>;
  32257. }
  32258. /**
  32259. * Class used to represent renderable models
  32260. */
  32261. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32262. /**
  32263. * Mesh side orientation : usually the external or front surface
  32264. */
  32265. static readonly FRONTSIDE: number;
  32266. /**
  32267. * Mesh side orientation : usually the internal or back surface
  32268. */
  32269. static readonly BACKSIDE: number;
  32270. /**
  32271. * Mesh side orientation : both internal and external or front and back surfaces
  32272. */
  32273. static readonly DOUBLESIDE: number;
  32274. /**
  32275. * Mesh side orientation : by default, `FRONTSIDE`
  32276. */
  32277. static readonly DEFAULTSIDE: number;
  32278. /**
  32279. * Mesh cap setting : no cap
  32280. */
  32281. static readonly NO_CAP: number;
  32282. /**
  32283. * Mesh cap setting : one cap at the beginning of the mesh
  32284. */
  32285. static readonly CAP_START: number;
  32286. /**
  32287. * Mesh cap setting : one cap at the end of the mesh
  32288. */
  32289. static readonly CAP_END: number;
  32290. /**
  32291. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32292. */
  32293. static readonly CAP_ALL: number;
  32294. /**
  32295. * Mesh pattern setting : no flip or rotate
  32296. */
  32297. static readonly NO_FLIP: number;
  32298. /**
  32299. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32300. */
  32301. static readonly FLIP_TILE: number;
  32302. /**
  32303. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32304. */
  32305. static readonly ROTATE_TILE: number;
  32306. /**
  32307. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32308. */
  32309. static readonly FLIP_ROW: number;
  32310. /**
  32311. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32312. */
  32313. static readonly ROTATE_ROW: number;
  32314. /**
  32315. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32316. */
  32317. static readonly FLIP_N_ROTATE_TILE: number;
  32318. /**
  32319. * Mesh pattern setting : rotate pattern and rotate
  32320. */
  32321. static readonly FLIP_N_ROTATE_ROW: number;
  32322. /**
  32323. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32324. */
  32325. static readonly CENTER: number;
  32326. /**
  32327. * Mesh tile positioning : part tiles on left
  32328. */
  32329. static readonly LEFT: number;
  32330. /**
  32331. * Mesh tile positioning : part tiles on right
  32332. */
  32333. static readonly RIGHT: number;
  32334. /**
  32335. * Mesh tile positioning : part tiles on top
  32336. */
  32337. static readonly TOP: number;
  32338. /**
  32339. * Mesh tile positioning : part tiles on bottom
  32340. */
  32341. static readonly BOTTOM: number;
  32342. /**
  32343. * Gets the default side orientation.
  32344. * @param orientation the orientation to value to attempt to get
  32345. * @returns the default orientation
  32346. * @hidden
  32347. */
  32348. static _GetDefaultSideOrientation(orientation?: number): number;
  32349. private _internalMeshDataInfo;
  32350. get computeBonesUsingShaders(): boolean;
  32351. set computeBonesUsingShaders(value: boolean);
  32352. /**
  32353. * An event triggered before rendering the mesh
  32354. */
  32355. get onBeforeRenderObservable(): Observable<Mesh>;
  32356. /**
  32357. * An event triggered before binding the mesh
  32358. */
  32359. get onBeforeBindObservable(): Observable<Mesh>;
  32360. /**
  32361. * An event triggered after rendering the mesh
  32362. */
  32363. get onAfterRenderObservable(): Observable<Mesh>;
  32364. /**
  32365. * An event triggered before drawing the mesh
  32366. */
  32367. get onBeforeDrawObservable(): Observable<Mesh>;
  32368. private _onBeforeDrawObserver;
  32369. /**
  32370. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32371. */
  32372. set onBeforeDraw(callback: () => void);
  32373. get hasInstances(): boolean;
  32374. get hasThinInstances(): boolean;
  32375. /**
  32376. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32377. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32378. */
  32379. delayLoadState: number;
  32380. /**
  32381. * Gets the list of instances created from this mesh
  32382. * it is not supposed to be modified manually.
  32383. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32384. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32385. */
  32386. instances: InstancedMesh[];
  32387. /**
  32388. * Gets the file containing delay loading data for this mesh
  32389. */
  32390. delayLoadingFile: string;
  32391. /** @hidden */
  32392. _binaryInfo: any;
  32393. /**
  32394. * User defined function used to change how LOD level selection is done
  32395. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32396. */
  32397. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32398. /**
  32399. * Gets or sets the morph target manager
  32400. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32401. */
  32402. get morphTargetManager(): Nullable<MorphTargetManager>;
  32403. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32404. /** @hidden */
  32405. _creationDataStorage: Nullable<_CreationDataStorage>;
  32406. /** @hidden */
  32407. _geometry: Nullable<Geometry>;
  32408. /** @hidden */
  32409. _delayInfo: Array<string>;
  32410. /** @hidden */
  32411. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32412. /** @hidden */
  32413. _instanceDataStorage: _InstanceDataStorage;
  32414. /** @hidden */
  32415. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32416. private _effectiveMaterial;
  32417. /** @hidden */
  32418. _shouldGenerateFlatShading: boolean;
  32419. /** @hidden */
  32420. _originalBuilderSideOrientation: number;
  32421. /**
  32422. * Use this property to change the original side orientation defined at construction time
  32423. */
  32424. overrideMaterialSideOrientation: Nullable<number>;
  32425. /**
  32426. * Gets the source mesh (the one used to clone this one from)
  32427. */
  32428. get source(): Nullable<Mesh>;
  32429. /**
  32430. * Gets the list of clones of this mesh
  32431. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32432. * Note that useClonedMeshMap=true is the default setting
  32433. */
  32434. get cloneMeshMap(): Nullable<{
  32435. [id: string]: Mesh | undefined;
  32436. }>;
  32437. /**
  32438. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32439. */
  32440. get isUnIndexed(): boolean;
  32441. set isUnIndexed(value: boolean);
  32442. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32443. get worldMatrixInstancedBuffer(): Float32Array;
  32444. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32445. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32446. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32447. /**
  32448. * @constructor
  32449. * @param name The value used by scene.getMeshByName() to do a lookup.
  32450. * @param scene The scene to add this mesh to.
  32451. * @param parent The parent of this mesh, if it has one
  32452. * @param source An optional Mesh from which geometry is shared, cloned.
  32453. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32454. * When false, achieved by calling a clone(), also passing False.
  32455. * This will make creation of children, recursive.
  32456. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32457. */
  32458. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32459. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32460. doNotInstantiate: boolean;
  32461. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32462. /**
  32463. * Gets the class name
  32464. * @returns the string "Mesh".
  32465. */
  32466. getClassName(): string;
  32467. /** @hidden */
  32468. get _isMesh(): boolean;
  32469. /**
  32470. * Returns a description of this mesh
  32471. * @param fullDetails define if full details about this mesh must be used
  32472. * @returns a descriptive string representing this mesh
  32473. */
  32474. toString(fullDetails?: boolean): string;
  32475. /** @hidden */
  32476. _unBindEffect(): void;
  32477. /**
  32478. * Gets a boolean indicating if this mesh has LOD
  32479. */
  32480. get hasLODLevels(): boolean;
  32481. /**
  32482. * Gets the list of MeshLODLevel associated with the current mesh
  32483. * @returns an array of MeshLODLevel
  32484. */
  32485. getLODLevels(): MeshLODLevel[];
  32486. private _sortLODLevels;
  32487. /**
  32488. * Add a mesh as LOD level triggered at the given distance.
  32489. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32490. * @param distance The distance from the center of the object to show this level
  32491. * @param mesh The mesh to be added as LOD level (can be null)
  32492. * @return This mesh (for chaining)
  32493. */
  32494. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32495. /**
  32496. * Returns the LOD level mesh at the passed distance or null if not found.
  32497. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32498. * @param distance The distance from the center of the object to show this level
  32499. * @returns a Mesh or `null`
  32500. */
  32501. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32502. /**
  32503. * Remove a mesh from the LOD array
  32504. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32505. * @param mesh defines the mesh to be removed
  32506. * @return This mesh (for chaining)
  32507. */
  32508. removeLODLevel(mesh: Mesh): Mesh;
  32509. /**
  32510. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32511. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32512. * @param camera defines the camera to use to compute distance
  32513. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32514. * @return This mesh (for chaining)
  32515. */
  32516. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32517. /**
  32518. * Gets the mesh internal Geometry object
  32519. */
  32520. get geometry(): Nullable<Geometry>;
  32521. /**
  32522. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32523. * @returns the total number of vertices
  32524. */
  32525. getTotalVertices(): number;
  32526. /**
  32527. * Returns the content of an associated vertex buffer
  32528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32529. * - VertexBuffer.PositionKind
  32530. * - VertexBuffer.UVKind
  32531. * - VertexBuffer.UV2Kind
  32532. * - VertexBuffer.UV3Kind
  32533. * - VertexBuffer.UV4Kind
  32534. * - VertexBuffer.UV5Kind
  32535. * - VertexBuffer.UV6Kind
  32536. * - VertexBuffer.ColorKind
  32537. * - VertexBuffer.MatricesIndicesKind
  32538. * - VertexBuffer.MatricesIndicesExtraKind
  32539. * - VertexBuffer.MatricesWeightsKind
  32540. * - VertexBuffer.MatricesWeightsExtraKind
  32541. * @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
  32542. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32543. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32544. */
  32545. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32546. /**
  32547. * Returns the mesh VertexBuffer object from the requested `kind`
  32548. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32549. * - VertexBuffer.PositionKind
  32550. * - VertexBuffer.NormalKind
  32551. * - VertexBuffer.UVKind
  32552. * - VertexBuffer.UV2Kind
  32553. * - VertexBuffer.UV3Kind
  32554. * - VertexBuffer.UV4Kind
  32555. * - VertexBuffer.UV5Kind
  32556. * - VertexBuffer.UV6Kind
  32557. * - VertexBuffer.ColorKind
  32558. * - VertexBuffer.MatricesIndicesKind
  32559. * - VertexBuffer.MatricesIndicesExtraKind
  32560. * - VertexBuffer.MatricesWeightsKind
  32561. * - VertexBuffer.MatricesWeightsExtraKind
  32562. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32563. */
  32564. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32565. /**
  32566. * Tests if a specific vertex buffer is associated with this mesh
  32567. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32568. * - VertexBuffer.PositionKind
  32569. * - VertexBuffer.NormalKind
  32570. * - VertexBuffer.UVKind
  32571. * - VertexBuffer.UV2Kind
  32572. * - VertexBuffer.UV3Kind
  32573. * - VertexBuffer.UV4Kind
  32574. * - VertexBuffer.UV5Kind
  32575. * - VertexBuffer.UV6Kind
  32576. * - VertexBuffer.ColorKind
  32577. * - VertexBuffer.MatricesIndicesKind
  32578. * - VertexBuffer.MatricesIndicesExtraKind
  32579. * - VertexBuffer.MatricesWeightsKind
  32580. * - VertexBuffer.MatricesWeightsExtraKind
  32581. * @returns a boolean
  32582. */
  32583. isVerticesDataPresent(kind: string): boolean;
  32584. /**
  32585. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32586. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32587. * - VertexBuffer.PositionKind
  32588. * - VertexBuffer.UVKind
  32589. * - VertexBuffer.UV2Kind
  32590. * - VertexBuffer.UV3Kind
  32591. * - VertexBuffer.UV4Kind
  32592. * - VertexBuffer.UV5Kind
  32593. * - VertexBuffer.UV6Kind
  32594. * - VertexBuffer.ColorKind
  32595. * - VertexBuffer.MatricesIndicesKind
  32596. * - VertexBuffer.MatricesIndicesExtraKind
  32597. * - VertexBuffer.MatricesWeightsKind
  32598. * - VertexBuffer.MatricesWeightsExtraKind
  32599. * @returns a boolean
  32600. */
  32601. isVertexBufferUpdatable(kind: string): boolean;
  32602. /**
  32603. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32604. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32605. * - VertexBuffer.PositionKind
  32606. * - VertexBuffer.NormalKind
  32607. * - VertexBuffer.UVKind
  32608. * - VertexBuffer.UV2Kind
  32609. * - VertexBuffer.UV3Kind
  32610. * - VertexBuffer.UV4Kind
  32611. * - VertexBuffer.UV5Kind
  32612. * - VertexBuffer.UV6Kind
  32613. * - VertexBuffer.ColorKind
  32614. * - VertexBuffer.MatricesIndicesKind
  32615. * - VertexBuffer.MatricesIndicesExtraKind
  32616. * - VertexBuffer.MatricesWeightsKind
  32617. * - VertexBuffer.MatricesWeightsExtraKind
  32618. * @returns an array of strings
  32619. */
  32620. getVerticesDataKinds(): string[];
  32621. /**
  32622. * Returns a positive integer : the total number of indices in this mesh geometry.
  32623. * @returns the numner of indices or zero if the mesh has no geometry.
  32624. */
  32625. getTotalIndices(): number;
  32626. /**
  32627. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32628. * @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.
  32629. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32630. * @returns the indices array or an empty array if the mesh has no geometry
  32631. */
  32632. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32633. get isBlocked(): boolean;
  32634. /**
  32635. * Determine if the current mesh is ready to be rendered
  32636. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32637. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32638. * @returns true if all associated assets are ready (material, textures, shaders)
  32639. */
  32640. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32641. /**
  32642. * 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.
  32643. */
  32644. get areNormalsFrozen(): boolean;
  32645. /**
  32646. * 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.
  32647. * @returns the current mesh
  32648. */
  32649. freezeNormals(): Mesh;
  32650. /**
  32651. * 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
  32652. * @returns the current mesh
  32653. */
  32654. unfreezeNormals(): Mesh;
  32655. /**
  32656. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32657. */
  32658. set overridenInstanceCount(count: number);
  32659. /** @hidden */
  32660. _preActivate(): Mesh;
  32661. /** @hidden */
  32662. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32663. /** @hidden */
  32664. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32665. protected _afterComputeWorldMatrix(): void;
  32666. /** @hidden */
  32667. _postActivate(): void;
  32668. /**
  32669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32670. * This means the mesh underlying bounding box and sphere are recomputed.
  32671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32672. * @returns the current mesh
  32673. */
  32674. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32675. /** @hidden */
  32676. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32677. /**
  32678. * This function will subdivide the mesh into multiple submeshes
  32679. * @param count defines the expected number of submeshes
  32680. */
  32681. subdivide(count: number): void;
  32682. /**
  32683. * Copy a FloatArray into a specific associated vertex buffer
  32684. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32685. * - VertexBuffer.PositionKind
  32686. * - VertexBuffer.UVKind
  32687. * - VertexBuffer.UV2Kind
  32688. * - VertexBuffer.UV3Kind
  32689. * - VertexBuffer.UV4Kind
  32690. * - VertexBuffer.UV5Kind
  32691. * - VertexBuffer.UV6Kind
  32692. * - VertexBuffer.ColorKind
  32693. * - VertexBuffer.MatricesIndicesKind
  32694. * - VertexBuffer.MatricesIndicesExtraKind
  32695. * - VertexBuffer.MatricesWeightsKind
  32696. * - VertexBuffer.MatricesWeightsExtraKind
  32697. * @param data defines the data source
  32698. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32699. * @param stride defines the data stride size (can be null)
  32700. * @returns the current mesh
  32701. */
  32702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32703. /**
  32704. * Delete a vertex buffer associated with this mesh
  32705. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32706. * - VertexBuffer.PositionKind
  32707. * - VertexBuffer.UVKind
  32708. * - VertexBuffer.UV2Kind
  32709. * - VertexBuffer.UV3Kind
  32710. * - VertexBuffer.UV4Kind
  32711. * - VertexBuffer.UV5Kind
  32712. * - VertexBuffer.UV6Kind
  32713. * - VertexBuffer.ColorKind
  32714. * - VertexBuffer.MatricesIndicesKind
  32715. * - VertexBuffer.MatricesIndicesExtraKind
  32716. * - VertexBuffer.MatricesWeightsKind
  32717. * - VertexBuffer.MatricesWeightsExtraKind
  32718. */
  32719. removeVerticesData(kind: string): void;
  32720. /**
  32721. * Flags an associated vertex buffer as updatable
  32722. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32723. * - VertexBuffer.PositionKind
  32724. * - VertexBuffer.UVKind
  32725. * - VertexBuffer.UV2Kind
  32726. * - VertexBuffer.UV3Kind
  32727. * - VertexBuffer.UV4Kind
  32728. * - VertexBuffer.UV5Kind
  32729. * - VertexBuffer.UV6Kind
  32730. * - VertexBuffer.ColorKind
  32731. * - VertexBuffer.MatricesIndicesKind
  32732. * - VertexBuffer.MatricesIndicesExtraKind
  32733. * - VertexBuffer.MatricesWeightsKind
  32734. * - VertexBuffer.MatricesWeightsExtraKind
  32735. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32736. */
  32737. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32738. /**
  32739. * Sets the mesh global Vertex Buffer
  32740. * @param buffer defines the buffer to use
  32741. * @returns the current mesh
  32742. */
  32743. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32744. /**
  32745. * Update a specific associated vertex buffer
  32746. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32747. * - VertexBuffer.PositionKind
  32748. * - VertexBuffer.UVKind
  32749. * - VertexBuffer.UV2Kind
  32750. * - VertexBuffer.UV3Kind
  32751. * - VertexBuffer.UV4Kind
  32752. * - VertexBuffer.UV5Kind
  32753. * - VertexBuffer.UV6Kind
  32754. * - VertexBuffer.ColorKind
  32755. * - VertexBuffer.MatricesIndicesKind
  32756. * - VertexBuffer.MatricesIndicesExtraKind
  32757. * - VertexBuffer.MatricesWeightsKind
  32758. * - VertexBuffer.MatricesWeightsExtraKind
  32759. * @param data defines the data source
  32760. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32761. * @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)
  32762. * @returns the current mesh
  32763. */
  32764. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32765. /**
  32766. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32767. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32768. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32769. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32770. * @returns the current mesh
  32771. */
  32772. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32773. /**
  32774. * Creates a un-shared specific occurence of the geometry for the mesh.
  32775. * @returns the current mesh
  32776. */
  32777. makeGeometryUnique(): Mesh;
  32778. /**
  32779. * Set the index buffer of this mesh
  32780. * @param indices defines the source data
  32781. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32782. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32783. * @returns the current mesh
  32784. */
  32785. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32786. /**
  32787. * Update the current index buffer
  32788. * @param indices defines the source data
  32789. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32790. * @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)
  32791. * @returns the current mesh
  32792. */
  32793. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32794. /**
  32795. * Invert the geometry to move from a right handed system to a left handed one.
  32796. * @returns the current mesh
  32797. */
  32798. toLeftHanded(): Mesh;
  32799. /** @hidden */
  32800. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32801. /** @hidden */
  32802. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32803. /**
  32804. * Registers for this mesh a javascript function called just before the rendering process
  32805. * @param func defines the function to call before rendering this mesh
  32806. * @returns the current mesh
  32807. */
  32808. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32809. /**
  32810. * Disposes a previously registered javascript function called before the rendering
  32811. * @param func defines the function to remove
  32812. * @returns the current mesh
  32813. */
  32814. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32815. /**
  32816. * Registers for this mesh a javascript function called just after the rendering is complete
  32817. * @param func defines the function to call after rendering this mesh
  32818. * @returns the current mesh
  32819. */
  32820. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32821. /**
  32822. * Disposes a previously registered javascript function called after the rendering.
  32823. * @param func defines the function to remove
  32824. * @returns the current mesh
  32825. */
  32826. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32827. /** @hidden */
  32828. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32829. /** @hidden */
  32830. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32831. /** @hidden */
  32832. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32833. /** @hidden */
  32834. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32835. /** @hidden */
  32836. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32837. /** @hidden */
  32838. _rebuild(): void;
  32839. /** @hidden */
  32840. _freeze(): void;
  32841. /** @hidden */
  32842. _unFreeze(): void;
  32843. /**
  32844. * 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
  32845. * @param subMesh defines the subMesh to render
  32846. * @param enableAlphaMode defines if alpha mode can be changed
  32847. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32848. * @returns the current mesh
  32849. */
  32850. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32851. private _onBeforeDraw;
  32852. /**
  32853. * Renormalize the mesh and patch it up if there are no weights
  32854. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32855. * However in the case of zero weights then we set just a single influence to 1.
  32856. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32857. */
  32858. cleanMatrixWeights(): void;
  32859. private normalizeSkinFourWeights;
  32860. private normalizeSkinWeightsAndExtra;
  32861. /**
  32862. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32863. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32864. * the user know there was an issue with importing the mesh
  32865. * @returns a validation object with skinned, valid and report string
  32866. */
  32867. validateSkinning(): {
  32868. skinned: boolean;
  32869. valid: boolean;
  32870. report: string;
  32871. };
  32872. /** @hidden */
  32873. _checkDelayState(): Mesh;
  32874. private _queueLoad;
  32875. /**
  32876. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32877. * A mesh is in the frustum if its bounding box intersects the frustum
  32878. * @param frustumPlanes defines the frustum to test
  32879. * @returns true if the mesh is in the frustum planes
  32880. */
  32881. isInFrustum(frustumPlanes: Plane[]): boolean;
  32882. /**
  32883. * Sets the mesh material by the material or multiMaterial `id` property
  32884. * @param id is a string identifying the material or the multiMaterial
  32885. * @returns the current mesh
  32886. */
  32887. setMaterialByID(id: string): Mesh;
  32888. /**
  32889. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32890. * @returns an array of IAnimatable
  32891. */
  32892. getAnimatables(): IAnimatable[];
  32893. /**
  32894. * Modifies the mesh geometry according to the passed transformation matrix.
  32895. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32896. * The mesh normals are modified using the same transformation.
  32897. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32898. * @param transform defines the transform matrix to use
  32899. * @see https://doc.babylonjs.com/resources/baking_transformations
  32900. * @returns the current mesh
  32901. */
  32902. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32903. /**
  32904. * Modifies the mesh geometry according to its own current World Matrix.
  32905. * The mesh World Matrix is then reset.
  32906. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32907. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32908. * @see https://doc.babylonjs.com/resources/baking_transformations
  32909. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32910. * @returns the current mesh
  32911. */
  32912. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32913. /** @hidden */
  32914. get _positions(): Nullable<Vector3[]>;
  32915. /** @hidden */
  32916. _resetPointsArrayCache(): Mesh;
  32917. /** @hidden */
  32918. _generatePointsArray(): boolean;
  32919. /**
  32920. * Returns a new Mesh object generated from the current mesh properties.
  32921. * This method must not get confused with createInstance()
  32922. * @param name is a string, the name given to the new mesh
  32923. * @param newParent can be any Node object (default `null`)
  32924. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32925. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32926. * @returns a new mesh
  32927. */
  32928. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32929. /**
  32930. * Releases resources associated with this mesh.
  32931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32933. */
  32934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32935. /** @hidden */
  32936. _disposeInstanceSpecificData(): void;
  32937. /** @hidden */
  32938. _disposeThinInstanceSpecificData(): void;
  32939. /**
  32940. * Modifies the mesh geometry according to a displacement map.
  32941. * 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.
  32942. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32943. * @param url is a string, the URL from the image file is to be downloaded.
  32944. * @param minHeight is the lower limit of the displacement.
  32945. * @param maxHeight is the upper limit of the displacement.
  32946. * @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.
  32947. * @param uvOffset is an optional vector2 used to offset UV.
  32948. * @param uvScale is an optional vector2 used to scale UV.
  32949. * @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.
  32950. * @returns the Mesh.
  32951. */
  32952. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32953. /**
  32954. * Modifies the mesh geometry according to a displacementMap buffer.
  32955. * 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.
  32956. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32957. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32958. * @param heightMapWidth is the width of the buffer image.
  32959. * @param heightMapHeight is the height of the buffer image.
  32960. * @param minHeight is the lower limit of the displacement.
  32961. * @param maxHeight is the upper limit of the displacement.
  32962. * @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.
  32963. * @param uvOffset is an optional vector2 used to offset UV.
  32964. * @param uvScale is an optional vector2 used to scale UV.
  32965. * @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.
  32966. * @returns the Mesh.
  32967. */
  32968. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32969. /**
  32970. * Modify the mesh to get a flat shading rendering.
  32971. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32972. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32973. * @returns current mesh
  32974. */
  32975. convertToFlatShadedMesh(): Mesh;
  32976. /**
  32977. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32978. * In other words, more vertices, no more indices and a single bigger VBO.
  32979. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32980. * @returns current mesh
  32981. */
  32982. convertToUnIndexedMesh(): Mesh;
  32983. /**
  32984. * Inverses facet orientations.
  32985. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32986. * @param flipNormals will also inverts the normals
  32987. * @returns current mesh
  32988. */
  32989. flipFaces(flipNormals?: boolean): Mesh;
  32990. /**
  32991. * Increase the number of facets and hence vertices in a mesh
  32992. * Vertex normals are interpolated from existing vertex normals
  32993. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32994. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32995. */
  32996. increaseVertices(numberPerEdge: number): void;
  32997. /**
  32998. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32999. * This will undo any application of covertToFlatShadedMesh
  33000. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33001. */
  33002. forceSharedVertices(): void;
  33003. /** @hidden */
  33004. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33005. /** @hidden */
  33006. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33007. /**
  33008. * Creates a new InstancedMesh object from the mesh model.
  33009. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33010. * @param name defines the name of the new instance
  33011. * @returns a new InstancedMesh
  33012. */
  33013. createInstance(name: string): InstancedMesh;
  33014. /**
  33015. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33016. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33017. * @returns the current mesh
  33018. */
  33019. synchronizeInstances(): Mesh;
  33020. /**
  33021. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33022. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33023. * This should be used together with the simplification to avoid disappearing triangles.
  33024. * @param successCallback an optional success callback to be called after the optimization finished.
  33025. * @returns the current mesh
  33026. */
  33027. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33028. /**
  33029. * Serialize current mesh
  33030. * @param serializationObject defines the object which will receive the serialization data
  33031. */
  33032. serialize(serializationObject: any): void;
  33033. /** @hidden */
  33034. _syncGeometryWithMorphTargetManager(): void;
  33035. /** @hidden */
  33036. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33037. /**
  33038. * Returns a new Mesh object parsed from the source provided.
  33039. * @param parsedMesh is the source
  33040. * @param scene defines the hosting scene
  33041. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33042. * @returns a new Mesh
  33043. */
  33044. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33045. /**
  33046. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33048. * @param name defines the name of the mesh to create
  33049. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33050. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33051. * @param closePath creates a seam between the first and the last points of each path of the path array
  33052. * @param offset is taken in account only if the `pathArray` is containing a single path
  33053. * @param scene defines the hosting scene
  33054. * @param updatable defines if the mesh must be flagged as updatable
  33055. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33056. * @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)
  33057. * @returns a new Mesh
  33058. */
  33059. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33060. /**
  33061. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33062. * @param name defines the name of the mesh to create
  33063. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33064. * @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
  33065. * @param scene defines the hosting scene
  33066. * @param updatable defines if the mesh must be flagged as updatable
  33067. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33068. * @returns a new Mesh
  33069. */
  33070. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33071. /**
  33072. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33073. * @param name defines the name of the mesh to create
  33074. * @param size sets the size (float) of each box side (default 1)
  33075. * @param scene defines the hosting scene
  33076. * @param updatable defines if the mesh must be flagged as updatable
  33077. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33078. * @returns a new Mesh
  33079. */
  33080. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33081. /**
  33082. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33083. * @param name defines the name of the mesh to create
  33084. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33085. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33086. * @param scene defines the hosting scene
  33087. * @param updatable defines if the mesh must be flagged as updatable
  33088. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33089. * @returns a new Mesh
  33090. */
  33091. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33092. /**
  33093. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33094. * @param name defines the name of the mesh to create
  33095. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33096. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33097. * @param scene defines the hosting scene
  33098. * @returns a new Mesh
  33099. */
  33100. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33101. /**
  33102. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33103. * @param name defines the name of the mesh to create
  33104. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33105. * @param diameterTop set the top cap diameter (floats, default 1)
  33106. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33107. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33108. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33109. * @param scene defines the hosting scene
  33110. * @param updatable defines if the mesh must be flagged as updatable
  33111. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33112. * @returns a new Mesh
  33113. */
  33114. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33115. /**
  33116. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33117. * @param name defines the name of the mesh to create
  33118. * @param diameter sets the diameter size (float) of the torus (default 1)
  33119. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33120. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33121. * @param scene defines the hosting scene
  33122. * @param updatable defines if the mesh must be flagged as updatable
  33123. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33124. * @returns a new Mesh
  33125. */
  33126. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33127. /**
  33128. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33129. * @param name defines the name of the mesh to create
  33130. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33131. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33132. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33133. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33134. * @param p the number of windings on X axis (positive integers, default 2)
  33135. * @param q the number of windings on Y axis (positive integers, default 3)
  33136. * @param scene defines the hosting scene
  33137. * @param updatable defines if the mesh must be flagged as updatable
  33138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33139. * @returns a new Mesh
  33140. */
  33141. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33142. /**
  33143. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33144. * @param name defines the name of the mesh to create
  33145. * @param points is an array successive Vector3
  33146. * @param scene defines the hosting scene
  33147. * @param updatable defines if the mesh must be flagged as updatable
  33148. * @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).
  33149. * @returns a new Mesh
  33150. */
  33151. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33152. /**
  33153. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33154. * @param name defines the name of the mesh to create
  33155. * @param points is an array successive Vector3
  33156. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33157. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33158. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33159. * @param scene defines the hosting scene
  33160. * @param updatable defines if the mesh must be flagged as updatable
  33161. * @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)
  33162. * @returns a new Mesh
  33163. */
  33164. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33165. /**
  33166. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33167. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33168. * 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.
  33169. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33170. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33171. * Remember you can only change the shape positions, not their number when updating a polygon.
  33172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33173. * @param name defines the name of the mesh to create
  33174. * @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
  33175. * @param scene defines the hosting scene
  33176. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33177. * @param updatable defines if the mesh must be flagged as updatable
  33178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33179. * @param earcutInjection can be used to inject your own earcut reference
  33180. * @returns a new Mesh
  33181. */
  33182. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33183. /**
  33184. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33186. * @param name defines the name of the mesh to create
  33187. * @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
  33188. * @param depth defines the height of extrusion
  33189. * @param scene defines the hosting scene
  33190. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33191. * @param updatable defines if the mesh must be flagged as updatable
  33192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33193. * @param earcutInjection can be used to inject your own earcut reference
  33194. * @returns a new Mesh
  33195. */
  33196. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33197. /**
  33198. * Creates an extruded shape mesh.
  33199. * 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
  33200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33202. * @param name defines the name of the mesh to create
  33203. * @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
  33204. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33205. * @param scale is the value to scale the shape
  33206. * @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
  33207. * @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
  33208. * @param scene defines the hosting scene
  33209. * @param updatable defines if the mesh must be flagged as updatable
  33210. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33211. * @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)
  33212. * @returns a new Mesh
  33213. */
  33214. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33215. /**
  33216. * Creates an custom extruded shape mesh.
  33217. * The custom extrusion is a parametric shape.
  33218. * It has no predefined shape. Its final shape will depend on the input parameters.
  33219. * Please consider using the same method from the MeshBuilder class instead
  33220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33221. * @param name defines the name of the mesh to create
  33222. * @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
  33223. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33224. * @param scaleFunction is a custom Javascript function called on each path point
  33225. * @param rotationFunction is a custom Javascript function called on each path point
  33226. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33227. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33228. * @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
  33229. * @param scene defines the hosting scene
  33230. * @param updatable defines if the mesh must be flagged as updatable
  33231. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33232. * @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)
  33233. * @returns a new Mesh
  33234. */
  33235. 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;
  33236. /**
  33237. * Creates lathe mesh.
  33238. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33239. * Please consider using the same method from the MeshBuilder class instead
  33240. * @param name defines the name of the mesh to create
  33241. * @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
  33242. * @param radius is the radius value of the lathe
  33243. * @param tessellation is the side number of the lathe.
  33244. * @param scene defines the hosting scene
  33245. * @param updatable defines if the mesh must be flagged as updatable
  33246. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33247. * @returns a new Mesh
  33248. */
  33249. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33250. /**
  33251. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33252. * @param name defines the name of the mesh to create
  33253. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33254. * @param scene defines the hosting scene
  33255. * @param updatable defines if the mesh must be flagged as updatable
  33256. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33257. * @returns a new Mesh
  33258. */
  33259. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33260. /**
  33261. * Creates a ground mesh.
  33262. * Please consider using the same method from the MeshBuilder class instead
  33263. * @param name defines the name of the mesh to create
  33264. * @param width set the width of the ground
  33265. * @param height set the height of the ground
  33266. * @param subdivisions sets the number of subdivisions per side
  33267. * @param scene defines the hosting scene
  33268. * @param updatable defines if the mesh must be flagged as updatable
  33269. * @returns a new Mesh
  33270. */
  33271. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33272. /**
  33273. * Creates a tiled ground mesh.
  33274. * Please consider using the same method from the MeshBuilder class instead
  33275. * @param name defines the name of the mesh to create
  33276. * @param xmin set the ground minimum X coordinate
  33277. * @param zmin set the ground minimum Y coordinate
  33278. * @param xmax set the ground maximum X coordinate
  33279. * @param zmax set the ground maximum Z coordinate
  33280. * @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
  33281. * @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
  33282. * @param scene defines the hosting scene
  33283. * @param updatable defines if the mesh must be flagged as updatable
  33284. * @returns a new Mesh
  33285. */
  33286. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33287. w: number;
  33288. h: number;
  33289. }, precision: {
  33290. w: number;
  33291. h: number;
  33292. }, scene: Scene, updatable?: boolean): Mesh;
  33293. /**
  33294. * Creates a ground mesh from a height map.
  33295. * Please consider using the same method from the MeshBuilder class instead
  33296. * @see https://doc.babylonjs.com/babylon101/height_map
  33297. * @param name defines the name of the mesh to create
  33298. * @param url sets the URL of the height map image resource
  33299. * @param width set the ground width size
  33300. * @param height set the ground height size
  33301. * @param subdivisions sets the number of subdivision per side
  33302. * @param minHeight is the minimum altitude on the ground
  33303. * @param maxHeight is the maximum altitude on the ground
  33304. * @param scene defines the hosting scene
  33305. * @param updatable defines if the mesh must be flagged as updatable
  33306. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33307. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33308. * @returns a new Mesh
  33309. */
  33310. 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;
  33311. /**
  33312. * Creates a tube mesh.
  33313. * The tube is a parametric shape.
  33314. * It has no predefined shape. Its final shape will depend on the input parameters.
  33315. * Please consider using the same method from the MeshBuilder class instead
  33316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33317. * @param name defines the name of the mesh to create
  33318. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33319. * @param radius sets the tube radius size
  33320. * @param tessellation is the number of sides on the tubular surface
  33321. * @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
  33322. * @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
  33323. * @param scene defines the hosting scene
  33324. * @param updatable defines if the mesh must be flagged as updatable
  33325. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33326. * @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)
  33327. * @returns a new Mesh
  33328. */
  33329. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33330. (i: number, distance: number): number;
  33331. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33332. /**
  33333. * Creates a polyhedron mesh.
  33334. * Please consider using the same method from the MeshBuilder class instead.
  33335. * * 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
  33336. * * The parameter `size` (positive float, default 1) sets the polygon size
  33337. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33338. * * 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`
  33339. * * 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
  33340. * * 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)`)
  33341. * * 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
  33342. * * 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
  33343. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33344. * * 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
  33345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33346. * @param name defines the name of the mesh to create
  33347. * @param options defines the options used to create the mesh
  33348. * @param scene defines the hosting scene
  33349. * @returns a new Mesh
  33350. */
  33351. static CreatePolyhedron(name: string, options: {
  33352. type?: number;
  33353. size?: number;
  33354. sizeX?: number;
  33355. sizeY?: number;
  33356. sizeZ?: number;
  33357. custom?: any;
  33358. faceUV?: Vector4[];
  33359. faceColors?: Color4[];
  33360. updatable?: boolean;
  33361. sideOrientation?: number;
  33362. }, scene: Scene): Mesh;
  33363. /**
  33364. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33365. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33366. * * 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`)
  33367. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33368. * * 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
  33369. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33370. * * 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
  33371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33372. * @param name defines the name of the mesh
  33373. * @param options defines the options used to create the mesh
  33374. * @param scene defines the hosting scene
  33375. * @returns a new Mesh
  33376. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33377. */
  33378. static CreateIcoSphere(name: string, options: {
  33379. radius?: number;
  33380. flat?: boolean;
  33381. subdivisions?: number;
  33382. sideOrientation?: number;
  33383. updatable?: boolean;
  33384. }, scene: Scene): Mesh;
  33385. /**
  33386. * Creates a decal mesh.
  33387. * Please consider using the same method from the MeshBuilder class instead.
  33388. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33389. * @param name defines the name of the mesh
  33390. * @param sourceMesh defines the mesh receiving the decal
  33391. * @param position sets the position of the decal in world coordinates
  33392. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33393. * @param size sets the decal scaling
  33394. * @param angle sets the angle to rotate the decal
  33395. * @returns a new Mesh
  33396. */
  33397. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33398. /** Creates a Capsule Mesh
  33399. * @param name defines the name of the mesh.
  33400. * @param options the constructors options used to shape the mesh.
  33401. * @param scene defines the scene the mesh is scoped to.
  33402. * @returns the capsule mesh
  33403. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33404. */
  33405. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33406. /**
  33407. * Prepare internal position array for software CPU skinning
  33408. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33409. */
  33410. setPositionsForCPUSkinning(): Float32Array;
  33411. /**
  33412. * Prepare internal normal array for software CPU skinning
  33413. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33414. */
  33415. setNormalsForCPUSkinning(): Float32Array;
  33416. /**
  33417. * Updates the vertex buffer by applying transformation from the bones
  33418. * @param skeleton defines the skeleton to apply to current mesh
  33419. * @returns the current mesh
  33420. */
  33421. applySkeleton(skeleton: Skeleton): Mesh;
  33422. /**
  33423. * 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
  33424. * @param meshes defines the list of meshes to scan
  33425. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33426. */
  33427. static MinMax(meshes: AbstractMesh[]): {
  33428. min: Vector3;
  33429. max: Vector3;
  33430. };
  33431. /**
  33432. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33433. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33434. * @returns a vector3
  33435. */
  33436. static Center(meshesOrMinMaxVector: {
  33437. min: Vector3;
  33438. max: Vector3;
  33439. } | AbstractMesh[]): Vector3;
  33440. /**
  33441. * Merge the array of meshes into a single mesh for performance reasons.
  33442. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33443. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33444. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33445. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33446. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33447. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33448. * @returns a new mesh
  33449. */
  33450. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33451. /** @hidden */
  33452. addInstance(instance: InstancedMesh): void;
  33453. /** @hidden */
  33454. removeInstance(instance: InstancedMesh): void;
  33455. }
  33456. }
  33457. declare module BABYLON {
  33458. /**
  33459. * The options Interface for creating a Capsule Mesh
  33460. */
  33461. export interface ICreateCapsuleOptions {
  33462. /** The Orientation of the capsule. Default : Vector3.Up() */
  33463. orientation?: Vector3;
  33464. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33465. subdivisions: number;
  33466. /** Number of cylindrical segments on the capsule. */
  33467. tessellation: number;
  33468. /** Height or Length of the capsule. */
  33469. height: number;
  33470. /** Radius of the capsule. */
  33471. radius: number;
  33472. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33473. capSubdivisions: number;
  33474. /** Overwrite for the top radius. */
  33475. radiusTop?: number;
  33476. /** Overwrite for the bottom radius. */
  33477. radiusBottom?: number;
  33478. /** Overwrite for the top capSubdivisions. */
  33479. topCapSubdivisions?: number;
  33480. /** Overwrite for the bottom capSubdivisions. */
  33481. bottomCapSubdivisions?: number;
  33482. }
  33483. /**
  33484. * Class containing static functions to help procedurally build meshes
  33485. */
  33486. export class CapsuleBuilder {
  33487. /**
  33488. * Creates a capsule or a pill mesh
  33489. * @param name defines the name of the mesh
  33490. * @param options The constructors options.
  33491. * @param scene The scene the mesh is scoped to.
  33492. * @returns Capsule Mesh
  33493. */
  33494. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33495. }
  33496. }
  33497. declare module BABYLON {
  33498. /**
  33499. * Define an interface for all classes that will get and set the data on vertices
  33500. */
  33501. export interface IGetSetVerticesData {
  33502. /**
  33503. * Gets a boolean indicating if specific vertex data is present
  33504. * @param kind defines the vertex data kind to use
  33505. * @returns true is data kind is present
  33506. */
  33507. isVerticesDataPresent(kind: string): boolean;
  33508. /**
  33509. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33510. * @param kind defines the data kind (Position, normal, etc...)
  33511. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33513. * @returns a float array containing vertex data
  33514. */
  33515. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33516. /**
  33517. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33518. * @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.
  33519. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33520. * @returns the indices array or an empty array if the mesh has no geometry
  33521. */
  33522. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33523. /**
  33524. * Set specific vertex data
  33525. * @param kind defines the data kind (Position, normal, etc...)
  33526. * @param data defines the vertex data to use
  33527. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33528. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33529. */
  33530. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33531. /**
  33532. * Update a specific associated vertex buffer
  33533. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33534. * - VertexBuffer.PositionKind
  33535. * - VertexBuffer.UVKind
  33536. * - VertexBuffer.UV2Kind
  33537. * - VertexBuffer.UV3Kind
  33538. * - VertexBuffer.UV4Kind
  33539. * - VertexBuffer.UV5Kind
  33540. * - VertexBuffer.UV6Kind
  33541. * - VertexBuffer.ColorKind
  33542. * - VertexBuffer.MatricesIndicesKind
  33543. * - VertexBuffer.MatricesIndicesExtraKind
  33544. * - VertexBuffer.MatricesWeightsKind
  33545. * - VertexBuffer.MatricesWeightsExtraKind
  33546. * @param data defines the data source
  33547. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33548. * @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)
  33549. */
  33550. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33551. /**
  33552. * Creates a new index buffer
  33553. * @param indices defines the indices to store in the index buffer
  33554. * @param totalVertices defines the total number of vertices (could be null)
  33555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33556. */
  33557. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33558. }
  33559. /**
  33560. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33561. */
  33562. export class VertexData {
  33563. /**
  33564. * Mesh side orientation : usually the external or front surface
  33565. */
  33566. static readonly FRONTSIDE: number;
  33567. /**
  33568. * Mesh side orientation : usually the internal or back surface
  33569. */
  33570. static readonly BACKSIDE: number;
  33571. /**
  33572. * Mesh side orientation : both internal and external or front and back surfaces
  33573. */
  33574. static readonly DOUBLESIDE: number;
  33575. /**
  33576. * Mesh side orientation : by default, `FRONTSIDE`
  33577. */
  33578. static readonly DEFAULTSIDE: number;
  33579. /**
  33580. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33581. */
  33582. positions: Nullable<FloatArray>;
  33583. /**
  33584. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33585. */
  33586. normals: Nullable<FloatArray>;
  33587. /**
  33588. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33589. */
  33590. tangents: Nullable<FloatArray>;
  33591. /**
  33592. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33593. */
  33594. uvs: Nullable<FloatArray>;
  33595. /**
  33596. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33597. */
  33598. uvs2: Nullable<FloatArray>;
  33599. /**
  33600. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33601. */
  33602. uvs3: Nullable<FloatArray>;
  33603. /**
  33604. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33605. */
  33606. uvs4: Nullable<FloatArray>;
  33607. /**
  33608. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33609. */
  33610. uvs5: Nullable<FloatArray>;
  33611. /**
  33612. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33613. */
  33614. uvs6: Nullable<FloatArray>;
  33615. /**
  33616. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33617. */
  33618. colors: Nullable<FloatArray>;
  33619. /**
  33620. * 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).
  33621. */
  33622. matricesIndices: Nullable<FloatArray>;
  33623. /**
  33624. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33625. */
  33626. matricesWeights: Nullable<FloatArray>;
  33627. /**
  33628. * An array extending the number of possible indices
  33629. */
  33630. matricesIndicesExtra: Nullable<FloatArray>;
  33631. /**
  33632. * An array extending the number of possible weights when the number of indices is extended
  33633. */
  33634. matricesWeightsExtra: Nullable<FloatArray>;
  33635. /**
  33636. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33637. */
  33638. indices: Nullable<IndicesArray>;
  33639. /**
  33640. * Uses the passed data array to set the set the values for the specified kind of data
  33641. * @param data a linear array of floating numbers
  33642. * @param kind the type of data that is being set, eg positions, colors etc
  33643. */
  33644. set(data: FloatArray, kind: string): void;
  33645. /**
  33646. * Associates the vertexData to the passed Mesh.
  33647. * Sets it as updatable or not (default `false`)
  33648. * @param mesh the mesh the vertexData is applied to
  33649. * @param updatable when used and having the value true allows new data to update the vertexData
  33650. * @returns the VertexData
  33651. */
  33652. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33653. /**
  33654. * Associates the vertexData to the passed Geometry.
  33655. * Sets it as updatable or not (default `false`)
  33656. * @param geometry the geometry the vertexData is applied to
  33657. * @param updatable when used and having the value true allows new data to update the vertexData
  33658. * @returns VertexData
  33659. */
  33660. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33661. /**
  33662. * Updates the associated mesh
  33663. * @param mesh the mesh to be updated
  33664. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33665. * @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
  33666. * @returns VertexData
  33667. */
  33668. updateMesh(mesh: Mesh): VertexData;
  33669. /**
  33670. * Updates the associated geometry
  33671. * @param geometry the geometry to be updated
  33672. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33673. * @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
  33674. * @returns VertexData.
  33675. */
  33676. updateGeometry(geometry: Geometry): VertexData;
  33677. private _applyTo;
  33678. private _update;
  33679. /**
  33680. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33681. * @param matrix the transforming matrix
  33682. * @returns the VertexData
  33683. */
  33684. transform(matrix: Matrix): VertexData;
  33685. /**
  33686. * Merges the passed VertexData into the current one
  33687. * @param other the VertexData to be merged into the current one
  33688. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33689. * @returns the modified VertexData
  33690. */
  33691. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33692. private _mergeElement;
  33693. private _validate;
  33694. /**
  33695. * Serializes the VertexData
  33696. * @returns a serialized object
  33697. */
  33698. serialize(): any;
  33699. /**
  33700. * Extracts the vertexData from a mesh
  33701. * @param mesh the mesh from which to extract the VertexData
  33702. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33703. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33704. * @returns the object VertexData associated to the passed mesh
  33705. */
  33706. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33707. /**
  33708. * Extracts the vertexData from the geometry
  33709. * @param geometry the geometry from which to extract the VertexData
  33710. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33711. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33712. * @returns the object VertexData associated to the passed mesh
  33713. */
  33714. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33715. private static _ExtractFrom;
  33716. /**
  33717. * Creates the VertexData for a Ribbon
  33718. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33719. * * pathArray array of paths, each of which an array of successive Vector3
  33720. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33721. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33722. * * 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
  33723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33724. * * 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)
  33725. * * 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)
  33726. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33727. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33728. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33729. * @returns the VertexData of the ribbon
  33730. */
  33731. static CreateRibbon(options: {
  33732. pathArray: Vector3[][];
  33733. closeArray?: boolean;
  33734. closePath?: boolean;
  33735. offset?: number;
  33736. sideOrientation?: number;
  33737. frontUVs?: Vector4;
  33738. backUVs?: Vector4;
  33739. invertUV?: boolean;
  33740. uvs?: Vector2[];
  33741. colors?: Color4[];
  33742. }): VertexData;
  33743. /**
  33744. * Creates the VertexData for a box
  33745. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33746. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33747. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33748. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33749. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33750. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33751. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33753. * * 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)
  33754. * * 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)
  33755. * @returns the VertexData of the box
  33756. */
  33757. static CreateBox(options: {
  33758. size?: number;
  33759. width?: number;
  33760. height?: number;
  33761. depth?: number;
  33762. faceUV?: Vector4[];
  33763. faceColors?: Color4[];
  33764. sideOrientation?: number;
  33765. frontUVs?: Vector4;
  33766. backUVs?: Vector4;
  33767. }): VertexData;
  33768. /**
  33769. * Creates the VertexData for a tiled box
  33770. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33771. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33772. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33773. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33775. * @returns the VertexData of the box
  33776. */
  33777. static CreateTiledBox(options: {
  33778. pattern?: number;
  33779. width?: number;
  33780. height?: number;
  33781. depth?: number;
  33782. tileSize?: number;
  33783. tileWidth?: number;
  33784. tileHeight?: number;
  33785. alignHorizontal?: number;
  33786. alignVertical?: number;
  33787. faceUV?: Vector4[];
  33788. faceColors?: Color4[];
  33789. sideOrientation?: number;
  33790. }): VertexData;
  33791. /**
  33792. * Creates the VertexData for a tiled plane
  33793. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33794. * * pattern a limited pattern arrangement depending on the number
  33795. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33796. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33797. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33799. * * 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)
  33800. * * 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)
  33801. * @returns the VertexData of the tiled plane
  33802. */
  33803. static CreateTiledPlane(options: {
  33804. pattern?: number;
  33805. tileSize?: number;
  33806. tileWidth?: number;
  33807. tileHeight?: number;
  33808. size?: number;
  33809. width?: number;
  33810. height?: number;
  33811. alignHorizontal?: number;
  33812. alignVertical?: number;
  33813. sideOrientation?: number;
  33814. frontUVs?: Vector4;
  33815. backUVs?: Vector4;
  33816. }): VertexData;
  33817. /**
  33818. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33819. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33820. * * segments sets the number of horizontal strips optional, default 32
  33821. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33822. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33823. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33824. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33825. * * 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
  33826. * * 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
  33827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33828. * * 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)
  33829. * * 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)
  33830. * @returns the VertexData of the ellipsoid
  33831. */
  33832. static CreateSphere(options: {
  33833. segments?: number;
  33834. diameter?: number;
  33835. diameterX?: number;
  33836. diameterY?: number;
  33837. diameterZ?: number;
  33838. arc?: number;
  33839. slice?: number;
  33840. sideOrientation?: number;
  33841. frontUVs?: Vector4;
  33842. backUVs?: Vector4;
  33843. }): VertexData;
  33844. /**
  33845. * Creates the VertexData for a cylinder, cone or prism
  33846. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33847. * * height sets the height (y direction) of the cylinder, optional, default 2
  33848. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33849. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33850. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33851. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33852. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33853. * * 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
  33854. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33855. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33856. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33857. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33859. * * 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)
  33860. * * 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)
  33861. * @returns the VertexData of the cylinder, cone or prism
  33862. */
  33863. static CreateCylinder(options: {
  33864. height?: number;
  33865. diameterTop?: number;
  33866. diameterBottom?: number;
  33867. diameter?: number;
  33868. tessellation?: number;
  33869. subdivisions?: number;
  33870. arc?: number;
  33871. faceColors?: Color4[];
  33872. faceUV?: Vector4[];
  33873. hasRings?: boolean;
  33874. enclose?: boolean;
  33875. sideOrientation?: number;
  33876. frontUVs?: Vector4;
  33877. backUVs?: Vector4;
  33878. }): VertexData;
  33879. /**
  33880. * Creates the VertexData for a torus
  33881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33882. * * diameter the diameter of the torus, optional default 1
  33883. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33884. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33886. * * 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)
  33887. * * 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)
  33888. * @returns the VertexData of the torus
  33889. */
  33890. static CreateTorus(options: {
  33891. diameter?: number;
  33892. thickness?: number;
  33893. tessellation?: number;
  33894. sideOrientation?: number;
  33895. frontUVs?: Vector4;
  33896. backUVs?: Vector4;
  33897. }): VertexData;
  33898. /**
  33899. * Creates the VertexData of the LineSystem
  33900. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33901. * - lines an array of lines, each line being an array of successive Vector3
  33902. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33903. * @returns the VertexData of the LineSystem
  33904. */
  33905. static CreateLineSystem(options: {
  33906. lines: Vector3[][];
  33907. colors?: Nullable<Color4[][]>;
  33908. }): VertexData;
  33909. /**
  33910. * Create the VertexData for a DashedLines
  33911. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33912. * - points an array successive Vector3
  33913. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33914. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33915. * - dashNb the intended total number of dashes, optional, default 200
  33916. * @returns the VertexData for the DashedLines
  33917. */
  33918. static CreateDashedLines(options: {
  33919. points: Vector3[];
  33920. dashSize?: number;
  33921. gapSize?: number;
  33922. dashNb?: number;
  33923. }): VertexData;
  33924. /**
  33925. * Creates the VertexData for a Ground
  33926. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33927. * - width the width (x direction) of the ground, optional, default 1
  33928. * - height the height (z direction) of the ground, optional, default 1
  33929. * - subdivisions the number of subdivisions per side, optional, default 1
  33930. * @returns the VertexData of the Ground
  33931. */
  33932. static CreateGround(options: {
  33933. width?: number;
  33934. height?: number;
  33935. subdivisions?: number;
  33936. subdivisionsX?: number;
  33937. subdivisionsY?: number;
  33938. }): VertexData;
  33939. /**
  33940. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33941. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33942. * * xmin the ground minimum X coordinate, optional, default -1
  33943. * * zmin the ground minimum Z coordinate, optional, default -1
  33944. * * xmax the ground maximum X coordinate, optional, default 1
  33945. * * zmax the ground maximum Z coordinate, optional, default 1
  33946. * * 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}
  33947. * * 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}
  33948. * @returns the VertexData of the TiledGround
  33949. */
  33950. static CreateTiledGround(options: {
  33951. xmin: number;
  33952. zmin: number;
  33953. xmax: number;
  33954. zmax: number;
  33955. subdivisions?: {
  33956. w: number;
  33957. h: number;
  33958. };
  33959. precision?: {
  33960. w: number;
  33961. h: number;
  33962. };
  33963. }): VertexData;
  33964. /**
  33965. * Creates the VertexData of the Ground designed from a heightmap
  33966. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33967. * * width the width (x direction) of the ground
  33968. * * height the height (z direction) of the ground
  33969. * * subdivisions the number of subdivisions per side
  33970. * * minHeight the minimum altitude on the ground, optional, default 0
  33971. * * maxHeight the maximum altitude on the ground, optional default 1
  33972. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33973. * * buffer the array holding the image color data
  33974. * * bufferWidth the width of image
  33975. * * bufferHeight the height of image
  33976. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33977. * @returns the VertexData of the Ground designed from a heightmap
  33978. */
  33979. static CreateGroundFromHeightMap(options: {
  33980. width: number;
  33981. height: number;
  33982. subdivisions: number;
  33983. minHeight: number;
  33984. maxHeight: number;
  33985. colorFilter: Color3;
  33986. buffer: Uint8Array;
  33987. bufferWidth: number;
  33988. bufferHeight: number;
  33989. alphaFilter: number;
  33990. }): VertexData;
  33991. /**
  33992. * Creates the VertexData for a Plane
  33993. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33994. * * size sets the width and height of the plane to the value of size, optional default 1
  33995. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33996. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33998. * * 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)
  33999. * * 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)
  34000. * @returns the VertexData of the box
  34001. */
  34002. static CreatePlane(options: {
  34003. size?: number;
  34004. width?: number;
  34005. height?: number;
  34006. sideOrientation?: number;
  34007. frontUVs?: Vector4;
  34008. backUVs?: Vector4;
  34009. }): VertexData;
  34010. /**
  34011. * Creates the VertexData of the Disc or regular Polygon
  34012. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34013. * * radius the radius of the disc, optional default 0.5
  34014. * * tessellation the number of polygon sides, optional, default 64
  34015. * * 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
  34016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34017. * * 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)
  34018. * * 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)
  34019. * @returns the VertexData of the box
  34020. */
  34021. static CreateDisc(options: {
  34022. radius?: number;
  34023. tessellation?: number;
  34024. arc?: number;
  34025. sideOrientation?: number;
  34026. frontUVs?: Vector4;
  34027. backUVs?: Vector4;
  34028. }): VertexData;
  34029. /**
  34030. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34031. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34032. * @param polygon a mesh built from polygonTriangulation.build()
  34033. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34034. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34035. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34036. * @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)
  34037. * @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)
  34038. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34039. * @returns the VertexData of the Polygon
  34040. */
  34041. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34042. /**
  34043. * Creates the VertexData of the IcoSphere
  34044. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34045. * * radius the radius of the IcoSphere, optional default 1
  34046. * * radiusX allows stretching in the x direction, optional, default radius
  34047. * * radiusY allows stretching in the y direction, optional, default radius
  34048. * * radiusZ allows stretching in the z direction, optional, default radius
  34049. * * flat when true creates a flat shaded mesh, optional, default true
  34050. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34052. * * 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)
  34053. * * 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)
  34054. * @returns the VertexData of the IcoSphere
  34055. */
  34056. static CreateIcoSphere(options: {
  34057. radius?: number;
  34058. radiusX?: number;
  34059. radiusY?: number;
  34060. radiusZ?: number;
  34061. flat?: boolean;
  34062. subdivisions?: number;
  34063. sideOrientation?: number;
  34064. frontUVs?: Vector4;
  34065. backUVs?: Vector4;
  34066. }): VertexData;
  34067. /**
  34068. * Creates the VertexData for a Polyhedron
  34069. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34070. * * type provided types are:
  34071. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34072. * * 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)
  34073. * * size the size of the IcoSphere, optional default 1
  34074. * * sizeX allows stretching in the x direction, optional, default size
  34075. * * sizeY allows stretching in the y direction, optional, default size
  34076. * * sizeZ allows stretching in the z direction, optional, default size
  34077. * * 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
  34078. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34079. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34080. * * flat when true creates a flat shaded mesh, optional, default true
  34081. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34083. * * 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)
  34084. * * 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)
  34085. * @returns the VertexData of the Polyhedron
  34086. */
  34087. static CreatePolyhedron(options: {
  34088. type?: number;
  34089. size?: number;
  34090. sizeX?: number;
  34091. sizeY?: number;
  34092. sizeZ?: number;
  34093. custom?: any;
  34094. faceUV?: Vector4[];
  34095. faceColors?: Color4[];
  34096. flat?: boolean;
  34097. sideOrientation?: number;
  34098. frontUVs?: Vector4;
  34099. backUVs?: Vector4;
  34100. }): VertexData;
  34101. /**
  34102. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34103. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34104. * @returns the VertexData of the Capsule
  34105. */
  34106. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34107. /**
  34108. * Creates the VertexData for a TorusKnot
  34109. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34110. * * radius the radius of the torus knot, optional, default 2
  34111. * * tube the thickness of the tube, optional, default 0.5
  34112. * * radialSegments the number of sides on each tube segments, optional, default 32
  34113. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34114. * * p the number of windings around the z axis, optional, default 2
  34115. * * q the number of windings around the x axis, optional, default 3
  34116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34117. * * 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)
  34118. * * 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)
  34119. * @returns the VertexData of the Torus Knot
  34120. */
  34121. static CreateTorusKnot(options: {
  34122. radius?: number;
  34123. tube?: number;
  34124. radialSegments?: number;
  34125. tubularSegments?: number;
  34126. p?: number;
  34127. q?: number;
  34128. sideOrientation?: number;
  34129. frontUVs?: Vector4;
  34130. backUVs?: Vector4;
  34131. }): VertexData;
  34132. /**
  34133. * Compute normals for given positions and indices
  34134. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34135. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34136. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34137. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34138. * * facetNormals : optional array of facet normals (vector3)
  34139. * * facetPositions : optional array of facet positions (vector3)
  34140. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34141. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34142. * * bInfo : optional bounding info, required for facetPartitioning computation
  34143. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34144. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34145. * * useRightHandedSystem: optional boolean to for right handed system computation
  34146. * * depthSort : optional boolean to enable the facet depth sort computation
  34147. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34148. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34149. */
  34150. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34151. facetNormals?: any;
  34152. facetPositions?: any;
  34153. facetPartitioning?: any;
  34154. ratio?: number;
  34155. bInfo?: any;
  34156. bbSize?: Vector3;
  34157. subDiv?: any;
  34158. useRightHandedSystem?: boolean;
  34159. depthSort?: boolean;
  34160. distanceTo?: Vector3;
  34161. depthSortedFacets?: any;
  34162. }): void;
  34163. /** @hidden */
  34164. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34165. /**
  34166. * Applies VertexData created from the imported parameters to the geometry
  34167. * @param parsedVertexData the parsed data from an imported file
  34168. * @param geometry the geometry to apply the VertexData to
  34169. */
  34170. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34171. }
  34172. }
  34173. declare module BABYLON {
  34174. /**
  34175. * Class containing static functions to help procedurally build meshes
  34176. */
  34177. export class DiscBuilder {
  34178. /**
  34179. * Creates a plane polygonal mesh. By default, this is a disc
  34180. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34181. * * 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
  34182. * * 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
  34183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34184. * * 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
  34185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34186. * @param name defines the name of the mesh
  34187. * @param options defines the options used to create the mesh
  34188. * @param scene defines the hosting scene
  34189. * @returns the plane polygonal mesh
  34190. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34191. */
  34192. static CreateDisc(name: string, options: {
  34193. radius?: number;
  34194. tessellation?: number;
  34195. arc?: number;
  34196. updatable?: boolean;
  34197. sideOrientation?: number;
  34198. frontUVs?: Vector4;
  34199. backUVs?: Vector4;
  34200. }, scene?: Nullable<Scene>): Mesh;
  34201. }
  34202. }
  34203. declare module BABYLON {
  34204. /**
  34205. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34206. *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.
  34207. * The SPS is also a particle system. It provides some methods to manage the particles.
  34208. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34209. *
  34210. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34211. */
  34212. export class SolidParticleSystem implements IDisposable {
  34213. /**
  34214. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34215. * Example : var p = SPS.particles[i];
  34216. */
  34217. particles: SolidParticle[];
  34218. /**
  34219. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34220. */
  34221. nbParticles: number;
  34222. /**
  34223. * If the particles must ever face the camera (default false). Useful for planar particles.
  34224. */
  34225. billboard: boolean;
  34226. /**
  34227. * Recompute normals when adding a shape
  34228. */
  34229. recomputeNormals: boolean;
  34230. /**
  34231. * This a counter ofr your own usage. It's not set by any SPS functions.
  34232. */
  34233. counter: number;
  34234. /**
  34235. * The SPS name. This name is also given to the underlying mesh.
  34236. */
  34237. name: string;
  34238. /**
  34239. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34240. */
  34241. mesh: Mesh;
  34242. /**
  34243. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34244. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34245. */
  34246. vars: any;
  34247. /**
  34248. * This array is populated when the SPS is set as 'pickable'.
  34249. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34250. * Each element of this array is an object `{idx: int, faceId: int}`.
  34251. * `idx` is the picked particle index in the `SPS.particles` array
  34252. * `faceId` is the picked face index counted within this particle.
  34253. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34254. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34255. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34256. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34257. */
  34258. pickedParticles: {
  34259. idx: number;
  34260. faceId: number;
  34261. }[];
  34262. /**
  34263. * This array is populated when the SPS is set as 'pickable'
  34264. * Each key of this array is a submesh index.
  34265. * Each element of this array is a second array defined like this :
  34266. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34267. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34268. * `idx` is the picked particle index in the `SPS.particles` array
  34269. * `faceId` is the picked face index counted within this particle.
  34270. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34271. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34272. */
  34273. pickedBySubMesh: {
  34274. idx: number;
  34275. faceId: number;
  34276. }[][];
  34277. /**
  34278. * This array is populated when `enableDepthSort` is set to true.
  34279. * Each element of this array is an instance of the class DepthSortedParticle.
  34280. */
  34281. depthSortedParticles: DepthSortedParticle[];
  34282. /**
  34283. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34284. * @hidden
  34285. */
  34286. _bSphereOnly: boolean;
  34287. /**
  34288. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34289. * @hidden
  34290. */
  34291. _bSphereRadiusFactor: number;
  34292. private _scene;
  34293. private _positions;
  34294. private _indices;
  34295. private _normals;
  34296. private _colors;
  34297. private _uvs;
  34298. private _indices32;
  34299. private _positions32;
  34300. private _normals32;
  34301. private _fixedNormal32;
  34302. private _colors32;
  34303. private _uvs32;
  34304. private _index;
  34305. private _updatable;
  34306. private _pickable;
  34307. private _isVisibilityBoxLocked;
  34308. private _alwaysVisible;
  34309. private _depthSort;
  34310. private _expandable;
  34311. private _shapeCounter;
  34312. private _copy;
  34313. private _color;
  34314. private _computeParticleColor;
  34315. private _computeParticleTexture;
  34316. private _computeParticleRotation;
  34317. private _computeParticleVertex;
  34318. private _computeBoundingBox;
  34319. private _depthSortParticles;
  34320. private _camera;
  34321. private _mustUnrotateFixedNormals;
  34322. private _particlesIntersect;
  34323. private _needs32Bits;
  34324. private _isNotBuilt;
  34325. private _lastParticleId;
  34326. private _idxOfId;
  34327. private _multimaterialEnabled;
  34328. private _useModelMaterial;
  34329. private _indicesByMaterial;
  34330. private _materialIndexes;
  34331. private _depthSortFunction;
  34332. private _materialSortFunction;
  34333. private _materials;
  34334. private _multimaterial;
  34335. private _materialIndexesById;
  34336. private _defaultMaterial;
  34337. private _autoUpdateSubMeshes;
  34338. private _tmpVertex;
  34339. /**
  34340. * Creates a SPS (Solid Particle System) object.
  34341. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34342. * @param scene (Scene) is the scene in which the SPS is added.
  34343. * @param options defines the options of the sps e.g.
  34344. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34345. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34346. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34347. * * 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.
  34348. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34349. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34350. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34351. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34352. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34353. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34354. */
  34355. constructor(name: string, scene: Scene, options?: {
  34356. updatable?: boolean;
  34357. isPickable?: boolean;
  34358. enableDepthSort?: boolean;
  34359. particleIntersection?: boolean;
  34360. boundingSphereOnly?: boolean;
  34361. bSphereRadiusFactor?: number;
  34362. expandable?: boolean;
  34363. useModelMaterial?: boolean;
  34364. enableMultiMaterial?: boolean;
  34365. });
  34366. /**
  34367. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34368. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34369. * @returns the created mesh
  34370. */
  34371. buildMesh(): Mesh;
  34372. /**
  34373. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34374. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34375. * Thus the particles generated from `digest()` have their property `position` set yet.
  34376. * @param mesh ( Mesh ) is the mesh to be digested
  34377. * @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
  34378. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34379. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34380. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34381. * @returns the current SPS
  34382. */
  34383. digest(mesh: Mesh, options?: {
  34384. facetNb?: number;
  34385. number?: number;
  34386. delta?: number;
  34387. storage?: [];
  34388. }): SolidParticleSystem;
  34389. /**
  34390. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34391. * @hidden
  34392. */
  34393. private _unrotateFixedNormals;
  34394. /**
  34395. * Resets the temporary working copy particle
  34396. * @hidden
  34397. */
  34398. private _resetCopy;
  34399. /**
  34400. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34401. * @param p the current index in the positions array to be updated
  34402. * @param ind the current index in the indices array
  34403. * @param shape a Vector3 array, the shape geometry
  34404. * @param positions the positions array to be updated
  34405. * @param meshInd the shape indices array
  34406. * @param indices the indices array to be updated
  34407. * @param meshUV the shape uv array
  34408. * @param uvs the uv array to be updated
  34409. * @param meshCol the shape color array
  34410. * @param colors the color array to be updated
  34411. * @param meshNor the shape normals array
  34412. * @param normals the normals array to be updated
  34413. * @param idx the particle index
  34414. * @param idxInShape the particle index in its shape
  34415. * @param options the addShape() method passed options
  34416. * @model the particle model
  34417. * @hidden
  34418. */
  34419. private _meshBuilder;
  34420. /**
  34421. * Returns a shape Vector3 array from positions float array
  34422. * @param positions float array
  34423. * @returns a vector3 array
  34424. * @hidden
  34425. */
  34426. private _posToShape;
  34427. /**
  34428. * Returns a shapeUV array from a float uvs (array deep copy)
  34429. * @param uvs as a float array
  34430. * @returns a shapeUV array
  34431. * @hidden
  34432. */
  34433. private _uvsToShapeUV;
  34434. /**
  34435. * Adds a new particle object in the particles array
  34436. * @param idx particle index in particles array
  34437. * @param id particle id
  34438. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34439. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34440. * @param model particle ModelShape object
  34441. * @param shapeId model shape identifier
  34442. * @param idxInShape index of the particle in the current model
  34443. * @param bInfo model bounding info object
  34444. * @param storage target storage array, if any
  34445. * @hidden
  34446. */
  34447. private _addParticle;
  34448. /**
  34449. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34450. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34451. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34452. * @param nb (positive integer) the number of particles to be created from this model
  34453. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34454. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34455. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34456. * @returns the number of shapes in the system
  34457. */
  34458. addShape(mesh: Mesh, nb: number, options?: {
  34459. positionFunction?: any;
  34460. vertexFunction?: any;
  34461. storage?: [];
  34462. }): number;
  34463. /**
  34464. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34465. * @hidden
  34466. */
  34467. private _rebuildParticle;
  34468. /**
  34469. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34470. * @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.
  34471. * @returns the SPS.
  34472. */
  34473. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34474. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34475. * Returns an array with the removed particles.
  34476. * 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.
  34477. * The SPS can't be empty so at least one particle needs to remain in place.
  34478. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34479. * @param start index of the first particle to remove
  34480. * @param end index of the last particle to remove (included)
  34481. * @returns an array populated with the removed particles
  34482. */
  34483. removeParticles(start: number, end: number): SolidParticle[];
  34484. /**
  34485. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34486. * @param solidParticleArray an array populated with Solid Particles objects
  34487. * @returns the SPS
  34488. */
  34489. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34490. /**
  34491. * Creates a new particle and modifies the SPS mesh geometry :
  34492. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34493. * - calls _addParticle() to populate the particle array
  34494. * factorized code from addShape() and insertParticlesFromArray()
  34495. * @param idx particle index in the particles array
  34496. * @param i particle index in its shape
  34497. * @param modelShape particle ModelShape object
  34498. * @param shape shape vertex array
  34499. * @param meshInd shape indices array
  34500. * @param meshUV shape uv array
  34501. * @param meshCol shape color array
  34502. * @param meshNor shape normals array
  34503. * @param bbInfo shape bounding info
  34504. * @param storage target particle storage
  34505. * @options addShape() passed options
  34506. * @hidden
  34507. */
  34508. private _insertNewParticle;
  34509. /**
  34510. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34511. * This method calls `updateParticle()` for each particle of the SPS.
  34512. * For an animated SPS, it is usually called within the render loop.
  34513. * 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.
  34514. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34515. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34516. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34517. * @returns the SPS.
  34518. */
  34519. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34520. /**
  34521. * Disposes the SPS.
  34522. */
  34523. dispose(): void;
  34524. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34525. * idx is the particle index in the SPS
  34526. * faceId is the picked face index counted within this particle.
  34527. * Returns null if the pickInfo can't identify a picked particle.
  34528. * @param pickingInfo (PickingInfo object)
  34529. * @returns {idx: number, faceId: number} or null
  34530. */
  34531. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34532. idx: number;
  34533. faceId: number;
  34534. }>;
  34535. /**
  34536. * Returns a SolidParticle object from its identifier : particle.id
  34537. * @param id (integer) the particle Id
  34538. * @returns the searched particle or null if not found in the SPS.
  34539. */
  34540. getParticleById(id: number): Nullable<SolidParticle>;
  34541. /**
  34542. * Returns a new array populated with the particles having the passed shapeId.
  34543. * @param shapeId (integer) the shape identifier
  34544. * @returns a new solid particle array
  34545. */
  34546. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34547. /**
  34548. * Populates the passed array "ref" with the particles having the passed shapeId.
  34549. * @param shapeId the shape identifier
  34550. * @returns the SPS
  34551. * @param ref
  34552. */
  34553. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34554. /**
  34555. * Computes the required SubMeshes according the materials assigned to the particles.
  34556. * @returns the solid particle system.
  34557. * Does nothing if called before the SPS mesh is built.
  34558. */
  34559. computeSubMeshes(): SolidParticleSystem;
  34560. /**
  34561. * Sorts the solid particles by material when MultiMaterial is enabled.
  34562. * Updates the indices32 array.
  34563. * Updates the indicesByMaterial array.
  34564. * Updates the mesh indices array.
  34565. * @returns the SPS
  34566. * @hidden
  34567. */
  34568. private _sortParticlesByMaterial;
  34569. /**
  34570. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34571. * @hidden
  34572. */
  34573. private _setMaterialIndexesById;
  34574. /**
  34575. * Returns an array with unique values of Materials from the passed array
  34576. * @param array the material array to be checked and filtered
  34577. * @hidden
  34578. */
  34579. private _filterUniqueMaterialId;
  34580. /**
  34581. * Sets a new Standard Material as _defaultMaterial if not already set.
  34582. * @hidden
  34583. */
  34584. private _setDefaultMaterial;
  34585. /**
  34586. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34587. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34588. * @returns the SPS.
  34589. */
  34590. refreshVisibleSize(): SolidParticleSystem;
  34591. /**
  34592. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34593. * @param size the size (float) of the visibility box
  34594. * note : this doesn't lock the SPS mesh bounding box.
  34595. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34596. */
  34597. setVisibilityBox(size: number): void;
  34598. /**
  34599. * Gets whether the SPS as always visible or not
  34600. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34601. */
  34602. get isAlwaysVisible(): boolean;
  34603. /**
  34604. * Sets the SPS as always visible or not
  34605. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34606. */
  34607. set isAlwaysVisible(val: boolean);
  34608. /**
  34609. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34610. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34611. */
  34612. set isVisibilityBoxLocked(val: boolean);
  34613. /**
  34614. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34616. */
  34617. get isVisibilityBoxLocked(): boolean;
  34618. /**
  34619. * Tells to `setParticles()` to compute the particle rotations or not.
  34620. * Default value : true. The SPS is faster when it's set to false.
  34621. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34622. */
  34623. set computeParticleRotation(val: boolean);
  34624. /**
  34625. * Tells to `setParticles()` to compute the particle colors or not.
  34626. * Default value : true. The SPS is faster when it's set to false.
  34627. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34628. */
  34629. set computeParticleColor(val: boolean);
  34630. set computeParticleTexture(val: boolean);
  34631. /**
  34632. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34633. * Default value : false. The SPS is faster when it's set to false.
  34634. * Note : the particle custom vertex positions aren't stored values.
  34635. */
  34636. set computeParticleVertex(val: boolean);
  34637. /**
  34638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34639. */
  34640. set computeBoundingBox(val: boolean);
  34641. /**
  34642. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34643. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34644. * Default : `true`
  34645. */
  34646. set depthSortParticles(val: boolean);
  34647. /**
  34648. * Gets if `setParticles()` computes the particle rotations or not.
  34649. * Default value : true. The SPS is faster when it's set to false.
  34650. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34651. */
  34652. get computeParticleRotation(): boolean;
  34653. /**
  34654. * Gets if `setParticles()` computes the particle colors or not.
  34655. * Default value : true. The SPS is faster when it's set to false.
  34656. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34657. */
  34658. get computeParticleColor(): boolean;
  34659. /**
  34660. * Gets if `setParticles()` computes the particle textures or not.
  34661. * Default value : true. The SPS is faster when it's set to false.
  34662. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34663. */
  34664. get computeParticleTexture(): boolean;
  34665. /**
  34666. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34667. * Default value : false. The SPS is faster when it's set to false.
  34668. * Note : the particle custom vertex positions aren't stored values.
  34669. */
  34670. get computeParticleVertex(): boolean;
  34671. /**
  34672. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34673. */
  34674. get computeBoundingBox(): boolean;
  34675. /**
  34676. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34677. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34678. * Default : `true`
  34679. */
  34680. get depthSortParticles(): boolean;
  34681. /**
  34682. * Gets if the SPS is created as expandable at construction time.
  34683. * Default : `false`
  34684. */
  34685. get expandable(): boolean;
  34686. /**
  34687. * Gets if the SPS supports the Multi Materials
  34688. */
  34689. get multimaterialEnabled(): boolean;
  34690. /**
  34691. * Gets if the SPS uses the model materials for its own multimaterial.
  34692. */
  34693. get useModelMaterial(): boolean;
  34694. /**
  34695. * The SPS used material array.
  34696. */
  34697. get materials(): Material[];
  34698. /**
  34699. * Sets the SPS MultiMaterial from the passed materials.
  34700. * Note : the passed array is internally copied and not used then by reference.
  34701. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34702. */
  34703. setMultiMaterial(materials: Material[]): void;
  34704. /**
  34705. * The SPS computed multimaterial object
  34706. */
  34707. get multimaterial(): MultiMaterial;
  34708. set multimaterial(mm: MultiMaterial);
  34709. /**
  34710. * If the subMeshes must be updated on the next call to setParticles()
  34711. */
  34712. get autoUpdateSubMeshes(): boolean;
  34713. set autoUpdateSubMeshes(val: boolean);
  34714. /**
  34715. * This function does nothing. It may be overwritten to set all the particle first values.
  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. */
  34719. initParticles(): void;
  34720. /**
  34721. * This function does nothing. It may be overwritten to recycle a particle.
  34722. * The SPS doesn't call this function, you may have to call it by your own.
  34723. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34724. * @param particle The particle to recycle
  34725. * @returns the recycled particle
  34726. */
  34727. recycleParticle(particle: SolidParticle): SolidParticle;
  34728. /**
  34729. * Updates a particle : this function should be overwritten by the user.
  34730. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34731. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34732. * @example : just set a particle position or velocity and recycle conditions
  34733. * @param particle The particle to update
  34734. * @returns the updated particle
  34735. */
  34736. updateParticle(particle: SolidParticle): SolidParticle;
  34737. /**
  34738. * Updates a vertex of a particle : it can be overwritten by the user.
  34739. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34740. * @param particle the current particle
  34741. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34742. * @param pt the index of the current vertex in the particle shape
  34743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34744. * @example : just set a vertex particle position or color
  34745. * @returns the sps
  34746. */
  34747. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34748. /**
  34749. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34750. * This does nothing and may be overwritten by the user.
  34751. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34752. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34753. * @param update the boolean update value actually passed to setParticles()
  34754. */
  34755. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34756. /**
  34757. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34758. * This will be passed three parameters.
  34759. * This does nothing and may be overwritten by the user.
  34760. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34761. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34762. * @param update the boolean update value actually passed to setParticles()
  34763. */
  34764. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34765. }
  34766. }
  34767. declare module BABYLON {
  34768. /**
  34769. * Represents one particle of a solid particle system.
  34770. */
  34771. export class SolidParticle {
  34772. /**
  34773. * particle global index
  34774. */
  34775. idx: number;
  34776. /**
  34777. * particle identifier
  34778. */
  34779. id: number;
  34780. /**
  34781. * The color of the particle
  34782. */
  34783. color: Nullable<Color4>;
  34784. /**
  34785. * The world space position of the particle.
  34786. */
  34787. position: Vector3;
  34788. /**
  34789. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34790. */
  34791. rotation: Vector3;
  34792. /**
  34793. * The world space rotation quaternion of the particle.
  34794. */
  34795. rotationQuaternion: Nullable<Quaternion>;
  34796. /**
  34797. * The scaling of the particle.
  34798. */
  34799. scaling: Vector3;
  34800. /**
  34801. * The uvs of the particle.
  34802. */
  34803. uvs: Vector4;
  34804. /**
  34805. * The current speed of the particle.
  34806. */
  34807. velocity: Vector3;
  34808. /**
  34809. * The pivot point in the particle local space.
  34810. */
  34811. pivot: Vector3;
  34812. /**
  34813. * Must the particle be translated from its pivot point in its local space ?
  34814. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34815. * Default : false
  34816. */
  34817. translateFromPivot: boolean;
  34818. /**
  34819. * Is the particle active or not ?
  34820. */
  34821. alive: boolean;
  34822. /**
  34823. * Is the particle visible or not ?
  34824. */
  34825. isVisible: boolean;
  34826. /**
  34827. * Index of this particle in the global "positions" array (Internal use)
  34828. * @hidden
  34829. */
  34830. _pos: number;
  34831. /**
  34832. * @hidden Index of this particle in the global "indices" array (Internal use)
  34833. */
  34834. _ind: number;
  34835. /**
  34836. * @hidden ModelShape of this particle (Internal use)
  34837. */
  34838. _model: ModelShape;
  34839. /**
  34840. * ModelShape id of this particle
  34841. */
  34842. shapeId: number;
  34843. /**
  34844. * Index of the particle in its shape id
  34845. */
  34846. idxInShape: number;
  34847. /**
  34848. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34849. */
  34850. _modelBoundingInfo: BoundingInfo;
  34851. /**
  34852. * @hidden Particle BoundingInfo object (Internal use)
  34853. */
  34854. _boundingInfo: BoundingInfo;
  34855. /**
  34856. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34857. */
  34858. _sps: SolidParticleSystem;
  34859. /**
  34860. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34861. */
  34862. _stillInvisible: boolean;
  34863. /**
  34864. * @hidden Last computed particle rotation matrix
  34865. */
  34866. _rotationMatrix: number[];
  34867. /**
  34868. * Parent particle Id, if any.
  34869. * Default null.
  34870. */
  34871. parentId: Nullable<number>;
  34872. /**
  34873. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34874. */
  34875. materialIndex: Nullable<number>;
  34876. /**
  34877. * Custom object or properties.
  34878. */
  34879. props: Nullable<any>;
  34880. /**
  34881. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34882. * The possible values are :
  34883. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34884. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34886. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34887. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34888. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34889. * */
  34890. cullingStrategy: number;
  34891. /**
  34892. * @hidden Internal global position in the SPS.
  34893. */
  34894. _globalPosition: Vector3;
  34895. /**
  34896. * Creates a Solid Particle object.
  34897. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34898. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34899. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34900. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34901. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34902. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34903. * @param shapeId (integer) is the model shape identifier in the SPS.
  34904. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34905. * @param sps defines the sps it is associated to
  34906. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34907. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34908. */
  34909. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34910. /**
  34911. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34912. * @param target the particle target
  34913. * @returns the current particle
  34914. */
  34915. copyToRef(target: SolidParticle): SolidParticle;
  34916. /**
  34917. * Legacy support, changed scale to scaling
  34918. */
  34919. get scale(): Vector3;
  34920. /**
  34921. * Legacy support, changed scale to scaling
  34922. */
  34923. set scale(scale: Vector3);
  34924. /**
  34925. * Legacy support, changed quaternion to rotationQuaternion
  34926. */
  34927. get quaternion(): Nullable<Quaternion>;
  34928. /**
  34929. * Legacy support, changed quaternion to rotationQuaternion
  34930. */
  34931. set quaternion(q: Nullable<Quaternion>);
  34932. /**
  34933. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34934. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34935. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34936. * @returns true if it intersects
  34937. */
  34938. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34939. /**
  34940. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34941. * A particle is in the frustum if its bounding box intersects the frustum
  34942. * @param frustumPlanes defines the frustum to test
  34943. * @returns true if the particle is in the frustum planes
  34944. */
  34945. isInFrustum(frustumPlanes: Plane[]): boolean;
  34946. /**
  34947. * get the rotation matrix of the particle
  34948. * @hidden
  34949. */
  34950. getRotationMatrix(m: Matrix): void;
  34951. }
  34952. /**
  34953. * Represents the shape of the model used by one particle of a solid particle system.
  34954. * SPS internal tool, don't use it manually.
  34955. */
  34956. export class ModelShape {
  34957. /**
  34958. * The shape id
  34959. * @hidden
  34960. */
  34961. shapeID: number;
  34962. /**
  34963. * flat array of model positions (internal use)
  34964. * @hidden
  34965. */
  34966. _shape: Vector3[];
  34967. /**
  34968. * flat array of model UVs (internal use)
  34969. * @hidden
  34970. */
  34971. _shapeUV: number[];
  34972. /**
  34973. * color array of the model
  34974. * @hidden
  34975. */
  34976. _shapeColors: number[];
  34977. /**
  34978. * indices array of the model
  34979. * @hidden
  34980. */
  34981. _indices: number[];
  34982. /**
  34983. * normals array of the model
  34984. * @hidden
  34985. */
  34986. _normals: number[];
  34987. /**
  34988. * length of the shape in the model indices array (internal use)
  34989. * @hidden
  34990. */
  34991. _indicesLength: number;
  34992. /**
  34993. * Custom position function (internal use)
  34994. * @hidden
  34995. */
  34996. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34997. /**
  34998. * Custom vertex function (internal use)
  34999. * @hidden
  35000. */
  35001. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35002. /**
  35003. * Model material (internal use)
  35004. * @hidden
  35005. */
  35006. _material: Nullable<Material>;
  35007. /**
  35008. * 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.
  35009. * SPS internal tool, don't use it manually.
  35010. * @hidden
  35011. */
  35012. 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>);
  35013. }
  35014. /**
  35015. * Represents a Depth Sorted Particle in the solid particle system.
  35016. * @hidden
  35017. */
  35018. export class DepthSortedParticle {
  35019. /**
  35020. * Particle index
  35021. */
  35022. idx: number;
  35023. /**
  35024. * Index of the particle in the "indices" array
  35025. */
  35026. ind: number;
  35027. /**
  35028. * Length of the particle shape in the "indices" array
  35029. */
  35030. indicesLength: number;
  35031. /**
  35032. * Squared distance from the particle to the camera
  35033. */
  35034. sqDistance: number;
  35035. /**
  35036. * Material index when used with MultiMaterials
  35037. */
  35038. materialIndex: number;
  35039. /**
  35040. * Creates a new sorted particle
  35041. * @param materialIndex
  35042. */
  35043. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35044. }
  35045. /**
  35046. * Represents a solid particle vertex
  35047. */
  35048. export class SolidParticleVertex {
  35049. /**
  35050. * Vertex position
  35051. */
  35052. position: Vector3;
  35053. /**
  35054. * Vertex color
  35055. */
  35056. color: Color4;
  35057. /**
  35058. * Vertex UV
  35059. */
  35060. uv: Vector2;
  35061. /**
  35062. * Creates a new solid particle vertex
  35063. */
  35064. constructor();
  35065. /** Vertex x coordinate */
  35066. get x(): number;
  35067. set x(val: number);
  35068. /** Vertex y coordinate */
  35069. get y(): number;
  35070. set y(val: number);
  35071. /** Vertex z coordinate */
  35072. get z(): number;
  35073. set z(val: number);
  35074. }
  35075. }
  35076. declare module BABYLON {
  35077. /**
  35078. * @hidden
  35079. */
  35080. export class _MeshCollisionData {
  35081. _checkCollisions: boolean;
  35082. _collisionMask: number;
  35083. _collisionGroup: number;
  35084. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35085. _collider: Nullable<Collider>;
  35086. _oldPositionForCollisions: Vector3;
  35087. _diffPositionForCollisions: Vector3;
  35088. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35089. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35090. _collisionResponse: boolean;
  35091. }
  35092. }
  35093. declare module BABYLON {
  35094. /** @hidden */
  35095. class _FacetDataStorage {
  35096. facetPositions: Vector3[];
  35097. facetNormals: Vector3[];
  35098. facetPartitioning: number[][];
  35099. facetNb: number;
  35100. partitioningSubdivisions: number;
  35101. partitioningBBoxRatio: number;
  35102. facetDataEnabled: boolean;
  35103. facetParameters: any;
  35104. bbSize: Vector3;
  35105. subDiv: {
  35106. max: number;
  35107. X: number;
  35108. Y: number;
  35109. Z: number;
  35110. };
  35111. facetDepthSort: boolean;
  35112. facetDepthSortEnabled: boolean;
  35113. depthSortedIndices: IndicesArray;
  35114. depthSortedFacets: {
  35115. ind: number;
  35116. sqDistance: number;
  35117. }[];
  35118. facetDepthSortFunction: (f1: {
  35119. ind: number;
  35120. sqDistance: number;
  35121. }, f2: {
  35122. ind: number;
  35123. sqDistance: number;
  35124. }) => number;
  35125. facetDepthSortFrom: Vector3;
  35126. facetDepthSortOrigin: Vector3;
  35127. invertedMatrix: Matrix;
  35128. }
  35129. /**
  35130. * @hidden
  35131. **/
  35132. class _InternalAbstractMeshDataInfo {
  35133. _hasVertexAlpha: boolean;
  35134. _useVertexColors: boolean;
  35135. _numBoneInfluencers: number;
  35136. _applyFog: boolean;
  35137. _receiveShadows: boolean;
  35138. _facetData: _FacetDataStorage;
  35139. _visibility: number;
  35140. _skeleton: Nullable<Skeleton>;
  35141. _layerMask: number;
  35142. _computeBonesUsingShaders: boolean;
  35143. _isActive: boolean;
  35144. _onlyForInstances: boolean;
  35145. _isActiveIntermediate: boolean;
  35146. _onlyForInstancesIntermediate: boolean;
  35147. _actAsRegularMesh: boolean;
  35148. _currentLOD: Nullable<AbstractMesh>;
  35149. _currentLODIsUpToDate: boolean;
  35150. }
  35151. /**
  35152. * Class used to store all common mesh properties
  35153. */
  35154. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35155. /** No occlusion */
  35156. static OCCLUSION_TYPE_NONE: number;
  35157. /** Occlusion set to optimisitic */
  35158. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35159. /** Occlusion set to strict */
  35160. static OCCLUSION_TYPE_STRICT: number;
  35161. /** Use an accurante occlusion algorithm */
  35162. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35163. /** Use a conservative occlusion algorithm */
  35164. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35165. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35166. * Test order :
  35167. * Is the bounding sphere outside the frustum ?
  35168. * If not, are the bounding box vertices outside the frustum ?
  35169. * It not, then the cullable object is in the frustum.
  35170. */
  35171. static readonly CULLINGSTRATEGY_STANDARD: number;
  35172. /** Culling strategy : Bounding Sphere Only.
  35173. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35174. * It's also less accurate than the standard because some not visible objects can still be selected.
  35175. * Test : is the bounding sphere outside the frustum ?
  35176. * If not, then the cullable object is in the frustum.
  35177. */
  35178. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35179. /** Culling strategy : Optimistic Inclusion.
  35180. * This in an inclusion test first, then the standard exclusion test.
  35181. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35182. * 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.
  35183. * Anyway, it's as accurate as the standard strategy.
  35184. * Test :
  35185. * Is the cullable object bounding sphere center in the frustum ?
  35186. * If not, apply the default culling strategy.
  35187. */
  35188. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35189. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35190. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35191. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35192. * 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.
  35193. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35194. * Test :
  35195. * Is the cullable object bounding sphere center in the frustum ?
  35196. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35197. */
  35198. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35199. /**
  35200. * No billboard
  35201. */
  35202. static get BILLBOARDMODE_NONE(): number;
  35203. /** Billboard on X axis */
  35204. static get BILLBOARDMODE_X(): number;
  35205. /** Billboard on Y axis */
  35206. static get BILLBOARDMODE_Y(): number;
  35207. /** Billboard on Z axis */
  35208. static get BILLBOARDMODE_Z(): number;
  35209. /** Billboard on all axes */
  35210. static get BILLBOARDMODE_ALL(): number;
  35211. /** Billboard on using position instead of orientation */
  35212. static get BILLBOARDMODE_USE_POSITION(): number;
  35213. /** @hidden */
  35214. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35215. /**
  35216. * The culling strategy to use to check whether the mesh must be rendered or not.
  35217. * This value can be changed at any time and will be used on the next render mesh selection.
  35218. * The possible values are :
  35219. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35220. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35222. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35223. * Please read each static variable documentation to get details about the culling process.
  35224. * */
  35225. cullingStrategy: number;
  35226. /**
  35227. * Gets the number of facets in the mesh
  35228. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35229. */
  35230. get facetNb(): number;
  35231. /**
  35232. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35233. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35234. */
  35235. get partitioningSubdivisions(): number;
  35236. set partitioningSubdivisions(nb: number);
  35237. /**
  35238. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35239. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35240. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35241. */
  35242. get partitioningBBoxRatio(): number;
  35243. set partitioningBBoxRatio(ratio: number);
  35244. /**
  35245. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35246. * Works only for updatable meshes.
  35247. * Doesn't work with multi-materials
  35248. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35249. */
  35250. get mustDepthSortFacets(): boolean;
  35251. set mustDepthSortFacets(sort: boolean);
  35252. /**
  35253. * The location (Vector3) where the facet depth sort must be computed from.
  35254. * By default, the active camera position.
  35255. * Used only when facet depth sort is enabled
  35256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35257. */
  35258. get facetDepthSortFrom(): Vector3;
  35259. set facetDepthSortFrom(location: Vector3);
  35260. /**
  35261. * gets a boolean indicating if facetData is enabled
  35262. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35263. */
  35264. get isFacetDataEnabled(): boolean;
  35265. /** @hidden */
  35266. _updateNonUniformScalingState(value: boolean): boolean;
  35267. /**
  35268. * An event triggered when this mesh collides with another one
  35269. */
  35270. onCollideObservable: Observable<AbstractMesh>;
  35271. /** Set a function to call when this mesh collides with another one */
  35272. set onCollide(callback: () => void);
  35273. /**
  35274. * An event triggered when the collision's position changes
  35275. */
  35276. onCollisionPositionChangeObservable: Observable<Vector3>;
  35277. /** Set a function to call when the collision's position changes */
  35278. set onCollisionPositionChange(callback: () => void);
  35279. /**
  35280. * An event triggered when material is changed
  35281. */
  35282. onMaterialChangedObservable: Observable<AbstractMesh>;
  35283. /**
  35284. * Gets or sets the orientation for POV movement & rotation
  35285. */
  35286. definedFacingForward: boolean;
  35287. /** @hidden */
  35288. _occlusionQuery: Nullable<WebGLQuery>;
  35289. /** @hidden */
  35290. _renderingGroup: Nullable<RenderingGroup>;
  35291. /**
  35292. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35293. */
  35294. get visibility(): number;
  35295. /**
  35296. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35297. */
  35298. set visibility(value: number);
  35299. /** Gets or sets the alpha index used to sort transparent meshes
  35300. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35301. */
  35302. alphaIndex: number;
  35303. /**
  35304. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35305. */
  35306. isVisible: boolean;
  35307. /**
  35308. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35309. */
  35310. isPickable: boolean;
  35311. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35312. showSubMeshesBoundingBox: boolean;
  35313. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35314. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35315. */
  35316. isBlocker: boolean;
  35317. /**
  35318. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35319. */
  35320. enablePointerMoveEvents: boolean;
  35321. private _renderingGroupId;
  35322. /**
  35323. * Specifies the rendering group id for this mesh (0 by default)
  35324. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35325. */
  35326. get renderingGroupId(): number;
  35327. set renderingGroupId(value: number);
  35328. private _material;
  35329. /** Gets or sets current material */
  35330. get material(): Nullable<Material>;
  35331. set material(value: Nullable<Material>);
  35332. /**
  35333. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35334. * @see https://doc.babylonjs.com/babylon101/shadows
  35335. */
  35336. get receiveShadows(): boolean;
  35337. set receiveShadows(value: boolean);
  35338. /** Defines color to use when rendering outline */
  35339. outlineColor: Color3;
  35340. /** Define width to use when rendering outline */
  35341. outlineWidth: number;
  35342. /** Defines color to use when rendering overlay */
  35343. overlayColor: Color3;
  35344. /** Defines alpha to use when rendering overlay */
  35345. overlayAlpha: number;
  35346. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35347. get hasVertexAlpha(): boolean;
  35348. set hasVertexAlpha(value: boolean);
  35349. /** 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) */
  35350. get useVertexColors(): boolean;
  35351. set useVertexColors(value: boolean);
  35352. /**
  35353. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35354. */
  35355. get computeBonesUsingShaders(): boolean;
  35356. set computeBonesUsingShaders(value: boolean);
  35357. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35358. get numBoneInfluencers(): number;
  35359. set numBoneInfluencers(value: number);
  35360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35361. get applyFog(): boolean;
  35362. set applyFog(value: boolean);
  35363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35364. useOctreeForRenderingSelection: boolean;
  35365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35366. useOctreeForPicking: boolean;
  35367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35368. useOctreeForCollisions: boolean;
  35369. /**
  35370. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35371. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35372. */
  35373. get layerMask(): number;
  35374. set layerMask(value: number);
  35375. /**
  35376. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35377. */
  35378. alwaysSelectAsActiveMesh: boolean;
  35379. /**
  35380. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35381. */
  35382. doNotSyncBoundingInfo: boolean;
  35383. /**
  35384. * Gets or sets the current action manager
  35385. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35386. */
  35387. actionManager: Nullable<AbstractActionManager>;
  35388. private _meshCollisionData;
  35389. /**
  35390. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35391. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35392. */
  35393. ellipsoid: Vector3;
  35394. /**
  35395. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35396. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35397. */
  35398. ellipsoidOffset: Vector3;
  35399. /**
  35400. * Gets or sets a collision mask used to mask collisions (default is -1).
  35401. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35402. */
  35403. get collisionMask(): number;
  35404. set collisionMask(mask: number);
  35405. /**
  35406. * Gets or sets a collision response flag (default is true).
  35407. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35408. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35409. * to respond to the collision.
  35410. */
  35411. get collisionResponse(): boolean;
  35412. set collisionResponse(response: boolean);
  35413. /**
  35414. * Gets or sets the current collision group mask (-1 by default).
  35415. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35416. */
  35417. get collisionGroup(): number;
  35418. set collisionGroup(mask: number);
  35419. /**
  35420. * Gets or sets current surrounding meshes (null by default).
  35421. *
  35422. * By default collision detection is tested against every mesh in the scene.
  35423. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35424. * meshes will be tested for the collision.
  35425. *
  35426. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35427. */
  35428. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35429. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35430. /**
  35431. * Defines edge width used when edgesRenderer is enabled
  35432. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35433. */
  35434. edgesWidth: number;
  35435. /**
  35436. * Defines edge color used when edgesRenderer is enabled
  35437. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35438. */
  35439. edgesColor: Color4;
  35440. /** @hidden */
  35441. _edgesRenderer: Nullable<IEdgesRenderer>;
  35442. /** @hidden */
  35443. _masterMesh: Nullable<AbstractMesh>;
  35444. /** @hidden */
  35445. _boundingInfo: Nullable<BoundingInfo>;
  35446. /** @hidden */
  35447. _renderId: number;
  35448. /**
  35449. * Gets or sets the list of subMeshes
  35450. * @see https://doc.babylonjs.com/how_to/multi_materials
  35451. */
  35452. subMeshes: SubMesh[];
  35453. /** @hidden */
  35454. _intersectionsInProgress: AbstractMesh[];
  35455. /** @hidden */
  35456. _unIndexed: boolean;
  35457. /** @hidden */
  35458. _lightSources: Light[];
  35459. /** Gets the list of lights affecting that mesh */
  35460. get lightSources(): Light[];
  35461. /** @hidden */
  35462. get _positions(): Nullable<Vector3[]>;
  35463. /** @hidden */
  35464. _waitingData: {
  35465. lods: Nullable<any>;
  35466. actions: Nullable<any>;
  35467. freezeWorldMatrix: Nullable<boolean>;
  35468. };
  35469. /** @hidden */
  35470. _bonesTransformMatrices: Nullable<Float32Array>;
  35471. /** @hidden */
  35472. _transformMatrixTexture: Nullable<RawTexture>;
  35473. /**
  35474. * Gets or sets a skeleton to apply skining transformations
  35475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35476. */
  35477. set skeleton(value: Nullable<Skeleton>);
  35478. get skeleton(): Nullable<Skeleton>;
  35479. /**
  35480. * An event triggered when the mesh is rebuilt.
  35481. */
  35482. onRebuildObservable: Observable<AbstractMesh>;
  35483. /**
  35484. * Creates a new AbstractMesh
  35485. * @param name defines the name of the mesh
  35486. * @param scene defines the hosting scene
  35487. */
  35488. constructor(name: string, scene?: Nullable<Scene>);
  35489. /**
  35490. * Returns the string "AbstractMesh"
  35491. * @returns "AbstractMesh"
  35492. */
  35493. getClassName(): string;
  35494. /**
  35495. * Gets a string representation of the current mesh
  35496. * @param fullDetails defines a boolean indicating if full details must be included
  35497. * @returns a string representation of the current mesh
  35498. */
  35499. toString(fullDetails?: boolean): string;
  35500. /**
  35501. * @hidden
  35502. */
  35503. protected _getEffectiveParent(): Nullable<Node>;
  35504. /** @hidden */
  35505. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35506. /** @hidden */
  35507. _rebuild(): void;
  35508. /** @hidden */
  35509. _resyncLightSources(): void;
  35510. /** @hidden */
  35511. _resyncLightSource(light: Light): void;
  35512. /** @hidden */
  35513. _unBindEffect(): void;
  35514. /** @hidden */
  35515. _removeLightSource(light: Light, dispose: boolean): void;
  35516. private _markSubMeshesAsDirty;
  35517. /** @hidden */
  35518. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35519. /** @hidden */
  35520. _markSubMeshesAsAttributesDirty(): void;
  35521. /** @hidden */
  35522. _markSubMeshesAsMiscDirty(): void;
  35523. /**
  35524. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35525. */
  35526. get scaling(): Vector3;
  35527. set scaling(newScaling: Vector3);
  35528. /**
  35529. * Returns true if the mesh is blocked. Implemented by child classes
  35530. */
  35531. get isBlocked(): boolean;
  35532. /**
  35533. * Returns the mesh itself by default. Implemented by child classes
  35534. * @param camera defines the camera to use to pick the right LOD level
  35535. * @returns the currentAbstractMesh
  35536. */
  35537. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35538. /**
  35539. * Returns 0 by default. Implemented by child classes
  35540. * @returns an integer
  35541. */
  35542. getTotalVertices(): number;
  35543. /**
  35544. * Returns a positive integer : the total number of indices in this mesh geometry.
  35545. * @returns the numner of indices or zero if the mesh has no geometry.
  35546. */
  35547. getTotalIndices(): number;
  35548. /**
  35549. * Returns null by default. Implemented by child classes
  35550. * @returns null
  35551. */
  35552. getIndices(): Nullable<IndicesArray>;
  35553. /**
  35554. * Returns the array of the requested vertex data kind. Implemented by child classes
  35555. * @param kind defines the vertex data kind to use
  35556. * @returns null
  35557. */
  35558. getVerticesData(kind: string): Nullable<FloatArray>;
  35559. /**
  35560. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35561. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35562. * Note that a new underlying VertexBuffer object is created each call.
  35563. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35564. * @param kind defines vertex data kind:
  35565. * * VertexBuffer.PositionKind
  35566. * * VertexBuffer.UVKind
  35567. * * VertexBuffer.UV2Kind
  35568. * * VertexBuffer.UV3Kind
  35569. * * VertexBuffer.UV4Kind
  35570. * * VertexBuffer.UV5Kind
  35571. * * VertexBuffer.UV6Kind
  35572. * * VertexBuffer.ColorKind
  35573. * * VertexBuffer.MatricesIndicesKind
  35574. * * VertexBuffer.MatricesIndicesExtraKind
  35575. * * VertexBuffer.MatricesWeightsKind
  35576. * * VertexBuffer.MatricesWeightsExtraKind
  35577. * @param data defines the data source
  35578. * @param updatable defines if the data must be flagged as updatable (or static)
  35579. * @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
  35580. * @returns the current mesh
  35581. */
  35582. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35583. /**
  35584. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35585. * If the mesh has no geometry, it is simply returned as it is.
  35586. * @param kind defines vertex data kind:
  35587. * * VertexBuffer.PositionKind
  35588. * * VertexBuffer.UVKind
  35589. * * VertexBuffer.UV2Kind
  35590. * * VertexBuffer.UV3Kind
  35591. * * VertexBuffer.UV4Kind
  35592. * * VertexBuffer.UV5Kind
  35593. * * VertexBuffer.UV6Kind
  35594. * * VertexBuffer.ColorKind
  35595. * * VertexBuffer.MatricesIndicesKind
  35596. * * VertexBuffer.MatricesIndicesExtraKind
  35597. * * VertexBuffer.MatricesWeightsKind
  35598. * * VertexBuffer.MatricesWeightsExtraKind
  35599. * @param data defines the data source
  35600. * @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
  35601. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35602. * @returns the current mesh
  35603. */
  35604. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35605. /**
  35606. * Sets the mesh indices,
  35607. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35608. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35609. * @param totalVertices Defines the total number of vertices
  35610. * @returns the current mesh
  35611. */
  35612. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35613. /**
  35614. * Gets a boolean indicating if specific vertex data is present
  35615. * @param kind defines the vertex data kind to use
  35616. * @returns true is data kind is present
  35617. */
  35618. isVerticesDataPresent(kind: string): boolean;
  35619. /**
  35620. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35621. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35622. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35623. * @returns a BoundingInfo
  35624. */
  35625. getBoundingInfo(): BoundingInfo;
  35626. /**
  35627. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35628. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35629. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35630. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35631. * @returns the current mesh
  35632. */
  35633. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35634. /**
  35635. * Overwrite the current bounding info
  35636. * @param boundingInfo defines the new bounding info
  35637. * @returns the current mesh
  35638. */
  35639. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35640. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35641. get useBones(): boolean;
  35642. /** @hidden */
  35643. _preActivate(): void;
  35644. /** @hidden */
  35645. _preActivateForIntermediateRendering(renderId: number): void;
  35646. /** @hidden */
  35647. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35648. /** @hidden */
  35649. _postActivate(): void;
  35650. /** @hidden */
  35651. _freeze(): void;
  35652. /** @hidden */
  35653. _unFreeze(): void;
  35654. /**
  35655. * Gets the current world matrix
  35656. * @returns a Matrix
  35657. */
  35658. getWorldMatrix(): Matrix;
  35659. /** @hidden */
  35660. _getWorldMatrixDeterminant(): number;
  35661. /**
  35662. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35663. */
  35664. get isAnInstance(): boolean;
  35665. /**
  35666. * Gets a boolean indicating if this mesh has instances
  35667. */
  35668. get hasInstances(): boolean;
  35669. /**
  35670. * Gets a boolean indicating if this mesh has thin instances
  35671. */
  35672. get hasThinInstances(): boolean;
  35673. /**
  35674. * Perform relative position change from the point of view of behind the front of the mesh.
  35675. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35676. * Supports definition of mesh facing forward or backward
  35677. * @param amountRight defines the distance on the right axis
  35678. * @param amountUp defines the distance on the up axis
  35679. * @param amountForward defines the distance on the forward axis
  35680. * @returns the current mesh
  35681. */
  35682. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35683. /**
  35684. * Calculate relative position change from the point of view of behind the front of the mesh.
  35685. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35686. * Supports definition of mesh facing forward or backward
  35687. * @param amountRight defines the distance on the right axis
  35688. * @param amountUp defines the distance on the up axis
  35689. * @param amountForward defines the distance on the forward axis
  35690. * @returns the new displacement vector
  35691. */
  35692. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35693. /**
  35694. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35695. * Supports definition of mesh facing forward or backward
  35696. * @param flipBack defines the flip
  35697. * @param twirlClockwise defines the twirl
  35698. * @param tiltRight defines the tilt
  35699. * @returns the current mesh
  35700. */
  35701. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35702. /**
  35703. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35704. * Supports definition of mesh facing forward or backward.
  35705. * @param flipBack defines the flip
  35706. * @param twirlClockwise defines the twirl
  35707. * @param tiltRight defines the tilt
  35708. * @returns the new rotation vector
  35709. */
  35710. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35711. /**
  35712. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35713. * This means the mesh underlying bounding box and sphere are recomputed.
  35714. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35715. * @returns the current mesh
  35716. */
  35717. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35718. /** @hidden */
  35719. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35720. /** @hidden */
  35721. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35722. /** @hidden */
  35723. _updateBoundingInfo(): AbstractMesh;
  35724. /** @hidden */
  35725. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35726. /** @hidden */
  35727. protected _afterComputeWorldMatrix(): void;
  35728. /** @hidden */
  35729. get _effectiveMesh(): AbstractMesh;
  35730. /**
  35731. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35732. * A mesh is in the frustum if its bounding box intersects the frustum
  35733. * @param frustumPlanes defines the frustum to test
  35734. * @returns true if the mesh is in the frustum planes
  35735. */
  35736. isInFrustum(frustumPlanes: Plane[]): boolean;
  35737. /**
  35738. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35739. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35740. * @param frustumPlanes defines the frustum to test
  35741. * @returns true if the mesh is completely in the frustum planes
  35742. */
  35743. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35744. /**
  35745. * True if the mesh intersects another mesh or a SolidParticle object
  35746. * @param mesh defines a target mesh or SolidParticle to test
  35747. * @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)
  35748. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35749. * @returns true if there is an intersection
  35750. */
  35751. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35752. /**
  35753. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35754. * @param point defines the point to test
  35755. * @returns true if there is an intersection
  35756. */
  35757. intersectsPoint(point: Vector3): boolean;
  35758. /**
  35759. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35760. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35761. */
  35762. get checkCollisions(): boolean;
  35763. set checkCollisions(collisionEnabled: boolean);
  35764. /**
  35765. * Gets Collider object used to compute collisions (not physics)
  35766. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35767. */
  35768. get collider(): Nullable<Collider>;
  35769. /**
  35770. * Move the mesh using collision engine
  35771. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35772. * @param displacement defines the requested displacement vector
  35773. * @returns the current mesh
  35774. */
  35775. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35776. private _onCollisionPositionChange;
  35777. /** @hidden */
  35778. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35779. /** @hidden */
  35780. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35781. /** @hidden */
  35782. _checkCollision(collider: Collider): AbstractMesh;
  35783. /** @hidden */
  35784. _generatePointsArray(): boolean;
  35785. /**
  35786. * Checks if the passed Ray intersects with the mesh
  35787. * @param ray defines the ray to use
  35788. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35790. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35791. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35792. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35793. * @returns the picking info
  35794. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35795. */
  35796. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35797. /**
  35798. * Clones the current mesh
  35799. * @param name defines the mesh name
  35800. * @param newParent defines the new mesh parent
  35801. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35802. * @returns the new mesh
  35803. */
  35804. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35805. /**
  35806. * Disposes all the submeshes of the current meshnp
  35807. * @returns the current mesh
  35808. */
  35809. releaseSubMeshes(): AbstractMesh;
  35810. /**
  35811. * Releases resources associated with this abstract mesh.
  35812. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35813. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35814. */
  35815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35816. /**
  35817. * Adds the passed mesh as a child to the current mesh
  35818. * @param mesh defines the child mesh
  35819. * @returns the current mesh
  35820. */
  35821. addChild(mesh: AbstractMesh): AbstractMesh;
  35822. /**
  35823. * Removes the passed mesh from the current mesh children list
  35824. * @param mesh defines the child mesh
  35825. * @returns the current mesh
  35826. */
  35827. removeChild(mesh: AbstractMesh): AbstractMesh;
  35828. /** @hidden */
  35829. private _initFacetData;
  35830. /**
  35831. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35832. * This method can be called within the render loop.
  35833. * 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
  35834. * @returns the current mesh
  35835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35836. */
  35837. updateFacetData(): AbstractMesh;
  35838. /**
  35839. * Returns the facetLocalNormals array.
  35840. * The normals are expressed in the mesh local spac
  35841. * @returns an array of Vector3
  35842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35843. */
  35844. getFacetLocalNormals(): Vector3[];
  35845. /**
  35846. * Returns the facetLocalPositions array.
  35847. * The facet positions are expressed in the mesh local space
  35848. * @returns an array of Vector3
  35849. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35850. */
  35851. getFacetLocalPositions(): Vector3[];
  35852. /**
  35853. * Returns the facetLocalPartioning array
  35854. * @returns an array of array of numbers
  35855. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35856. */
  35857. getFacetLocalPartitioning(): number[][];
  35858. /**
  35859. * Returns the i-th facet position in the world system.
  35860. * This method allocates a new Vector3 per call
  35861. * @param i defines the facet index
  35862. * @returns a new Vector3
  35863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35864. */
  35865. getFacetPosition(i: number): Vector3;
  35866. /**
  35867. * Sets the reference Vector3 with the i-th facet position in the world system
  35868. * @param i defines the facet index
  35869. * @param ref defines the target vector
  35870. * @returns the current mesh
  35871. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35872. */
  35873. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35874. /**
  35875. * Returns the i-th facet normal in the world system.
  35876. * This method allocates a new Vector3 per call
  35877. * @param i defines the facet index
  35878. * @returns a new Vector3
  35879. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35880. */
  35881. getFacetNormal(i: number): Vector3;
  35882. /**
  35883. * Sets the reference Vector3 with the i-th facet normal in the world system
  35884. * @param i defines the facet index
  35885. * @param ref defines the target vector
  35886. * @returns the current mesh
  35887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35888. */
  35889. getFacetNormalToRef(i: number, ref: Vector3): this;
  35890. /**
  35891. * 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)
  35892. * @param x defines x coordinate
  35893. * @param y defines y coordinate
  35894. * @param z defines z coordinate
  35895. * @returns the array of facet indexes
  35896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35897. */
  35898. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35899. /**
  35900. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35901. * @param projected sets as the (x,y,z) world projection on the facet
  35902. * @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
  35903. * @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
  35904. * @param x defines x coordinate
  35905. * @param y defines y coordinate
  35906. * @param z defines z coordinate
  35907. * @returns the face index if found (or null instead)
  35908. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35909. */
  35910. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35911. /**
  35912. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35913. * @param projected sets as the (x,y,z) local projection on the facet
  35914. * @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
  35915. * @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
  35916. * @param x defines x coordinate
  35917. * @param y defines y coordinate
  35918. * @param z defines z coordinate
  35919. * @returns the face index if found (or null instead)
  35920. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35921. */
  35922. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35923. /**
  35924. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35925. * @returns the parameters
  35926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35927. */
  35928. getFacetDataParameters(): any;
  35929. /**
  35930. * Disables the feature FacetData and frees the related memory
  35931. * @returns the current mesh
  35932. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35933. */
  35934. disableFacetData(): AbstractMesh;
  35935. /**
  35936. * Updates the AbstractMesh indices array
  35937. * @param indices defines the data source
  35938. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35939. * @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)
  35940. * @returns the current mesh
  35941. */
  35942. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35943. /**
  35944. * Creates new normals data for the mesh
  35945. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35946. * @returns the current mesh
  35947. */
  35948. createNormals(updatable: boolean): AbstractMesh;
  35949. /**
  35950. * Align the mesh with a normal
  35951. * @param normal defines the normal to use
  35952. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35953. * @returns the current mesh
  35954. */
  35955. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35956. /** @hidden */
  35957. _checkOcclusionQuery(): boolean;
  35958. /**
  35959. * Disables the mesh edge rendering mode
  35960. * @returns the currentAbstractMesh
  35961. */
  35962. disableEdgesRendering(): AbstractMesh;
  35963. /**
  35964. * Enables the edge rendering mode on the mesh.
  35965. * This mode makes the mesh edges visible
  35966. * @param epsilon defines the maximal distance between two angles to detect a face
  35967. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35968. * @param options options to the edge renderer
  35969. * @returns the currentAbstractMesh
  35970. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35971. */
  35972. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35973. /**
  35974. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35975. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35976. */
  35977. getConnectedParticleSystems(): IParticleSystem[];
  35978. }
  35979. }
  35980. declare module BABYLON {
  35981. /**
  35982. * Interface used to define ActionEvent
  35983. */
  35984. export interface IActionEvent {
  35985. /** The mesh or sprite that triggered the action */
  35986. source: any;
  35987. /** The X mouse cursor position at the time of the event */
  35988. pointerX: number;
  35989. /** The Y mouse cursor position at the time of the event */
  35990. pointerY: number;
  35991. /** The mesh that is currently pointed at (can be null) */
  35992. meshUnderPointer: Nullable<AbstractMesh>;
  35993. /** the original (browser) event that triggered the ActionEvent */
  35994. sourceEvent?: any;
  35995. /** additional data for the event */
  35996. additionalData?: any;
  35997. }
  35998. /**
  35999. * ActionEvent is the event being sent when an action is triggered.
  36000. */
  36001. export class ActionEvent implements IActionEvent {
  36002. /** The mesh or sprite that triggered the action */
  36003. source: any;
  36004. /** The X mouse cursor position at the time of the event */
  36005. pointerX: number;
  36006. /** The Y mouse cursor position at the time of the event */
  36007. pointerY: number;
  36008. /** The mesh that is currently pointed at (can be null) */
  36009. meshUnderPointer: Nullable<AbstractMesh>;
  36010. /** the original (browser) event that triggered the ActionEvent */
  36011. sourceEvent?: any;
  36012. /** additional data for the event */
  36013. additionalData?: any;
  36014. /**
  36015. * Creates a new ActionEvent
  36016. * @param source The mesh or sprite that triggered the action
  36017. * @param pointerX The X mouse cursor position at the time of the event
  36018. * @param pointerY The Y mouse cursor position at the time of the event
  36019. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36020. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36021. * @param additionalData additional data for the event
  36022. */
  36023. constructor(
  36024. /** The mesh or sprite that triggered the action */
  36025. source: any,
  36026. /** The X mouse cursor position at the time of the event */
  36027. pointerX: number,
  36028. /** The Y mouse cursor position at the time of the event */
  36029. pointerY: number,
  36030. /** The mesh that is currently pointed at (can be null) */
  36031. meshUnderPointer: Nullable<AbstractMesh>,
  36032. /** the original (browser) event that triggered the ActionEvent */
  36033. sourceEvent?: any,
  36034. /** additional data for the event */
  36035. additionalData?: any);
  36036. /**
  36037. * Helper function to auto-create an ActionEvent from a source mesh.
  36038. * @param source The source mesh that triggered the event
  36039. * @param evt The original (browser) event
  36040. * @param additionalData additional data for the event
  36041. * @returns the new ActionEvent
  36042. */
  36043. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36044. /**
  36045. * Helper function to auto-create an ActionEvent from a source sprite
  36046. * @param source The source sprite that triggered the event
  36047. * @param scene Scene associated with the sprite
  36048. * @param evt The original (browser) event
  36049. * @param additionalData additional data for the event
  36050. * @returns the new ActionEvent
  36051. */
  36052. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36053. /**
  36054. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36055. * @param scene the scene where the event occurred
  36056. * @param evt The original (browser) event
  36057. * @returns the new ActionEvent
  36058. */
  36059. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36060. /**
  36061. * Helper function to auto-create an ActionEvent from a primitive
  36062. * @param prim defines the target primitive
  36063. * @param pointerPos defines the pointer position
  36064. * @param evt The original (browser) event
  36065. * @param additionalData additional data for the event
  36066. * @returns the new ActionEvent
  36067. */
  36068. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36069. }
  36070. }
  36071. declare module BABYLON {
  36072. /**
  36073. * Abstract class used to decouple action Manager from scene and meshes.
  36074. * Do not instantiate.
  36075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36076. */
  36077. export abstract class AbstractActionManager implements IDisposable {
  36078. /** Gets the list of active triggers */
  36079. static Triggers: {
  36080. [key: string]: number;
  36081. };
  36082. /** Gets the cursor to use when hovering items */
  36083. hoverCursor: string;
  36084. /** Gets the list of actions */
  36085. actions: IAction[];
  36086. /**
  36087. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36088. */
  36089. isRecursive: boolean;
  36090. /**
  36091. * Releases all associated resources
  36092. */
  36093. abstract dispose(): void;
  36094. /**
  36095. * Does this action manager has pointer triggers
  36096. */
  36097. abstract get hasPointerTriggers(): boolean;
  36098. /**
  36099. * Does this action manager has pick triggers
  36100. */
  36101. abstract get hasPickTriggers(): boolean;
  36102. /**
  36103. * Process a specific trigger
  36104. * @param trigger defines the trigger to process
  36105. * @param evt defines the event details to be processed
  36106. */
  36107. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36108. /**
  36109. * Does this action manager handles actions of any of the given triggers
  36110. * @param triggers defines the triggers to be tested
  36111. * @return a boolean indicating whether one (or more) of the triggers is handled
  36112. */
  36113. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36114. /**
  36115. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36116. * speed.
  36117. * @param triggerA defines the trigger to be tested
  36118. * @param triggerB defines the trigger to be tested
  36119. * @return a boolean indicating whether one (or more) of the triggers is handled
  36120. */
  36121. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36122. /**
  36123. * Does this action manager handles actions of a given trigger
  36124. * @param trigger defines the trigger to be tested
  36125. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36126. * @return whether the trigger is handled
  36127. */
  36128. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36129. /**
  36130. * Serialize this manager to a JSON object
  36131. * @param name defines the property name to store this manager
  36132. * @returns a JSON representation of this manager
  36133. */
  36134. abstract serialize(name: string): any;
  36135. /**
  36136. * Registers an action to this action manager
  36137. * @param action defines the action to be registered
  36138. * @return the action amended (prepared) after registration
  36139. */
  36140. abstract registerAction(action: IAction): Nullable<IAction>;
  36141. /**
  36142. * Unregisters an action to this action manager
  36143. * @param action defines the action to be unregistered
  36144. * @return a boolean indicating whether the action has been unregistered
  36145. */
  36146. abstract unregisterAction(action: IAction): Boolean;
  36147. /**
  36148. * Does exist one action manager with at least one trigger
  36149. **/
  36150. static get HasTriggers(): boolean;
  36151. /**
  36152. * Does exist one action manager with at least one pick trigger
  36153. **/
  36154. static get HasPickTriggers(): boolean;
  36155. /**
  36156. * Does exist one action manager that handles actions of a given trigger
  36157. * @param trigger defines the trigger to be tested
  36158. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36159. **/
  36160. static HasSpecificTrigger(trigger: number): boolean;
  36161. }
  36162. }
  36163. declare module BABYLON {
  36164. /**
  36165. * Defines how a node can be built from a string name.
  36166. */
  36167. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36168. /**
  36169. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36170. */
  36171. export class Node implements IBehaviorAware<Node> {
  36172. /** @hidden */
  36173. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36174. private static _NodeConstructors;
  36175. /**
  36176. * Add a new node constructor
  36177. * @param type defines the type name of the node to construct
  36178. * @param constructorFunc defines the constructor function
  36179. */
  36180. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36181. /**
  36182. * Returns a node constructor based on type name
  36183. * @param type defines the type name
  36184. * @param name defines the new node name
  36185. * @param scene defines the hosting scene
  36186. * @param options defines optional options to transmit to constructors
  36187. * @returns the new constructor or null
  36188. */
  36189. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36190. /**
  36191. * Gets or sets the name of the node
  36192. */
  36193. name: string;
  36194. /**
  36195. * Gets or sets the id of the node
  36196. */
  36197. id: string;
  36198. /**
  36199. * Gets or sets the unique id of the node
  36200. */
  36201. uniqueId: number;
  36202. /**
  36203. * Gets or sets a string used to store user defined state for the node
  36204. */
  36205. state: string;
  36206. /**
  36207. * Gets or sets an object used to store user defined information for the node
  36208. */
  36209. metadata: any;
  36210. /**
  36211. * For internal use only. Please do not use.
  36212. */
  36213. reservedDataStore: any;
  36214. /**
  36215. * List of inspectable custom properties (used by the Inspector)
  36216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36217. */
  36218. inspectableCustomProperties: IInspectable[];
  36219. private _doNotSerialize;
  36220. /**
  36221. * Gets or sets a boolean used to define if the node must be serialized
  36222. */
  36223. get doNotSerialize(): boolean;
  36224. set doNotSerialize(value: boolean);
  36225. /** @hidden */
  36226. _isDisposed: boolean;
  36227. /**
  36228. * Gets a list of Animations associated with the node
  36229. */
  36230. animations: Animation[];
  36231. protected _ranges: {
  36232. [name: string]: Nullable<AnimationRange>;
  36233. };
  36234. /**
  36235. * Callback raised when the node is ready to be used
  36236. */
  36237. onReady: Nullable<(node: Node) => void>;
  36238. private _isEnabled;
  36239. private _isParentEnabled;
  36240. private _isReady;
  36241. /** @hidden */
  36242. _currentRenderId: number;
  36243. private _parentUpdateId;
  36244. /** @hidden */
  36245. _childUpdateId: number;
  36246. /** @hidden */
  36247. _waitingParentId: Nullable<string>;
  36248. /** @hidden */
  36249. _scene: Scene;
  36250. /** @hidden */
  36251. _cache: any;
  36252. private _parentNode;
  36253. private _children;
  36254. /** @hidden */
  36255. _worldMatrix: Matrix;
  36256. /** @hidden */
  36257. _worldMatrixDeterminant: number;
  36258. /** @hidden */
  36259. _worldMatrixDeterminantIsDirty: boolean;
  36260. /** @hidden */
  36261. private _sceneRootNodesIndex;
  36262. /**
  36263. * Gets a boolean indicating if the node has been disposed
  36264. * @returns true if the node was disposed
  36265. */
  36266. isDisposed(): boolean;
  36267. /**
  36268. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36269. * @see https://doc.babylonjs.com/how_to/parenting
  36270. */
  36271. set parent(parent: Nullable<Node>);
  36272. get parent(): Nullable<Node>;
  36273. /** @hidden */
  36274. _addToSceneRootNodes(): void;
  36275. /** @hidden */
  36276. _removeFromSceneRootNodes(): void;
  36277. private _animationPropertiesOverride;
  36278. /**
  36279. * Gets or sets the animation properties override
  36280. */
  36281. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36282. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36283. /**
  36284. * Gets a string identifying the name of the class
  36285. * @returns "Node" string
  36286. */
  36287. getClassName(): string;
  36288. /** @hidden */
  36289. readonly _isNode: boolean;
  36290. /**
  36291. * An event triggered when the mesh is disposed
  36292. */
  36293. onDisposeObservable: Observable<Node>;
  36294. private _onDisposeObserver;
  36295. /**
  36296. * Sets a callback that will be raised when the node will be disposed
  36297. */
  36298. set onDispose(callback: () => void);
  36299. /**
  36300. * Creates a new Node
  36301. * @param name the name and id to be given to this node
  36302. * @param scene the scene this node will be added to
  36303. */
  36304. constructor(name: string, scene?: Nullable<Scene>);
  36305. /**
  36306. * Gets the scene of the node
  36307. * @returns a scene
  36308. */
  36309. getScene(): Scene;
  36310. /**
  36311. * Gets the engine of the node
  36312. * @returns a Engine
  36313. */
  36314. getEngine(): Engine;
  36315. private _behaviors;
  36316. /**
  36317. * Attach a behavior to the node
  36318. * @see https://doc.babylonjs.com/features/behaviour
  36319. * @param behavior defines the behavior to attach
  36320. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36321. * @returns the current Node
  36322. */
  36323. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36324. /**
  36325. * Remove an attached behavior
  36326. * @see https://doc.babylonjs.com/features/behaviour
  36327. * @param behavior defines the behavior to attach
  36328. * @returns the current Node
  36329. */
  36330. removeBehavior(behavior: Behavior<Node>): Node;
  36331. /**
  36332. * Gets the list of attached behaviors
  36333. * @see https://doc.babylonjs.com/features/behaviour
  36334. */
  36335. get behaviors(): Behavior<Node>[];
  36336. /**
  36337. * Gets an attached behavior by name
  36338. * @param name defines the name of the behavior to look for
  36339. * @see https://doc.babylonjs.com/features/behaviour
  36340. * @returns null if behavior was not found else the requested behavior
  36341. */
  36342. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36343. /**
  36344. * Returns the latest update of the World matrix
  36345. * @returns a Matrix
  36346. */
  36347. getWorldMatrix(): Matrix;
  36348. /** @hidden */
  36349. _getWorldMatrixDeterminant(): number;
  36350. /**
  36351. * Returns directly the latest state of the mesh World matrix.
  36352. * A Matrix is returned.
  36353. */
  36354. get worldMatrixFromCache(): Matrix;
  36355. /** @hidden */
  36356. _initCache(): void;
  36357. /** @hidden */
  36358. updateCache(force?: boolean): void;
  36359. /** @hidden */
  36360. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36361. /** @hidden */
  36362. _updateCache(ignoreParentClass?: boolean): void;
  36363. /** @hidden */
  36364. _isSynchronized(): boolean;
  36365. /** @hidden */
  36366. _markSyncedWithParent(): void;
  36367. /** @hidden */
  36368. isSynchronizedWithParent(): boolean;
  36369. /** @hidden */
  36370. isSynchronized(): boolean;
  36371. /**
  36372. * Is this node ready to be used/rendered
  36373. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36374. * @return true if the node is ready
  36375. */
  36376. isReady(completeCheck?: boolean): boolean;
  36377. /**
  36378. * Is this node enabled?
  36379. * 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
  36380. * @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
  36381. * @return whether this node (and its parent) is enabled
  36382. */
  36383. isEnabled(checkAncestors?: boolean): boolean;
  36384. /** @hidden */
  36385. protected _syncParentEnabledState(): void;
  36386. /**
  36387. * Set the enabled state of this node
  36388. * @param value defines the new enabled state
  36389. */
  36390. setEnabled(value: boolean): void;
  36391. /**
  36392. * Is this node a descendant of the given node?
  36393. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36394. * @param ancestor defines the parent node to inspect
  36395. * @returns a boolean indicating if this node is a descendant of the given node
  36396. */
  36397. isDescendantOf(ancestor: Node): boolean;
  36398. /** @hidden */
  36399. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36400. /**
  36401. * Will return all nodes that have this node as ascendant
  36402. * @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
  36403. * @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
  36404. * @return all children nodes of all types
  36405. */
  36406. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36407. /**
  36408. * Get all child-meshes of this node
  36409. * @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)
  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. * @returns an array of AbstractMesh
  36412. */
  36413. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36414. /**
  36415. * Get all direct children of this node
  36416. * @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
  36417. * @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)
  36418. * @returns an array of Node
  36419. */
  36420. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36421. /** @hidden */
  36422. _setReady(state: boolean): void;
  36423. /**
  36424. * Get an animation by name
  36425. * @param name defines the name of the animation to look for
  36426. * @returns null if not found else the requested animation
  36427. */
  36428. getAnimationByName(name: string): Nullable<Animation>;
  36429. /**
  36430. * Creates an animation range for this node
  36431. * @param name defines the name of the range
  36432. * @param from defines the starting key
  36433. * @param to defines the end key
  36434. */
  36435. createAnimationRange(name: string, from: number, to: number): void;
  36436. /**
  36437. * Delete a specific animation range
  36438. * @param name defines the name of the range to delete
  36439. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36440. */
  36441. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36442. /**
  36443. * Get an animation range by name
  36444. * @param name defines the name of the animation range to look for
  36445. * @returns null if not found else the requested animation range
  36446. */
  36447. getAnimationRange(name: string): Nullable<AnimationRange>;
  36448. /**
  36449. * Gets the list of all animation ranges defined on this node
  36450. * @returns an array
  36451. */
  36452. getAnimationRanges(): Nullable<AnimationRange>[];
  36453. /**
  36454. * Will start the animation sequence
  36455. * @param name defines the range frames for animation sequence
  36456. * @param loop defines if the animation should loop (false by default)
  36457. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36458. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36459. * @returns the object created for this animation. If range does not exist, it will return null
  36460. */
  36461. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36462. /**
  36463. * Serialize animation ranges into a JSON compatible object
  36464. * @returns serialization object
  36465. */
  36466. serializeAnimationRanges(): any;
  36467. /**
  36468. * Computes the world matrix of the node
  36469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36470. * @returns the world matrix
  36471. */
  36472. computeWorldMatrix(force?: boolean): Matrix;
  36473. /**
  36474. * Releases resources associated with this node.
  36475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36477. */
  36478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36479. /**
  36480. * Parse animation range data from a serialization object and store them into a given node
  36481. * @param node defines where to store the animation ranges
  36482. * @param parsedNode defines the serialization object to read data from
  36483. * @param scene defines the hosting scene
  36484. */
  36485. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36486. /**
  36487. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36488. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36489. * @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
  36490. * @returns the new bounding vectors
  36491. */
  36492. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36493. min: Vector3;
  36494. max: Vector3;
  36495. };
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. /**
  36500. * @hidden
  36501. */
  36502. export class _IAnimationState {
  36503. key: number;
  36504. repeatCount: number;
  36505. workValue?: any;
  36506. loopMode?: number;
  36507. offsetValue?: any;
  36508. highLimitValue?: any;
  36509. }
  36510. /**
  36511. * Class used to store any kind of animation
  36512. */
  36513. export class Animation {
  36514. /**Name of the animation */
  36515. name: string;
  36516. /**Property to animate */
  36517. targetProperty: string;
  36518. /**The frames per second of the animation */
  36519. framePerSecond: number;
  36520. /**The data type of the animation */
  36521. dataType: number;
  36522. /**The loop mode of the animation */
  36523. loopMode?: number | undefined;
  36524. /**Specifies if blending should be enabled */
  36525. enableBlending?: boolean | undefined;
  36526. /**
  36527. * Use matrix interpolation instead of using direct key value when animating matrices
  36528. */
  36529. static AllowMatricesInterpolation: boolean;
  36530. /**
  36531. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36532. */
  36533. static AllowMatrixDecomposeForInterpolation: boolean;
  36534. /** Define the Url to load snippets */
  36535. static SnippetUrl: string;
  36536. /** Snippet ID if the animation was created from the snippet server */
  36537. snippetId: string;
  36538. /**
  36539. * Stores the key frames of the animation
  36540. */
  36541. private _keys;
  36542. /**
  36543. * Stores the easing function of the animation
  36544. */
  36545. private _easingFunction;
  36546. /**
  36547. * @hidden Internal use only
  36548. */
  36549. _runtimeAnimations: RuntimeAnimation[];
  36550. /**
  36551. * The set of event that will be linked to this animation
  36552. */
  36553. private _events;
  36554. /**
  36555. * Stores an array of target property paths
  36556. */
  36557. targetPropertyPath: string[];
  36558. /**
  36559. * Stores the blending speed of the animation
  36560. */
  36561. blendingSpeed: number;
  36562. /**
  36563. * Stores the animation ranges for the animation
  36564. */
  36565. private _ranges;
  36566. /**
  36567. * @hidden Internal use
  36568. */
  36569. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36570. /**
  36571. * Sets up an animation
  36572. * @param property The property to animate
  36573. * @param animationType The animation type to apply
  36574. * @param framePerSecond The frames per second of the animation
  36575. * @param easingFunction The easing function used in the animation
  36576. * @returns The created animation
  36577. */
  36578. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36579. /**
  36580. * Create and start an animation on a node
  36581. * @param name defines the name of the global animation that will be run on all nodes
  36582. * @param node defines the root node where the animation will take place
  36583. * @param targetProperty defines property to animate
  36584. * @param framePerSecond defines the number of frame per second yo use
  36585. * @param totalFrame defines the number of frames in total
  36586. * @param from defines the initial value
  36587. * @param to defines the final value
  36588. * @param loopMode defines which loop mode you want to use (off by default)
  36589. * @param easingFunction defines the easing function to use (linear by default)
  36590. * @param onAnimationEnd defines the callback to call when animation end
  36591. * @returns the animatable created for this animation
  36592. */
  36593. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36594. /**
  36595. * Create and start an animation on a node and its descendants
  36596. * @param name defines the name of the global animation that will be run on all nodes
  36597. * @param node defines the root node where the animation will take place
  36598. * @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
  36599. * @param targetProperty defines property to animate
  36600. * @param framePerSecond defines the number of frame per second to use
  36601. * @param totalFrame defines the number of frames in total
  36602. * @param from defines the initial value
  36603. * @param to defines the final value
  36604. * @param loopMode defines which loop mode you want to use (off by default)
  36605. * @param easingFunction defines the easing function to use (linear by default)
  36606. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36607. * @returns the list of animatables created for all nodes
  36608. * @example https://www.babylonjs-playground.com/#MH0VLI
  36609. */
  36610. 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[]>;
  36611. /**
  36612. * Creates a new animation, merges it with the existing animations and starts it
  36613. * @param name Name of the animation
  36614. * @param node Node which contains the scene that begins the animations
  36615. * @param targetProperty Specifies which property to animate
  36616. * @param framePerSecond The frames per second of the animation
  36617. * @param totalFrame The total number of frames
  36618. * @param from The frame at the beginning of the animation
  36619. * @param to The frame at the end of the animation
  36620. * @param loopMode Specifies the loop mode of the animation
  36621. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36622. * @param onAnimationEnd Callback to run once the animation is complete
  36623. * @returns Nullable animation
  36624. */
  36625. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36626. /**
  36627. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36628. * @param sourceAnimation defines the Animation containing keyframes to convert
  36629. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36630. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36631. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36632. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36633. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36634. */
  36635. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36636. /**
  36637. * Transition property of an host to the target Value
  36638. * @param property The property to transition
  36639. * @param targetValue The target Value of the property
  36640. * @param host The object where the property to animate belongs
  36641. * @param scene Scene used to run the animation
  36642. * @param frameRate Framerate (in frame/s) to use
  36643. * @param transition The transition type we want to use
  36644. * @param duration The duration of the animation, in milliseconds
  36645. * @param onAnimationEnd Callback trigger at the end of the animation
  36646. * @returns Nullable animation
  36647. */
  36648. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36649. /**
  36650. * Return the array of runtime animations currently using this animation
  36651. */
  36652. get runtimeAnimations(): RuntimeAnimation[];
  36653. /**
  36654. * Specifies if any of the runtime animations are currently running
  36655. */
  36656. get hasRunningRuntimeAnimations(): boolean;
  36657. /**
  36658. * Initializes the animation
  36659. * @param name Name of the animation
  36660. * @param targetProperty Property to animate
  36661. * @param framePerSecond The frames per second of the animation
  36662. * @param dataType The data type of the animation
  36663. * @param loopMode The loop mode of the animation
  36664. * @param enableBlending Specifies if blending should be enabled
  36665. */
  36666. constructor(
  36667. /**Name of the animation */
  36668. name: string,
  36669. /**Property to animate */
  36670. targetProperty: string,
  36671. /**The frames per second of the animation */
  36672. framePerSecond: number,
  36673. /**The data type of the animation */
  36674. dataType: number,
  36675. /**The loop mode of the animation */
  36676. loopMode?: number | undefined,
  36677. /**Specifies if blending should be enabled */
  36678. enableBlending?: boolean | undefined);
  36679. /**
  36680. * Converts the animation to a string
  36681. * @param fullDetails support for multiple levels of logging within scene loading
  36682. * @returns String form of the animation
  36683. */
  36684. toString(fullDetails?: boolean): string;
  36685. /**
  36686. * Add an event to this animation
  36687. * @param event Event to add
  36688. */
  36689. addEvent(event: AnimationEvent): void;
  36690. /**
  36691. * Remove all events found at the given frame
  36692. * @param frame The frame to remove events from
  36693. */
  36694. removeEvents(frame: number): void;
  36695. /**
  36696. * Retrieves all the events from the animation
  36697. * @returns Events from the animation
  36698. */
  36699. getEvents(): AnimationEvent[];
  36700. /**
  36701. * Creates an animation range
  36702. * @param name Name of the animation range
  36703. * @param from Starting frame of the animation range
  36704. * @param to Ending frame of the animation
  36705. */
  36706. createRange(name: string, from: number, to: number): void;
  36707. /**
  36708. * Deletes an animation range by name
  36709. * @param name Name of the animation range to delete
  36710. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36711. */
  36712. deleteRange(name: string, deleteFrames?: boolean): void;
  36713. /**
  36714. * Gets the animation range by name, or null if not defined
  36715. * @param name Name of the animation range
  36716. * @returns Nullable animation range
  36717. */
  36718. getRange(name: string): Nullable<AnimationRange>;
  36719. /**
  36720. * Gets the key frames from the animation
  36721. * @returns The key frames of the animation
  36722. */
  36723. getKeys(): Array<IAnimationKey>;
  36724. /**
  36725. * Gets the highest frame rate of the animation
  36726. * @returns Highest frame rate of the animation
  36727. */
  36728. getHighestFrame(): number;
  36729. /**
  36730. * Gets the easing function of the animation
  36731. * @returns Easing function of the animation
  36732. */
  36733. getEasingFunction(): IEasingFunction;
  36734. /**
  36735. * Sets the easing function of the animation
  36736. * @param easingFunction A custom mathematical formula for animation
  36737. */
  36738. setEasingFunction(easingFunction: EasingFunction): void;
  36739. /**
  36740. * Interpolates a scalar linearly
  36741. * @param startValue Start value of the animation curve
  36742. * @param endValue End value of the animation curve
  36743. * @param gradient Scalar amount to interpolate
  36744. * @returns Interpolated scalar value
  36745. */
  36746. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36747. /**
  36748. * Interpolates a scalar cubically
  36749. * @param startValue Start value of the animation curve
  36750. * @param outTangent End tangent of the animation
  36751. * @param endValue End value of the animation curve
  36752. * @param inTangent Start tangent of the animation curve
  36753. * @param gradient Scalar amount to interpolate
  36754. * @returns Interpolated scalar value
  36755. */
  36756. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36757. /**
  36758. * Interpolates a quaternion using a spherical linear interpolation
  36759. * @param startValue Start value of the animation curve
  36760. * @param endValue End value of the animation curve
  36761. * @param gradient Scalar amount to interpolate
  36762. * @returns Interpolated quaternion value
  36763. */
  36764. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36765. /**
  36766. * Interpolates a quaternion cubically
  36767. * @param startValue Start value of the animation curve
  36768. * @param outTangent End tangent of the animation curve
  36769. * @param endValue End value of the animation curve
  36770. * @param inTangent Start tangent of the animation curve
  36771. * @param gradient Scalar amount to interpolate
  36772. * @returns Interpolated quaternion value
  36773. */
  36774. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36775. /**
  36776. * Interpolates a Vector3 linearl
  36777. * @param startValue Start value of the animation curve
  36778. * @param endValue End value of the animation curve
  36779. * @param gradient Scalar amount to interpolate
  36780. * @returns Interpolated scalar value
  36781. */
  36782. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36783. /**
  36784. * Interpolates a Vector3 cubically
  36785. * @param startValue Start value of the animation curve
  36786. * @param outTangent End tangent of the animation
  36787. * @param endValue End value of the animation curve
  36788. * @param inTangent Start tangent of the animation curve
  36789. * @param gradient Scalar amount to interpolate
  36790. * @returns InterpolatedVector3 value
  36791. */
  36792. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36793. /**
  36794. * Interpolates a Vector2 linearly
  36795. * @param startValue Start value of the animation curve
  36796. * @param endValue End value of the animation curve
  36797. * @param gradient Scalar amount to interpolate
  36798. * @returns Interpolated Vector2 value
  36799. */
  36800. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36801. /**
  36802. * Interpolates a Vector2 cubically
  36803. * @param startValue Start value of the animation curve
  36804. * @param outTangent End tangent of the animation
  36805. * @param endValue End value of the animation curve
  36806. * @param inTangent Start tangent of the animation curve
  36807. * @param gradient Scalar amount to interpolate
  36808. * @returns Interpolated Vector2 value
  36809. */
  36810. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36811. /**
  36812. * Interpolates a size linearly
  36813. * @param startValue Start value of the animation curve
  36814. * @param endValue End value of the animation curve
  36815. * @param gradient Scalar amount to interpolate
  36816. * @returns Interpolated Size value
  36817. */
  36818. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36819. /**
  36820. * Interpolates a Color3 linearly
  36821. * @param startValue Start value of the animation curve
  36822. * @param endValue End value of the animation curve
  36823. * @param gradient Scalar amount to interpolate
  36824. * @returns Interpolated Color3 value
  36825. */
  36826. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36827. /**
  36828. * Interpolates a Color4 linearly
  36829. * @param startValue Start value of the animation curve
  36830. * @param endValue End value of the animation curve
  36831. * @param gradient Scalar amount to interpolate
  36832. * @returns Interpolated Color3 value
  36833. */
  36834. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36835. /**
  36836. * @hidden Internal use only
  36837. */
  36838. _getKeyValue(value: any): any;
  36839. /**
  36840. * @hidden Internal use only
  36841. */
  36842. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36843. /**
  36844. * Defines the function to use to interpolate matrices
  36845. * @param startValue defines the start matrix
  36846. * @param endValue defines the end matrix
  36847. * @param gradient defines the gradient between both matrices
  36848. * @param result defines an optional target matrix where to store the interpolation
  36849. * @returns the interpolated matrix
  36850. */
  36851. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36852. /**
  36853. * Makes a copy of the animation
  36854. * @returns Cloned animation
  36855. */
  36856. clone(): Animation;
  36857. /**
  36858. * Sets the key frames of the animation
  36859. * @param values The animation key frames to set
  36860. */
  36861. setKeys(values: Array<IAnimationKey>): void;
  36862. /**
  36863. * Serializes the animation to an object
  36864. * @returns Serialized object
  36865. */
  36866. serialize(): any;
  36867. /**
  36868. * Float animation type
  36869. */
  36870. static readonly ANIMATIONTYPE_FLOAT: number;
  36871. /**
  36872. * Vector3 animation type
  36873. */
  36874. static readonly ANIMATIONTYPE_VECTOR3: number;
  36875. /**
  36876. * Quaternion animation type
  36877. */
  36878. static readonly ANIMATIONTYPE_QUATERNION: number;
  36879. /**
  36880. * Matrix animation type
  36881. */
  36882. static readonly ANIMATIONTYPE_MATRIX: number;
  36883. /**
  36884. * Color3 animation type
  36885. */
  36886. static readonly ANIMATIONTYPE_COLOR3: number;
  36887. /**
  36888. * Color3 animation type
  36889. */
  36890. static readonly ANIMATIONTYPE_COLOR4: number;
  36891. /**
  36892. * Vector2 animation type
  36893. */
  36894. static readonly ANIMATIONTYPE_VECTOR2: number;
  36895. /**
  36896. * Size animation type
  36897. */
  36898. static readonly ANIMATIONTYPE_SIZE: number;
  36899. /**
  36900. * Relative Loop Mode
  36901. */
  36902. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36903. /**
  36904. * Cycle Loop Mode
  36905. */
  36906. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36907. /**
  36908. * Constant Loop Mode
  36909. */
  36910. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36911. /** @hidden */
  36912. static _UniversalLerp(left: any, right: any, amount: number): any;
  36913. /**
  36914. * Parses an animation object and creates an animation
  36915. * @param parsedAnimation Parsed animation object
  36916. * @returns Animation object
  36917. */
  36918. static Parse(parsedAnimation: any): Animation;
  36919. /**
  36920. * Appends the serialized animations from the source animations
  36921. * @param source Source containing the animations
  36922. * @param destination Target to store the animations
  36923. */
  36924. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36925. /**
  36926. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36927. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36928. * @param url defines the url to load from
  36929. * @returns a promise that will resolve to the new animation or an array of animations
  36930. */
  36931. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36932. /**
  36933. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36934. * @param snippetId defines the snippet to load
  36935. * @returns a promise that will resolve to the new animation or a new array of animations
  36936. */
  36937. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36938. }
  36939. }
  36940. declare module BABYLON {
  36941. /**
  36942. * Interface containing an array of animations
  36943. */
  36944. export interface IAnimatable {
  36945. /**
  36946. * Array of animations
  36947. */
  36948. animations: Nullable<Array<Animation>>;
  36949. }
  36950. }
  36951. declare module BABYLON {
  36952. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36953. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36954. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36955. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36956. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36957. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36958. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36962. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36963. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36964. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36965. /**
  36966. * Decorator used to define property that can be serialized as reference to a camera
  36967. * @param sourceName defines the name of the property to decorate
  36968. */
  36969. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36970. /**
  36971. * Class used to help serialization objects
  36972. */
  36973. export class SerializationHelper {
  36974. /** @hidden */
  36975. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36976. /** @hidden */
  36977. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36978. /** @hidden */
  36979. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36980. /** @hidden */
  36981. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36982. /**
  36983. * Appends the serialized animations from the source animations
  36984. * @param source Source containing the animations
  36985. * @param destination Target to store the animations
  36986. */
  36987. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36988. /**
  36989. * Static function used to serialized a specific entity
  36990. * @param entity defines the entity to serialize
  36991. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36992. * @returns a JSON compatible object representing the serialization of the entity
  36993. */
  36994. static Serialize<T>(entity: T, serializationObject?: any): any;
  36995. /**
  36996. * Creates a new entity from a serialization data object
  36997. * @param creationFunction defines a function used to instanciated the new entity
  36998. * @param source defines the source serialization data
  36999. * @param scene defines the hosting scene
  37000. * @param rootUrl defines the root url for resources
  37001. * @returns a new entity
  37002. */
  37003. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37004. /**
  37005. * Clones an object
  37006. * @param creationFunction defines the function used to instanciate the new object
  37007. * @param source defines the source object
  37008. * @returns the cloned object
  37009. */
  37010. static Clone<T>(creationFunction: () => T, source: T): T;
  37011. /**
  37012. * Instanciates a new object based on a source one (some data will be shared between both object)
  37013. * @param creationFunction defines the function used to instanciate the new object
  37014. * @param source defines the source object
  37015. * @returns the new object
  37016. */
  37017. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37018. }
  37019. }
  37020. declare module BABYLON {
  37021. /**
  37022. * This is the base class of all the camera used in the application.
  37023. * @see https://doc.babylonjs.com/features/cameras
  37024. */
  37025. export class Camera extends Node {
  37026. /** @hidden */
  37027. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37028. /**
  37029. * This is the default projection mode used by the cameras.
  37030. * It helps recreating a feeling of perspective and better appreciate depth.
  37031. * This is the best way to simulate real life cameras.
  37032. */
  37033. static readonly PERSPECTIVE_CAMERA: number;
  37034. /**
  37035. * This helps creating camera with an orthographic mode.
  37036. * 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.
  37037. */
  37038. static readonly ORTHOGRAPHIC_CAMERA: number;
  37039. /**
  37040. * This is the default FOV mode for perspective cameras.
  37041. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37042. */
  37043. static readonly FOVMODE_VERTICAL_FIXED: number;
  37044. /**
  37045. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37046. */
  37047. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37048. /**
  37049. * This specifies ther is no need for a camera rig.
  37050. * Basically only one eye is rendered corresponding to the camera.
  37051. */
  37052. static readonly RIG_MODE_NONE: number;
  37053. /**
  37054. * Simulates a camera Rig with one blue eye and one red eye.
  37055. * This can be use with 3d blue and red glasses.
  37056. */
  37057. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37058. /**
  37059. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37060. */
  37061. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37062. /**
  37063. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37064. */
  37065. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37066. /**
  37067. * Defines that both eyes of the camera will be rendered over under each other.
  37068. */
  37069. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37070. /**
  37071. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37072. */
  37073. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37074. /**
  37075. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37076. */
  37077. static readonly RIG_MODE_VR: number;
  37078. /**
  37079. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37080. */
  37081. static readonly RIG_MODE_WEBVR: number;
  37082. /**
  37083. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37084. */
  37085. static readonly RIG_MODE_CUSTOM: number;
  37086. /**
  37087. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37088. */
  37089. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37090. /**
  37091. * Define the input manager associated with the camera.
  37092. */
  37093. inputs: CameraInputsManager<Camera>;
  37094. /** @hidden */
  37095. _position: Vector3;
  37096. /**
  37097. * Define the current local position of the camera in the scene
  37098. */
  37099. get position(): Vector3;
  37100. set position(newPosition: Vector3);
  37101. protected _upVector: Vector3;
  37102. /**
  37103. * The vector the camera should consider as up.
  37104. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37105. */
  37106. set upVector(vec: Vector3);
  37107. get upVector(): Vector3;
  37108. /**
  37109. * Define the current limit on the left side for an orthographic camera
  37110. * In scene unit
  37111. */
  37112. orthoLeft: Nullable<number>;
  37113. /**
  37114. * Define the current limit on the right side for an orthographic camera
  37115. * In scene unit
  37116. */
  37117. orthoRight: Nullable<number>;
  37118. /**
  37119. * Define the current limit on the bottom side for an orthographic camera
  37120. * In scene unit
  37121. */
  37122. orthoBottom: Nullable<number>;
  37123. /**
  37124. * Define the current limit on the top side for an orthographic camera
  37125. * In scene unit
  37126. */
  37127. orthoTop: Nullable<number>;
  37128. /**
  37129. * Field Of View is set in Radians. (default is 0.8)
  37130. */
  37131. fov: number;
  37132. /**
  37133. * Define the minimum distance the camera can see from.
  37134. * This is important to note that the depth buffer are not infinite and the closer it starts
  37135. * the more your scene might encounter depth fighting issue.
  37136. */
  37137. minZ: number;
  37138. /**
  37139. * Define the maximum distance the camera can see to.
  37140. * This is important to note that the depth buffer are not infinite and the further it end
  37141. * the more your scene might encounter depth fighting issue.
  37142. */
  37143. maxZ: number;
  37144. /**
  37145. * Define the default inertia of the camera.
  37146. * This helps giving a smooth feeling to the camera movement.
  37147. */
  37148. inertia: number;
  37149. /**
  37150. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37151. */
  37152. mode: number;
  37153. /**
  37154. * Define whether the camera is intermediate.
  37155. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37156. */
  37157. isIntermediate: boolean;
  37158. /**
  37159. * Define the viewport of the camera.
  37160. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37161. */
  37162. viewport: Viewport;
  37163. /**
  37164. * Restricts the camera to viewing objects with the same layerMask.
  37165. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37166. */
  37167. layerMask: number;
  37168. /**
  37169. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37170. */
  37171. fovMode: number;
  37172. /**
  37173. * Rig mode of the camera.
  37174. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37175. * This is normally controlled byt the camera themselves as internal use.
  37176. */
  37177. cameraRigMode: number;
  37178. /**
  37179. * Defines the distance between both "eyes" in case of a RIG
  37180. */
  37181. interaxialDistance: number;
  37182. /**
  37183. * Defines if stereoscopic rendering is done side by side or over under.
  37184. */
  37185. isStereoscopicSideBySide: boolean;
  37186. /**
  37187. * 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
  37188. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37189. * else in the scene. (Eg. security camera)
  37190. *
  37191. * 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)
  37192. */
  37193. customRenderTargets: RenderTargetTexture[];
  37194. /**
  37195. * When set, the camera will render to this render target instead of the default canvas
  37196. *
  37197. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37198. */
  37199. outputRenderTarget: Nullable<RenderTargetTexture>;
  37200. /**
  37201. * Observable triggered when the camera view matrix has changed.
  37202. */
  37203. onViewMatrixChangedObservable: Observable<Camera>;
  37204. /**
  37205. * Observable triggered when the camera Projection matrix has changed.
  37206. */
  37207. onProjectionMatrixChangedObservable: Observable<Camera>;
  37208. /**
  37209. * Observable triggered when the inputs have been processed.
  37210. */
  37211. onAfterCheckInputsObservable: Observable<Camera>;
  37212. /**
  37213. * Observable triggered when reset has been called and applied to the camera.
  37214. */
  37215. onRestoreStateObservable: Observable<Camera>;
  37216. /**
  37217. * Is this camera a part of a rig system?
  37218. */
  37219. isRigCamera: boolean;
  37220. /**
  37221. * If isRigCamera set to true this will be set with the parent camera.
  37222. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37223. */
  37224. rigParent?: Camera;
  37225. /** @hidden */
  37226. _cameraRigParams: any;
  37227. /** @hidden */
  37228. _rigCameras: Camera[];
  37229. /** @hidden */
  37230. _rigPostProcess: Nullable<PostProcess>;
  37231. protected _webvrViewMatrix: Matrix;
  37232. /** @hidden */
  37233. _skipRendering: boolean;
  37234. /** @hidden */
  37235. _projectionMatrix: Matrix;
  37236. /** @hidden */
  37237. _postProcesses: Nullable<PostProcess>[];
  37238. /** @hidden */
  37239. _activeMeshes: SmartArray<AbstractMesh>;
  37240. protected _globalPosition: Vector3;
  37241. /** @hidden */
  37242. _computedViewMatrix: Matrix;
  37243. private _doNotComputeProjectionMatrix;
  37244. private _transformMatrix;
  37245. private _frustumPlanes;
  37246. private _refreshFrustumPlanes;
  37247. private _storedFov;
  37248. private _stateStored;
  37249. /**
  37250. * Instantiates a new camera object.
  37251. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37252. * @see https://doc.babylonjs.com/features/cameras
  37253. * @param name Defines the name of the camera in the scene
  37254. * @param position Defines the position of the camera
  37255. * @param scene Defines the scene the camera belongs too
  37256. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37257. */
  37258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37259. /**
  37260. * Store current camera state (fov, position, etc..)
  37261. * @returns the camera
  37262. */
  37263. storeState(): Camera;
  37264. /**
  37265. * Restores the camera state values if it has been stored. You must call storeState() first
  37266. */
  37267. protected _restoreStateValues(): boolean;
  37268. /**
  37269. * Restored camera state. You must call storeState() first.
  37270. * @returns true if restored and false otherwise
  37271. */
  37272. restoreState(): boolean;
  37273. /**
  37274. * Gets the class name of the camera.
  37275. * @returns the class name
  37276. */
  37277. getClassName(): string;
  37278. /** @hidden */
  37279. readonly _isCamera: boolean;
  37280. /**
  37281. * Gets a string representation of the camera useful for debug purpose.
  37282. * @param fullDetails Defines that a more verboe level of logging is required
  37283. * @returns the string representation
  37284. */
  37285. toString(fullDetails?: boolean): string;
  37286. /**
  37287. * Gets the current world space position of the camera.
  37288. */
  37289. get globalPosition(): Vector3;
  37290. /**
  37291. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37292. * @returns the active meshe list
  37293. */
  37294. getActiveMeshes(): SmartArray<AbstractMesh>;
  37295. /**
  37296. * Check whether a mesh is part of the current active mesh list of the camera
  37297. * @param mesh Defines the mesh to check
  37298. * @returns true if active, false otherwise
  37299. */
  37300. isActiveMesh(mesh: Mesh): boolean;
  37301. /**
  37302. * Is this camera ready to be used/rendered
  37303. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37304. * @return true if the camera is ready
  37305. */
  37306. isReady(completeCheck?: boolean): boolean;
  37307. /** @hidden */
  37308. _initCache(): void;
  37309. /** @hidden */
  37310. _updateCache(ignoreParentClass?: boolean): void;
  37311. /** @hidden */
  37312. _isSynchronized(): boolean;
  37313. /** @hidden */
  37314. _isSynchronizedViewMatrix(): boolean;
  37315. /** @hidden */
  37316. _isSynchronizedProjectionMatrix(): boolean;
  37317. /**
  37318. * Attach the input controls to a specific dom element to get the input from.
  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. */
  37321. attachControl(noPreventDefault?: boolean): void;
  37322. /**
  37323. * Attach the input controls to a specific dom element to get the input from.
  37324. * @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
  37325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37326. * BACK COMPAT SIGNATURE ONLY.
  37327. */
  37328. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37329. /**
  37330. * Detach the current controls from the specified dom element.
  37331. */
  37332. detachControl(): void;
  37333. /**
  37334. * Detach the current controls from the specified dom element.
  37335. * @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
  37336. */
  37337. detachControl(ignored: any): void;
  37338. /**
  37339. * Update the camera state according to the different inputs gathered during the frame.
  37340. */
  37341. update(): void;
  37342. /** @hidden */
  37343. _checkInputs(): void;
  37344. /** @hidden */
  37345. get rigCameras(): Camera[];
  37346. /**
  37347. * Gets the post process used by the rig cameras
  37348. */
  37349. get rigPostProcess(): Nullable<PostProcess>;
  37350. /**
  37351. * Internal, gets the first post proces.
  37352. * @returns the first post process to be run on this camera.
  37353. */
  37354. _getFirstPostProcess(): Nullable<PostProcess>;
  37355. private _cascadePostProcessesToRigCams;
  37356. /**
  37357. * Attach a post process to the camera.
  37358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37359. * @param postProcess The post process to attach to the camera
  37360. * @param insertAt The position of the post process in case several of them are in use in the scene
  37361. * @returns the position the post process has been inserted at
  37362. */
  37363. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37364. /**
  37365. * Detach a post process to the camera.
  37366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37367. * @param postProcess The post process to detach from the camera
  37368. */
  37369. detachPostProcess(postProcess: PostProcess): void;
  37370. /**
  37371. * Gets the current world matrix of the camera
  37372. */
  37373. getWorldMatrix(): Matrix;
  37374. /** @hidden */
  37375. _getViewMatrix(): Matrix;
  37376. /**
  37377. * Gets the current view matrix of the camera.
  37378. * @param force forces the camera to recompute the matrix without looking at the cached state
  37379. * @returns the view matrix
  37380. */
  37381. getViewMatrix(force?: boolean): Matrix;
  37382. /**
  37383. * Freeze the projection matrix.
  37384. * It will prevent the cache check of the camera projection compute and can speed up perf
  37385. * if no parameter of the camera are meant to change
  37386. * @param projection Defines manually a projection if necessary
  37387. */
  37388. freezeProjectionMatrix(projection?: Matrix): void;
  37389. /**
  37390. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37391. */
  37392. unfreezeProjectionMatrix(): void;
  37393. /**
  37394. * Gets the current projection matrix of the camera.
  37395. * @param force forces the camera to recompute the matrix without looking at the cached state
  37396. * @returns the projection matrix
  37397. */
  37398. getProjectionMatrix(force?: boolean): Matrix;
  37399. /**
  37400. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37401. * @returns a Matrix
  37402. */
  37403. getTransformationMatrix(): Matrix;
  37404. private _updateFrustumPlanes;
  37405. /**
  37406. * Checks if a cullable object (mesh...) is in the camera frustum
  37407. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37408. * @param target The object to check
  37409. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37410. * @returns true if the object is in frustum otherwise false
  37411. */
  37412. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37413. /**
  37414. * Checks if a cullable object (mesh...) is in the camera frustum
  37415. * Unlike isInFrustum this cheks the full bounding box
  37416. * @param target The object to check
  37417. * @returns true if the object is in frustum otherwise false
  37418. */
  37419. isCompletelyInFrustum(target: ICullable): boolean;
  37420. /**
  37421. * Gets a ray in the forward direction from the camera.
  37422. * @param length Defines the length of the ray to create
  37423. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37424. * @param origin Defines the start point of the ray which defaults to the camera position
  37425. * @returns the forward ray
  37426. */
  37427. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37428. /**
  37429. * Gets a ray in the forward direction from the camera.
  37430. * @param refRay the ray to (re)use when setting the values
  37431. * @param length Defines the length of the ray to create
  37432. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37433. * @param origin Defines the start point of the ray which defaults to the camera position
  37434. * @returns the forward ray
  37435. */
  37436. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37437. /**
  37438. * Releases resources associated with this node.
  37439. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37440. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37441. */
  37442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37443. /** @hidden */
  37444. _isLeftCamera: boolean;
  37445. /**
  37446. * Gets the left camera of a rig setup in case of Rigged Camera
  37447. */
  37448. get isLeftCamera(): boolean;
  37449. /** @hidden */
  37450. _isRightCamera: boolean;
  37451. /**
  37452. * Gets the right camera of a rig setup in case of Rigged Camera
  37453. */
  37454. get isRightCamera(): boolean;
  37455. /**
  37456. * Gets the left camera of a rig setup in case of Rigged Camera
  37457. */
  37458. get leftCamera(): Nullable<FreeCamera>;
  37459. /**
  37460. * Gets the right camera of a rig setup in case of Rigged Camera
  37461. */
  37462. get rightCamera(): Nullable<FreeCamera>;
  37463. /**
  37464. * Gets the left camera target of a rig setup in case of Rigged Camera
  37465. * @returns the target position
  37466. */
  37467. getLeftTarget(): Nullable<Vector3>;
  37468. /**
  37469. * Gets the right camera target of a rig setup in case of Rigged Camera
  37470. * @returns the target position
  37471. */
  37472. getRightTarget(): Nullable<Vector3>;
  37473. /**
  37474. * @hidden
  37475. */
  37476. setCameraRigMode(mode: number, rigParams: any): void;
  37477. /** @hidden */
  37478. static _setStereoscopicRigMode(camera: Camera): void;
  37479. /** @hidden */
  37480. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37481. /** @hidden */
  37482. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37483. /** @hidden */
  37484. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37485. /** @hidden */
  37486. _getVRProjectionMatrix(): Matrix;
  37487. protected _updateCameraRotationMatrix(): void;
  37488. protected _updateWebVRCameraRotationMatrix(): void;
  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. _getWebVRProjectionMatrix(): Matrix;
  37495. /**
  37496. * This function MUST be overwritten by the different WebVR cameras available.
  37497. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37498. * @hidden
  37499. */
  37500. _getWebVRViewMatrix(): Matrix;
  37501. /** @hidden */
  37502. setCameraRigParameter(name: string, value: any): void;
  37503. /**
  37504. * needs to be overridden by children so sub has required properties to be copied
  37505. * @hidden
  37506. */
  37507. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37508. /**
  37509. * May need to be overridden by children
  37510. * @hidden
  37511. */
  37512. _updateRigCameras(): void;
  37513. /** @hidden */
  37514. _setupInputs(): void;
  37515. /**
  37516. * Serialiaze the camera setup to a json represention
  37517. * @returns the JSON representation
  37518. */
  37519. serialize(): any;
  37520. /**
  37521. * Clones the current camera.
  37522. * @param name The cloned camera name
  37523. * @returns the cloned camera
  37524. */
  37525. clone(name: string): Camera;
  37526. /**
  37527. * Gets the direction of the camera relative to a given local axis.
  37528. * @param localAxis Defines the reference axis to provide a relative direction.
  37529. * @return the direction
  37530. */
  37531. getDirection(localAxis: Vector3): Vector3;
  37532. /**
  37533. * Returns the current camera absolute rotation
  37534. */
  37535. get absoluteRotation(): Quaternion;
  37536. /**
  37537. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37538. * @param localAxis Defines the reference axis to provide a relative direction.
  37539. * @param result Defines the vector to store the result in
  37540. */
  37541. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37542. /**
  37543. * Gets a camera constructor for a given camera type
  37544. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37545. * @param name The name of the camera the result will be able to instantiate
  37546. * @param scene The scene the result will construct the camera in
  37547. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37548. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37549. * @returns a factory method to construc the camera
  37550. */
  37551. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37552. /**
  37553. * Compute the world matrix of the camera.
  37554. * @returns the camera world matrix
  37555. */
  37556. computeWorldMatrix(): Matrix;
  37557. /**
  37558. * Parse a JSON and creates the camera from the parsed information
  37559. * @param parsedCamera The JSON to parse
  37560. * @param scene The scene to instantiate the camera in
  37561. * @returns the newly constructed camera
  37562. */
  37563. static Parse(parsedCamera: any, scene: Scene): Camera;
  37564. }
  37565. }
  37566. declare module BABYLON {
  37567. /**
  37568. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37569. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37570. */
  37571. export class PostProcessManager {
  37572. private _scene;
  37573. private _indexBuffer;
  37574. private _vertexBuffers;
  37575. /**
  37576. * Creates a new instance PostProcess
  37577. * @param scene The scene that the post process is associated with.
  37578. */
  37579. constructor(scene: Scene);
  37580. private _prepareBuffers;
  37581. private _buildIndexBuffer;
  37582. /**
  37583. * Rebuilds the vertex buffers of the manager.
  37584. * @hidden
  37585. */
  37586. _rebuild(): void;
  37587. /**
  37588. * Prepares a frame to be run through a post process.
  37589. * @param sourceTexture The input texture to the post procesess. (default: null)
  37590. * @param postProcesses An array of post processes to be run. (default: null)
  37591. * @returns True if the post processes were able to be run.
  37592. * @hidden
  37593. */
  37594. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37595. /**
  37596. * Manually render a set of post processes to a texture.
  37597. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37598. * @param postProcesses An array of post processes to be run.
  37599. * @param targetTexture The target texture to render to.
  37600. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37601. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37602. * @param lodLevel defines which lod of the texture to render to
  37603. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37604. */
  37605. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37606. /**
  37607. * Finalize the result of the output of the postprocesses.
  37608. * @param doNotPresent If true the result will not be displayed to the screen.
  37609. * @param targetTexture The target texture to render to.
  37610. * @param faceIndex The index of the face to bind the target texture to.
  37611. * @param postProcesses The array of post processes to render.
  37612. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37613. * @hidden
  37614. */
  37615. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37616. /**
  37617. * Disposes of the post process manager.
  37618. */
  37619. dispose(): void;
  37620. }
  37621. }
  37622. declare module BABYLON {
  37623. /**
  37624. * This Helps creating a texture that will be created from a camera in your scene.
  37625. * It is basically a dynamic texture that could be used to create special effects for instance.
  37626. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37627. */
  37628. export class RenderTargetTexture extends Texture {
  37629. /**
  37630. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37631. */
  37632. static readonly REFRESHRATE_RENDER_ONCE: number;
  37633. /**
  37634. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37635. */
  37636. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37637. /**
  37638. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37639. * the central point of your effect and can save a lot of performances.
  37640. */
  37641. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37642. /**
  37643. * Use this predicate to dynamically define the list of mesh you want to render.
  37644. * If set, the renderList property will be overwritten.
  37645. */
  37646. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37647. private _renderList;
  37648. /**
  37649. * Use this list to define the list of mesh you want to render.
  37650. */
  37651. get renderList(): Nullable<Array<AbstractMesh>>;
  37652. set renderList(value: Nullable<Array<AbstractMesh>>);
  37653. /**
  37654. * Use this function to overload the renderList array at rendering time.
  37655. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37656. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37657. * the cube (if the RTT is a cube, else layerOrFace=0).
  37658. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37659. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37660. * hold dummy elements!
  37661. */
  37662. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37663. private _hookArray;
  37664. /**
  37665. * Define if particles should be rendered in your texture.
  37666. */
  37667. renderParticles: boolean;
  37668. /**
  37669. * Define if sprites should be rendered in your texture.
  37670. */
  37671. renderSprites: boolean;
  37672. /**
  37673. * Define the camera used to render the texture.
  37674. */
  37675. activeCamera: Nullable<Camera>;
  37676. /**
  37677. * Override the mesh isReady function with your own one.
  37678. */
  37679. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37680. /**
  37681. * Override the render function of the texture with your own one.
  37682. */
  37683. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37684. /**
  37685. * Define if camera post processes should be use while rendering the texture.
  37686. */
  37687. useCameraPostProcesses: boolean;
  37688. /**
  37689. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37690. */
  37691. ignoreCameraViewport: boolean;
  37692. private _postProcessManager;
  37693. private _postProcesses;
  37694. private _resizeObserver;
  37695. /**
  37696. * An event triggered when the texture is unbind.
  37697. */
  37698. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37699. /**
  37700. * An event triggered when the texture is unbind.
  37701. */
  37702. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37703. private _onAfterUnbindObserver;
  37704. /**
  37705. * Set a after unbind callback in the texture.
  37706. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37707. */
  37708. set onAfterUnbind(callback: () => void);
  37709. /**
  37710. * An event triggered before rendering the texture
  37711. */
  37712. onBeforeRenderObservable: Observable<number>;
  37713. private _onBeforeRenderObserver;
  37714. /**
  37715. * Set a before render callback in the texture.
  37716. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37717. */
  37718. set onBeforeRender(callback: (faceIndex: number) => void);
  37719. /**
  37720. * An event triggered after rendering the texture
  37721. */
  37722. onAfterRenderObservable: Observable<number>;
  37723. private _onAfterRenderObserver;
  37724. /**
  37725. * Set a after render callback in the texture.
  37726. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37727. */
  37728. set onAfterRender(callback: (faceIndex: number) => void);
  37729. /**
  37730. * An event triggered after the texture clear
  37731. */
  37732. onClearObservable: Observable<Engine>;
  37733. private _onClearObserver;
  37734. /**
  37735. * Set a clear callback in the texture.
  37736. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37737. */
  37738. set onClear(callback: (Engine: Engine) => void);
  37739. /**
  37740. * An event triggered when the texture is resized.
  37741. */
  37742. onResizeObservable: Observable<RenderTargetTexture>;
  37743. /**
  37744. * Define the clear color of the Render Target if it should be different from the scene.
  37745. */
  37746. clearColor: Color4;
  37747. protected _size: number | {
  37748. width: number;
  37749. height: number;
  37750. layers?: number;
  37751. };
  37752. protected _initialSizeParameter: number | {
  37753. width: number;
  37754. height: number;
  37755. } | {
  37756. ratio: number;
  37757. };
  37758. protected _sizeRatio: Nullable<number>;
  37759. /** @hidden */
  37760. _generateMipMaps: boolean;
  37761. protected _renderingManager: RenderingManager;
  37762. /** @hidden */
  37763. _waitingRenderList?: string[];
  37764. protected _doNotChangeAspectRatio: boolean;
  37765. protected _currentRefreshId: number;
  37766. protected _refreshRate: number;
  37767. protected _textureMatrix: Matrix;
  37768. protected _samples: number;
  37769. protected _renderTargetOptions: RenderTargetCreationOptions;
  37770. /**
  37771. * Gets render target creation options that were used.
  37772. */
  37773. get renderTargetOptions(): RenderTargetCreationOptions;
  37774. protected _onRatioRescale(): void;
  37775. /**
  37776. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37777. * It must define where the camera used to render the texture is set
  37778. */
  37779. boundingBoxPosition: Vector3;
  37780. private _boundingBoxSize;
  37781. /**
  37782. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37783. * When defined, the cubemap will switch to local mode
  37784. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37785. * @example https://www.babylonjs-playground.com/#RNASML
  37786. */
  37787. set boundingBoxSize(value: Vector3);
  37788. get boundingBoxSize(): Vector3;
  37789. /**
  37790. * In case the RTT has been created with a depth texture, get the associated
  37791. * depth texture.
  37792. * Otherwise, return null.
  37793. */
  37794. get depthStencilTexture(): Nullable<InternalTexture>;
  37795. /**
  37796. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37797. * or used a shadow, depth texture...
  37798. * @param name The friendly name of the texture
  37799. * @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)
  37800. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37801. * @param generateMipMaps True if mip maps need to be generated after render.
  37802. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37803. * @param type The type of the buffer in the RTT (int, half float, float...)
  37804. * @param isCube True if a cube texture needs to be created
  37805. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37806. * @param generateDepthBuffer True to generate a depth buffer
  37807. * @param generateStencilBuffer True to generate a stencil buffer
  37808. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37809. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37810. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37811. */
  37812. constructor(name: string, size: number | {
  37813. width: number;
  37814. height: number;
  37815. layers?: number;
  37816. } | {
  37817. ratio: number;
  37818. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37819. /**
  37820. * Creates a depth stencil texture.
  37821. * This is only available in WebGL 2 or with the depth texture extension available.
  37822. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37823. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37824. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37825. */
  37826. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37827. private _processSizeParameter;
  37828. /**
  37829. * Define the number of samples to use in case of MSAA.
  37830. * It defaults to one meaning no MSAA has been enabled.
  37831. */
  37832. get samples(): number;
  37833. set samples(value: number);
  37834. /**
  37835. * Resets the refresh counter of the texture and start bak from scratch.
  37836. * Could be useful to regenerate the texture if it is setup to render only once.
  37837. */
  37838. resetRefreshCounter(): void;
  37839. /**
  37840. * Define the refresh rate of the texture or the rendering frequency.
  37841. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37842. */
  37843. get refreshRate(): number;
  37844. set refreshRate(value: number);
  37845. /**
  37846. * Adds a post process to the render target rendering passes.
  37847. * @param postProcess define the post process to add
  37848. */
  37849. addPostProcess(postProcess: PostProcess): void;
  37850. /**
  37851. * Clear all the post processes attached to the render target
  37852. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37853. */
  37854. clearPostProcesses(dispose?: boolean): void;
  37855. /**
  37856. * Remove one of the post process from the list of attached post processes to the texture
  37857. * @param postProcess define the post process to remove from the list
  37858. */
  37859. removePostProcess(postProcess: PostProcess): void;
  37860. /** @hidden */
  37861. _shouldRender(): boolean;
  37862. /**
  37863. * Gets the actual render size of the texture.
  37864. * @returns the width of the render size
  37865. */
  37866. getRenderSize(): number;
  37867. /**
  37868. * Gets the actual render width of the texture.
  37869. * @returns the width of the render size
  37870. */
  37871. getRenderWidth(): number;
  37872. /**
  37873. * Gets the actual render height of the texture.
  37874. * @returns the height of the render size
  37875. */
  37876. getRenderHeight(): number;
  37877. /**
  37878. * Gets the actual number of layers of the texture.
  37879. * @returns the number of layers
  37880. */
  37881. getRenderLayers(): number;
  37882. /**
  37883. * Get if the texture can be rescaled or not.
  37884. */
  37885. get canRescale(): boolean;
  37886. /**
  37887. * Resize the texture using a ratio.
  37888. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37889. */
  37890. scale(ratio: number): void;
  37891. /**
  37892. * Get the texture reflection matrix used to rotate/transform the reflection.
  37893. * @returns the reflection matrix
  37894. */
  37895. getReflectionTextureMatrix(): Matrix;
  37896. /**
  37897. * Resize the texture to a new desired size.
  37898. * Be carrefull as it will recreate all the data in the new texture.
  37899. * @param size Define the new size. It can be:
  37900. * - a number for squared texture,
  37901. * - an object containing { width: number, height: number }
  37902. * - or an object containing a ratio { ratio: number }
  37903. */
  37904. resize(size: number | {
  37905. width: number;
  37906. height: number;
  37907. } | {
  37908. ratio: number;
  37909. }): void;
  37910. private _defaultRenderListPrepared;
  37911. /**
  37912. * Renders all the objects from the render list into the texture.
  37913. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37914. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37915. */
  37916. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37917. private _bestReflectionRenderTargetDimension;
  37918. private _prepareRenderingManager;
  37919. /**
  37920. * @hidden
  37921. * @param faceIndex face index to bind to if this is a cubetexture
  37922. * @param layer defines the index of the texture to bind in the array
  37923. */
  37924. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37925. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37926. private renderToTarget;
  37927. /**
  37928. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37929. * This allowed control for front to back rendering or reversly depending of the special needs.
  37930. *
  37931. * @param renderingGroupId The rendering group id corresponding to its index
  37932. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37933. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37934. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37935. */
  37936. 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;
  37937. /**
  37938. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37939. *
  37940. * @param renderingGroupId The rendering group id corresponding to its index
  37941. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37942. */
  37943. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37944. /**
  37945. * Clones the texture.
  37946. * @returns the cloned texture
  37947. */
  37948. clone(): RenderTargetTexture;
  37949. /**
  37950. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37951. * @returns The JSON representation of the texture
  37952. */
  37953. serialize(): any;
  37954. /**
  37955. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37956. */
  37957. disposeFramebufferObjects(): void;
  37958. /**
  37959. * Dispose the texture and release its associated resources.
  37960. */
  37961. dispose(): void;
  37962. /** @hidden */
  37963. _rebuild(): void;
  37964. /**
  37965. * Clear the info related to rendering groups preventing retention point in material dispose.
  37966. */
  37967. freeRenderingGroups(): void;
  37968. /**
  37969. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37970. * @returns the view count
  37971. */
  37972. getViewCount(): number;
  37973. }
  37974. }
  37975. declare module BABYLON {
  37976. /**
  37977. * Options to be used when creating an effect.
  37978. */
  37979. export interface IEffectCreationOptions {
  37980. /**
  37981. * Atrributes that will be used in the shader.
  37982. */
  37983. attributes: string[];
  37984. /**
  37985. * Uniform varible names that will be set in the shader.
  37986. */
  37987. uniformsNames: string[];
  37988. /**
  37989. * Uniform buffer variable names that will be set in the shader.
  37990. */
  37991. uniformBuffersNames: string[];
  37992. /**
  37993. * Sampler texture variable names that will be set in the shader.
  37994. */
  37995. samplers: string[];
  37996. /**
  37997. * Define statements that will be set in the shader.
  37998. */
  37999. defines: any;
  38000. /**
  38001. * Possible fallbacks for this effect to improve performance when needed.
  38002. */
  38003. fallbacks: Nullable<IEffectFallbacks>;
  38004. /**
  38005. * Callback that will be called when the shader is compiled.
  38006. */
  38007. onCompiled: Nullable<(effect: Effect) => void>;
  38008. /**
  38009. * Callback that will be called if an error occurs during shader compilation.
  38010. */
  38011. onError: Nullable<(effect: Effect, errors: string) => void>;
  38012. /**
  38013. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38014. */
  38015. indexParameters?: any;
  38016. /**
  38017. * Max number of lights that can be used in the shader.
  38018. */
  38019. maxSimultaneousLights?: number;
  38020. /**
  38021. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38022. */
  38023. transformFeedbackVaryings?: Nullable<string[]>;
  38024. /**
  38025. * 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
  38026. */
  38027. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38028. /**
  38029. * Is this effect rendering to several color attachments ?
  38030. */
  38031. multiTarget?: boolean;
  38032. }
  38033. /**
  38034. * Effect containing vertex and fragment shader that can be executed on an object.
  38035. */
  38036. export class Effect implements IDisposable {
  38037. /**
  38038. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38039. */
  38040. static ShadersRepository: string;
  38041. /**
  38042. * Enable logging of the shader code when a compilation error occurs
  38043. */
  38044. static LogShaderCodeOnCompilationError: boolean;
  38045. /**
  38046. * Name of the effect.
  38047. */
  38048. name: any;
  38049. /**
  38050. * String container all the define statements that should be set on the shader.
  38051. */
  38052. defines: string;
  38053. /**
  38054. * Callback that will be called when the shader is compiled.
  38055. */
  38056. onCompiled: Nullable<(effect: Effect) => void>;
  38057. /**
  38058. * Callback that will be called if an error occurs during shader compilation.
  38059. */
  38060. onError: Nullable<(effect: Effect, errors: string) => void>;
  38061. /**
  38062. * Callback that will be called when effect is bound.
  38063. */
  38064. onBind: Nullable<(effect: Effect) => void>;
  38065. /**
  38066. * Unique ID of the effect.
  38067. */
  38068. uniqueId: number;
  38069. /**
  38070. * Observable that will be called when the shader is compiled.
  38071. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38072. */
  38073. onCompileObservable: Observable<Effect>;
  38074. /**
  38075. * Observable that will be called if an error occurs during shader compilation.
  38076. */
  38077. onErrorObservable: Observable<Effect>;
  38078. /** @hidden */
  38079. _onBindObservable: Nullable<Observable<Effect>>;
  38080. /**
  38081. * @hidden
  38082. * Specifies if the effect was previously ready
  38083. */
  38084. _wasPreviouslyReady: boolean;
  38085. /**
  38086. * Observable that will be called when effect is bound.
  38087. */
  38088. get onBindObservable(): Observable<Effect>;
  38089. /** @hidden */
  38090. _bonesComputationForcedToCPU: boolean;
  38091. /** @hidden */
  38092. _multiTarget: boolean;
  38093. private static _uniqueIdSeed;
  38094. private _engine;
  38095. private _uniformBuffersNames;
  38096. private _uniformBuffersNamesList;
  38097. private _uniformsNames;
  38098. private _samplerList;
  38099. private _samplers;
  38100. private _isReady;
  38101. private _compilationError;
  38102. private _allFallbacksProcessed;
  38103. private _attributesNames;
  38104. private _attributes;
  38105. private _attributeLocationByName;
  38106. private _uniforms;
  38107. /**
  38108. * Key for the effect.
  38109. * @hidden
  38110. */
  38111. _key: string;
  38112. private _indexParameters;
  38113. private _fallbacks;
  38114. private _vertexSourceCode;
  38115. private _fragmentSourceCode;
  38116. private _vertexSourceCodeOverride;
  38117. private _fragmentSourceCodeOverride;
  38118. private _transformFeedbackVaryings;
  38119. private _rawVertexSourceCode;
  38120. private _rawFragmentSourceCode;
  38121. /**
  38122. * Compiled shader to webGL program.
  38123. * @hidden
  38124. */
  38125. _pipelineContext: Nullable<IPipelineContext>;
  38126. private _valueCache;
  38127. private static _baseCache;
  38128. /**
  38129. * Instantiates an effect.
  38130. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38131. * @param baseName Name of the effect.
  38132. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38133. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38134. * @param samplers List of sampler variables that will be passed to the shader.
  38135. * @param engine Engine to be used to render the effect
  38136. * @param defines Define statements to be added to the shader.
  38137. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38138. * @param onCompiled Callback that will be called when the shader is compiled.
  38139. * @param onError Callback that will be called if an error occurs during shader compilation.
  38140. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38141. */
  38142. 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);
  38143. private _useFinalCode;
  38144. /**
  38145. * Unique key for this effect
  38146. */
  38147. get key(): string;
  38148. /**
  38149. * If the effect has been compiled and prepared.
  38150. * @returns if the effect is compiled and prepared.
  38151. */
  38152. isReady(): boolean;
  38153. private _isReadyInternal;
  38154. /**
  38155. * The engine the effect was initialized with.
  38156. * @returns the engine.
  38157. */
  38158. getEngine(): Engine;
  38159. /**
  38160. * The pipeline context for this effect
  38161. * @returns the associated pipeline context
  38162. */
  38163. getPipelineContext(): Nullable<IPipelineContext>;
  38164. /**
  38165. * The set of names of attribute variables for the shader.
  38166. * @returns An array of attribute names.
  38167. */
  38168. getAttributesNames(): string[];
  38169. /**
  38170. * Returns the attribute at the given index.
  38171. * @param index The index of the attribute.
  38172. * @returns The location of the attribute.
  38173. */
  38174. getAttributeLocation(index: number): number;
  38175. /**
  38176. * Returns the attribute based on the name of the variable.
  38177. * @param name of the attribute to look up.
  38178. * @returns the attribute location.
  38179. */
  38180. getAttributeLocationByName(name: string): number;
  38181. /**
  38182. * The number of attributes.
  38183. * @returns the numnber of attributes.
  38184. */
  38185. getAttributesCount(): number;
  38186. /**
  38187. * Gets the index of a uniform variable.
  38188. * @param uniformName of the uniform to look up.
  38189. * @returns the index.
  38190. */
  38191. getUniformIndex(uniformName: string): number;
  38192. /**
  38193. * Returns the attribute based on the name of the variable.
  38194. * @param uniformName of the uniform to look up.
  38195. * @returns the location of the uniform.
  38196. */
  38197. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38198. /**
  38199. * Returns an array of sampler variable names
  38200. * @returns The array of sampler variable names.
  38201. */
  38202. getSamplers(): string[];
  38203. /**
  38204. * Returns an array of uniform variable names
  38205. * @returns The array of uniform variable names.
  38206. */
  38207. getUniformNames(): string[];
  38208. /**
  38209. * Returns an array of uniform buffer variable names
  38210. * @returns The array of uniform buffer variable names.
  38211. */
  38212. getUniformBuffersNames(): string[];
  38213. /**
  38214. * Returns the index parameters used to create the effect
  38215. * @returns The index parameters object
  38216. */
  38217. getIndexParameters(): any;
  38218. /**
  38219. * The error from the last compilation.
  38220. * @returns the error string.
  38221. */
  38222. getCompilationError(): string;
  38223. /**
  38224. * Gets a boolean indicating that all fallbacks were used during compilation
  38225. * @returns true if all fallbacks were used
  38226. */
  38227. allFallbacksProcessed(): boolean;
  38228. /**
  38229. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38230. * @param func The callback to be used.
  38231. */
  38232. executeWhenCompiled(func: (effect: Effect) => void): void;
  38233. private _checkIsReady;
  38234. private _loadShader;
  38235. /**
  38236. * Gets the vertex shader source code of this effect
  38237. */
  38238. get vertexSourceCode(): string;
  38239. /**
  38240. * Gets the fragment shader source code of this effect
  38241. */
  38242. get fragmentSourceCode(): string;
  38243. /**
  38244. * Gets the vertex shader source code before it has been processed by the preprocessor
  38245. */
  38246. get rawVertexSourceCode(): string;
  38247. /**
  38248. * Gets the fragment shader source code before it has been processed by the preprocessor
  38249. */
  38250. get rawFragmentSourceCode(): string;
  38251. /**
  38252. * Recompiles the webGL program
  38253. * @param vertexSourceCode The source code for the vertex shader.
  38254. * @param fragmentSourceCode The source code for the fragment shader.
  38255. * @param onCompiled Callback called when completed.
  38256. * @param onError Callback called on error.
  38257. * @hidden
  38258. */
  38259. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38260. /**
  38261. * Prepares the effect
  38262. * @hidden
  38263. */
  38264. _prepareEffect(): void;
  38265. private _getShaderCodeAndErrorLine;
  38266. private _processCompilationErrors;
  38267. /**
  38268. * Checks if the effect is supported. (Must be called after compilation)
  38269. */
  38270. get isSupported(): boolean;
  38271. /**
  38272. * Binds a texture to the engine to be used as output of the shader.
  38273. * @param channel Name of the output variable.
  38274. * @param texture Texture to bind.
  38275. * @hidden
  38276. */
  38277. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38278. /**
  38279. * Sets a texture 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. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38284. /**
  38285. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38286. * @param channel Name of the sampler variable.
  38287. * @param texture Texture to set.
  38288. */
  38289. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38290. /**
  38291. * Sets an array of textures on the engine to be used in the shader.
  38292. * @param channel Name of the variable.
  38293. * @param textures Textures to set.
  38294. */
  38295. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38296. /**
  38297. * 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)
  38298. * @param channel Name of the sampler variable.
  38299. * @param postProcess Post process to get the input texture from.
  38300. */
  38301. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38302. /**
  38303. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38304. * 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)
  38305. * @param channel Name of the sampler variable.
  38306. * @param postProcess Post process to get the output texture from.
  38307. */
  38308. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38309. /** @hidden */
  38310. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38311. /** @hidden */
  38312. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38313. /** @hidden */
  38314. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38315. /** @hidden */
  38316. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38317. /**
  38318. * Binds a buffer to a uniform.
  38319. * @param buffer Buffer to bind.
  38320. * @param name Name of the uniform variable to bind to.
  38321. */
  38322. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38323. /**
  38324. * Binds block to a uniform.
  38325. * @param blockName Name of the block to bind.
  38326. * @param index Index to bind.
  38327. */
  38328. bindUniformBlock(blockName: string, index: number): void;
  38329. /**
  38330. * Sets an interger value on a uniform variable.
  38331. * @param uniformName Name of the variable.
  38332. * @param value Value to be set.
  38333. * @returns this effect.
  38334. */
  38335. setInt(uniformName: string, value: number): Effect;
  38336. /**
  38337. * Sets an int array on a uniform variable.
  38338. * @param uniformName Name of the variable.
  38339. * @param array array to be set.
  38340. * @returns this effect.
  38341. */
  38342. setIntArray(uniformName: string, array: Int32Array): Effect;
  38343. /**
  38344. * 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)
  38345. * @param uniformName Name of the variable.
  38346. * @param array array to be set.
  38347. * @returns this effect.
  38348. */
  38349. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38350. /**
  38351. * 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)
  38352. * @param uniformName Name of the variable.
  38353. * @param array array to be set.
  38354. * @returns this effect.
  38355. */
  38356. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38357. /**
  38358. * 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)
  38359. * @param uniformName Name of the variable.
  38360. * @param array array to be set.
  38361. * @returns this effect.
  38362. */
  38363. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38364. /**
  38365. * Sets an float array on a uniform variable.
  38366. * @param uniformName Name of the variable.
  38367. * @param array array to be set.
  38368. * @returns this effect.
  38369. */
  38370. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38371. /**
  38372. * 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)
  38373. * @param uniformName Name of the variable.
  38374. * @param array array to be set.
  38375. * @returns this effect.
  38376. */
  38377. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38378. /**
  38379. * 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)
  38380. * @param uniformName Name of the variable.
  38381. * @param array array to be set.
  38382. * @returns this effect.
  38383. */
  38384. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38385. /**
  38386. * 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)
  38387. * @param uniformName Name of the variable.
  38388. * @param array array to be set.
  38389. * @returns this effect.
  38390. */
  38391. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38392. /**
  38393. * Sets an array on a uniform variable.
  38394. * @param uniformName Name of the variable.
  38395. * @param array array to be set.
  38396. * @returns this effect.
  38397. */
  38398. setArray(uniformName: string, array: number[]): Effect;
  38399. /**
  38400. * 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)
  38401. * @param uniformName Name of the variable.
  38402. * @param array array to be set.
  38403. * @returns this effect.
  38404. */
  38405. setArray2(uniformName: string, array: number[]): Effect;
  38406. /**
  38407. * 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)
  38408. * @param uniformName Name of the variable.
  38409. * @param array array to be set.
  38410. * @returns this effect.
  38411. */
  38412. setArray3(uniformName: string, array: number[]): Effect;
  38413. /**
  38414. * 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)
  38415. * @param uniformName Name of the variable.
  38416. * @param array array to be set.
  38417. * @returns this effect.
  38418. */
  38419. setArray4(uniformName: string, array: number[]): Effect;
  38420. /**
  38421. * Sets matrices on a uniform variable.
  38422. * @param uniformName Name of the variable.
  38423. * @param matrices matrices to be set.
  38424. * @returns this effect.
  38425. */
  38426. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38427. /**
  38428. * Sets matrix on a uniform variable.
  38429. * @param uniformName Name of the variable.
  38430. * @param matrix matrix to be set.
  38431. * @returns this effect.
  38432. */
  38433. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38434. /**
  38435. * 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)
  38436. * @param uniformName Name of the variable.
  38437. * @param matrix matrix to be set.
  38438. * @returns this effect.
  38439. */
  38440. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38441. /**
  38442. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38443. * @param uniformName Name of the variable.
  38444. * @param matrix matrix to be set.
  38445. * @returns this effect.
  38446. */
  38447. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38448. /**
  38449. * Sets a float on a uniform variable.
  38450. * @param uniformName Name of the variable.
  38451. * @param value value to be set.
  38452. * @returns this effect.
  38453. */
  38454. setFloat(uniformName: string, value: number): Effect;
  38455. /**
  38456. * Sets a boolean on a uniform variable.
  38457. * @param uniformName Name of the variable.
  38458. * @param bool value to be set.
  38459. * @returns this effect.
  38460. */
  38461. setBool(uniformName: string, bool: boolean): Effect;
  38462. /**
  38463. * Sets a Vector2 on a uniform variable.
  38464. * @param uniformName Name of the variable.
  38465. * @param vector2 vector2 to be set.
  38466. * @returns this effect.
  38467. */
  38468. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38469. /**
  38470. * Sets a float2 on a uniform variable.
  38471. * @param uniformName Name of the variable.
  38472. * @param x First float in float2.
  38473. * @param y Second float in float2.
  38474. * @returns this effect.
  38475. */
  38476. setFloat2(uniformName: string, x: number, y: number): Effect;
  38477. /**
  38478. * Sets a Vector3 on a uniform variable.
  38479. * @param uniformName Name of the variable.
  38480. * @param vector3 Value to be set.
  38481. * @returns this effect.
  38482. */
  38483. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38484. /**
  38485. * Sets a float3 on a uniform variable.
  38486. * @param uniformName Name of the variable.
  38487. * @param x First float in float3.
  38488. * @param y Second float in float3.
  38489. * @param z Third float in float3.
  38490. * @returns this effect.
  38491. */
  38492. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38493. /**
  38494. * Sets a Vector4 on a uniform variable.
  38495. * @param uniformName Name of the variable.
  38496. * @param vector4 Value to be set.
  38497. * @returns this effect.
  38498. */
  38499. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38500. /**
  38501. * Sets a float4 on a uniform variable.
  38502. * @param uniformName Name of the variable.
  38503. * @param x First float in float4.
  38504. * @param y Second float in float4.
  38505. * @param z Third float in float4.
  38506. * @param w Fourth float in float4.
  38507. * @returns this effect.
  38508. */
  38509. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38510. /**
  38511. * Sets a Color3 on a uniform variable.
  38512. * @param uniformName Name of the variable.
  38513. * @param color3 Value to be set.
  38514. * @returns this effect.
  38515. */
  38516. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38517. /**
  38518. * Sets a Color4 on a uniform variable.
  38519. * @param uniformName Name of the variable.
  38520. * @param color3 Value to be set.
  38521. * @param alpha Alpha value to be set.
  38522. * @returns this effect.
  38523. */
  38524. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38525. /**
  38526. * Sets a Color4 on a uniform variable
  38527. * @param uniformName defines the name of the variable
  38528. * @param color4 defines the value to be set
  38529. * @returns this effect.
  38530. */
  38531. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38532. /** Release all associated resources */
  38533. dispose(): void;
  38534. /**
  38535. * This function will add a new shader to the shader store
  38536. * @param name the name of the shader
  38537. * @param pixelShader optional pixel shader content
  38538. * @param vertexShader optional vertex shader content
  38539. */
  38540. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38541. /**
  38542. * Store of each shader (The can be looked up using effect.key)
  38543. */
  38544. static ShadersStore: {
  38545. [key: string]: string;
  38546. };
  38547. /**
  38548. * Store of each included file for a shader (The can be looked up using effect.key)
  38549. */
  38550. static IncludesShadersStore: {
  38551. [key: string]: string;
  38552. };
  38553. /**
  38554. * Resets the cache of effects.
  38555. */
  38556. static ResetCache(): void;
  38557. }
  38558. }
  38559. declare module BABYLON {
  38560. /**
  38561. * Interface used to describe the capabilities of the engine relatively to the current browser
  38562. */
  38563. export interface EngineCapabilities {
  38564. /** Maximum textures units per fragment shader */
  38565. maxTexturesImageUnits: number;
  38566. /** Maximum texture units per vertex shader */
  38567. maxVertexTextureImageUnits: number;
  38568. /** Maximum textures units in the entire pipeline */
  38569. maxCombinedTexturesImageUnits: number;
  38570. /** Maximum texture size */
  38571. maxTextureSize: number;
  38572. /** Maximum texture samples */
  38573. maxSamples?: number;
  38574. /** Maximum cube texture size */
  38575. maxCubemapTextureSize: number;
  38576. /** Maximum render texture size */
  38577. maxRenderTextureSize: number;
  38578. /** Maximum number of vertex attributes */
  38579. maxVertexAttribs: number;
  38580. /** Maximum number of varyings */
  38581. maxVaryingVectors: number;
  38582. /** Maximum number of uniforms per vertex shader */
  38583. maxVertexUniformVectors: number;
  38584. /** Maximum number of uniforms per fragment shader */
  38585. maxFragmentUniformVectors: number;
  38586. /** Defines if standard derivates (dx/dy) are supported */
  38587. standardDerivatives: boolean;
  38588. /** Defines if s3tc texture compression is supported */
  38589. s3tc?: WEBGL_compressed_texture_s3tc;
  38590. /** Defines if pvrtc texture compression is supported */
  38591. pvrtc: any;
  38592. /** Defines if etc1 texture compression is supported */
  38593. etc1: any;
  38594. /** Defines if etc2 texture compression is supported */
  38595. etc2: any;
  38596. /** Defines if astc texture compression is supported */
  38597. astc: any;
  38598. /** Defines if bptc texture compression is supported */
  38599. bptc: any;
  38600. /** Defines if float textures are supported */
  38601. textureFloat: boolean;
  38602. /** Defines if vertex array objects are supported */
  38603. vertexArrayObject: boolean;
  38604. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38605. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38606. /** Gets the maximum level of anisotropy supported */
  38607. maxAnisotropy: number;
  38608. /** Defines if instancing is supported */
  38609. instancedArrays: boolean;
  38610. /** Defines if 32 bits indices are supported */
  38611. uintIndices: boolean;
  38612. /** Defines if high precision shaders are supported */
  38613. highPrecisionShaderSupported: boolean;
  38614. /** Defines if depth reading in the fragment shader is supported */
  38615. fragmentDepthSupported: boolean;
  38616. /** Defines if float texture linear filtering is supported*/
  38617. textureFloatLinearFiltering: boolean;
  38618. /** Defines if rendering to float textures is supported */
  38619. textureFloatRender: boolean;
  38620. /** Defines if half float textures are supported*/
  38621. textureHalfFloat: boolean;
  38622. /** Defines if half float texture linear filtering is supported*/
  38623. textureHalfFloatLinearFiltering: boolean;
  38624. /** Defines if rendering to half float textures is supported */
  38625. textureHalfFloatRender: boolean;
  38626. /** Defines if textureLOD shader command is supported */
  38627. textureLOD: boolean;
  38628. /** Defines if draw buffers extension is supported */
  38629. drawBuffersExtension: boolean;
  38630. /** Defines if depth textures are supported */
  38631. depthTextureExtension: boolean;
  38632. /** Defines if float color buffer are supported */
  38633. colorBufferFloat: boolean;
  38634. /** Gets disjoint timer query extension (null if not supported) */
  38635. timerQuery?: EXT_disjoint_timer_query;
  38636. /** Defines if timestamp can be used with timer query */
  38637. canUseTimestampForTimerQuery: boolean;
  38638. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38639. multiview?: any;
  38640. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38641. oculusMultiview?: any;
  38642. /** Function used to let the system compiles shaders in background */
  38643. parallelShaderCompile?: {
  38644. COMPLETION_STATUS_KHR: number;
  38645. };
  38646. /** Max number of texture samples for MSAA */
  38647. maxMSAASamples: number;
  38648. /** Defines if the blend min max extension is supported */
  38649. blendMinMax: boolean;
  38650. }
  38651. }
  38652. declare module BABYLON {
  38653. /**
  38654. * @hidden
  38655. **/
  38656. export class DepthCullingState {
  38657. private _isDepthTestDirty;
  38658. private _isDepthMaskDirty;
  38659. private _isDepthFuncDirty;
  38660. private _isCullFaceDirty;
  38661. private _isCullDirty;
  38662. private _isZOffsetDirty;
  38663. private _isFrontFaceDirty;
  38664. private _depthTest;
  38665. private _depthMask;
  38666. private _depthFunc;
  38667. private _cull;
  38668. private _cullFace;
  38669. private _zOffset;
  38670. private _frontFace;
  38671. /**
  38672. * Initializes the state.
  38673. */
  38674. constructor();
  38675. get isDirty(): boolean;
  38676. get zOffset(): number;
  38677. set zOffset(value: number);
  38678. get cullFace(): Nullable<number>;
  38679. set cullFace(value: Nullable<number>);
  38680. get cull(): Nullable<boolean>;
  38681. set cull(value: Nullable<boolean>);
  38682. get depthFunc(): Nullable<number>;
  38683. set depthFunc(value: Nullable<number>);
  38684. get depthMask(): boolean;
  38685. set depthMask(value: boolean);
  38686. get depthTest(): boolean;
  38687. set depthTest(value: boolean);
  38688. get frontFace(): Nullable<number>;
  38689. set frontFace(value: Nullable<number>);
  38690. reset(): void;
  38691. apply(gl: WebGLRenderingContext): void;
  38692. }
  38693. }
  38694. declare module BABYLON {
  38695. /**
  38696. * @hidden
  38697. **/
  38698. export class StencilState {
  38699. /** 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 */
  38700. static readonly ALWAYS: number;
  38701. /** Passed to stencilOperation to specify that stencil value must be kept */
  38702. static readonly KEEP: number;
  38703. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38704. static readonly REPLACE: number;
  38705. private _isStencilTestDirty;
  38706. private _isStencilMaskDirty;
  38707. private _isStencilFuncDirty;
  38708. private _isStencilOpDirty;
  38709. private _stencilTest;
  38710. private _stencilMask;
  38711. private _stencilFunc;
  38712. private _stencilFuncRef;
  38713. private _stencilFuncMask;
  38714. private _stencilOpStencilFail;
  38715. private _stencilOpDepthFail;
  38716. private _stencilOpStencilDepthPass;
  38717. get isDirty(): boolean;
  38718. get stencilFunc(): number;
  38719. set stencilFunc(value: number);
  38720. get stencilFuncRef(): number;
  38721. set stencilFuncRef(value: number);
  38722. get stencilFuncMask(): number;
  38723. set stencilFuncMask(value: number);
  38724. get stencilOpStencilFail(): number;
  38725. set stencilOpStencilFail(value: number);
  38726. get stencilOpDepthFail(): number;
  38727. set stencilOpDepthFail(value: number);
  38728. get stencilOpStencilDepthPass(): number;
  38729. set stencilOpStencilDepthPass(value: number);
  38730. get stencilMask(): number;
  38731. set stencilMask(value: number);
  38732. get stencilTest(): boolean;
  38733. set stencilTest(value: boolean);
  38734. constructor();
  38735. reset(): void;
  38736. apply(gl: WebGLRenderingContext): void;
  38737. }
  38738. }
  38739. declare module BABYLON {
  38740. /**
  38741. * @hidden
  38742. **/
  38743. export class AlphaState {
  38744. private _isAlphaBlendDirty;
  38745. private _isBlendFunctionParametersDirty;
  38746. private _isBlendEquationParametersDirty;
  38747. private _isBlendConstantsDirty;
  38748. private _alphaBlend;
  38749. private _blendFunctionParameters;
  38750. private _blendEquationParameters;
  38751. private _blendConstants;
  38752. /**
  38753. * Initializes the state.
  38754. */
  38755. constructor();
  38756. get isDirty(): boolean;
  38757. get alphaBlend(): boolean;
  38758. set alphaBlend(value: boolean);
  38759. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38760. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38761. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38762. reset(): void;
  38763. apply(gl: WebGLRenderingContext): void;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /** @hidden */
  38768. export class WebGLShaderProcessor implements IShaderProcessor {
  38769. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /** @hidden */
  38774. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38775. attributeProcessor(attribute: string): string;
  38776. varyingProcessor(varying: string, isFragment: boolean): string;
  38777. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Interface for attribute information associated with buffer instanciation
  38783. */
  38784. export interface InstancingAttributeInfo {
  38785. /**
  38786. * Name of the GLSL attribute
  38787. * if attribute index is not specified, this is used to retrieve the index from the effect
  38788. */
  38789. attributeName: string;
  38790. /**
  38791. * Index/offset of the attribute in the vertex shader
  38792. * if not specified, this will be computes from the name.
  38793. */
  38794. index?: number;
  38795. /**
  38796. * size of the attribute, 1, 2, 3 or 4
  38797. */
  38798. attributeSize: number;
  38799. /**
  38800. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38801. */
  38802. offset: number;
  38803. /**
  38804. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38805. * default to 1
  38806. */
  38807. divisor?: number;
  38808. /**
  38809. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38810. * default is FLOAT
  38811. */
  38812. attributeType?: number;
  38813. /**
  38814. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38815. */
  38816. normalized?: boolean;
  38817. }
  38818. }
  38819. declare module BABYLON {
  38820. interface ThinEngine {
  38821. /**
  38822. * Update a video texture
  38823. * @param texture defines the texture to update
  38824. * @param video defines the video element to use
  38825. * @param invertY defines if data must be stored with Y axis inverted
  38826. */
  38827. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38828. }
  38829. }
  38830. declare module BABYLON {
  38831. interface ThinEngine {
  38832. /**
  38833. * Creates a dynamic texture
  38834. * @param width defines the width of the texture
  38835. * @param height defines the height of the texture
  38836. * @param generateMipMaps defines if the engine should generate the mip levels
  38837. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38838. * @returns the dynamic texture inside an InternalTexture
  38839. */
  38840. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38841. /**
  38842. * Update the content of a dynamic texture
  38843. * @param texture defines the texture to update
  38844. * @param source defines the source containing the data
  38845. * @param invertY defines if data must be stored with Y axis inverted
  38846. * @param premulAlpha defines if alpha is stored as premultiplied
  38847. * @param format defines the format of the data
  38848. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38849. */
  38850. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38851. }
  38852. }
  38853. declare module BABYLON {
  38854. /**
  38855. * Settings for finer control over video usage
  38856. */
  38857. export interface VideoTextureSettings {
  38858. /**
  38859. * Applies `autoplay` to video, if specified
  38860. */
  38861. autoPlay?: boolean;
  38862. /**
  38863. * Applies `muted` to video, if specified
  38864. */
  38865. muted?: boolean;
  38866. /**
  38867. * Applies `loop` to video, if specified
  38868. */
  38869. loop?: boolean;
  38870. /**
  38871. * Automatically updates internal texture from video at every frame in the render loop
  38872. */
  38873. autoUpdateTexture: boolean;
  38874. /**
  38875. * Image src displayed during the video loading or until the user interacts with the video.
  38876. */
  38877. poster?: string;
  38878. }
  38879. /**
  38880. * If you want to display a video in your scene, this is the special texture for that.
  38881. * This special texture works similar to other textures, with the exception of a few parameters.
  38882. * @see https://doc.babylonjs.com/how_to/video_texture
  38883. */
  38884. export class VideoTexture extends Texture {
  38885. /**
  38886. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38887. */
  38888. readonly autoUpdateTexture: boolean;
  38889. /**
  38890. * The video instance used by the texture internally
  38891. */
  38892. readonly video: HTMLVideoElement;
  38893. private _onUserActionRequestedObservable;
  38894. /**
  38895. * Event triggerd when a dom action is required by the user to play the video.
  38896. * This happens due to recent changes in browser policies preventing video to auto start.
  38897. */
  38898. get onUserActionRequestedObservable(): Observable<Texture>;
  38899. private _generateMipMaps;
  38900. private _stillImageCaptured;
  38901. private _displayingPosterTexture;
  38902. private _settings;
  38903. private _createInternalTextureOnEvent;
  38904. private _frameId;
  38905. private _currentSrc;
  38906. /**
  38907. * Creates a video texture.
  38908. * If you want to display a video in your scene, this is the special texture for that.
  38909. * This special texture works similar to other textures, with the exception of a few parameters.
  38910. * @see https://doc.babylonjs.com/how_to/video_texture
  38911. * @param name optional name, will detect from video source, if not defined
  38912. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38913. * @param scene is obviously the current scene.
  38914. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38915. * @param invertY is false by default but can be used to invert video on Y axis
  38916. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38917. * @param settings allows finer control over video usage
  38918. */
  38919. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38920. private _getName;
  38921. private _getVideo;
  38922. private _createInternalTexture;
  38923. private reset;
  38924. /**
  38925. * @hidden Internal method to initiate `update`.
  38926. */
  38927. _rebuild(): void;
  38928. /**
  38929. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38930. */
  38931. update(): void;
  38932. /**
  38933. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38934. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38935. */
  38936. updateTexture(isVisible: boolean): void;
  38937. protected _updateInternalTexture: () => void;
  38938. /**
  38939. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38940. * @param url New url.
  38941. */
  38942. updateURL(url: string): void;
  38943. /**
  38944. * Clones the texture.
  38945. * @returns the cloned texture
  38946. */
  38947. clone(): VideoTexture;
  38948. /**
  38949. * Dispose the texture and release its associated resources.
  38950. */
  38951. dispose(): void;
  38952. /**
  38953. * Creates a video texture straight from a stream.
  38954. * @param scene Define the scene the texture should be created in
  38955. * @param stream Define the stream the texture should be created from
  38956. * @returns The created video texture as a promise
  38957. */
  38958. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38959. /**
  38960. * Creates a video texture straight from your WebCam video feed.
  38961. * @param scene Define the scene the texture should be created in
  38962. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38963. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38964. * @returns The created video texture as a promise
  38965. */
  38966. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38967. minWidth: number;
  38968. maxWidth: number;
  38969. minHeight: number;
  38970. maxHeight: number;
  38971. deviceId: string;
  38972. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38973. /**
  38974. * Creates a video texture straight from your WebCam video feed.
  38975. * @param scene Define the scene the texture should be created in
  38976. * @param onReady Define a callback to triggered once the texture will be ready
  38977. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38978. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38979. */
  38980. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38981. minWidth: number;
  38982. maxWidth: number;
  38983. minHeight: number;
  38984. maxHeight: number;
  38985. deviceId: string;
  38986. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38987. }
  38988. }
  38989. declare module BABYLON {
  38990. /**
  38991. * Defines the interface used by objects working like Scene
  38992. * @hidden
  38993. */
  38994. export interface ISceneLike {
  38995. _addPendingData(data: any): void;
  38996. _removePendingData(data: any): void;
  38997. offlineProvider: IOfflineProvider;
  38998. }
  38999. /**
  39000. * Information about the current host
  39001. */
  39002. export interface HostInformation {
  39003. /**
  39004. * Defines if the current host is a mobile
  39005. */
  39006. isMobile: boolean;
  39007. }
  39008. /** Interface defining initialization parameters for Engine class */
  39009. export interface EngineOptions extends WebGLContextAttributes {
  39010. /**
  39011. * Defines if the engine should no exceed a specified device ratio
  39012. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39013. */
  39014. limitDeviceRatio?: number;
  39015. /**
  39016. * Defines if webvr should be enabled automatically
  39017. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39018. */
  39019. autoEnableWebVR?: boolean;
  39020. /**
  39021. * Defines if webgl2 should be turned off even if supported
  39022. * @see https://doc.babylonjs.com/features/webgl2
  39023. */
  39024. disableWebGL2Support?: boolean;
  39025. /**
  39026. * Defines if webaudio should be initialized as well
  39027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39028. */
  39029. audioEngine?: boolean;
  39030. /**
  39031. * Defines if animations should run using a deterministic lock step
  39032. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39033. */
  39034. deterministicLockstep?: boolean;
  39035. /** Defines the maximum steps to use with deterministic lock step mode */
  39036. lockstepMaxSteps?: number;
  39037. /** Defines the seconds between each deterministic lock step */
  39038. timeStep?: number;
  39039. /**
  39040. * Defines that engine should ignore context lost events
  39041. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39042. */
  39043. doNotHandleContextLost?: boolean;
  39044. /**
  39045. * Defines that engine should ignore modifying touch action attribute and style
  39046. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39047. */
  39048. doNotHandleTouchAction?: boolean;
  39049. /**
  39050. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39051. */
  39052. useHighPrecisionFloats?: boolean;
  39053. /**
  39054. * Make the canvas XR Compatible for XR sessions
  39055. */
  39056. xrCompatible?: boolean;
  39057. /**
  39058. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39059. */
  39060. useHighPrecisionMatrix?: boolean;
  39061. /**
  39062. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39063. */
  39064. failIfMajorPerformanceCaveat?: boolean;
  39065. }
  39066. /**
  39067. * The base engine class (root of all engines)
  39068. */
  39069. export class ThinEngine {
  39070. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39071. static ExceptionList: ({
  39072. key: string;
  39073. capture: string;
  39074. captureConstraint: number;
  39075. targets: string[];
  39076. } | {
  39077. key: string;
  39078. capture: null;
  39079. captureConstraint: null;
  39080. targets: string[];
  39081. })[];
  39082. /** @hidden */
  39083. static _TextureLoaders: IInternalTextureLoader[];
  39084. /**
  39085. * Returns the current npm package of the sdk
  39086. */
  39087. static get NpmPackage(): string;
  39088. /**
  39089. * Returns the current version of the framework
  39090. */
  39091. static get Version(): string;
  39092. /**
  39093. * Returns a string describing the current engine
  39094. */
  39095. get description(): string;
  39096. /**
  39097. * Gets or sets the epsilon value used by collision engine
  39098. */
  39099. static CollisionsEpsilon: number;
  39100. /**
  39101. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39102. */
  39103. static get ShadersRepository(): string;
  39104. static set ShadersRepository(value: string);
  39105. /** @hidden */
  39106. _shaderProcessor: IShaderProcessor;
  39107. /**
  39108. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39109. */
  39110. forcePOTTextures: boolean;
  39111. /**
  39112. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39113. */
  39114. isFullscreen: boolean;
  39115. /**
  39116. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39117. */
  39118. cullBackFaces: boolean;
  39119. /**
  39120. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39121. */
  39122. renderEvenInBackground: boolean;
  39123. /**
  39124. * Gets or sets a boolean indicating that cache can be kept between frames
  39125. */
  39126. preventCacheWipeBetweenFrames: boolean;
  39127. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39128. validateShaderPrograms: boolean;
  39129. /**
  39130. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39131. * This can provide greater z depth for distant objects.
  39132. */
  39133. useReverseDepthBuffer: boolean;
  39134. /**
  39135. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39136. */
  39137. disableUniformBuffers: boolean;
  39138. /** @hidden */
  39139. _uniformBuffers: UniformBuffer[];
  39140. /**
  39141. * Gets a boolean indicating that the engine supports uniform buffers
  39142. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39143. */
  39144. get supportsUniformBuffers(): boolean;
  39145. /** @hidden */
  39146. _gl: WebGLRenderingContext;
  39147. /** @hidden */
  39148. _webGLVersion: number;
  39149. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39150. protected _windowIsBackground: boolean;
  39151. protected _creationOptions: EngineOptions;
  39152. protected _highPrecisionShadersAllowed: boolean;
  39153. /** @hidden */
  39154. get _shouldUseHighPrecisionShader(): boolean;
  39155. /**
  39156. * Gets a boolean indicating that only power of 2 textures are supported
  39157. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39158. */
  39159. get needPOTTextures(): boolean;
  39160. /** @hidden */
  39161. _badOS: boolean;
  39162. /** @hidden */
  39163. _badDesktopOS: boolean;
  39164. private _hardwareScalingLevel;
  39165. /** @hidden */
  39166. _caps: EngineCapabilities;
  39167. private _isStencilEnable;
  39168. private _glVersion;
  39169. private _glRenderer;
  39170. private _glVendor;
  39171. /** @hidden */
  39172. _videoTextureSupported: boolean;
  39173. protected _renderingQueueLaunched: boolean;
  39174. protected _activeRenderLoops: (() => void)[];
  39175. /**
  39176. * Observable signaled when a context lost event is raised
  39177. */
  39178. onContextLostObservable: Observable<ThinEngine>;
  39179. /**
  39180. * Observable signaled when a context restored event is raised
  39181. */
  39182. onContextRestoredObservable: Observable<ThinEngine>;
  39183. private _onContextLost;
  39184. private _onContextRestored;
  39185. protected _contextWasLost: boolean;
  39186. /** @hidden */
  39187. _doNotHandleContextLost: boolean;
  39188. /**
  39189. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39191. */
  39192. get doNotHandleContextLost(): boolean;
  39193. set doNotHandleContextLost(value: boolean);
  39194. /**
  39195. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39196. */
  39197. disableVertexArrayObjects: boolean;
  39198. /** @hidden */
  39199. protected _colorWrite: boolean;
  39200. /** @hidden */
  39201. protected _colorWriteChanged: boolean;
  39202. /** @hidden */
  39203. protected _depthCullingState: DepthCullingState;
  39204. /** @hidden */
  39205. protected _stencilState: StencilState;
  39206. /** @hidden */
  39207. _alphaState: AlphaState;
  39208. /** @hidden */
  39209. _alphaMode: number;
  39210. /** @hidden */
  39211. _alphaEquation: number;
  39212. /** @hidden */
  39213. _internalTexturesCache: InternalTexture[];
  39214. /** @hidden */
  39215. protected _activeChannel: number;
  39216. private _currentTextureChannel;
  39217. /** @hidden */
  39218. protected _boundTexturesCache: {
  39219. [key: string]: Nullable<InternalTexture>;
  39220. };
  39221. /** @hidden */
  39222. protected _currentEffect: Nullable<Effect>;
  39223. /** @hidden */
  39224. protected _currentProgram: Nullable<WebGLProgram>;
  39225. private _compiledEffects;
  39226. private _vertexAttribArraysEnabled;
  39227. /** @hidden */
  39228. protected _cachedViewport: Nullable<IViewportLike>;
  39229. private _cachedVertexArrayObject;
  39230. /** @hidden */
  39231. protected _cachedVertexBuffers: any;
  39232. /** @hidden */
  39233. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39234. /** @hidden */
  39235. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39236. /** @hidden */
  39237. _currentRenderTarget: Nullable<InternalTexture>;
  39238. private _uintIndicesCurrentlySet;
  39239. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39240. /** @hidden */
  39241. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39242. /** @hidden */
  39243. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39244. private _currentBufferPointers;
  39245. private _currentInstanceLocations;
  39246. private _currentInstanceBuffers;
  39247. private _textureUnits;
  39248. /** @hidden */
  39249. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39250. /** @hidden */
  39251. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39252. /** @hidden */
  39253. _boundRenderFunction: any;
  39254. private _vaoRecordInProgress;
  39255. private _mustWipeVertexAttributes;
  39256. private _emptyTexture;
  39257. private _emptyCubeTexture;
  39258. private _emptyTexture3D;
  39259. private _emptyTexture2DArray;
  39260. /** @hidden */
  39261. _frameHandler: number;
  39262. private _nextFreeTextureSlots;
  39263. private _maxSimultaneousTextures;
  39264. private _activeRequests;
  39265. /** @hidden */
  39266. _transformTextureUrl: Nullable<(url: string) => string>;
  39267. /**
  39268. * Gets information about the current host
  39269. */
  39270. hostInformation: HostInformation;
  39271. protected get _supportsHardwareTextureRescaling(): boolean;
  39272. private _framebufferDimensionsObject;
  39273. /**
  39274. * sets the object from which width and height will be taken from when getting render width and height
  39275. * Will fallback to the gl object
  39276. * @param dimensions the framebuffer width and height that will be used.
  39277. */
  39278. set framebufferDimensionsObject(dimensions: Nullable<{
  39279. framebufferWidth: number;
  39280. framebufferHeight: number;
  39281. }>);
  39282. /**
  39283. * Gets the current viewport
  39284. */
  39285. get currentViewport(): Nullable<IViewportLike>;
  39286. /**
  39287. * Gets the default empty texture
  39288. */
  39289. get emptyTexture(): InternalTexture;
  39290. /**
  39291. * Gets the default empty 3D texture
  39292. */
  39293. get emptyTexture3D(): InternalTexture;
  39294. /**
  39295. * Gets the default empty 2D array texture
  39296. */
  39297. get emptyTexture2DArray(): InternalTexture;
  39298. /**
  39299. * Gets the default empty cube texture
  39300. */
  39301. get emptyCubeTexture(): InternalTexture;
  39302. /**
  39303. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39304. */
  39305. readonly premultipliedAlpha: boolean;
  39306. /**
  39307. * Observable event triggered before each texture is initialized
  39308. */
  39309. onBeforeTextureInitObservable: Observable<Texture>;
  39310. /**
  39311. * Creates a new engine
  39312. * @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
  39313. * @param antialias defines enable antialiasing (default: false)
  39314. * @param options defines further options to be sent to the getContext() function
  39315. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39316. */
  39317. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39318. private _rebuildInternalTextures;
  39319. private _rebuildEffects;
  39320. /**
  39321. * Gets a boolean indicating if all created effects are ready
  39322. * @returns true if all effects are ready
  39323. */
  39324. areAllEffectsReady(): boolean;
  39325. protected _rebuildBuffers(): void;
  39326. protected _initGLContext(): void;
  39327. /**
  39328. * Gets version of the current webGL context
  39329. */
  39330. get webGLVersion(): number;
  39331. /**
  39332. * Gets a string identifying the name of the class
  39333. * @returns "Engine" string
  39334. */
  39335. getClassName(): string;
  39336. /**
  39337. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39338. */
  39339. get isStencilEnable(): boolean;
  39340. /** @hidden */
  39341. _prepareWorkingCanvas(): void;
  39342. /**
  39343. * Reset the texture cache to empty state
  39344. */
  39345. resetTextureCache(): void;
  39346. /**
  39347. * Gets an object containing information about the current webGL context
  39348. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39349. */
  39350. getGlInfo(): {
  39351. vendor: string;
  39352. renderer: string;
  39353. version: string;
  39354. };
  39355. /**
  39356. * Defines the hardware scaling level.
  39357. * By default the hardware scaling level is computed from the window device ratio.
  39358. * 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.
  39359. * @param level defines the level to use
  39360. */
  39361. setHardwareScalingLevel(level: number): void;
  39362. /**
  39363. * Gets the current hardware scaling level.
  39364. * By default the hardware scaling level is computed from the window device ratio.
  39365. * 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.
  39366. * @returns a number indicating the current hardware scaling level
  39367. */
  39368. getHardwareScalingLevel(): number;
  39369. /**
  39370. * Gets the list of loaded textures
  39371. * @returns an array containing all loaded textures
  39372. */
  39373. getLoadedTexturesCache(): InternalTexture[];
  39374. /**
  39375. * Gets the object containing all engine capabilities
  39376. * @returns the EngineCapabilities object
  39377. */
  39378. getCaps(): EngineCapabilities;
  39379. /**
  39380. * stop executing a render loop function and remove it from the execution array
  39381. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39382. */
  39383. stopRenderLoop(renderFunction?: () => void): void;
  39384. /** @hidden */
  39385. _renderLoop(): void;
  39386. /**
  39387. * Gets the HTML canvas attached with the current webGL context
  39388. * @returns a HTML canvas
  39389. */
  39390. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39391. /**
  39392. * Gets host window
  39393. * @returns the host window object
  39394. */
  39395. getHostWindow(): Nullable<Window>;
  39396. /**
  39397. * Gets the current render width
  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 width
  39400. */
  39401. getRenderWidth(useScreen?: boolean): number;
  39402. /**
  39403. * Gets the current render height
  39404. * @param useScreen defines if screen size must be used (or the current render target if any)
  39405. * @returns a number defining the current render height
  39406. */
  39407. getRenderHeight(useScreen?: boolean): number;
  39408. /**
  39409. * Can be used to override the current requestAnimationFrame requester.
  39410. * @hidden
  39411. */
  39412. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39413. /**
  39414. * Register and execute a render loop. The engine can have more than one render function
  39415. * @param renderFunction defines the function to continuously execute
  39416. */
  39417. runRenderLoop(renderFunction: () => void): void;
  39418. /**
  39419. * Clear the current render buffer or the current render target (if any is set up)
  39420. * @param color defines the color to use
  39421. * @param backBuffer defines if the back buffer must be cleared
  39422. * @param depth defines if the depth buffer must be cleared
  39423. * @param stencil defines if the stencil buffer must be cleared
  39424. */
  39425. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39426. private _viewportCached;
  39427. /** @hidden */
  39428. _viewport(x: number, y: number, width: number, height: number): void;
  39429. /**
  39430. * Set the WebGL's viewport
  39431. * @param viewport defines the viewport element to be used
  39432. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39433. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39434. */
  39435. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39436. /**
  39437. * Begin a new frame
  39438. */
  39439. beginFrame(): void;
  39440. /**
  39441. * Enf the current frame
  39442. */
  39443. endFrame(): void;
  39444. /**
  39445. * Resize the view according to the canvas' size
  39446. */
  39447. resize(): void;
  39448. /**
  39449. * Force a specific size of the canvas
  39450. * @param width defines the new canvas' width
  39451. * @param height defines the new canvas' height
  39452. * @returns true if the size was changed
  39453. */
  39454. setSize(width: number, height: number): boolean;
  39455. /**
  39456. * Binds the frame buffer to the specified texture.
  39457. * @param texture The texture to render to or null for the default canvas
  39458. * @param faceIndex The face of the texture to render to in case of cube texture
  39459. * @param requiredWidth The width of the target to render to
  39460. * @param requiredHeight The height of the target to render to
  39461. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39462. * @param lodLevel defines the lod level to bind to the frame buffer
  39463. * @param layer defines the 2d array index to bind to frame buffer to
  39464. */
  39465. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39466. /** @hidden */
  39467. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39468. /**
  39469. * Unbind the current render target texture from the webGL context
  39470. * @param texture defines the render target texture to unbind
  39471. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39472. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39473. */
  39474. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39475. /**
  39476. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39477. */
  39478. flushFramebuffer(): void;
  39479. /**
  39480. * Unbind the current render target and bind the default framebuffer
  39481. */
  39482. restoreDefaultFramebuffer(): void;
  39483. /** @hidden */
  39484. protected _resetVertexBufferBinding(): void;
  39485. /**
  39486. * Creates a vertex buffer
  39487. * @param data the data for the vertex buffer
  39488. * @returns the new WebGL static buffer
  39489. */
  39490. createVertexBuffer(data: DataArray): DataBuffer;
  39491. private _createVertexBuffer;
  39492. /**
  39493. * Creates a dynamic vertex buffer
  39494. * @param data the data for the dynamic vertex buffer
  39495. * @returns the new WebGL dynamic buffer
  39496. */
  39497. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39498. protected _resetIndexBufferBinding(): void;
  39499. /**
  39500. * Creates a new index buffer
  39501. * @param indices defines the content of the index buffer
  39502. * @param updatable defines if the index buffer must be updatable
  39503. * @returns a new webGL buffer
  39504. */
  39505. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39506. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39507. /**
  39508. * Bind a webGL buffer to the webGL context
  39509. * @param buffer defines the buffer to bind
  39510. */
  39511. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39512. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39513. private bindBuffer;
  39514. /**
  39515. * update the bound buffer with the given data
  39516. * @param data defines the data to update
  39517. */
  39518. updateArrayBuffer(data: Float32Array): void;
  39519. private _vertexAttribPointer;
  39520. /** @hidden */
  39521. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39522. private _bindVertexBuffersAttributes;
  39523. /**
  39524. * Records a vertex array object
  39525. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39526. * @param vertexBuffers defines the list of vertex buffers to store
  39527. * @param indexBuffer defines the index buffer to store
  39528. * @param effect defines the effect to store
  39529. * @returns the new vertex array object
  39530. */
  39531. recordVertexArrayObject(vertexBuffers: {
  39532. [key: string]: VertexBuffer;
  39533. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39534. /**
  39535. * Bind a specific vertex array object
  39536. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39537. * @param vertexArrayObject defines the vertex array object to bind
  39538. * @param indexBuffer defines the index buffer to bind
  39539. */
  39540. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39541. /**
  39542. * Bind webGl buffers directly to the webGL context
  39543. * @param vertexBuffer defines the vertex buffer to bind
  39544. * @param indexBuffer defines the index buffer to bind
  39545. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39546. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39547. * @param effect defines the effect associated with the vertex buffer
  39548. */
  39549. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39550. private _unbindVertexArrayObject;
  39551. /**
  39552. * Bind a list of vertex buffers to the webGL context
  39553. * @param vertexBuffers defines the list of vertex buffers to bind
  39554. * @param indexBuffer defines the index buffer to bind
  39555. * @param effect defines the effect associated with the vertex buffers
  39556. */
  39557. bindBuffers(vertexBuffers: {
  39558. [key: string]: Nullable<VertexBuffer>;
  39559. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39560. /**
  39561. * Unbind all instance attributes
  39562. */
  39563. unbindInstanceAttributes(): void;
  39564. /**
  39565. * Release and free the memory of a vertex array object
  39566. * @param vao defines the vertex array object to delete
  39567. */
  39568. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39569. /** @hidden */
  39570. _releaseBuffer(buffer: DataBuffer): boolean;
  39571. protected _deleteBuffer(buffer: DataBuffer): void;
  39572. /**
  39573. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39574. * @param instancesBuffer defines the webGL buffer to update and bind
  39575. * @param data defines the data to store in the buffer
  39576. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39577. */
  39578. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39579. /**
  39580. * Bind the content of a webGL buffer used with instantiation
  39581. * @param instancesBuffer defines the webGL buffer to bind
  39582. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39583. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39584. */
  39585. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39586. /**
  39587. * Disable the instance attribute corresponding to the name in parameter
  39588. * @param name defines the name of the attribute to disable
  39589. */
  39590. disableInstanceAttributeByName(name: string): void;
  39591. /**
  39592. * Disable the instance attribute corresponding to the location in parameter
  39593. * @param attributeLocation defines the attribute location of the attribute to disable
  39594. */
  39595. disableInstanceAttribute(attributeLocation: number): void;
  39596. /**
  39597. * Disable the attribute corresponding to the location in parameter
  39598. * @param attributeLocation defines the attribute location of the attribute to disable
  39599. */
  39600. disableAttributeByIndex(attributeLocation: number): void;
  39601. /**
  39602. * Send a draw order
  39603. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39604. * @param indexStart defines the starting index
  39605. * @param indexCount defines the number of index to draw
  39606. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39607. */
  39608. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39609. /**
  39610. * Draw a list of points
  39611. * @param verticesStart defines the index of first vertex to draw
  39612. * @param verticesCount defines the count of vertices to draw
  39613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39614. */
  39615. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39616. /**
  39617. * Draw a list of unindexed primitives
  39618. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39619. * @param verticesStart defines the index of first vertex to draw
  39620. * @param verticesCount defines the count of vertices to draw
  39621. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39622. */
  39623. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39624. /**
  39625. * Draw a list of indexed primitives
  39626. * @param fillMode defines the primitive to use
  39627. * @param indexStart defines the starting index
  39628. * @param indexCount defines the number of index to draw
  39629. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39630. */
  39631. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39632. /**
  39633. * Draw a list of unindexed primitives
  39634. * @param fillMode defines the primitive to use
  39635. * @param verticesStart defines the index of first vertex to draw
  39636. * @param verticesCount defines the count of vertices to draw
  39637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39638. */
  39639. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39640. private _drawMode;
  39641. /** @hidden */
  39642. protected _reportDrawCall(): void;
  39643. /** @hidden */
  39644. _releaseEffect(effect: Effect): void;
  39645. /** @hidden */
  39646. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39647. /**
  39648. * Create a new effect (used to store vertex/fragment shaders)
  39649. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39650. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39651. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39652. * @param samplers defines an array of string used to represent textures
  39653. * @param defines defines the string containing the defines to use to compile the shaders
  39654. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39655. * @param onCompiled defines a function to call when the effect creation is successful
  39656. * @param onError defines a function to call when the effect creation has failed
  39657. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39658. * @returns the new Effect
  39659. */
  39660. 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;
  39661. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39662. private _compileShader;
  39663. private _compileRawShader;
  39664. /** @hidden */
  39665. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39666. /**
  39667. * Directly creates a webGL program
  39668. * @param pipelineContext defines the pipeline context to attach to
  39669. * @param vertexCode defines the vertex shader code to use
  39670. * @param fragmentCode defines the fragment shader code to use
  39671. * @param context defines the webGL context to use (if not set, the current one will be used)
  39672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39673. * @returns the new webGL program
  39674. */
  39675. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39676. /**
  39677. * Creates a webGL program
  39678. * @param pipelineContext defines the pipeline context to attach to
  39679. * @param vertexCode defines the vertex shader code to use
  39680. * @param fragmentCode defines the fragment shader code to use
  39681. * @param defines defines the string containing the defines to use to compile the shaders
  39682. * @param context defines the webGL context to use (if not set, the current one will be used)
  39683. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39684. * @returns the new webGL program
  39685. */
  39686. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39687. /**
  39688. * Creates a new pipeline context
  39689. * @returns the new pipeline
  39690. */
  39691. createPipelineContext(): IPipelineContext;
  39692. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39693. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39694. /** @hidden */
  39695. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39696. /** @hidden */
  39697. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39698. /** @hidden */
  39699. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39700. /**
  39701. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39702. * @param pipelineContext defines the pipeline context to use
  39703. * @param uniformsNames defines the list of uniform names
  39704. * @returns an array of webGL uniform locations
  39705. */
  39706. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39707. /**
  39708. * Gets the lsit of active attributes for a given webGL program
  39709. * @param pipelineContext defines the pipeline context to use
  39710. * @param attributesNames defines the list of attribute names to get
  39711. * @returns an array of indices indicating the offset of each attribute
  39712. */
  39713. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39714. /**
  39715. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39716. * @param effect defines the effect to activate
  39717. */
  39718. enableEffect(effect: Nullable<Effect>): void;
  39719. /**
  39720. * Set the value of an uniform to a number (int)
  39721. * @param uniform defines the webGL uniform location where to store the value
  39722. * @param value defines the int number to store
  39723. * @returns true if the value was set
  39724. */
  39725. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39726. /**
  39727. * Set the value of an uniform to an array of int32
  39728. * @param uniform defines the webGL uniform location where to store the value
  39729. * @param array defines the array of int32 to store
  39730. * @returns true if the value was set
  39731. */
  39732. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39733. /**
  39734. * Set the value of an uniform to an array of int32 (stored as vec2)
  39735. * @param uniform defines the webGL uniform location where to store the value
  39736. * @param array defines the array of int32 to store
  39737. * @returns true if the value was set
  39738. */
  39739. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39740. /**
  39741. * Set the value of an uniform to an array of int32 (stored as vec3)
  39742. * @param uniform defines the webGL uniform location where to store the value
  39743. * @param array defines the array of int32 to store
  39744. * @returns true if the value was set
  39745. */
  39746. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39747. /**
  39748. * Set the value of an uniform to an array of int32 (stored as vec4)
  39749. * @param uniform defines the webGL uniform location where to store the value
  39750. * @param array defines the array of int32 to store
  39751. * @returns true if the value was set
  39752. */
  39753. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39754. /**
  39755. * Set the value of an uniform to an array of number
  39756. * @param uniform defines the webGL uniform location where to store the value
  39757. * @param array defines the array of number to store
  39758. * @returns true if the value was set
  39759. */
  39760. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39761. /**
  39762. * Set the value of an uniform to an array of number (stored as vec2)
  39763. * @param uniform defines the webGL uniform location where to store the value
  39764. * @param array defines the array of number to store
  39765. * @returns true if the value was set
  39766. */
  39767. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39768. /**
  39769. * Set the value of an uniform to an array of number (stored as vec3)
  39770. * @param uniform defines the webGL uniform location where to store the value
  39771. * @param array defines the array of number to store
  39772. * @returns true if the value was set
  39773. */
  39774. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39775. /**
  39776. * Set the value of an uniform to an array of number (stored as vec4)
  39777. * @param uniform defines the webGL uniform location where to store the value
  39778. * @param array defines the array of number to store
  39779. * @returns true if the value was set
  39780. */
  39781. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39782. /**
  39783. * Set the value of an uniform to an array of float32 (stored as matrices)
  39784. * @param uniform defines the webGL uniform location where to store the value
  39785. * @param matrices defines the array of float32 to store
  39786. * @returns true if the value was set
  39787. */
  39788. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39789. /**
  39790. * Set the value of an uniform to a matrix (3x3)
  39791. * @param uniform defines the webGL uniform location where to store the value
  39792. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39793. * @returns true if the value was set
  39794. */
  39795. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39796. /**
  39797. * Set the value of an uniform to a matrix (2x2)
  39798. * @param uniform defines the webGL uniform location where to store the value
  39799. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39800. * @returns true if the value was set
  39801. */
  39802. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39803. /**
  39804. * Set the value of an uniform to a number (float)
  39805. * @param uniform defines the webGL uniform location where to store the value
  39806. * @param value defines the float number to store
  39807. * @returns true if the value was transfered
  39808. */
  39809. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39810. /**
  39811. * Set the value of an uniform to a vec2
  39812. * @param uniform defines the webGL uniform location where to store the value
  39813. * @param x defines the 1st component of the value
  39814. * @param y defines the 2nd component of the value
  39815. * @returns true if the value was set
  39816. */
  39817. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39818. /**
  39819. * Set the value of an uniform to a vec3
  39820. * @param uniform defines the webGL uniform location where to store the value
  39821. * @param x defines the 1st component of the value
  39822. * @param y defines the 2nd component of the value
  39823. * @param z defines the 3rd component of the value
  39824. * @returns true if the value was set
  39825. */
  39826. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39827. /**
  39828. * Set the value of an uniform to a vec4
  39829. * @param uniform defines the webGL uniform location where to store the value
  39830. * @param x defines the 1st component of the value
  39831. * @param y defines the 2nd component of the value
  39832. * @param z defines the 3rd component of the value
  39833. * @param w defines the 4th component of the value
  39834. * @returns true if the value was set
  39835. */
  39836. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39837. /**
  39838. * Apply all cached states (depth, culling, stencil and alpha)
  39839. */
  39840. applyStates(): void;
  39841. /**
  39842. * Enable or disable color writing
  39843. * @param enable defines the state to set
  39844. */
  39845. setColorWrite(enable: boolean): void;
  39846. /**
  39847. * Gets a boolean indicating if color writing is enabled
  39848. * @returns the current color writing state
  39849. */
  39850. getColorWrite(): boolean;
  39851. /**
  39852. * Gets the depth culling state manager
  39853. */
  39854. get depthCullingState(): DepthCullingState;
  39855. /**
  39856. * Gets the alpha state manager
  39857. */
  39858. get alphaState(): AlphaState;
  39859. /**
  39860. * Gets the stencil state manager
  39861. */
  39862. get stencilState(): StencilState;
  39863. /**
  39864. * Clears the list of texture accessible through engine.
  39865. * This can help preventing texture load conflict due to name collision.
  39866. */
  39867. clearInternalTexturesCache(): void;
  39868. /**
  39869. * Force the entire cache to be cleared
  39870. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39871. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39872. */
  39873. wipeCaches(bruteForce?: boolean): void;
  39874. /** @hidden */
  39875. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39876. min: number;
  39877. mag: number;
  39878. };
  39879. /** @hidden */
  39880. _createTexture(): WebGLTexture;
  39881. /**
  39882. * Usually called from Texture.ts.
  39883. * Passed information to create a WebGLTexture
  39884. * @param url defines a value which contains one of the following:
  39885. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39886. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39887. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39888. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39889. * @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)
  39890. * @param scene needed for loading to the correct scene
  39891. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39892. * @param onLoad optional callback to be called upon successful completion
  39893. * @param onError optional callback to be called upon failure
  39894. * @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
  39895. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39896. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39897. * @param forcedExtension defines the extension to use to pick the right loader
  39898. * @param mimeType defines an optional mime type
  39899. * @param loaderOptions options to be passed to the loader
  39900. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39901. */
  39902. 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;
  39903. /**
  39904. * Loads an image as an HTMLImageElement.
  39905. * @param input url string, ArrayBuffer, or Blob to load
  39906. * @param onLoad callback called when the image successfully loads
  39907. * @param onError callback called when the image fails to load
  39908. * @param offlineProvider offline provider for caching
  39909. * @param mimeType optional mime type
  39910. * @returns the HTMLImageElement of the loaded image
  39911. * @hidden
  39912. */
  39913. 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>;
  39914. /**
  39915. * @hidden
  39916. */
  39917. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39918. private _unpackFlipYCached;
  39919. /**
  39920. * In case you are sharing the context with other applications, it might
  39921. * be interested to not cache the unpack flip y state to ensure a consistent
  39922. * value would be set.
  39923. */
  39924. enableUnpackFlipYCached: boolean;
  39925. /** @hidden */
  39926. _unpackFlipY(value: boolean): void;
  39927. /** @hidden */
  39928. _getUnpackAlignement(): number;
  39929. private _getTextureTarget;
  39930. /**
  39931. * Update the sampling mode of a given texture
  39932. * @param samplingMode defines the required sampling mode
  39933. * @param texture defines the texture to update
  39934. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39935. */
  39936. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39937. /**
  39938. * Update the sampling mode of a given texture
  39939. * @param texture defines the texture to update
  39940. * @param wrapU defines the texture wrap mode of the u coordinates
  39941. * @param wrapV defines the texture wrap mode of the v coordinates
  39942. * @param wrapR defines the texture wrap mode of the r coordinates
  39943. */
  39944. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39945. /** @hidden */
  39946. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39947. width: number;
  39948. height: number;
  39949. layers?: number;
  39950. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39951. /** @hidden */
  39952. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39953. /** @hidden */
  39954. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39955. /**
  39956. * Update a portion of an internal texture
  39957. * @param texture defines the texture to update
  39958. * @param imageData defines the data to store into the texture
  39959. * @param xOffset defines the x coordinates of the update rectangle
  39960. * @param yOffset defines the y coordinates of the update rectangle
  39961. * @param width defines the width of the update rectangle
  39962. * @param height defines the height of the update rectangle
  39963. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39964. * @param lod defines the lod level to update (0 by default)
  39965. */
  39966. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39967. /** @hidden */
  39968. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39969. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39970. private _prepareWebGLTexture;
  39971. /** @hidden */
  39972. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39973. private _getDepthStencilBuffer;
  39974. /** @hidden */
  39975. _releaseFramebufferObjects(texture: InternalTexture): void;
  39976. /** @hidden */
  39977. _releaseTexture(texture: InternalTexture): void;
  39978. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39979. protected _setProgram(program: WebGLProgram): void;
  39980. protected _boundUniforms: {
  39981. [key: number]: WebGLUniformLocation;
  39982. };
  39983. /**
  39984. * Binds an effect to the webGL context
  39985. * @param effect defines the effect to bind
  39986. */
  39987. bindSamplers(effect: Effect): void;
  39988. private _activateCurrentTexture;
  39989. /** @hidden */
  39990. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39991. /** @hidden */
  39992. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39993. /**
  39994. * Unbind all textures from the webGL context
  39995. */
  39996. unbindAllTextures(): void;
  39997. /**
  39998. * Sets a texture to the according uniform.
  39999. * @param channel The texture channel
  40000. * @param uniform The uniform to set
  40001. * @param texture The texture to apply
  40002. */
  40003. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  40004. private _bindSamplerUniformToChannel;
  40005. private _getTextureWrapMode;
  40006. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40007. /**
  40008. * Sets an array of texture to the webGL context
  40009. * @param channel defines the channel where the texture array must be set
  40010. * @param uniform defines the associated uniform location
  40011. * @param textures defines the array of textures to bind
  40012. */
  40013. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  40014. /** @hidden */
  40015. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40016. private _setTextureParameterFloat;
  40017. private _setTextureParameterInteger;
  40018. /**
  40019. * Unbind all vertex attributes from the webGL context
  40020. */
  40021. unbindAllAttributes(): void;
  40022. /**
  40023. * 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
  40024. */
  40025. releaseEffects(): void;
  40026. /**
  40027. * Dispose and release all associated resources
  40028. */
  40029. dispose(): void;
  40030. /**
  40031. * Attach a new callback raised when context lost event is fired
  40032. * @param callback defines the callback to call
  40033. */
  40034. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40035. /**
  40036. * Attach a new callback raised when context restored event is fired
  40037. * @param callback defines the callback to call
  40038. */
  40039. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40040. /**
  40041. * Get the current error code of the webGL context
  40042. * @returns the error code
  40043. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40044. */
  40045. getError(): number;
  40046. private _canRenderToFloatFramebuffer;
  40047. private _canRenderToHalfFloatFramebuffer;
  40048. private _canRenderToFramebuffer;
  40049. /** @hidden */
  40050. _getWebGLTextureType(type: number): number;
  40051. /** @hidden */
  40052. _getInternalFormat(format: number): number;
  40053. /** @hidden */
  40054. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40055. /** @hidden */
  40056. _getRGBAMultiSampleBufferFormat(type: number): number;
  40057. /** @hidden */
  40058. _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;
  40059. /**
  40060. * Loads a file from a url
  40061. * @param url url to load
  40062. * @param onSuccess callback called when the file successfully loads
  40063. * @param onProgress callback called while file is loading (if the server supports this mode)
  40064. * @param offlineProvider defines the offline provider for caching
  40065. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40066. * @param onError callback called when the file fails to load
  40067. * @returns a file request object
  40068. * @hidden
  40069. */
  40070. 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;
  40071. /**
  40072. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40073. * @param x defines the x coordinate of the rectangle where pixels must be read
  40074. * @param y defines the y coordinate of the rectangle where pixels must be read
  40075. * @param width defines the width of the rectangle where pixels must be read
  40076. * @param height defines the height of the rectangle where pixels must be read
  40077. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40078. * @returns a Uint8Array containing RGBA colors
  40079. */
  40080. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40081. private static _IsSupported;
  40082. private static _HasMajorPerformanceCaveat;
  40083. /**
  40084. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40085. */
  40086. static get IsSupported(): boolean;
  40087. /**
  40088. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40089. * @returns true if the engine can be created
  40090. * @ignorenaming
  40091. */
  40092. static isSupported(): boolean;
  40093. /**
  40094. * 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)
  40095. */
  40096. static get HasMajorPerformanceCaveat(): boolean;
  40097. /**
  40098. * Find the next highest power of two.
  40099. * @param x Number to start search from.
  40100. * @return Next highest power of two.
  40101. */
  40102. static CeilingPOT(x: number): number;
  40103. /**
  40104. * Find the next lowest power of two.
  40105. * @param x Number to start search from.
  40106. * @return Next lowest power of two.
  40107. */
  40108. static FloorPOT(x: number): number;
  40109. /**
  40110. * Find the nearest power of two.
  40111. * @param x Number to start search from.
  40112. * @return Next nearest power of two.
  40113. */
  40114. static NearestPOT(x: number): number;
  40115. /**
  40116. * Get the closest exponent of two
  40117. * @param value defines the value to approximate
  40118. * @param max defines the maximum value to return
  40119. * @param mode defines how to define the closest value
  40120. * @returns closest exponent of two of the given value
  40121. */
  40122. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40123. /**
  40124. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40125. * @param func - the function to be called
  40126. * @param requester - the object that will request the next frame. Falls back to window.
  40127. * @returns frame number
  40128. */
  40129. static QueueNewFrame(func: () => void, requester?: any): number;
  40130. /**
  40131. * Gets host document
  40132. * @returns the host document object
  40133. */
  40134. getHostDocument(): Nullable<Document>;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. /**
  40139. * Defines the source of the internal texture
  40140. */
  40141. export enum InternalTextureSource {
  40142. /**
  40143. * The source of the texture data is unknown
  40144. */
  40145. Unknown = 0,
  40146. /**
  40147. * Texture data comes from an URL
  40148. */
  40149. Url = 1,
  40150. /**
  40151. * Texture data is only used for temporary storage
  40152. */
  40153. Temp = 2,
  40154. /**
  40155. * Texture data comes from raw data (ArrayBuffer)
  40156. */
  40157. Raw = 3,
  40158. /**
  40159. * Texture content is dynamic (video or dynamic texture)
  40160. */
  40161. Dynamic = 4,
  40162. /**
  40163. * Texture content is generated by rendering to it
  40164. */
  40165. RenderTarget = 5,
  40166. /**
  40167. * Texture content is part of a multi render target process
  40168. */
  40169. MultiRenderTarget = 6,
  40170. /**
  40171. * Texture data comes from a cube data file
  40172. */
  40173. Cube = 7,
  40174. /**
  40175. * Texture data comes from a raw cube data
  40176. */
  40177. CubeRaw = 8,
  40178. /**
  40179. * Texture data come from a prefiltered cube data file
  40180. */
  40181. CubePrefiltered = 9,
  40182. /**
  40183. * Texture content is raw 3D data
  40184. */
  40185. Raw3D = 10,
  40186. /**
  40187. * Texture content is raw 2D array data
  40188. */
  40189. Raw2DArray = 11,
  40190. /**
  40191. * Texture content is a depth texture
  40192. */
  40193. Depth = 12,
  40194. /**
  40195. * Texture data comes from a raw cube data encoded with RGBD
  40196. */
  40197. CubeRawRGBD = 13
  40198. }
  40199. /**
  40200. * Class used to store data associated with WebGL texture data for the engine
  40201. * This class should not be used directly
  40202. */
  40203. export class InternalTexture {
  40204. /** @hidden */
  40205. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40206. /**
  40207. * Defines if the texture is ready
  40208. */
  40209. isReady: boolean;
  40210. /**
  40211. * Defines if the texture is a cube texture
  40212. */
  40213. isCube: boolean;
  40214. /**
  40215. * Defines if the texture contains 3D data
  40216. */
  40217. is3D: boolean;
  40218. /**
  40219. * Defines if the texture contains 2D array data
  40220. */
  40221. is2DArray: boolean;
  40222. /**
  40223. * Defines if the texture contains multiview data
  40224. */
  40225. isMultiview: boolean;
  40226. /**
  40227. * Gets the URL used to load this texture
  40228. */
  40229. url: string;
  40230. /** @hidden */
  40231. _originalUrl: string;
  40232. /**
  40233. * Gets the sampling mode of the texture
  40234. */
  40235. samplingMode: number;
  40236. /**
  40237. * Gets a boolean indicating if the texture needs mipmaps generation
  40238. */
  40239. generateMipMaps: boolean;
  40240. /**
  40241. * Gets the number of samples used by the texture (WebGL2+ only)
  40242. */
  40243. samples: number;
  40244. /**
  40245. * Gets the type of the texture (int, float...)
  40246. */
  40247. type: number;
  40248. /**
  40249. * Gets the format of the texture (RGB, RGBA...)
  40250. */
  40251. format: number;
  40252. /**
  40253. * Observable called when the texture is loaded
  40254. */
  40255. onLoadedObservable: Observable<InternalTexture>;
  40256. /**
  40257. * Gets the width of the texture
  40258. */
  40259. width: number;
  40260. /**
  40261. * Gets the height of the texture
  40262. */
  40263. height: number;
  40264. /**
  40265. * Gets the depth of the texture
  40266. */
  40267. depth: number;
  40268. /**
  40269. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40270. */
  40271. baseWidth: number;
  40272. /**
  40273. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40274. */
  40275. baseHeight: number;
  40276. /**
  40277. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40278. */
  40279. baseDepth: number;
  40280. /**
  40281. * Gets a boolean indicating if the texture is inverted on Y axis
  40282. */
  40283. invertY: boolean;
  40284. /** @hidden */
  40285. _invertVScale: boolean;
  40286. /** @hidden */
  40287. _associatedChannel: number;
  40288. /** @hidden */
  40289. _source: InternalTextureSource;
  40290. /** @hidden */
  40291. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40292. /** @hidden */
  40293. _bufferView: Nullable<ArrayBufferView>;
  40294. /** @hidden */
  40295. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40296. /** @hidden */
  40297. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40298. /** @hidden */
  40299. _size: number;
  40300. /** @hidden */
  40301. _extension: string;
  40302. /** @hidden */
  40303. _files: Nullable<string[]>;
  40304. /** @hidden */
  40305. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40306. /** @hidden */
  40307. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40308. /** @hidden */
  40309. _framebuffer: Nullable<WebGLFramebuffer>;
  40310. /** @hidden */
  40311. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40312. /** @hidden */
  40313. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40314. /** @hidden */
  40315. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40316. /** @hidden */
  40317. _attachments: Nullable<number[]>;
  40318. /** @hidden */
  40319. _textureArray: Nullable<InternalTexture[]>;
  40320. /** @hidden */
  40321. _cachedCoordinatesMode: Nullable<number>;
  40322. /** @hidden */
  40323. _cachedWrapU: Nullable<number>;
  40324. /** @hidden */
  40325. _cachedWrapV: Nullable<number>;
  40326. /** @hidden */
  40327. _cachedWrapR: Nullable<number>;
  40328. /** @hidden */
  40329. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40330. /** @hidden */
  40331. _isDisabled: boolean;
  40332. /** @hidden */
  40333. _compression: Nullable<string>;
  40334. /** @hidden */
  40335. _generateStencilBuffer: boolean;
  40336. /** @hidden */
  40337. _generateDepthBuffer: boolean;
  40338. /** @hidden */
  40339. _comparisonFunction: number;
  40340. /** @hidden */
  40341. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40342. /** @hidden */
  40343. _lodGenerationScale: number;
  40344. /** @hidden */
  40345. _lodGenerationOffset: number;
  40346. /** @hidden */
  40347. _depthStencilTexture: Nullable<InternalTexture>;
  40348. /** @hidden */
  40349. _colorTextureArray: Nullable<WebGLTexture>;
  40350. /** @hidden */
  40351. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40352. /** @hidden */
  40353. _lodTextureHigh: Nullable<BaseTexture>;
  40354. /** @hidden */
  40355. _lodTextureMid: Nullable<BaseTexture>;
  40356. /** @hidden */
  40357. _lodTextureLow: Nullable<BaseTexture>;
  40358. /** @hidden */
  40359. _isRGBD: boolean;
  40360. /** @hidden */
  40361. _linearSpecularLOD: boolean;
  40362. /** @hidden */
  40363. _irradianceTexture: Nullable<BaseTexture>;
  40364. /** @hidden */
  40365. _webGLTexture: Nullable<WebGLTexture>;
  40366. /** @hidden */
  40367. _references: number;
  40368. /** @hidden */
  40369. _gammaSpace: Nullable<boolean>;
  40370. private _engine;
  40371. /**
  40372. * Gets the Engine the texture belongs to.
  40373. * @returns The babylon engine
  40374. */
  40375. getEngine(): ThinEngine;
  40376. /**
  40377. * Gets the data source type of the texture
  40378. */
  40379. get source(): InternalTextureSource;
  40380. /**
  40381. * Creates a new InternalTexture
  40382. * @param engine defines the engine to use
  40383. * @param source defines the type of data that will be used
  40384. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40385. */
  40386. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40387. /**
  40388. * Increments the number of references (ie. the number of Texture that point to it)
  40389. */
  40390. incrementReferences(): void;
  40391. /**
  40392. * Change the size of the texture (not the size of the content)
  40393. * @param width defines the new width
  40394. * @param height defines the new height
  40395. * @param depth defines the new depth (1 by default)
  40396. */
  40397. updateSize(width: int, height: int, depth?: int): void;
  40398. /** @hidden */
  40399. _rebuild(): void;
  40400. /** @hidden */
  40401. _swapAndDie(target: InternalTexture): void;
  40402. /**
  40403. * Dispose the current allocated resources
  40404. */
  40405. dispose(): void;
  40406. }
  40407. }
  40408. declare module BABYLON {
  40409. /**
  40410. * Interface used to present a loading screen while loading a scene
  40411. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40412. */
  40413. export interface ILoadingScreen {
  40414. /**
  40415. * Function called to display the loading screen
  40416. */
  40417. displayLoadingUI: () => void;
  40418. /**
  40419. * Function called to hide the loading screen
  40420. */
  40421. hideLoadingUI: () => void;
  40422. /**
  40423. * Gets or sets the color to use for the background
  40424. */
  40425. loadingUIBackgroundColor: string;
  40426. /**
  40427. * Gets or sets the text to display while loading
  40428. */
  40429. loadingUIText: string;
  40430. }
  40431. /**
  40432. * Class used for the default loading screen
  40433. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40434. */
  40435. export class DefaultLoadingScreen implements ILoadingScreen {
  40436. private _renderingCanvas;
  40437. private _loadingText;
  40438. private _loadingDivBackgroundColor;
  40439. private _loadingDiv;
  40440. private _loadingTextDiv;
  40441. /** Gets or sets the logo url to use for the default loading screen */
  40442. static DefaultLogoUrl: string;
  40443. /** Gets or sets the spinner url to use for the default loading screen */
  40444. static DefaultSpinnerUrl: string;
  40445. /**
  40446. * Creates a new default loading screen
  40447. * @param _renderingCanvas defines the canvas used to render the scene
  40448. * @param _loadingText defines the default text to display
  40449. * @param _loadingDivBackgroundColor defines the default background color
  40450. */
  40451. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40452. /**
  40453. * Function called to display the loading screen
  40454. */
  40455. displayLoadingUI(): void;
  40456. /**
  40457. * Function called to hide the loading screen
  40458. */
  40459. hideLoadingUI(): void;
  40460. /**
  40461. * Gets or sets the text to display while loading
  40462. */
  40463. set loadingUIText(text: string);
  40464. get loadingUIText(): string;
  40465. /**
  40466. * Gets or sets the color to use for the background
  40467. */
  40468. get loadingUIBackgroundColor(): string;
  40469. set loadingUIBackgroundColor(color: string);
  40470. private _resizeLoadingUI;
  40471. }
  40472. }
  40473. declare module BABYLON {
  40474. /**
  40475. * Interface for any object that can request an animation frame
  40476. */
  40477. export interface ICustomAnimationFrameRequester {
  40478. /**
  40479. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40480. */
  40481. renderFunction?: Function;
  40482. /**
  40483. * Called to request the next frame to render to
  40484. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40485. */
  40486. requestAnimationFrame: Function;
  40487. /**
  40488. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40490. */
  40491. requestID?: number;
  40492. }
  40493. }
  40494. declare module BABYLON {
  40495. /**
  40496. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40497. */
  40498. export class PerformanceMonitor {
  40499. private _enabled;
  40500. private _rollingFrameTime;
  40501. private _lastFrameTimeMs;
  40502. /**
  40503. * constructor
  40504. * @param frameSampleSize The number of samples required to saturate the sliding window
  40505. */
  40506. constructor(frameSampleSize?: number);
  40507. /**
  40508. * Samples current frame
  40509. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40510. */
  40511. sampleFrame(timeMs?: number): void;
  40512. /**
  40513. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40514. */
  40515. get averageFrameTime(): number;
  40516. /**
  40517. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40518. */
  40519. get averageFrameTimeVariance(): number;
  40520. /**
  40521. * Returns the frame time of the most recent frame
  40522. */
  40523. get instantaneousFrameTime(): number;
  40524. /**
  40525. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40526. */
  40527. get averageFPS(): number;
  40528. /**
  40529. * Returns the average framerate in frames per second using the most recent frame time
  40530. */
  40531. get instantaneousFPS(): number;
  40532. /**
  40533. * Returns true if enough samples have been taken to completely fill the sliding window
  40534. */
  40535. get isSaturated(): boolean;
  40536. /**
  40537. * Enables contributions to the sliding window sample set
  40538. */
  40539. enable(): void;
  40540. /**
  40541. * Disables contributions to the sliding window sample set
  40542. * Samples will not be interpolated over the disabled period
  40543. */
  40544. disable(): void;
  40545. /**
  40546. * Returns true if sampling is enabled
  40547. */
  40548. get isEnabled(): boolean;
  40549. /**
  40550. * Resets performance monitor
  40551. */
  40552. reset(): void;
  40553. }
  40554. /**
  40555. * RollingAverage
  40556. *
  40557. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40558. */
  40559. export class RollingAverage {
  40560. /**
  40561. * Current average
  40562. */
  40563. average: number;
  40564. /**
  40565. * Current variance
  40566. */
  40567. variance: number;
  40568. protected _samples: Array<number>;
  40569. protected _sampleCount: number;
  40570. protected _pos: number;
  40571. protected _m2: number;
  40572. /**
  40573. * constructor
  40574. * @param length The number of samples required to saturate the sliding window
  40575. */
  40576. constructor(length: number);
  40577. /**
  40578. * Adds a sample to the sample set
  40579. * @param v The sample value
  40580. */
  40581. add(v: number): void;
  40582. /**
  40583. * Returns previously added values or null if outside of history or outside the sliding window domain
  40584. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40585. * @return Value previously recorded with add() or null if outside of range
  40586. */
  40587. history(i: number): number;
  40588. /**
  40589. * Returns true if enough samples have been taken to completely fill the sliding window
  40590. * @return true if sample-set saturated
  40591. */
  40592. isSaturated(): boolean;
  40593. /**
  40594. * Resets the rolling average (equivalent to 0 samples taken so far)
  40595. */
  40596. reset(): void;
  40597. /**
  40598. * Wraps a value around the sample range boundaries
  40599. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40600. * @return Wrapped position in sample range
  40601. */
  40602. protected _wrapPosition(i: number): number;
  40603. }
  40604. }
  40605. declare module BABYLON {
  40606. /**
  40607. * This class is used to track a performance counter which is number based.
  40608. * The user has access to many properties which give statistics of different nature.
  40609. *
  40610. * The implementer can track two kinds of Performance Counter: time and count.
  40611. * 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.
  40612. * 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.
  40613. */
  40614. export class PerfCounter {
  40615. /**
  40616. * Gets or sets a global boolean to turn on and off all the counters
  40617. */
  40618. static Enabled: boolean;
  40619. /**
  40620. * Returns the smallest value ever
  40621. */
  40622. get min(): number;
  40623. /**
  40624. * Returns the biggest value ever
  40625. */
  40626. get max(): number;
  40627. /**
  40628. * Returns the average value since the performance counter is running
  40629. */
  40630. get average(): number;
  40631. /**
  40632. * Returns the average value of the last second the counter was monitored
  40633. */
  40634. get lastSecAverage(): number;
  40635. /**
  40636. * Returns the current value
  40637. */
  40638. get current(): number;
  40639. /**
  40640. * Gets the accumulated total
  40641. */
  40642. get total(): number;
  40643. /**
  40644. * Gets the total value count
  40645. */
  40646. get count(): number;
  40647. /**
  40648. * Creates a new counter
  40649. */
  40650. constructor();
  40651. /**
  40652. * Call this method to start monitoring a new frame.
  40653. * 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.
  40654. */
  40655. fetchNewFrame(): void;
  40656. /**
  40657. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40658. * @param newCount the count value to add to the monitored count
  40659. * @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.
  40660. */
  40661. addCount(newCount: number, fetchResult: boolean): void;
  40662. /**
  40663. * Start monitoring this performance counter
  40664. */
  40665. beginMonitoring(): void;
  40666. /**
  40667. * Compute the time lapsed since the previous beginMonitoring() call.
  40668. * @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
  40669. */
  40670. endMonitoring(newFrame?: boolean): void;
  40671. private _fetchResult;
  40672. private _startMonitoringTime;
  40673. private _min;
  40674. private _max;
  40675. private _average;
  40676. private _current;
  40677. private _totalValueCount;
  40678. private _totalAccumulated;
  40679. private _lastSecAverage;
  40680. private _lastSecAccumulated;
  40681. private _lastSecTime;
  40682. private _lastSecValueCount;
  40683. }
  40684. }
  40685. declare module BABYLON {
  40686. interface ThinEngine {
  40687. /** @hidden */
  40688. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40689. }
  40690. }
  40691. declare module BABYLON {
  40692. /**
  40693. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40695. */
  40696. export class Analyser {
  40697. /**
  40698. * Gets or sets the smoothing
  40699. * @ignorenaming
  40700. */
  40701. SMOOTHING: number;
  40702. /**
  40703. * Gets or sets the FFT table size
  40704. * @ignorenaming
  40705. */
  40706. FFT_SIZE: number;
  40707. /**
  40708. * Gets or sets the bar graph amplitude
  40709. * @ignorenaming
  40710. */
  40711. BARGRAPHAMPLITUDE: number;
  40712. /**
  40713. * Gets or sets the position of the debug canvas
  40714. * @ignorenaming
  40715. */
  40716. DEBUGCANVASPOS: {
  40717. x: number;
  40718. y: number;
  40719. };
  40720. /**
  40721. * Gets or sets the debug canvas size
  40722. * @ignorenaming
  40723. */
  40724. DEBUGCANVASSIZE: {
  40725. width: number;
  40726. height: number;
  40727. };
  40728. private _byteFreqs;
  40729. private _byteTime;
  40730. private _floatFreqs;
  40731. private _webAudioAnalyser;
  40732. private _debugCanvas;
  40733. private _debugCanvasContext;
  40734. private _scene;
  40735. private _registerFunc;
  40736. private _audioEngine;
  40737. /**
  40738. * Creates a new analyser
  40739. * @param scene defines hosting scene
  40740. */
  40741. constructor(scene: Scene);
  40742. /**
  40743. * Get the number of data values you will have to play with for the visualization
  40744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40745. * @returns a number
  40746. */
  40747. getFrequencyBinCount(): number;
  40748. /**
  40749. * Gets the current frequency data as a byte array
  40750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40751. * @returns a Uint8Array
  40752. */
  40753. getByteFrequencyData(): Uint8Array;
  40754. /**
  40755. * Gets the current waveform as a byte array
  40756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40757. * @returns a Uint8Array
  40758. */
  40759. getByteTimeDomainData(): Uint8Array;
  40760. /**
  40761. * Gets the current frequency data as a float array
  40762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40763. * @returns a Float32Array
  40764. */
  40765. getFloatFrequencyData(): Float32Array;
  40766. /**
  40767. * Renders the debug canvas
  40768. */
  40769. drawDebugCanvas(): void;
  40770. /**
  40771. * Stops rendering the debug canvas and removes it
  40772. */
  40773. stopDebugCanvas(): void;
  40774. /**
  40775. * Connects two audio nodes
  40776. * @param inputAudioNode defines first node to connect
  40777. * @param outputAudioNode defines second node to connect
  40778. */
  40779. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40780. /**
  40781. * Releases all associated resources
  40782. */
  40783. dispose(): void;
  40784. }
  40785. }
  40786. declare module BABYLON {
  40787. /**
  40788. * This represents an audio engine and it is responsible
  40789. * to play, synchronize and analyse sounds throughout the application.
  40790. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40791. */
  40792. export interface IAudioEngine extends IDisposable {
  40793. /**
  40794. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40795. */
  40796. readonly canUseWebAudio: boolean;
  40797. /**
  40798. * Gets the current AudioContext if available.
  40799. */
  40800. readonly audioContext: Nullable<AudioContext>;
  40801. /**
  40802. * The master gain node defines the global audio volume of your audio engine.
  40803. */
  40804. readonly masterGain: GainNode;
  40805. /**
  40806. * Gets whether or not mp3 are supported by your browser.
  40807. */
  40808. readonly isMP3supported: boolean;
  40809. /**
  40810. * Gets whether or not ogg are supported by your browser.
  40811. */
  40812. readonly isOGGsupported: boolean;
  40813. /**
  40814. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40815. * @ignoreNaming
  40816. */
  40817. WarnedWebAudioUnsupported: boolean;
  40818. /**
  40819. * Defines if the audio engine relies on a custom unlocked button.
  40820. * In this case, the embedded button will not be displayed.
  40821. */
  40822. useCustomUnlockedButton: boolean;
  40823. /**
  40824. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40825. */
  40826. readonly unlocked: boolean;
  40827. /**
  40828. * Event raised when audio has been unlocked on the browser.
  40829. */
  40830. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40831. /**
  40832. * Event raised when audio has been locked on the browser.
  40833. */
  40834. onAudioLockedObservable: Observable<IAudioEngine>;
  40835. /**
  40836. * Flags the audio engine in Locked state.
  40837. * This happens due to new browser policies preventing audio to autoplay.
  40838. */
  40839. lock(): void;
  40840. /**
  40841. * Unlocks the audio engine once a user action has been done on the dom.
  40842. * This is helpful to resume play once browser policies have been satisfied.
  40843. */
  40844. unlock(): void;
  40845. /**
  40846. * Gets the global volume sets on the master gain.
  40847. * @returns the global volume if set or -1 otherwise
  40848. */
  40849. getGlobalVolume(): number;
  40850. /**
  40851. * Sets the global volume of your experience (sets on the master gain).
  40852. * @param newVolume Defines the new global volume of the application
  40853. */
  40854. setGlobalVolume(newVolume: number): void;
  40855. /**
  40856. * Connect the audio engine to an audio analyser allowing some amazing
  40857. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40858. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40859. * @param analyser The analyser to connect to the engine
  40860. */
  40861. connectToAnalyser(analyser: Analyser): void;
  40862. }
  40863. }
  40864. declare module BABYLON {
  40865. /**
  40866. * Defines the interface used by display changed events
  40867. */
  40868. export interface IDisplayChangedEventArgs {
  40869. /** Gets the vrDisplay object (if any) */
  40870. vrDisplay: Nullable<any>;
  40871. /** Gets a boolean indicating if webVR is supported */
  40872. vrSupported: boolean;
  40873. }
  40874. /**
  40875. * Defines the interface used by objects containing a viewport (like a camera)
  40876. */
  40877. interface IViewportOwnerLike {
  40878. /**
  40879. * Gets or sets the viewport
  40880. */
  40881. viewport: IViewportLike;
  40882. }
  40883. /**
  40884. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40885. */
  40886. export class Engine extends ThinEngine {
  40887. /** Defines that alpha blending is disabled */
  40888. static readonly ALPHA_DISABLE: number;
  40889. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40890. static readonly ALPHA_ADD: number;
  40891. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40892. static readonly ALPHA_COMBINE: number;
  40893. /** Defines that alpha blending to DEST - SRC * DEST */
  40894. static readonly ALPHA_SUBTRACT: number;
  40895. /** Defines that alpha blending to SRC * DEST */
  40896. static readonly ALPHA_MULTIPLY: number;
  40897. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40898. static readonly ALPHA_MAXIMIZED: number;
  40899. /** Defines that alpha blending to SRC + DEST */
  40900. static readonly ALPHA_ONEONE: number;
  40901. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40902. static readonly ALPHA_PREMULTIPLIED: number;
  40903. /**
  40904. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40905. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40906. */
  40907. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40908. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40909. static readonly ALPHA_INTERPOLATE: number;
  40910. /**
  40911. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40912. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40913. */
  40914. static readonly ALPHA_SCREENMODE: number;
  40915. /** Defines that the ressource is not delayed*/
  40916. static readonly DELAYLOADSTATE_NONE: number;
  40917. /** Defines that the ressource was successfully delay loaded */
  40918. static readonly DELAYLOADSTATE_LOADED: number;
  40919. /** Defines that the ressource is currently delay loading */
  40920. static readonly DELAYLOADSTATE_LOADING: number;
  40921. /** Defines that the ressource is delayed and has not started loading */
  40922. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40923. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40924. static readonly NEVER: number;
  40925. /** 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 */
  40926. static readonly ALWAYS: number;
  40927. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40928. static readonly LESS: number;
  40929. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40930. static readonly EQUAL: number;
  40931. /** 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 */
  40932. static readonly LEQUAL: number;
  40933. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40934. static readonly GREATER: number;
  40935. /** 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 */
  40936. static readonly GEQUAL: number;
  40937. /** 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 */
  40938. static readonly NOTEQUAL: number;
  40939. /** Passed to stencilOperation to specify that stencil value must be kept */
  40940. static readonly KEEP: number;
  40941. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40942. static readonly REPLACE: number;
  40943. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40944. static readonly INCR: number;
  40945. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40946. static readonly DECR: number;
  40947. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40948. static readonly INVERT: number;
  40949. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40950. static readonly INCR_WRAP: number;
  40951. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40952. static readonly DECR_WRAP: number;
  40953. /** Texture is not repeating outside of 0..1 UVs */
  40954. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40955. /** Texture is repeating outside of 0..1 UVs */
  40956. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40957. /** Texture is repeating and mirrored */
  40958. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40959. /** ALPHA */
  40960. static readonly TEXTUREFORMAT_ALPHA: number;
  40961. /** LUMINANCE */
  40962. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40963. /** LUMINANCE_ALPHA */
  40964. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40965. /** RGB */
  40966. static readonly TEXTUREFORMAT_RGB: number;
  40967. /** RGBA */
  40968. static readonly TEXTUREFORMAT_RGBA: number;
  40969. /** RED */
  40970. static readonly TEXTUREFORMAT_RED: number;
  40971. /** RED (2nd reference) */
  40972. static readonly TEXTUREFORMAT_R: number;
  40973. /** RG */
  40974. static readonly TEXTUREFORMAT_RG: number;
  40975. /** RED_INTEGER */
  40976. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40977. /** RED_INTEGER (2nd reference) */
  40978. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40979. /** RG_INTEGER */
  40980. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40981. /** RGB_INTEGER */
  40982. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40983. /** RGBA_INTEGER */
  40984. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40985. /** UNSIGNED_BYTE */
  40986. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40987. /** UNSIGNED_BYTE (2nd reference) */
  40988. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40989. /** FLOAT */
  40990. static readonly TEXTURETYPE_FLOAT: number;
  40991. /** HALF_FLOAT */
  40992. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40993. /** BYTE */
  40994. static readonly TEXTURETYPE_BYTE: number;
  40995. /** SHORT */
  40996. static readonly TEXTURETYPE_SHORT: number;
  40997. /** UNSIGNED_SHORT */
  40998. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40999. /** INT */
  41000. static readonly TEXTURETYPE_INT: number;
  41001. /** UNSIGNED_INT */
  41002. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41003. /** UNSIGNED_SHORT_4_4_4_4 */
  41004. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41005. /** UNSIGNED_SHORT_5_5_5_1 */
  41006. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41007. /** UNSIGNED_SHORT_5_6_5 */
  41008. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41009. /** UNSIGNED_INT_2_10_10_10_REV */
  41010. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41011. /** UNSIGNED_INT_24_8 */
  41012. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41013. /** UNSIGNED_INT_10F_11F_11F_REV */
  41014. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41015. /** UNSIGNED_INT_5_9_9_9_REV */
  41016. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41017. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41018. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41019. /** nearest is mag = nearest and min = nearest and mip = linear */
  41020. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41021. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41022. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41023. /** Trilinear is mag = linear and min = linear and mip = linear */
  41024. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41025. /** nearest is mag = nearest and min = nearest and mip = linear */
  41026. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41027. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41028. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41029. /** Trilinear is mag = linear and min = linear and mip = linear */
  41030. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41031. /** mag = nearest and min = nearest and mip = nearest */
  41032. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41033. /** mag = nearest and min = linear and mip = nearest */
  41034. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41035. /** mag = nearest and min = linear and mip = linear */
  41036. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41037. /** mag = nearest and min = linear and mip = none */
  41038. static readonly TEXTURE_NEAREST_LINEAR: number;
  41039. /** mag = nearest and min = nearest and mip = none */
  41040. static readonly TEXTURE_NEAREST_NEAREST: number;
  41041. /** mag = linear and min = nearest and mip = nearest */
  41042. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41043. /** mag = linear and min = nearest and mip = linear */
  41044. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41045. /** mag = linear and min = linear and mip = none */
  41046. static readonly TEXTURE_LINEAR_LINEAR: number;
  41047. /** mag = linear and min = nearest and mip = none */
  41048. static readonly TEXTURE_LINEAR_NEAREST: number;
  41049. /** Explicit coordinates mode */
  41050. static readonly TEXTURE_EXPLICIT_MODE: number;
  41051. /** Spherical coordinates mode */
  41052. static readonly TEXTURE_SPHERICAL_MODE: number;
  41053. /** Planar coordinates mode */
  41054. static readonly TEXTURE_PLANAR_MODE: number;
  41055. /** Cubic coordinates mode */
  41056. static readonly TEXTURE_CUBIC_MODE: number;
  41057. /** Projection coordinates mode */
  41058. static readonly TEXTURE_PROJECTION_MODE: number;
  41059. /** Skybox coordinates mode */
  41060. static readonly TEXTURE_SKYBOX_MODE: number;
  41061. /** Inverse Cubic coordinates mode */
  41062. static readonly TEXTURE_INVCUBIC_MODE: number;
  41063. /** Equirectangular coordinates mode */
  41064. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41065. /** Equirectangular Fixed coordinates mode */
  41066. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41067. /** Equirectangular Fixed Mirrored coordinates mode */
  41068. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41069. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41070. static readonly SCALEMODE_FLOOR: number;
  41071. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41072. static readonly SCALEMODE_NEAREST: number;
  41073. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41074. static readonly SCALEMODE_CEILING: number;
  41075. /**
  41076. * Returns the current npm package of the sdk
  41077. */
  41078. static get NpmPackage(): string;
  41079. /**
  41080. * Returns the current version of the framework
  41081. */
  41082. static get Version(): string;
  41083. /** Gets the list of created engines */
  41084. static get Instances(): Engine[];
  41085. /**
  41086. * Gets the latest created engine
  41087. */
  41088. static get LastCreatedEngine(): Nullable<Engine>;
  41089. /**
  41090. * Gets the latest created scene
  41091. */
  41092. static get LastCreatedScene(): Nullable<Scene>;
  41093. /**
  41094. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41095. * @param flag defines which part of the materials must be marked as dirty
  41096. * @param predicate defines a predicate used to filter which materials should be affected
  41097. */
  41098. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41099. /**
  41100. * Method called to create the default loading screen.
  41101. * This can be overriden in your own app.
  41102. * @param canvas The rendering canvas element
  41103. * @returns The loading screen
  41104. */
  41105. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41106. /**
  41107. * Method called to create the default rescale post process on each engine.
  41108. */
  41109. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41110. /**
  41111. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41112. **/
  41113. enableOfflineSupport: boolean;
  41114. /**
  41115. * 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)
  41116. **/
  41117. disableManifestCheck: boolean;
  41118. /**
  41119. * Gets the list of created scenes
  41120. */
  41121. scenes: Scene[];
  41122. /**
  41123. * Event raised when a new scene is created
  41124. */
  41125. onNewSceneAddedObservable: Observable<Scene>;
  41126. /**
  41127. * Gets the list of created postprocesses
  41128. */
  41129. postProcesses: PostProcess[];
  41130. /**
  41131. * Gets a boolean indicating if the pointer is currently locked
  41132. */
  41133. isPointerLock: boolean;
  41134. /**
  41135. * Observable event triggered each time the rendering canvas is resized
  41136. */
  41137. onResizeObservable: Observable<Engine>;
  41138. /**
  41139. * Observable event triggered each time the canvas loses focus
  41140. */
  41141. onCanvasBlurObservable: Observable<Engine>;
  41142. /**
  41143. * Observable event triggered each time the canvas gains focus
  41144. */
  41145. onCanvasFocusObservable: Observable<Engine>;
  41146. /**
  41147. * Observable event triggered each time the canvas receives pointerout event
  41148. */
  41149. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41150. /**
  41151. * Observable raised when the engine begins a new frame
  41152. */
  41153. onBeginFrameObservable: Observable<Engine>;
  41154. /**
  41155. * If set, will be used to request the next animation frame for the render loop
  41156. */
  41157. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41158. /**
  41159. * Observable raised when the engine ends the current frame
  41160. */
  41161. onEndFrameObservable: Observable<Engine>;
  41162. /**
  41163. * Observable raised when the engine is about to compile a shader
  41164. */
  41165. onBeforeShaderCompilationObservable: Observable<Engine>;
  41166. /**
  41167. * Observable raised when the engine has jsut compiled a shader
  41168. */
  41169. onAfterShaderCompilationObservable: Observable<Engine>;
  41170. /**
  41171. * Gets the audio engine
  41172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41173. * @ignorenaming
  41174. */
  41175. static audioEngine: IAudioEngine;
  41176. /**
  41177. * Default AudioEngine factory responsible of creating the Audio Engine.
  41178. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41179. */
  41180. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41181. /**
  41182. * Default offline support factory responsible of creating a tool used to store data locally.
  41183. * By default, this will create a Database object if the workload has been embedded.
  41184. */
  41185. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41186. private _loadingScreen;
  41187. private _pointerLockRequested;
  41188. private _rescalePostProcess;
  41189. private _deterministicLockstep;
  41190. private _lockstepMaxSteps;
  41191. private _timeStep;
  41192. protected get _supportsHardwareTextureRescaling(): boolean;
  41193. private _fps;
  41194. private _deltaTime;
  41195. /** @hidden */
  41196. _drawCalls: PerfCounter;
  41197. /** 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 */
  41198. canvasTabIndex: number;
  41199. /**
  41200. * Turn this value on if you want to pause FPS computation when in background
  41201. */
  41202. disablePerformanceMonitorInBackground: boolean;
  41203. private _performanceMonitor;
  41204. /**
  41205. * Gets the performance monitor attached to this engine
  41206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41207. */
  41208. get performanceMonitor(): PerformanceMonitor;
  41209. private _onFocus;
  41210. private _onBlur;
  41211. private _onCanvasPointerOut;
  41212. private _onCanvasBlur;
  41213. private _onCanvasFocus;
  41214. private _onFullscreenChange;
  41215. private _onPointerLockChange;
  41216. /**
  41217. * Gets the HTML element used to attach event listeners
  41218. * @returns a HTML element
  41219. */
  41220. getInputElement(): Nullable<HTMLElement>;
  41221. /**
  41222. * Creates a new engine
  41223. * @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
  41224. * @param antialias defines enable antialiasing (default: false)
  41225. * @param options defines further options to be sent to the getContext() function
  41226. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41227. */
  41228. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41229. /**
  41230. * Gets current aspect ratio
  41231. * @param viewportOwner defines the camera to use to get the aspect ratio
  41232. * @param useScreen defines if screen size must be used (or the current render target if any)
  41233. * @returns a number defining the aspect ratio
  41234. */
  41235. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41236. /**
  41237. * Gets current screen aspect ratio
  41238. * @returns a number defining the aspect ratio
  41239. */
  41240. getScreenAspectRatio(): number;
  41241. /**
  41242. * Gets the client rect of the HTML canvas attached with the current webGL context
  41243. * @returns a client rectanglee
  41244. */
  41245. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41246. /**
  41247. * Gets the client rect of the HTML element used for events
  41248. * @returns a client rectanglee
  41249. */
  41250. getInputElementClientRect(): Nullable<ClientRect>;
  41251. /**
  41252. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41253. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41254. * @returns true if engine is in deterministic lock step mode
  41255. */
  41256. isDeterministicLockStep(): boolean;
  41257. /**
  41258. * Gets the max steps when engine is running in deterministic lock step
  41259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41260. * @returns the max steps
  41261. */
  41262. getLockstepMaxSteps(): number;
  41263. /**
  41264. * Returns the time in ms between steps when using deterministic lock step.
  41265. * @returns time step in (ms)
  41266. */
  41267. getTimeStep(): number;
  41268. /**
  41269. * Force the mipmap generation for the given render target texture
  41270. * @param texture defines the render target texture to use
  41271. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41272. */
  41273. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41274. /** States */
  41275. /**
  41276. * Set various states to the webGL context
  41277. * @param culling defines backface culling state
  41278. * @param zOffset defines the value to apply to zOffset (0 by default)
  41279. * @param force defines if states must be applied even if cache is up to date
  41280. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41281. */
  41282. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41283. /**
  41284. * Set the z offset to apply to current rendering
  41285. * @param value defines the offset to apply
  41286. */
  41287. setZOffset(value: number): void;
  41288. /**
  41289. * Gets the current value of the zOffset
  41290. * @returns the current zOffset state
  41291. */
  41292. getZOffset(): number;
  41293. /**
  41294. * Enable or disable depth buffering
  41295. * @param enable defines the state to set
  41296. */
  41297. setDepthBuffer(enable: boolean): void;
  41298. /**
  41299. * Gets a boolean indicating if depth writing is enabled
  41300. * @returns the current depth writing state
  41301. */
  41302. getDepthWrite(): boolean;
  41303. /**
  41304. * Enable or disable depth writing
  41305. * @param enable defines the state to set
  41306. */
  41307. setDepthWrite(enable: boolean): void;
  41308. /**
  41309. * Gets a boolean indicating if stencil buffer is enabled
  41310. * @returns the current stencil buffer state
  41311. */
  41312. getStencilBuffer(): boolean;
  41313. /**
  41314. * Enable or disable the stencil buffer
  41315. * @param enable defines if the stencil buffer must be enabled or disabled
  41316. */
  41317. setStencilBuffer(enable: boolean): void;
  41318. /**
  41319. * Gets the current stencil mask
  41320. * @returns a number defining the new stencil mask to use
  41321. */
  41322. getStencilMask(): number;
  41323. /**
  41324. * Sets the current stencil mask
  41325. * @param mask defines the new stencil mask to use
  41326. */
  41327. setStencilMask(mask: number): void;
  41328. /**
  41329. * Gets the current stencil function
  41330. * @returns a number defining the stencil function to use
  41331. */
  41332. getStencilFunction(): number;
  41333. /**
  41334. * Gets the current stencil reference value
  41335. * @returns a number defining the stencil reference value to use
  41336. */
  41337. getStencilFunctionReference(): number;
  41338. /**
  41339. * Gets the current stencil mask
  41340. * @returns a number defining the stencil mask to use
  41341. */
  41342. getStencilFunctionMask(): number;
  41343. /**
  41344. * Sets the current stencil function
  41345. * @param stencilFunc defines the new stencil function to use
  41346. */
  41347. setStencilFunction(stencilFunc: number): void;
  41348. /**
  41349. * Sets the current stencil reference
  41350. * @param reference defines the new stencil reference to use
  41351. */
  41352. setStencilFunctionReference(reference: number): void;
  41353. /**
  41354. * Sets the current stencil mask
  41355. * @param mask defines the new stencil mask to use
  41356. */
  41357. setStencilFunctionMask(mask: number): void;
  41358. /**
  41359. * Gets the current stencil operation when stencil fails
  41360. * @returns a number defining stencil operation to use when stencil fails
  41361. */
  41362. getStencilOperationFail(): number;
  41363. /**
  41364. * Gets the current stencil operation when depth fails
  41365. * @returns a number defining stencil operation to use when depth fails
  41366. */
  41367. getStencilOperationDepthFail(): number;
  41368. /**
  41369. * Gets the current stencil operation when stencil passes
  41370. * @returns a number defining stencil operation to use when stencil passes
  41371. */
  41372. getStencilOperationPass(): number;
  41373. /**
  41374. * Sets the stencil operation to use when stencil fails
  41375. * @param operation defines the stencil operation to use when stencil fails
  41376. */
  41377. setStencilOperationFail(operation: number): void;
  41378. /**
  41379. * Sets the stencil operation to use when depth fails
  41380. * @param operation defines the stencil operation to use when depth fails
  41381. */
  41382. setStencilOperationDepthFail(operation: number): void;
  41383. /**
  41384. * Sets the stencil operation to use when stencil passes
  41385. * @param operation defines the stencil operation to use when stencil passes
  41386. */
  41387. setStencilOperationPass(operation: number): void;
  41388. /**
  41389. * Sets a boolean indicating if the dithering state is enabled or disabled
  41390. * @param value defines the dithering state
  41391. */
  41392. setDitheringState(value: boolean): void;
  41393. /**
  41394. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41395. * @param value defines the rasterizer state
  41396. */
  41397. setRasterizerState(value: boolean): void;
  41398. /**
  41399. * Gets the current depth function
  41400. * @returns a number defining the depth function
  41401. */
  41402. getDepthFunction(): Nullable<number>;
  41403. /**
  41404. * Sets the current depth function
  41405. * @param depthFunc defines the function to use
  41406. */
  41407. setDepthFunction(depthFunc: number): void;
  41408. /**
  41409. * Sets the current depth function to GREATER
  41410. */
  41411. setDepthFunctionToGreater(): void;
  41412. /**
  41413. * Sets the current depth function to GEQUAL
  41414. */
  41415. setDepthFunctionToGreaterOrEqual(): void;
  41416. /**
  41417. * Sets the current depth function to LESS
  41418. */
  41419. setDepthFunctionToLess(): void;
  41420. /**
  41421. * Sets the current depth function to LEQUAL
  41422. */
  41423. setDepthFunctionToLessOrEqual(): void;
  41424. private _cachedStencilBuffer;
  41425. private _cachedStencilFunction;
  41426. private _cachedStencilMask;
  41427. private _cachedStencilOperationPass;
  41428. private _cachedStencilOperationFail;
  41429. private _cachedStencilOperationDepthFail;
  41430. private _cachedStencilReference;
  41431. /**
  41432. * Caches the the state of the stencil buffer
  41433. */
  41434. cacheStencilState(): void;
  41435. /**
  41436. * Restores the state of the stencil buffer
  41437. */
  41438. restoreStencilState(): void;
  41439. /**
  41440. * Directly set the WebGL Viewport
  41441. * @param x defines the x coordinate of the viewport (in screen space)
  41442. * @param y defines the y coordinate of the viewport (in screen space)
  41443. * @param width defines the width of the viewport (in screen space)
  41444. * @param height defines the height of the viewport (in screen space)
  41445. * @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
  41446. */
  41447. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41448. /**
  41449. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41450. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41451. * @param y defines the y-coordinate of the corner of the clear rectangle
  41452. * @param width defines the width of the clear rectangle
  41453. * @param height defines the height of the clear rectangle
  41454. * @param clearColor defines the clear color
  41455. */
  41456. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41457. /**
  41458. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41459. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41460. * @param y defines the y-coordinate of the corner of the clear rectangle
  41461. * @param width defines the width of the clear rectangle
  41462. * @param height defines the height of the clear rectangle
  41463. */
  41464. enableScissor(x: number, y: number, width: number, height: number): void;
  41465. /**
  41466. * Disable previously set scissor test rectangle
  41467. */
  41468. disableScissor(): void;
  41469. protected _reportDrawCall(): void;
  41470. /**
  41471. * Initializes a webVR display and starts listening to display change events
  41472. * The onVRDisplayChangedObservable will be notified upon these changes
  41473. * @returns The onVRDisplayChangedObservable
  41474. */
  41475. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41476. /** @hidden */
  41477. _prepareVRComponent(): void;
  41478. /** @hidden */
  41479. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41480. /** @hidden */
  41481. _submitVRFrame(): void;
  41482. /**
  41483. * Call this function to leave webVR mode
  41484. * Will do nothing if webVR is not supported or if there is no webVR device
  41485. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41486. */
  41487. disableVR(): void;
  41488. /**
  41489. * Gets a boolean indicating that the system is in VR mode and is presenting
  41490. * @returns true if VR mode is engaged
  41491. */
  41492. isVRPresenting(): boolean;
  41493. /** @hidden */
  41494. _requestVRFrame(): void;
  41495. /** @hidden */
  41496. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41497. /**
  41498. * Gets the source code of the vertex 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 vertex shader associated with the program
  41501. */
  41502. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41503. /**
  41504. * Gets the source code of the fragment shader associated with a specific webGL program
  41505. * @param program defines the program to use
  41506. * @returns a string containing the source code of the fragment shader associated with the program
  41507. */
  41508. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41509. /**
  41510. * Sets a depth stencil texture from a render target to the according uniform.
  41511. * @param channel The texture channel
  41512. * @param uniform The uniform to set
  41513. * @param texture The render target texture containing the depth stencil texture to apply
  41514. */
  41515. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41516. /**
  41517. * Sets a texture to the webGL context from a postprocess
  41518. * @param channel defines the channel to use
  41519. * @param postProcess defines the source postprocess
  41520. */
  41521. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41522. /**
  41523. * Binds the output of the passed in post process to the texture channel specified
  41524. * @param channel The channel the texture should be bound to
  41525. * @param postProcess The post process which's output should be bound
  41526. */
  41527. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41528. protected _rebuildBuffers(): void;
  41529. /** @hidden */
  41530. _renderFrame(): void;
  41531. _renderLoop(): void;
  41532. /** @hidden */
  41533. _renderViews(): boolean;
  41534. /**
  41535. * Toggle full screen mode
  41536. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41537. */
  41538. switchFullscreen(requestPointerLock: boolean): void;
  41539. /**
  41540. * Enters full screen mode
  41541. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41542. */
  41543. enterFullscreen(requestPointerLock: boolean): void;
  41544. /**
  41545. * Exits full screen mode
  41546. */
  41547. exitFullscreen(): void;
  41548. /**
  41549. * Enters Pointerlock mode
  41550. */
  41551. enterPointerlock(): void;
  41552. /**
  41553. * Exits Pointerlock mode
  41554. */
  41555. exitPointerlock(): void;
  41556. /**
  41557. * Begin a new frame
  41558. */
  41559. beginFrame(): void;
  41560. /**
  41561. * Enf the current frame
  41562. */
  41563. endFrame(): void;
  41564. resize(): void;
  41565. /**
  41566. * Force a specific size of the canvas
  41567. * @param width defines the new canvas' width
  41568. * @param height defines the new canvas' height
  41569. * @returns true if the size was changed
  41570. */
  41571. setSize(width: number, height: number): boolean;
  41572. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41573. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41574. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41575. _releaseTexture(texture: InternalTexture): void;
  41576. /**
  41577. * @hidden
  41578. * Rescales a texture
  41579. * @param source input texutre
  41580. * @param destination destination texture
  41581. * @param scene scene to use to render the resize
  41582. * @param internalFormat format to use when resizing
  41583. * @param onComplete callback to be called when resize has completed
  41584. */
  41585. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41586. /**
  41587. * Gets the current framerate
  41588. * @returns a number representing the framerate
  41589. */
  41590. getFps(): number;
  41591. /**
  41592. * Gets the time spent between current and previous frame
  41593. * @returns a number representing the delta time in ms
  41594. */
  41595. getDeltaTime(): number;
  41596. private _measureFps;
  41597. /** @hidden */
  41598. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41599. /**
  41600. * Updates the sample count of a render target texture
  41601. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41602. * @param texture defines the texture to update
  41603. * @param samples defines the sample count to set
  41604. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41605. */
  41606. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41607. /**
  41608. * Updates a depth texture Comparison Mode and Function.
  41609. * If the comparison Function is equal to 0, the mode will be set to none.
  41610. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41611. * @param texture The texture to set the comparison function for
  41612. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41613. */
  41614. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41615. /**
  41616. * Creates a webGL buffer to use with instanciation
  41617. * @param capacity defines the size of the buffer
  41618. * @returns the webGL buffer
  41619. */
  41620. createInstancesBuffer(capacity: number): DataBuffer;
  41621. /**
  41622. * Delete a webGL buffer used with instanciation
  41623. * @param buffer defines the webGL buffer to delete
  41624. */
  41625. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41626. private _clientWaitAsync;
  41627. /** @hidden */
  41628. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41629. dispose(): void;
  41630. private _disableTouchAction;
  41631. /**
  41632. * Display the loading screen
  41633. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41634. */
  41635. displayLoadingUI(): void;
  41636. /**
  41637. * Hide the loading screen
  41638. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41639. */
  41640. hideLoadingUI(): void;
  41641. /**
  41642. * Gets the current loading screen object
  41643. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41644. */
  41645. get loadingScreen(): ILoadingScreen;
  41646. /**
  41647. * Sets the current loading screen object
  41648. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41649. */
  41650. set loadingScreen(loadingScreen: ILoadingScreen);
  41651. /**
  41652. * Sets the current loading screen text
  41653. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41654. */
  41655. set loadingUIText(text: string);
  41656. /**
  41657. * Sets the current loading screen background color
  41658. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41659. */
  41660. set loadingUIBackgroundColor(color: string);
  41661. /** Pointerlock and fullscreen */
  41662. /**
  41663. * Ask the browser to promote the current element to pointerlock mode
  41664. * @param element defines the DOM element to promote
  41665. */
  41666. static _RequestPointerlock(element: HTMLElement): void;
  41667. /**
  41668. * Asks the browser to exit pointerlock mode
  41669. */
  41670. static _ExitPointerlock(): void;
  41671. /**
  41672. * Ask the browser to promote the current element to fullscreen rendering mode
  41673. * @param element defines the DOM element to promote
  41674. */
  41675. static _RequestFullscreen(element: HTMLElement): void;
  41676. /**
  41677. * Asks the browser to exit fullscreen mode
  41678. */
  41679. static _ExitFullscreen(): void;
  41680. }
  41681. }
  41682. declare module BABYLON {
  41683. /**
  41684. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41685. * during the life time of the application.
  41686. */
  41687. export class EngineStore {
  41688. /** Gets the list of created engines */
  41689. static Instances: Engine[];
  41690. /** @hidden */
  41691. static _LastCreatedScene: Nullable<Scene>;
  41692. /**
  41693. * Gets the latest created engine
  41694. */
  41695. static get LastCreatedEngine(): Nullable<Engine>;
  41696. /**
  41697. * Gets the latest created scene
  41698. */
  41699. static get LastCreatedScene(): Nullable<Scene>;
  41700. /**
  41701. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41702. * @ignorenaming
  41703. */
  41704. static UseFallbackTexture: boolean;
  41705. /**
  41706. * Texture content used if a texture cannot loaded
  41707. * @ignorenaming
  41708. */
  41709. static FallbackTexture: string;
  41710. }
  41711. }
  41712. declare module BABYLON {
  41713. /**
  41714. * Helper class that provides a small promise polyfill
  41715. */
  41716. export class PromisePolyfill {
  41717. /**
  41718. * Static function used to check if the polyfill is required
  41719. * If this is the case then the function will inject the polyfill to window.Promise
  41720. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41721. */
  41722. static Apply(force?: boolean): void;
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * Interface for screenshot methods with describe argument called `size` as object with options
  41728. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41729. */
  41730. export interface IScreenshotSize {
  41731. /**
  41732. * number in pixels for canvas height
  41733. */
  41734. height?: number;
  41735. /**
  41736. * multiplier allowing render at a higher or lower resolution
  41737. * If value is defined then height and width will be ignored and taken from camera
  41738. */
  41739. precision?: number;
  41740. /**
  41741. * number in pixels for canvas width
  41742. */
  41743. width?: number;
  41744. }
  41745. }
  41746. declare module BABYLON {
  41747. interface IColor4Like {
  41748. r: float;
  41749. g: float;
  41750. b: float;
  41751. a: float;
  41752. }
  41753. /**
  41754. * Class containing a set of static utilities functions
  41755. */
  41756. export class Tools {
  41757. /**
  41758. * Gets or sets the base URL to use to load assets
  41759. */
  41760. static get BaseUrl(): string;
  41761. static set BaseUrl(value: string);
  41762. /**
  41763. * Enable/Disable Custom HTTP Request Headers globally.
  41764. * default = false
  41765. * @see CustomRequestHeaders
  41766. */
  41767. static UseCustomRequestHeaders: boolean;
  41768. /**
  41769. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41770. * i.e. when loading files, where the server/service expects an Authorization header
  41771. */
  41772. static CustomRequestHeaders: {
  41773. [key: string]: string;
  41774. };
  41775. /**
  41776. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41777. */
  41778. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41779. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41780. /**
  41781. * Default behaviour for cors in the application.
  41782. * It can be a string if the expected behavior is identical in the entire app.
  41783. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41784. */
  41785. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41786. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41787. /**
  41788. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41789. * @ignorenaming
  41790. */
  41791. static get UseFallbackTexture(): boolean;
  41792. static set UseFallbackTexture(value: boolean);
  41793. /**
  41794. * Use this object to register external classes like custom textures or material
  41795. * to allow the laoders to instantiate them
  41796. */
  41797. static get RegisteredExternalClasses(): {
  41798. [key: string]: Object;
  41799. };
  41800. static set RegisteredExternalClasses(classes: {
  41801. [key: string]: Object;
  41802. });
  41803. /**
  41804. * Texture content used if a texture cannot loaded
  41805. * @ignorenaming
  41806. */
  41807. static get fallbackTexture(): string;
  41808. static set fallbackTexture(value: string);
  41809. /**
  41810. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41811. * @param u defines the coordinate on X axis
  41812. * @param v defines the coordinate on Y axis
  41813. * @param width defines the width of the source data
  41814. * @param height defines the height of the source data
  41815. * @param pixels defines the source byte array
  41816. * @param color defines the output color
  41817. */
  41818. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41819. /**
  41820. * Interpolates between a and b via alpha
  41821. * @param a The lower value (returned when alpha = 0)
  41822. * @param b The upper value (returned when alpha = 1)
  41823. * @param alpha The interpolation-factor
  41824. * @return The mixed value
  41825. */
  41826. static Mix(a: number, b: number, alpha: number): number;
  41827. /**
  41828. * Tries to instantiate a new object from a given class name
  41829. * @param className defines the class name to instantiate
  41830. * @returns the new object or null if the system was not able to do the instantiation
  41831. */
  41832. static Instantiate(className: string): any;
  41833. /**
  41834. * Provides a slice function that will work even on IE
  41835. * @param data defines the array to slice
  41836. * @param start defines the start of the data (optional)
  41837. * @param end defines the end of the data (optional)
  41838. * @returns the new sliced array
  41839. */
  41840. static Slice<T>(data: T, start?: number, end?: number): T;
  41841. /**
  41842. * Provides a slice function that will work even on IE
  41843. * The difference between this and Slice is that this will force-convert to array
  41844. * @param data defines the array to slice
  41845. * @param start defines the start of the data (optional)
  41846. * @param end defines the end of the data (optional)
  41847. * @returns the new sliced array
  41848. */
  41849. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41850. /**
  41851. * Polyfill for setImmediate
  41852. * @param action defines the action to execute after the current execution block
  41853. */
  41854. static SetImmediate(action: () => void): void;
  41855. /**
  41856. * Function indicating if a number is an exponent of 2
  41857. * @param value defines the value to test
  41858. * @returns true if the value is an exponent of 2
  41859. */
  41860. static IsExponentOfTwo(value: number): boolean;
  41861. private static _tmpFloatArray;
  41862. /**
  41863. * Returns the nearest 32-bit single precision float representation of a Number
  41864. * @param value A Number. If the parameter is of a different type, it will get converted
  41865. * to a number or to NaN if it cannot be converted
  41866. * @returns number
  41867. */
  41868. static FloatRound(value: number): number;
  41869. /**
  41870. * Extracts the filename from a path
  41871. * @param path defines the path to use
  41872. * @returns the filename
  41873. */
  41874. static GetFilename(path: string): string;
  41875. /**
  41876. * Extracts the "folder" part of a path (everything before the filename).
  41877. * @param uri The URI to extract the info from
  41878. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41879. * @returns The "folder" part of the path
  41880. */
  41881. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41882. /**
  41883. * Extracts text content from a DOM element hierarchy
  41884. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41885. */
  41886. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41887. /**
  41888. * Convert an angle in radians to degrees
  41889. * @param angle defines the angle to convert
  41890. * @returns the angle in degrees
  41891. */
  41892. static ToDegrees(angle: number): number;
  41893. /**
  41894. * Convert an angle in degrees to radians
  41895. * @param angle defines the angle to convert
  41896. * @returns the angle in radians
  41897. */
  41898. static ToRadians(angle: number): number;
  41899. /**
  41900. * Returns an array if obj is not an array
  41901. * @param obj defines the object to evaluate as an array
  41902. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41903. * @returns either obj directly if obj is an array or a new array containing obj
  41904. */
  41905. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41906. /**
  41907. * Gets the pointer prefix to use
  41908. * @param engine defines the engine we are finding the prefix for
  41909. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41910. */
  41911. static GetPointerPrefix(engine: Engine): string;
  41912. /**
  41913. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41914. * @param url define the url we are trying
  41915. * @param element define the dom element where to configure the cors policy
  41916. */
  41917. static SetCorsBehavior(url: string | string[], element: {
  41918. crossOrigin: string | null;
  41919. }): void;
  41920. /**
  41921. * Removes unwanted characters from an url
  41922. * @param url defines the url to clean
  41923. * @returns the cleaned url
  41924. */
  41925. static CleanUrl(url: string): string;
  41926. /**
  41927. * Gets or sets a function used to pre-process url before using them to load assets
  41928. */
  41929. static get PreprocessUrl(): (url: string) => string;
  41930. static set PreprocessUrl(processor: (url: string) => string);
  41931. /**
  41932. * Loads an image as an HTMLImageElement.
  41933. * @param input url string, ArrayBuffer, or Blob to load
  41934. * @param onLoad callback called when the image successfully loads
  41935. * @param onError callback called when the image fails to load
  41936. * @param offlineProvider offline provider for caching
  41937. * @param mimeType optional mime type
  41938. * @returns the HTMLImageElement of the loaded image
  41939. */
  41940. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41941. /**
  41942. * Loads a file from a url
  41943. * @param url url string, ArrayBuffer, or Blob to load
  41944. * @param onSuccess callback called when the file successfully loads
  41945. * @param onProgress callback called while file is loading (if the server supports this mode)
  41946. * @param offlineProvider defines the offline provider for caching
  41947. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41948. * @param onError callback called when the file fails to load
  41949. * @returns a file request object
  41950. */
  41951. 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;
  41952. /**
  41953. * Loads a file from a url
  41954. * @param url the file url to load
  41955. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41956. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41957. */
  41958. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41959. /**
  41960. * Load a script (identified by an url). When the url returns, the
  41961. * content of this file is added into a new script element, attached to the DOM (body element)
  41962. * @param scriptUrl defines the url of the script to laod
  41963. * @param onSuccess defines the callback called when the script is loaded
  41964. * @param onError defines the callback to call if an error occurs
  41965. * @param scriptId defines the id of the script element
  41966. */
  41967. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41968. /**
  41969. * Load an asynchronous script (identified by an url). When the url returns, the
  41970. * content of this file is added into a new script element, attached to the DOM (body element)
  41971. * @param scriptUrl defines the url of the script to laod
  41972. * @param scriptId defines the id of the script element
  41973. * @returns a promise request object
  41974. */
  41975. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41976. /**
  41977. * Loads a file from a blob
  41978. * @param fileToLoad defines the blob to use
  41979. * @param callback defines the callback to call when data is loaded
  41980. * @param progressCallback defines the callback to call during loading process
  41981. * @returns a file request object
  41982. */
  41983. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41984. /**
  41985. * Reads a file from a File object
  41986. * @param file defines the file to load
  41987. * @param onSuccess defines the callback to call when data is loaded
  41988. * @param onProgress defines the callback to call during loading process
  41989. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41990. * @param onError defines the callback to call when an error occurs
  41991. * @returns a file request object
  41992. */
  41993. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41994. /**
  41995. * Creates a data url from a given string content
  41996. * @param content defines the content to convert
  41997. * @returns the new data url link
  41998. */
  41999. static FileAsURL(content: string): string;
  42000. /**
  42001. * Format the given number to a specific decimal format
  42002. * @param value defines the number to format
  42003. * @param decimals defines the number of decimals to use
  42004. * @returns the formatted string
  42005. */
  42006. static Format(value: number, decimals?: number): string;
  42007. /**
  42008. * Tries to copy an object by duplicating every property
  42009. * @param source defines the source object
  42010. * @param destination defines the target object
  42011. * @param doNotCopyList defines a list of properties to avoid
  42012. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42013. */
  42014. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42015. /**
  42016. * Gets a boolean indicating if the given object has no own property
  42017. * @param obj defines the object to test
  42018. * @returns true if object has no own property
  42019. */
  42020. static IsEmpty(obj: any): boolean;
  42021. /**
  42022. * Function used to register events at window level
  42023. * @param windowElement defines the Window object to use
  42024. * @param events defines the events to register
  42025. */
  42026. static RegisterTopRootEvents(windowElement: Window, events: {
  42027. name: string;
  42028. handler: Nullable<(e: FocusEvent) => any>;
  42029. }[]): void;
  42030. /**
  42031. * Function used to unregister events from window level
  42032. * @param windowElement defines the Window object to use
  42033. * @param events defines the events to unregister
  42034. */
  42035. static UnregisterTopRootEvents(windowElement: Window, events: {
  42036. name: string;
  42037. handler: Nullable<(e: FocusEvent) => any>;
  42038. }[]): void;
  42039. /**
  42040. * @ignore
  42041. */
  42042. static _ScreenshotCanvas: HTMLCanvasElement;
  42043. /**
  42044. * Dumps the current bound framebuffer
  42045. * @param width defines the rendering width
  42046. * @param height defines the rendering height
  42047. * @param engine defines the hosting engine
  42048. * @param successCallback defines the callback triggered once the data are available
  42049. * @param mimeType defines the mime type of the result
  42050. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42051. */
  42052. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42053. /**
  42054. * Converts the canvas data to blob.
  42055. * This acts as a polyfill for browsers not supporting the to blob function.
  42056. * @param canvas Defines the canvas to extract the data from
  42057. * @param successCallback Defines the callback triggered once the data are available
  42058. * @param mimeType Defines the mime type of the result
  42059. */
  42060. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42061. /**
  42062. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42063. * @param successCallback defines the callback triggered once the data are available
  42064. * @param mimeType defines the mime type of the result
  42065. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42066. */
  42067. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42068. /**
  42069. * Downloads a blob in the browser
  42070. * @param blob defines the blob to download
  42071. * @param fileName defines the name of the downloaded file
  42072. */
  42073. static Download(blob: Blob, fileName: string): void;
  42074. /**
  42075. * Will return the right value of the noPreventDefault variable
  42076. * Needed to keep backwards compatibility to the old API.
  42077. *
  42078. * @param args arguments passed to the attachControl function
  42079. * @returns the correct value for noPreventDefault
  42080. */
  42081. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42082. /**
  42083. * Captures a screenshot of the current rendering
  42084. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42085. * @param engine defines the rendering engine
  42086. * @param camera defines the source camera
  42087. * @param size This parameter can be set to a single number or to an object with the
  42088. * following (optional) properties: precision, width, height. If a single number is passed,
  42089. * it will be used for both width and height. If an object is passed, the screenshot size
  42090. * will be derived from the parameters. The precision property is a multiplier allowing
  42091. * rendering at a higher or lower resolution
  42092. * @param successCallback defines the callback receives a single parameter which contains the
  42093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42094. * src parameter of an <img> to display it
  42095. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42096. * Check your browser for supported MIME types
  42097. */
  42098. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42099. /**
  42100. * Captures a screenshot of the current rendering
  42101. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42102. * @param engine defines the rendering engine
  42103. * @param camera defines the source camera
  42104. * @param size This parameter can be set to a single number or to an object with the
  42105. * following (optional) properties: precision, width, height. If a single number is passed,
  42106. * it will be used for both width and height. If an object is passed, the screenshot size
  42107. * will be derived from the parameters. The precision property is a multiplier allowing
  42108. * rendering at a higher or lower resolution
  42109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42110. * Check your browser for supported MIME types
  42111. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42112. * to the src parameter of an <img> to display it
  42113. */
  42114. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42115. /**
  42116. * Generates an image screenshot from the specified camera.
  42117. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42118. * @param engine The engine to use for rendering
  42119. * @param camera The camera to use for rendering
  42120. * @param size This parameter can be set to a single number or to an object with the
  42121. * following (optional) properties: precision, width, height. If a single number is passed,
  42122. * it will be used for both width and height. If an object is passed, the screenshot size
  42123. * will be derived from the parameters. The precision property is a multiplier allowing
  42124. * rendering at a higher or lower resolution
  42125. * @param successCallback The callback receives a single parameter which contains the
  42126. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42127. * src parameter of an <img> to display it
  42128. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42129. * Check your browser for supported MIME types
  42130. * @param samples Texture samples (default: 1)
  42131. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42132. * @param fileName A name for for the downloaded file.
  42133. */
  42134. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42135. /**
  42136. * Generates an image screenshot from the specified camera.
  42137. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42138. * @param engine The engine to use for rendering
  42139. * @param camera The camera to use for rendering
  42140. * @param size This parameter can be set to a single number or to an object with the
  42141. * following (optional) properties: precision, width, height. If a single number is passed,
  42142. * it will be used for both width and height. If an object is passed, the screenshot size
  42143. * will be derived from the parameters. The precision property is a multiplier allowing
  42144. * rendering at a higher or lower resolution
  42145. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42146. * Check your browser for supported MIME types
  42147. * @param samples Texture samples (default: 1)
  42148. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42149. * @param fileName A name for for the downloaded file.
  42150. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42151. * to the src parameter of an <img> to display it
  42152. */
  42153. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42154. /**
  42155. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42156. * Be aware Math.random() could cause collisions, but:
  42157. * "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"
  42158. * @returns a pseudo random id
  42159. */
  42160. static RandomId(): string;
  42161. /**
  42162. * Test if the given uri is a base64 string
  42163. * @param uri The uri to test
  42164. * @return True if the uri is a base64 string or false otherwise
  42165. */
  42166. static IsBase64(uri: string): boolean;
  42167. /**
  42168. * Decode the given base64 uri.
  42169. * @param uri The uri to decode
  42170. * @return The decoded base64 data.
  42171. */
  42172. static DecodeBase64(uri: string): ArrayBuffer;
  42173. /**
  42174. * Gets the absolute url.
  42175. * @param url the input url
  42176. * @return the absolute url
  42177. */
  42178. static GetAbsoluteUrl(url: string): string;
  42179. /**
  42180. * No log
  42181. */
  42182. static readonly NoneLogLevel: number;
  42183. /**
  42184. * Only message logs
  42185. */
  42186. static readonly MessageLogLevel: number;
  42187. /**
  42188. * Only warning logs
  42189. */
  42190. static readonly WarningLogLevel: number;
  42191. /**
  42192. * Only error logs
  42193. */
  42194. static readonly ErrorLogLevel: number;
  42195. /**
  42196. * All logs
  42197. */
  42198. static readonly AllLogLevel: number;
  42199. /**
  42200. * Gets a value indicating the number of loading errors
  42201. * @ignorenaming
  42202. */
  42203. static get errorsCount(): number;
  42204. /**
  42205. * Callback called when a new log is added
  42206. */
  42207. static OnNewCacheEntry: (entry: string) => void;
  42208. /**
  42209. * Log a message to the console
  42210. * @param message defines the message to log
  42211. */
  42212. static Log(message: string): void;
  42213. /**
  42214. * Write a warning message to the console
  42215. * @param message defines the message to log
  42216. */
  42217. static Warn(message: string): void;
  42218. /**
  42219. * Write an error message to the console
  42220. * @param message defines the message to log
  42221. */
  42222. static Error(message: string): void;
  42223. /**
  42224. * Gets current log cache (list of logs)
  42225. */
  42226. static get LogCache(): string;
  42227. /**
  42228. * Clears the log cache
  42229. */
  42230. static ClearLogCache(): void;
  42231. /**
  42232. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42233. */
  42234. static set LogLevels(level: number);
  42235. /**
  42236. * Checks if the window object exists
  42237. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42238. */
  42239. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42240. /**
  42241. * No performance log
  42242. */
  42243. static readonly PerformanceNoneLogLevel: number;
  42244. /**
  42245. * Use user marks to log performance
  42246. */
  42247. static readonly PerformanceUserMarkLogLevel: number;
  42248. /**
  42249. * Log performance to the console
  42250. */
  42251. static readonly PerformanceConsoleLogLevel: number;
  42252. private static _performance;
  42253. /**
  42254. * Sets the current performance log level
  42255. */
  42256. static set PerformanceLogLevel(level: number);
  42257. private static _StartPerformanceCounterDisabled;
  42258. private static _EndPerformanceCounterDisabled;
  42259. private static _StartUserMark;
  42260. private static _EndUserMark;
  42261. private static _StartPerformanceConsole;
  42262. private static _EndPerformanceConsole;
  42263. /**
  42264. * Starts a performance counter
  42265. */
  42266. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42267. /**
  42268. * Ends a specific performance coutner
  42269. */
  42270. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42271. /**
  42272. * Gets either window.performance.now() if supported or Date.now() else
  42273. */
  42274. static get Now(): number;
  42275. /**
  42276. * This method will return the name of the class used to create the instance of the given object.
  42277. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42278. * @param object the object to get the class name from
  42279. * @param isType defines if the object is actually a type
  42280. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42281. */
  42282. static GetClassName(object: any, isType?: boolean): string;
  42283. /**
  42284. * Gets the first element of an array satisfying a given predicate
  42285. * @param array defines the array to browse
  42286. * @param predicate defines the predicate to use
  42287. * @returns null if not found or the element
  42288. */
  42289. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42290. /**
  42291. * This method will return the name of the full name of the class, including its owning module (if any).
  42292. * 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).
  42293. * @param object the object to get the class name from
  42294. * @param isType defines if the object is actually a type
  42295. * @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.
  42296. * @ignorenaming
  42297. */
  42298. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42299. /**
  42300. * Returns a promise that resolves after the given amount of time.
  42301. * @param delay Number of milliseconds to delay
  42302. * @returns Promise that resolves after the given amount of time
  42303. */
  42304. static DelayAsync(delay: number): Promise<void>;
  42305. /**
  42306. * Utility function to detect if the current user agent is Safari
  42307. * @returns whether or not the current user agent is safari
  42308. */
  42309. static IsSafari(): boolean;
  42310. }
  42311. /**
  42312. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42313. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42314. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42315. * @param name The name of the class, case should be preserved
  42316. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42317. */
  42318. export function className(name: string, module?: string): (target: Object) => void;
  42319. /**
  42320. * An implementation of a loop for asynchronous functions.
  42321. */
  42322. export class AsyncLoop {
  42323. /**
  42324. * Defines the number of iterations for the loop
  42325. */
  42326. iterations: number;
  42327. /**
  42328. * Defines the current index of the loop.
  42329. */
  42330. index: number;
  42331. private _done;
  42332. private _fn;
  42333. private _successCallback;
  42334. /**
  42335. * Constructor.
  42336. * @param iterations the number of iterations.
  42337. * @param func the function to run each iteration
  42338. * @param successCallback the callback that will be called upon succesful execution
  42339. * @param offset starting offset.
  42340. */
  42341. constructor(
  42342. /**
  42343. * Defines the number of iterations for the loop
  42344. */
  42345. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42346. /**
  42347. * Execute the next iteration. Must be called after the last iteration was finished.
  42348. */
  42349. executeNext(): void;
  42350. /**
  42351. * Break the loop and run the success callback.
  42352. */
  42353. breakLoop(): void;
  42354. /**
  42355. * Create and run an async loop.
  42356. * @param iterations the number of iterations.
  42357. * @param fn the function to run each iteration
  42358. * @param successCallback the callback that will be called upon succesful execution
  42359. * @param offset starting offset.
  42360. * @returns the created async loop object
  42361. */
  42362. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42363. /**
  42364. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42365. * @param iterations total number of iterations
  42366. * @param syncedIterations number of synchronous iterations in each async iteration.
  42367. * @param fn the function to call each iteration.
  42368. * @param callback a success call back that will be called when iterating stops.
  42369. * @param breakFunction a break condition (optional)
  42370. * @param timeout timeout settings for the setTimeout function. default - 0.
  42371. * @returns the created async loop object
  42372. */
  42373. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42374. }
  42375. }
  42376. declare module BABYLON {
  42377. /**
  42378. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42379. * The underlying implementation relies on an associative array to ensure the best performances.
  42380. * The value can be anything including 'null' but except 'undefined'
  42381. */
  42382. export class StringDictionary<T> {
  42383. /**
  42384. * This will clear this dictionary and copy the content from the 'source' one.
  42385. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42386. * @param source the dictionary to take the content from and copy to this dictionary
  42387. */
  42388. copyFrom(source: StringDictionary<T>): void;
  42389. /**
  42390. * Get a value based from its key
  42391. * @param key the given key to get the matching value from
  42392. * @return the value if found, otherwise undefined is returned
  42393. */
  42394. get(key: string): T | undefined;
  42395. /**
  42396. * Get a value from its key or add it if it doesn't exist.
  42397. * This method will ensure you that a given key/data will be present in the dictionary.
  42398. * @param key the given key to get the matching value from
  42399. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42400. * The factory will only be invoked if there's no data for the given key.
  42401. * @return the value corresponding to the key.
  42402. */
  42403. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42404. /**
  42405. * Get a value from its key if present in the dictionary otherwise add it
  42406. * @param key the key to get the value from
  42407. * @param val if there's no such key/value pair in the dictionary add it with this value
  42408. * @return the value corresponding to the key
  42409. */
  42410. getOrAdd(key: string, val: T): T;
  42411. /**
  42412. * Check if there's a given key in the dictionary
  42413. * @param key the key to check for
  42414. * @return true if the key is present, false otherwise
  42415. */
  42416. contains(key: string): boolean;
  42417. /**
  42418. * Add a new key and its corresponding value
  42419. * @param key the key to add
  42420. * @param value the value corresponding to the key
  42421. * @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
  42422. */
  42423. add(key: string, value: T): boolean;
  42424. /**
  42425. * Update a specific value associated to a key
  42426. * @param key defines the key to use
  42427. * @param value defines the value to store
  42428. * @returns true if the value was updated (or false if the key was not found)
  42429. */
  42430. set(key: string, value: T): boolean;
  42431. /**
  42432. * Get the element of the given key and remove it from the dictionary
  42433. * @param key defines the key to search
  42434. * @returns the value associated with the key or null if not found
  42435. */
  42436. getAndRemove(key: string): Nullable<T>;
  42437. /**
  42438. * Remove a key/value from the dictionary.
  42439. * @param key the key to remove
  42440. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42441. */
  42442. remove(key: string): boolean;
  42443. /**
  42444. * Clear the whole content of the dictionary
  42445. */
  42446. clear(): void;
  42447. /**
  42448. * Gets the current count
  42449. */
  42450. get count(): number;
  42451. /**
  42452. * Execute a callback on each key/val of the dictionary.
  42453. * Note that you can remove any element in this dictionary in the callback implementation
  42454. * @param callback the callback to execute on a given key/value pair
  42455. */
  42456. forEach(callback: (key: string, val: T) => void): void;
  42457. /**
  42458. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42459. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42460. * Note that you can remove any element in this dictionary in the callback implementation
  42461. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42462. * @returns the first item
  42463. */
  42464. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42465. private _count;
  42466. private _data;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /** @hidden */
  42471. export interface ICollisionCoordinator {
  42472. createCollider(): Collider;
  42473. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42474. init(scene: Scene): void;
  42475. }
  42476. /** @hidden */
  42477. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42478. private _scene;
  42479. private _scaledPosition;
  42480. private _scaledVelocity;
  42481. private _finalPosition;
  42482. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42483. createCollider(): Collider;
  42484. init(scene: Scene): void;
  42485. private _collideWithWorld;
  42486. }
  42487. }
  42488. declare module BABYLON {
  42489. /**
  42490. * Class used to manage all inputs for the scene.
  42491. */
  42492. export class InputManager {
  42493. /** The distance in pixel that you have to move to prevent some events */
  42494. static DragMovementThreshold: number;
  42495. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42496. static LongPressDelay: number;
  42497. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42498. static DoubleClickDelay: number;
  42499. /** If you need to check double click without raising a single click at first click, enable this flag */
  42500. static ExclusiveDoubleClickMode: boolean;
  42501. /** 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. */
  42502. private _alreadyAttached;
  42503. private _alreadyAttachedTo;
  42504. private _wheelEventName;
  42505. private _onPointerMove;
  42506. private _onPointerDown;
  42507. private _onPointerUp;
  42508. private _initClickEvent;
  42509. private _initActionManager;
  42510. private _delayedSimpleClick;
  42511. private _delayedSimpleClickTimeout;
  42512. private _previousDelayedSimpleClickTimeout;
  42513. private _meshPickProceed;
  42514. private _previousButtonPressed;
  42515. private _currentPickResult;
  42516. private _previousPickResult;
  42517. private _totalPointersPressed;
  42518. private _doubleClickOccured;
  42519. private _pointerOverMesh;
  42520. private _pickedDownMesh;
  42521. private _pickedUpMesh;
  42522. private _pointerX;
  42523. private _pointerY;
  42524. private _unTranslatedPointerX;
  42525. private _unTranslatedPointerY;
  42526. private _startingPointerPosition;
  42527. private _previousStartingPointerPosition;
  42528. private _startingPointerTime;
  42529. private _previousStartingPointerTime;
  42530. private _pointerCaptures;
  42531. private _meshUnderPointerId;
  42532. private _onKeyDown;
  42533. private _onKeyUp;
  42534. private _keyboardIsAttached;
  42535. private _onCanvasFocusObserver;
  42536. private _onCanvasBlurObserver;
  42537. private _scene;
  42538. /**
  42539. * Creates a new InputManager
  42540. * @param scene defines the hosting scene
  42541. */
  42542. constructor(scene: Scene);
  42543. /**
  42544. * Gets the mesh that is currently under the pointer
  42545. */
  42546. get meshUnderPointer(): Nullable<AbstractMesh>;
  42547. /**
  42548. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42549. * @param pointerId the pointer id to use
  42550. * @returns The mesh under this pointer id or null if not found
  42551. */
  42552. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42553. /**
  42554. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42555. */
  42556. get unTranslatedPointer(): Vector2;
  42557. /**
  42558. * Gets or sets the current on-screen X position of the pointer
  42559. */
  42560. get pointerX(): number;
  42561. set pointerX(value: number);
  42562. /**
  42563. * Gets or sets the current on-screen Y position of the pointer
  42564. */
  42565. get pointerY(): number;
  42566. set pointerY(value: number);
  42567. private _updatePointerPosition;
  42568. private _processPointerMove;
  42569. private _setRayOnPointerInfo;
  42570. private _checkPrePointerObservable;
  42571. /**
  42572. * Use this method to simulate a pointer move on a mesh
  42573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42576. */
  42577. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42578. /**
  42579. * Use this method to simulate a pointer down on a mesh
  42580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42583. */
  42584. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42585. private _processPointerDown;
  42586. /** @hidden */
  42587. _isPointerSwiping(): boolean;
  42588. /**
  42589. * Use this method to simulate a pointer up on a mesh
  42590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42593. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42594. */
  42595. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42596. private _processPointerUp;
  42597. /**
  42598. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42599. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42600. * @returns true if the pointer was captured
  42601. */
  42602. isPointerCaptured(pointerId?: number): boolean;
  42603. /**
  42604. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42605. * @param attachUp defines if you want to attach events to pointerup
  42606. * @param attachDown defines if you want to attach events to pointerdown
  42607. * @param attachMove defines if you want to attach events to pointermove
  42608. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42609. */
  42610. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42611. /**
  42612. * Detaches all event handlers
  42613. */
  42614. detachControl(): void;
  42615. /**
  42616. * Force the value of meshUnderPointer
  42617. * @param mesh defines the mesh to use
  42618. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42619. */
  42620. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42621. /**
  42622. * Gets the mesh under the pointer
  42623. * @returns a Mesh or null if no mesh is under the pointer
  42624. */
  42625. getPointerOverMesh(): Nullable<AbstractMesh>;
  42626. }
  42627. }
  42628. declare module BABYLON {
  42629. /**
  42630. * This class defines the direct association between an animation and a target
  42631. */
  42632. export class TargetedAnimation {
  42633. /**
  42634. * Animation to perform
  42635. */
  42636. animation: Animation;
  42637. /**
  42638. * Target to animate
  42639. */
  42640. target: any;
  42641. /**
  42642. * Returns the string "TargetedAnimation"
  42643. * @returns "TargetedAnimation"
  42644. */
  42645. getClassName(): string;
  42646. /**
  42647. * Serialize the object
  42648. * @returns the JSON object representing the current entity
  42649. */
  42650. serialize(): any;
  42651. }
  42652. /**
  42653. * Use this class to create coordinated animations on multiple targets
  42654. */
  42655. export class AnimationGroup implements IDisposable {
  42656. /** The name of the animation group */
  42657. name: string;
  42658. private _scene;
  42659. private _targetedAnimations;
  42660. private _animatables;
  42661. private _from;
  42662. private _to;
  42663. private _isStarted;
  42664. private _isPaused;
  42665. private _speedRatio;
  42666. private _loopAnimation;
  42667. private _isAdditive;
  42668. /**
  42669. * Gets or sets the unique id of the node
  42670. */
  42671. uniqueId: number;
  42672. /**
  42673. * This observable will notify when one animation have ended
  42674. */
  42675. onAnimationEndObservable: Observable<TargetedAnimation>;
  42676. /**
  42677. * Observer raised when one animation loops
  42678. */
  42679. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42680. /**
  42681. * Observer raised when all animations have looped
  42682. */
  42683. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42684. /**
  42685. * This observable will notify when all animations have ended.
  42686. */
  42687. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42688. /**
  42689. * This observable will notify when all animations have paused.
  42690. */
  42691. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42692. /**
  42693. * This observable will notify when all animations are playing.
  42694. */
  42695. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42696. /**
  42697. * Gets the first frame
  42698. */
  42699. get from(): number;
  42700. /**
  42701. * Gets the last frame
  42702. */
  42703. get to(): number;
  42704. /**
  42705. * Define if the animations are started
  42706. */
  42707. get isStarted(): boolean;
  42708. /**
  42709. * Gets a value indicating that the current group is playing
  42710. */
  42711. get isPlaying(): boolean;
  42712. /**
  42713. * Gets or sets the speed ratio to use for all animations
  42714. */
  42715. get speedRatio(): number;
  42716. /**
  42717. * Gets or sets the speed ratio to use for all animations
  42718. */
  42719. set speedRatio(value: number);
  42720. /**
  42721. * Gets or sets if all animations should loop or not
  42722. */
  42723. get loopAnimation(): boolean;
  42724. set loopAnimation(value: boolean);
  42725. /**
  42726. * Gets or sets if all animations should be evaluated additively
  42727. */
  42728. get isAdditive(): boolean;
  42729. set isAdditive(value: boolean);
  42730. /**
  42731. * Gets the targeted animations for this animation group
  42732. */
  42733. get targetedAnimations(): Array<TargetedAnimation>;
  42734. /**
  42735. * returning the list of animatables controlled by this animation group.
  42736. */
  42737. get animatables(): Array<Animatable>;
  42738. /**
  42739. * Gets the list of target animations
  42740. */
  42741. get children(): TargetedAnimation[];
  42742. /**
  42743. * Instantiates a new Animation Group.
  42744. * This helps managing several animations at once.
  42745. * @see https://doc.babylonjs.com/how_to/group
  42746. * @param name Defines the name of the group
  42747. * @param scene Defines the scene the group belongs to
  42748. */
  42749. constructor(
  42750. /** The name of the animation group */
  42751. name: string, scene?: Nullable<Scene>);
  42752. /**
  42753. * Add an animation (with its target) in the group
  42754. * @param animation defines the animation we want to add
  42755. * @param target defines the target of the animation
  42756. * @returns the TargetedAnimation object
  42757. */
  42758. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42759. /**
  42760. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42761. * It can add constant keys at begin or end
  42762. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42763. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42764. * @returns the animation group
  42765. */
  42766. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42767. private _animationLoopCount;
  42768. private _animationLoopFlags;
  42769. private _processLoop;
  42770. /**
  42771. * Start all animations on given targets
  42772. * @param loop defines if animations must loop
  42773. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42774. * @param from defines the from key (optional)
  42775. * @param to defines the to key (optional)
  42776. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42777. * @returns the current animation group
  42778. */
  42779. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42780. /**
  42781. * Pause all animations
  42782. * @returns the animation group
  42783. */
  42784. pause(): AnimationGroup;
  42785. /**
  42786. * Play all animations to initial state
  42787. * This function will start() the animations if they were not started or will restart() them if they were paused
  42788. * @param loop defines if animations must loop
  42789. * @returns the animation group
  42790. */
  42791. play(loop?: boolean): AnimationGroup;
  42792. /**
  42793. * Reset all animations to initial state
  42794. * @returns the animation group
  42795. */
  42796. reset(): AnimationGroup;
  42797. /**
  42798. * Restart animations from key 0
  42799. * @returns the animation group
  42800. */
  42801. restart(): AnimationGroup;
  42802. /**
  42803. * Stop all animations
  42804. * @returns the animation group
  42805. */
  42806. stop(): AnimationGroup;
  42807. /**
  42808. * Set animation weight for all animatables
  42809. * @param weight defines the weight to use
  42810. * @return the animationGroup
  42811. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42812. */
  42813. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42814. /**
  42815. * Synchronize and normalize all animatables with a source animatable
  42816. * @param root defines the root animatable to synchronize with
  42817. * @return the animationGroup
  42818. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42819. */
  42820. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42821. /**
  42822. * Goes to a specific frame in this animation group
  42823. * @param frame the frame number to go to
  42824. * @return the animationGroup
  42825. */
  42826. goToFrame(frame: number): AnimationGroup;
  42827. /**
  42828. * Dispose all associated resources
  42829. */
  42830. dispose(): void;
  42831. private _checkAnimationGroupEnded;
  42832. /**
  42833. * Clone the current animation group and returns a copy
  42834. * @param newName defines the name of the new group
  42835. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42836. * @returns the new aniamtion group
  42837. */
  42838. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42839. /**
  42840. * Serializes the animationGroup to an object
  42841. * @returns Serialized object
  42842. */
  42843. serialize(): any;
  42844. /**
  42845. * Returns a new AnimationGroup object parsed from the source provided.
  42846. * @param parsedAnimationGroup defines the source
  42847. * @param scene defines the scene that will receive the animationGroup
  42848. * @returns a new AnimationGroup
  42849. */
  42850. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42851. /**
  42852. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42853. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42854. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42855. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42856. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42857. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42858. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42859. */
  42860. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42861. /**
  42862. * Returns the string "AnimationGroup"
  42863. * @returns "AnimationGroup"
  42864. */
  42865. getClassName(): string;
  42866. /**
  42867. * Creates a detailled string about the object
  42868. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42869. * @returns a string representing the object
  42870. */
  42871. toString(fullDetails?: boolean): string;
  42872. }
  42873. }
  42874. declare module BABYLON {
  42875. /**
  42876. * Define an interface for all classes that will hold resources
  42877. */
  42878. export interface IDisposable {
  42879. /**
  42880. * Releases all held resources
  42881. */
  42882. dispose(): void;
  42883. }
  42884. /** Interface defining initialization parameters for Scene class */
  42885. export interface SceneOptions {
  42886. /**
  42887. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42888. * It will improve performance when the number of geometries becomes important.
  42889. */
  42890. useGeometryUniqueIdsMap?: boolean;
  42891. /**
  42892. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42893. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42894. */
  42895. useMaterialMeshMap?: boolean;
  42896. /**
  42897. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42898. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42899. */
  42900. useClonedMeshMap?: boolean;
  42901. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42902. virtual?: boolean;
  42903. }
  42904. /**
  42905. * Represents a scene to be rendered by the engine.
  42906. * @see https://doc.babylonjs.com/features/scene
  42907. */
  42908. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42909. /** The fog is deactivated */
  42910. static readonly FOGMODE_NONE: number;
  42911. /** The fog density is following an exponential function */
  42912. static readonly FOGMODE_EXP: number;
  42913. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42914. static readonly FOGMODE_EXP2: number;
  42915. /** The fog density is following a linear function. */
  42916. static readonly FOGMODE_LINEAR: number;
  42917. /**
  42918. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42919. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42920. */
  42921. static MinDeltaTime: number;
  42922. /**
  42923. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42924. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42925. */
  42926. static MaxDeltaTime: number;
  42927. /**
  42928. * Factory used to create the default material.
  42929. * @param name The name of the material to create
  42930. * @param scene The scene to create the material for
  42931. * @returns The default material
  42932. */
  42933. static DefaultMaterialFactory(scene: Scene): Material;
  42934. /**
  42935. * Factory used to create the a collision coordinator.
  42936. * @returns The collision coordinator
  42937. */
  42938. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42939. /** @hidden */
  42940. _inputManager: InputManager;
  42941. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42942. cameraToUseForPointers: Nullable<Camera>;
  42943. /** @hidden */
  42944. readonly _isScene: boolean;
  42945. /** @hidden */
  42946. _blockEntityCollection: boolean;
  42947. /**
  42948. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42949. */
  42950. autoClear: boolean;
  42951. /**
  42952. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42953. */
  42954. autoClearDepthAndStencil: boolean;
  42955. /**
  42956. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42957. */
  42958. clearColor: Color4;
  42959. /**
  42960. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42961. */
  42962. ambientColor: Color3;
  42963. /**
  42964. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42965. * It should only be one of the following (if not the default embedded one):
  42966. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42967. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42968. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42969. * The material properties need to be setup according to the type of texture in use.
  42970. */
  42971. environmentBRDFTexture: 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 reference from here than from all the materials.
  42976. */
  42977. get environmentTexture(): Nullable<BaseTexture>;
  42978. /**
  42979. * Texture used in all pbr material as the reflection texture.
  42980. * As in the majority of the scene they are the same (exception for multi room and so on),
  42981. * this is easier to set here than in all the materials.
  42982. */
  42983. set environmentTexture(value: Nullable<BaseTexture>);
  42984. /** @hidden */
  42985. protected _environmentIntensity: number;
  42986. /**
  42987. * Intensity of the environment in all pbr material.
  42988. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42989. * As in the majority of the scene they are the same (exception for multi room and so on),
  42990. * this is easier to reference from here than from all the materials.
  42991. */
  42992. get environmentIntensity(): number;
  42993. /**
  42994. * Intensity of the environment in all pbr material.
  42995. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42996. * As in the majority of the scene they are the same (exception for multi room and so on),
  42997. * this is easier to set here than in all the materials.
  42998. */
  42999. set environmentIntensity(value: number);
  43000. /** @hidden */
  43001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43002. /**
  43003. * Default image processing configuration used either in the rendering
  43004. * Forward main pass or through the imageProcessingPostProcess if present.
  43005. * As in the majority of the scene they are the same (exception for multi camera),
  43006. * this is easier to reference from here than from all the materials and post process.
  43007. *
  43008. * No setter as we it is a shared configuration, you can set the values instead.
  43009. */
  43010. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43011. private _forceWireframe;
  43012. /**
  43013. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43014. */
  43015. set forceWireframe(value: boolean);
  43016. get forceWireframe(): boolean;
  43017. private _skipFrustumClipping;
  43018. /**
  43019. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43020. */
  43021. set skipFrustumClipping(value: boolean);
  43022. get skipFrustumClipping(): boolean;
  43023. private _forcePointsCloud;
  43024. /**
  43025. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43026. */
  43027. set forcePointsCloud(value: boolean);
  43028. get forcePointsCloud(): boolean;
  43029. /**
  43030. * Gets or sets the active clipplane 1
  43031. */
  43032. clipPlane: Nullable<Plane>;
  43033. /**
  43034. * Gets or sets the active clipplane 2
  43035. */
  43036. clipPlane2: Nullable<Plane>;
  43037. /**
  43038. * Gets or sets the active clipplane 3
  43039. */
  43040. clipPlane3: Nullable<Plane>;
  43041. /**
  43042. * Gets or sets the active clipplane 4
  43043. */
  43044. clipPlane4: Nullable<Plane>;
  43045. /**
  43046. * Gets or sets the active clipplane 5
  43047. */
  43048. clipPlane5: Nullable<Plane>;
  43049. /**
  43050. * Gets or sets the active clipplane 6
  43051. */
  43052. clipPlane6: Nullable<Plane>;
  43053. /**
  43054. * Gets or sets a boolean indicating if animations are enabled
  43055. */
  43056. animationsEnabled: boolean;
  43057. private _animationPropertiesOverride;
  43058. /**
  43059. * Gets or sets the animation properties override
  43060. */
  43061. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43062. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43063. /**
  43064. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43065. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43066. */
  43067. useConstantAnimationDeltaTime: boolean;
  43068. /**
  43069. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43070. * Please note that it requires to run a ray cast through the scene on every frame
  43071. */
  43072. constantlyUpdateMeshUnderPointer: boolean;
  43073. /**
  43074. * Defines the HTML cursor to use when hovering over interactive elements
  43075. */
  43076. hoverCursor: string;
  43077. /**
  43078. * Defines the HTML default cursor to use (empty by default)
  43079. */
  43080. defaultCursor: string;
  43081. /**
  43082. * Defines whether cursors are handled by the scene.
  43083. */
  43084. doNotHandleCursors: boolean;
  43085. /**
  43086. * This is used to call preventDefault() on pointer down
  43087. * in order to block unwanted artifacts like system double clicks
  43088. */
  43089. preventDefaultOnPointerDown: boolean;
  43090. /**
  43091. * This is used to call preventDefault() on pointer up
  43092. * in order to block unwanted artifacts like system double clicks
  43093. */
  43094. preventDefaultOnPointerUp: boolean;
  43095. /**
  43096. * Gets or sets user defined metadata
  43097. */
  43098. metadata: any;
  43099. /**
  43100. * For internal use only. Please do not use.
  43101. */
  43102. reservedDataStore: any;
  43103. /**
  43104. * Gets the name of the plugin used to load this scene (null by default)
  43105. */
  43106. loadingPluginName: string;
  43107. /**
  43108. * Use this array to add regular expressions used to disable offline support for specific urls
  43109. */
  43110. disableOfflineSupportExceptionRules: RegExp[];
  43111. /**
  43112. * An event triggered when the scene is disposed.
  43113. */
  43114. onDisposeObservable: Observable<Scene>;
  43115. private _onDisposeObserver;
  43116. /** Sets a function to be executed when this scene is disposed. */
  43117. set onDispose(callback: () => void);
  43118. /**
  43119. * An event triggered before rendering the scene (right after animations and physics)
  43120. */
  43121. onBeforeRenderObservable: Observable<Scene>;
  43122. private _onBeforeRenderObserver;
  43123. /** Sets a function to be executed before rendering this scene */
  43124. set beforeRender(callback: Nullable<() => void>);
  43125. /**
  43126. * An event triggered after rendering the scene
  43127. */
  43128. onAfterRenderObservable: Observable<Scene>;
  43129. /**
  43130. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43131. */
  43132. onAfterRenderCameraObservable: Observable<Camera>;
  43133. private _onAfterRenderObserver;
  43134. /** Sets a function to be executed after rendering this scene */
  43135. set afterRender(callback: Nullable<() => void>);
  43136. /**
  43137. * An event triggered before animating the scene
  43138. */
  43139. onBeforeAnimationsObservable: Observable<Scene>;
  43140. /**
  43141. * An event triggered after animations processing
  43142. */
  43143. onAfterAnimationsObservable: Observable<Scene>;
  43144. /**
  43145. * An event triggered before draw calls are ready to be sent
  43146. */
  43147. onBeforeDrawPhaseObservable: Observable<Scene>;
  43148. /**
  43149. * An event triggered after draw calls have been sent
  43150. */
  43151. onAfterDrawPhaseObservable: Observable<Scene>;
  43152. /**
  43153. * An event triggered when the scene is ready
  43154. */
  43155. onReadyObservable: Observable<Scene>;
  43156. /**
  43157. * An event triggered before rendering a camera
  43158. */
  43159. onBeforeCameraRenderObservable: Observable<Camera>;
  43160. private _onBeforeCameraRenderObserver;
  43161. /** Sets a function to be executed before rendering a camera*/
  43162. set beforeCameraRender(callback: () => void);
  43163. /**
  43164. * An event triggered after rendering a camera
  43165. */
  43166. onAfterCameraRenderObservable: Observable<Camera>;
  43167. private _onAfterCameraRenderObserver;
  43168. /** Sets a function to be executed after rendering a camera*/
  43169. set afterCameraRender(callback: () => void);
  43170. /**
  43171. * An event triggered when active meshes evaluation is about to start
  43172. */
  43173. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43174. /**
  43175. * An event triggered when active meshes evaluation is done
  43176. */
  43177. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43178. /**
  43179. * An event triggered when particles rendering is about to start
  43180. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43181. */
  43182. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43183. /**
  43184. * An event triggered when particles rendering is done
  43185. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43186. */
  43187. onAfterParticlesRenderingObservable: Observable<Scene>;
  43188. /**
  43189. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43190. */
  43191. onDataLoadedObservable: Observable<Scene>;
  43192. /**
  43193. * An event triggered when a camera is created
  43194. */
  43195. onNewCameraAddedObservable: Observable<Camera>;
  43196. /**
  43197. * An event triggered when a camera is removed
  43198. */
  43199. onCameraRemovedObservable: Observable<Camera>;
  43200. /**
  43201. * An event triggered when a light is created
  43202. */
  43203. onNewLightAddedObservable: Observable<Light>;
  43204. /**
  43205. * An event triggered when a light is removed
  43206. */
  43207. onLightRemovedObservable: Observable<Light>;
  43208. /**
  43209. * An event triggered when a geometry is created
  43210. */
  43211. onNewGeometryAddedObservable: Observable<Geometry>;
  43212. /**
  43213. * An event triggered when a geometry is removed
  43214. */
  43215. onGeometryRemovedObservable: Observable<Geometry>;
  43216. /**
  43217. * An event triggered when a transform node is created
  43218. */
  43219. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43220. /**
  43221. * An event triggered when a transform node is removed
  43222. */
  43223. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43224. /**
  43225. * An event triggered when a mesh is created
  43226. */
  43227. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43228. /**
  43229. * An event triggered when a mesh is removed
  43230. */
  43231. onMeshRemovedObservable: Observable<AbstractMesh>;
  43232. /**
  43233. * An event triggered when a skeleton is created
  43234. */
  43235. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43236. /**
  43237. * An event triggered when a skeleton is removed
  43238. */
  43239. onSkeletonRemovedObservable: Observable<Skeleton>;
  43240. /**
  43241. * An event triggered when a material is created
  43242. */
  43243. onNewMaterialAddedObservable: Observable<Material>;
  43244. /**
  43245. * An event triggered when a multi material is created
  43246. */
  43247. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43248. /**
  43249. * An event triggered when a material is removed
  43250. */
  43251. onMaterialRemovedObservable: Observable<Material>;
  43252. /**
  43253. * An event triggered when a multi material is removed
  43254. */
  43255. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43256. /**
  43257. * An event triggered when a texture is created
  43258. */
  43259. onNewTextureAddedObservable: Observable<BaseTexture>;
  43260. /**
  43261. * An event triggered when a texture is removed
  43262. */
  43263. onTextureRemovedObservable: Observable<BaseTexture>;
  43264. /**
  43265. * An event triggered when render targets are about to be rendered
  43266. * Can happen multiple times per frame.
  43267. */
  43268. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43269. /**
  43270. * An event triggered when render targets were rendered.
  43271. * Can happen multiple times per frame.
  43272. */
  43273. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43274. /**
  43275. * An event triggered before calculating deterministic simulation step
  43276. */
  43277. onBeforeStepObservable: Observable<Scene>;
  43278. /**
  43279. * An event triggered after calculating deterministic simulation step
  43280. */
  43281. onAfterStepObservable: Observable<Scene>;
  43282. /**
  43283. * An event triggered when the activeCamera property is updated
  43284. */
  43285. onActiveCameraChanged: Observable<Scene>;
  43286. /**
  43287. * This Observable will be triggered before 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. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43292. /**
  43293. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43294. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43295. * 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)
  43296. */
  43297. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43298. /**
  43299. * This Observable will when a mesh has been imported into the scene.
  43300. */
  43301. onMeshImportedObservable: Observable<AbstractMesh>;
  43302. /**
  43303. * This Observable will when an animation file has been imported into the scene.
  43304. */
  43305. onAnimationFileImportedObservable: Observable<Scene>;
  43306. /**
  43307. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43308. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43309. */
  43310. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43311. /** @hidden */
  43312. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43313. /**
  43314. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43315. */
  43316. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43317. /**
  43318. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43319. */
  43320. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43321. /**
  43322. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43323. */
  43324. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43325. /** Callback called when a pointer move is detected */
  43326. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43327. /** Callback called when a pointer down is detected */
  43328. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43329. /** Callback called when a pointer up is detected */
  43330. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43331. /** Callback called when a pointer pick is detected */
  43332. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43333. /**
  43334. * 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).
  43335. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43336. */
  43337. onPrePointerObservable: Observable<PointerInfoPre>;
  43338. /**
  43339. * Observable event triggered each time an input event is received from the rendering canvas
  43340. */
  43341. onPointerObservable: Observable<PointerInfo>;
  43342. /**
  43343. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43344. */
  43345. get unTranslatedPointer(): Vector2;
  43346. /**
  43347. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43348. */
  43349. static get DragMovementThreshold(): number;
  43350. static set DragMovementThreshold(value: number);
  43351. /**
  43352. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43353. */
  43354. static get LongPressDelay(): number;
  43355. static set LongPressDelay(value: number);
  43356. /**
  43357. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43358. */
  43359. static get DoubleClickDelay(): number;
  43360. static set DoubleClickDelay(value: number);
  43361. /** If you need to check double click without raising a single click at first click, enable this flag */
  43362. static get ExclusiveDoubleClickMode(): boolean;
  43363. static set ExclusiveDoubleClickMode(value: boolean);
  43364. /** @hidden */
  43365. _mirroredCameraPosition: Nullable<Vector3>;
  43366. /**
  43367. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43368. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43369. */
  43370. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43371. /**
  43372. * Observable event triggered each time an keyboard event is received from the hosting window
  43373. */
  43374. onKeyboardObservable: Observable<KeyboardInfo>;
  43375. private _useRightHandedSystem;
  43376. /**
  43377. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43378. */
  43379. set useRightHandedSystem(value: boolean);
  43380. get useRightHandedSystem(): boolean;
  43381. private _timeAccumulator;
  43382. private _currentStepId;
  43383. private _currentInternalStep;
  43384. /**
  43385. * Sets the step Id used by deterministic lock step
  43386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43387. * @param newStepId defines the step Id
  43388. */
  43389. setStepId(newStepId: number): void;
  43390. /**
  43391. * Gets the step Id used by deterministic lock step
  43392. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43393. * @returns the step Id
  43394. */
  43395. getStepId(): number;
  43396. /**
  43397. * Gets the internal step used by deterministic lock step
  43398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43399. * @returns the internal step
  43400. */
  43401. getInternalStep(): number;
  43402. private _fogEnabled;
  43403. /**
  43404. * Gets or sets a boolean indicating if fog is enabled on this scene
  43405. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43406. * (Default is true)
  43407. */
  43408. set fogEnabled(value: boolean);
  43409. get fogEnabled(): boolean;
  43410. private _fogMode;
  43411. /**
  43412. * Gets or sets the fog mode to use
  43413. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43414. * | mode | value |
  43415. * | --- | --- |
  43416. * | FOGMODE_NONE | 0 |
  43417. * | FOGMODE_EXP | 1 |
  43418. * | FOGMODE_EXP2 | 2 |
  43419. * | FOGMODE_LINEAR | 3 |
  43420. */
  43421. set fogMode(value: number);
  43422. get fogMode(): number;
  43423. /**
  43424. * Gets or sets the fog color to use
  43425. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43426. * (Default is Color3(0.2, 0.2, 0.3))
  43427. */
  43428. fogColor: Color3;
  43429. /**
  43430. * Gets or sets the fog density to use
  43431. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43432. * (Default is 0.1)
  43433. */
  43434. fogDensity: number;
  43435. /**
  43436. * Gets or sets the fog start distance to use
  43437. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43438. * (Default is 0)
  43439. */
  43440. fogStart: number;
  43441. /**
  43442. * Gets or sets the fog end distance to use
  43443. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43444. * (Default is 1000)
  43445. */
  43446. fogEnd: number;
  43447. /**
  43448. * Flag indicating that the frame buffer binding is handled by another component
  43449. */
  43450. prePass: boolean;
  43451. private _shadowsEnabled;
  43452. /**
  43453. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43454. */
  43455. set shadowsEnabled(value: boolean);
  43456. get shadowsEnabled(): boolean;
  43457. private _lightsEnabled;
  43458. /**
  43459. * Gets or sets a boolean indicating if lights are enabled on this scene
  43460. */
  43461. set lightsEnabled(value: boolean);
  43462. get lightsEnabled(): boolean;
  43463. /** All of the active cameras added to this scene. */
  43464. activeCameras: Nullable<Camera[]>;
  43465. /** @hidden */
  43466. _activeCamera: Nullable<Camera>;
  43467. /** Gets or sets the current active camera */
  43468. get activeCamera(): Nullable<Camera>;
  43469. set activeCamera(value: Nullable<Camera>);
  43470. private _defaultMaterial;
  43471. /** The default material used on meshes when no material is affected */
  43472. get defaultMaterial(): Material;
  43473. /** The default material used on meshes when no material is affected */
  43474. set defaultMaterial(value: Material);
  43475. private _texturesEnabled;
  43476. /**
  43477. * Gets or sets a boolean indicating if textures are enabled on this scene
  43478. */
  43479. set texturesEnabled(value: boolean);
  43480. get texturesEnabled(): boolean;
  43481. /**
  43482. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43483. */
  43484. physicsEnabled: boolean;
  43485. /**
  43486. * Gets or sets a boolean indicating if particles are enabled on this scene
  43487. */
  43488. particlesEnabled: boolean;
  43489. /**
  43490. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43491. */
  43492. spritesEnabled: boolean;
  43493. private _skeletonsEnabled;
  43494. /**
  43495. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43496. */
  43497. set skeletonsEnabled(value: boolean);
  43498. get skeletonsEnabled(): boolean;
  43499. /**
  43500. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43501. */
  43502. lensFlaresEnabled: boolean;
  43503. /**
  43504. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43505. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43506. */
  43507. collisionsEnabled: boolean;
  43508. private _collisionCoordinator;
  43509. /** @hidden */
  43510. get collisionCoordinator(): ICollisionCoordinator;
  43511. /**
  43512. * Defines the gravity applied to this scene (used only for collisions)
  43513. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43514. */
  43515. gravity: Vector3;
  43516. /**
  43517. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43518. */
  43519. postProcessesEnabled: boolean;
  43520. /**
  43521. * Gets the current postprocess manager
  43522. */
  43523. postProcessManager: PostProcessManager;
  43524. /**
  43525. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43526. */
  43527. renderTargetsEnabled: boolean;
  43528. /**
  43529. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43530. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43531. */
  43532. dumpNextRenderTargets: boolean;
  43533. /**
  43534. * The list of user defined render targets added to the scene
  43535. */
  43536. customRenderTargets: RenderTargetTexture[];
  43537. /**
  43538. * Defines if texture loading must be delayed
  43539. * If true, textures will only be loaded when they need to be rendered
  43540. */
  43541. useDelayedTextureLoading: boolean;
  43542. /**
  43543. * Gets the list of meshes imported to the scene through SceneLoader
  43544. */
  43545. importedMeshesFiles: String[];
  43546. /**
  43547. * Gets or sets a boolean indicating if probes are enabled on this scene
  43548. */
  43549. probesEnabled: boolean;
  43550. /**
  43551. * Gets or sets the current offline provider to use to store scene data
  43552. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43553. */
  43554. offlineProvider: IOfflineProvider;
  43555. /**
  43556. * Gets or sets the action manager associated with the scene
  43557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43558. */
  43559. actionManager: AbstractActionManager;
  43560. private _meshesForIntersections;
  43561. /**
  43562. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43563. */
  43564. proceduralTexturesEnabled: boolean;
  43565. private _engine;
  43566. private _totalVertices;
  43567. /** @hidden */
  43568. _activeIndices: PerfCounter;
  43569. /** @hidden */
  43570. _activeParticles: PerfCounter;
  43571. /** @hidden */
  43572. _activeBones: PerfCounter;
  43573. private _animationRatio;
  43574. /** @hidden */
  43575. _animationTimeLast: number;
  43576. /** @hidden */
  43577. _animationTime: number;
  43578. /**
  43579. * Gets or sets a general scale for animation speed
  43580. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43581. */
  43582. animationTimeScale: number;
  43583. /** @hidden */
  43584. _cachedMaterial: Nullable<Material>;
  43585. /** @hidden */
  43586. _cachedEffect: Nullable<Effect>;
  43587. /** @hidden */
  43588. _cachedVisibility: Nullable<number>;
  43589. private _renderId;
  43590. private _frameId;
  43591. private _executeWhenReadyTimeoutId;
  43592. private _intermediateRendering;
  43593. private _viewUpdateFlag;
  43594. private _projectionUpdateFlag;
  43595. /** @hidden */
  43596. _toBeDisposed: Nullable<IDisposable>[];
  43597. private _activeRequests;
  43598. /** @hidden */
  43599. _pendingData: any[];
  43600. private _isDisposed;
  43601. /**
  43602. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43603. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43604. */
  43605. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43606. private _activeMeshes;
  43607. private _processedMaterials;
  43608. private _renderTargets;
  43609. /** @hidden */
  43610. _activeParticleSystems: SmartArray<IParticleSystem>;
  43611. private _activeSkeletons;
  43612. private _softwareSkinnedMeshes;
  43613. private _renderingManager;
  43614. /** @hidden */
  43615. _activeAnimatables: Animatable[];
  43616. private _transformMatrix;
  43617. private _sceneUbo;
  43618. /** @hidden */
  43619. _viewMatrix: Matrix;
  43620. private _projectionMatrix;
  43621. /** @hidden */
  43622. _forcedViewPosition: Nullable<Vector3>;
  43623. /** @hidden */
  43624. _frustumPlanes: Plane[];
  43625. /**
  43626. * Gets the list of frustum planes (built from the active camera)
  43627. */
  43628. get frustumPlanes(): Plane[];
  43629. /**
  43630. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43631. * This is useful if there are more lights that the maximum simulteanous authorized
  43632. */
  43633. requireLightSorting: boolean;
  43634. /** @hidden */
  43635. readonly useMaterialMeshMap: boolean;
  43636. /** @hidden */
  43637. readonly useClonedMeshMap: boolean;
  43638. private _externalData;
  43639. private _uid;
  43640. /**
  43641. * @hidden
  43642. * Backing store of defined scene components.
  43643. */
  43644. _components: ISceneComponent[];
  43645. /**
  43646. * @hidden
  43647. * Backing store of defined scene components.
  43648. */
  43649. _serializableComponents: ISceneSerializableComponent[];
  43650. /**
  43651. * List of components to register on the next registration step.
  43652. */
  43653. private _transientComponents;
  43654. /**
  43655. * Registers the transient components if needed.
  43656. */
  43657. private _registerTransientComponents;
  43658. /**
  43659. * @hidden
  43660. * Add a component to the scene.
  43661. * Note that the ccomponent could be registered on th next frame if this is called after
  43662. * the register component stage.
  43663. * @param component Defines the component to add to the scene
  43664. */
  43665. _addComponent(component: ISceneComponent): void;
  43666. /**
  43667. * @hidden
  43668. * Gets a component from the scene.
  43669. * @param name defines the name of the component to retrieve
  43670. * @returns the component or null if not present
  43671. */
  43672. _getComponent(name: string): Nullable<ISceneComponent>;
  43673. /**
  43674. * @hidden
  43675. * Defines the actions happening before camera updates.
  43676. */
  43677. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43678. /**
  43679. * @hidden
  43680. * Defines the actions happening before clear the canvas.
  43681. */
  43682. _beforeClearStage: Stage<SimpleStageAction>;
  43683. /**
  43684. * @hidden
  43685. * Defines the actions when collecting render targets for the frame.
  43686. */
  43687. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43688. /**
  43689. * @hidden
  43690. * Defines the actions happening for one camera in the frame.
  43691. */
  43692. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43693. /**
  43694. * @hidden
  43695. * Defines the actions happening during the per mesh ready checks.
  43696. */
  43697. _isReadyForMeshStage: Stage<MeshStageAction>;
  43698. /**
  43699. * @hidden
  43700. * Defines the actions happening before evaluate active mesh checks.
  43701. */
  43702. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43703. /**
  43704. * @hidden
  43705. * Defines the actions happening during the evaluate sub mesh checks.
  43706. */
  43707. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43708. /**
  43709. * @hidden
  43710. * Defines the actions happening during the active mesh stage.
  43711. */
  43712. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43713. /**
  43714. * @hidden
  43715. * Defines the actions happening during the per camera render target step.
  43716. */
  43717. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43718. /**
  43719. * @hidden
  43720. * Defines the actions happening just before the active camera is drawing.
  43721. */
  43722. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43723. /**
  43724. * @hidden
  43725. * Defines the actions happening just before a render target is drawing.
  43726. */
  43727. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43728. /**
  43729. * @hidden
  43730. * Defines the actions happening just before a rendering group is drawing.
  43731. */
  43732. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43733. /**
  43734. * @hidden
  43735. * Defines the actions happening just before a mesh is drawing.
  43736. */
  43737. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43738. /**
  43739. * @hidden
  43740. * Defines the actions happening just after a mesh has been drawn.
  43741. */
  43742. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43743. /**
  43744. * @hidden
  43745. * Defines the actions happening just after a rendering group has been drawn.
  43746. */
  43747. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43748. /**
  43749. * @hidden
  43750. * Defines the actions happening just after the active camera has been drawn.
  43751. */
  43752. _afterCameraDrawStage: Stage<CameraStageAction>;
  43753. /**
  43754. * @hidden
  43755. * Defines the actions happening just after a render target has been drawn.
  43756. */
  43757. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43758. /**
  43759. * @hidden
  43760. * Defines the actions happening just after rendering all cameras and computing intersections.
  43761. */
  43762. _afterRenderStage: Stage<SimpleStageAction>;
  43763. /**
  43764. * @hidden
  43765. * Defines the actions happening when a pointer move event happens.
  43766. */
  43767. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43768. /**
  43769. * @hidden
  43770. * Defines the actions happening when a pointer down event happens.
  43771. */
  43772. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43773. /**
  43774. * @hidden
  43775. * Defines the actions happening when a pointer up event happens.
  43776. */
  43777. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43778. /**
  43779. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43780. */
  43781. private geometriesByUniqueId;
  43782. /**
  43783. * Creates a new Scene
  43784. * @param engine defines the engine to use to render this scene
  43785. * @param options defines the scene options
  43786. */
  43787. constructor(engine: Engine, options?: SceneOptions);
  43788. /**
  43789. * Gets a string identifying the name of the class
  43790. * @returns "Scene" string
  43791. */
  43792. getClassName(): string;
  43793. private _defaultMeshCandidates;
  43794. /**
  43795. * @hidden
  43796. */
  43797. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43798. private _defaultSubMeshCandidates;
  43799. /**
  43800. * @hidden
  43801. */
  43802. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43803. /**
  43804. * Sets the default candidate providers for the scene.
  43805. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43806. * and getCollidingSubMeshCandidates to their default function
  43807. */
  43808. setDefaultCandidateProviders(): void;
  43809. /**
  43810. * Gets the mesh that is currently under the pointer
  43811. */
  43812. get meshUnderPointer(): Nullable<AbstractMesh>;
  43813. /**
  43814. * Gets or sets the current on-screen X position of the pointer
  43815. */
  43816. get pointerX(): number;
  43817. set pointerX(value: number);
  43818. /**
  43819. * Gets or sets the current on-screen Y position of the pointer
  43820. */
  43821. get pointerY(): number;
  43822. set pointerY(value: number);
  43823. /**
  43824. * Gets the cached material (ie. the latest rendered one)
  43825. * @returns the cached material
  43826. */
  43827. getCachedMaterial(): Nullable<Material>;
  43828. /**
  43829. * Gets the cached effect (ie. the latest rendered one)
  43830. * @returns the cached effect
  43831. */
  43832. getCachedEffect(): Nullable<Effect>;
  43833. /**
  43834. * Gets the cached visibility state (ie. the latest rendered one)
  43835. * @returns the cached visibility state
  43836. */
  43837. getCachedVisibility(): Nullable<number>;
  43838. /**
  43839. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43840. * @param material defines the current material
  43841. * @param effect defines the current effect
  43842. * @param visibility defines the current visibility state
  43843. * @returns true if one parameter is not cached
  43844. */
  43845. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43846. /**
  43847. * Gets the engine associated with the scene
  43848. * @returns an Engine
  43849. */
  43850. getEngine(): Engine;
  43851. /**
  43852. * Gets the total number of vertices rendered per frame
  43853. * @returns the total number of vertices rendered per frame
  43854. */
  43855. getTotalVertices(): number;
  43856. /**
  43857. * Gets the performance counter for total vertices
  43858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43859. */
  43860. get totalVerticesPerfCounter(): PerfCounter;
  43861. /**
  43862. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43863. * @returns the total number of active indices rendered per frame
  43864. */
  43865. getActiveIndices(): number;
  43866. /**
  43867. * Gets the performance counter for active indices
  43868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43869. */
  43870. get totalActiveIndicesPerfCounter(): PerfCounter;
  43871. /**
  43872. * Gets the total number of active particles rendered per frame
  43873. * @returns the total number of active particles rendered per frame
  43874. */
  43875. getActiveParticles(): number;
  43876. /**
  43877. * Gets the performance counter for active particles
  43878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43879. */
  43880. get activeParticlesPerfCounter(): PerfCounter;
  43881. /**
  43882. * Gets the total number of active bones rendered per frame
  43883. * @returns the total number of active bones rendered per frame
  43884. */
  43885. getActiveBones(): number;
  43886. /**
  43887. * Gets the performance counter for active bones
  43888. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43889. */
  43890. get activeBonesPerfCounter(): PerfCounter;
  43891. /**
  43892. * Gets the array of active meshes
  43893. * @returns an array of AbstractMesh
  43894. */
  43895. getActiveMeshes(): SmartArray<AbstractMesh>;
  43896. /**
  43897. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43898. * @returns a number
  43899. */
  43900. getAnimationRatio(): number;
  43901. /**
  43902. * Gets an unique Id for the current render phase
  43903. * @returns a number
  43904. */
  43905. getRenderId(): number;
  43906. /**
  43907. * Gets an unique Id for the current frame
  43908. * @returns a number
  43909. */
  43910. getFrameId(): number;
  43911. /** Call this function if you want to manually increment the render Id*/
  43912. incrementRenderId(): void;
  43913. private _createUbo;
  43914. /**
  43915. * Use this method to simulate a pointer move on a mesh
  43916. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43917. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43918. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43919. * @returns the current scene
  43920. */
  43921. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43922. /**
  43923. * Use this method to simulate a pointer down on a mesh
  43924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43927. * @returns the current scene
  43928. */
  43929. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43930. /**
  43931. * Use this method to simulate a pointer up on a mesh
  43932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43935. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43936. * @returns the current scene
  43937. */
  43938. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43939. /**
  43940. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43941. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43942. * @returns true if the pointer was captured
  43943. */
  43944. isPointerCaptured(pointerId?: number): boolean;
  43945. /**
  43946. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43947. * @param attachUp defines if you want to attach events to pointerup
  43948. * @param attachDown defines if you want to attach events to pointerdown
  43949. * @param attachMove defines if you want to attach events to pointermove
  43950. */
  43951. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43952. /** Detaches all event handlers*/
  43953. detachControl(): void;
  43954. /**
  43955. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43956. * Delay loaded resources are not taking in account
  43957. * @return true if all required resources are ready
  43958. */
  43959. isReady(): boolean;
  43960. /** Resets all cached information relative to material (including effect and visibility) */
  43961. resetCachedMaterial(): void;
  43962. /**
  43963. * Registers a function to be called before every frame render
  43964. * @param func defines the function to register
  43965. */
  43966. registerBeforeRender(func: () => void): void;
  43967. /**
  43968. * Unregisters a function called before every frame render
  43969. * @param func defines the function to unregister
  43970. */
  43971. unregisterBeforeRender(func: () => void): void;
  43972. /**
  43973. * Registers a function to be called after every frame render
  43974. * @param func defines the function to register
  43975. */
  43976. registerAfterRender(func: () => void): void;
  43977. /**
  43978. * Unregisters a function called after every frame render
  43979. * @param func defines the function to unregister
  43980. */
  43981. unregisterAfterRender(func: () => void): void;
  43982. private _executeOnceBeforeRender;
  43983. /**
  43984. * The provided function will run before render once and will be disposed afterwards.
  43985. * A timeout delay can be provided so that the function will be executed in N ms.
  43986. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43987. * @param func The function to be executed.
  43988. * @param timeout optional delay in ms
  43989. */
  43990. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43991. /** @hidden */
  43992. _addPendingData(data: any): void;
  43993. /** @hidden */
  43994. _removePendingData(data: any): void;
  43995. /**
  43996. * Returns the number of items waiting to be loaded
  43997. * @returns the number of items waiting to be loaded
  43998. */
  43999. getWaitingItemsCount(): number;
  44000. /**
  44001. * Returns a boolean indicating if the scene is still loading data
  44002. */
  44003. get isLoading(): boolean;
  44004. /**
  44005. * Registers a function to be executed when the scene is ready
  44006. * @param {Function} func - the function to be executed
  44007. */
  44008. executeWhenReady(func: () => void): void;
  44009. /**
  44010. * Returns a promise that resolves when the scene is ready
  44011. * @returns A promise that resolves when the scene is ready
  44012. */
  44013. whenReadyAsync(): Promise<void>;
  44014. /** @hidden */
  44015. _checkIsReady(): void;
  44016. /**
  44017. * Gets all animatable attached to the scene
  44018. */
  44019. get animatables(): Animatable[];
  44020. /**
  44021. * Resets the last animation time frame.
  44022. * Useful to override when animations start running when loading a scene for the first time.
  44023. */
  44024. resetLastAnimationTimeFrame(): void;
  44025. /**
  44026. * Gets the current view matrix
  44027. * @returns a Matrix
  44028. */
  44029. getViewMatrix(): Matrix;
  44030. /**
  44031. * Gets the current projection matrix
  44032. * @returns a Matrix
  44033. */
  44034. getProjectionMatrix(): Matrix;
  44035. /**
  44036. * Gets the current transform matrix
  44037. * @returns a Matrix made of View * Projection
  44038. */
  44039. getTransformMatrix(): Matrix;
  44040. /**
  44041. * Sets the current transform matrix
  44042. * @param viewL defines the View matrix to use
  44043. * @param projectionL defines the Projection matrix to use
  44044. * @param viewR defines the right View matrix to use (if provided)
  44045. * @param projectionR defines the right Projection matrix to use (if provided)
  44046. */
  44047. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44048. /**
  44049. * Gets the uniform buffer used to store scene data
  44050. * @returns a UniformBuffer
  44051. */
  44052. getSceneUniformBuffer(): UniformBuffer;
  44053. /**
  44054. * Gets an unique (relatively to the current scene) Id
  44055. * @returns an unique number for the scene
  44056. */
  44057. getUniqueId(): number;
  44058. /**
  44059. * Add a mesh to the list of scene's meshes
  44060. * @param newMesh defines the mesh to add
  44061. * @param recursive if all child meshes should also be added to the scene
  44062. */
  44063. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44064. /**
  44065. * Remove a mesh for the list of scene's meshes
  44066. * @param toRemove defines the mesh to remove
  44067. * @param recursive if all child meshes should also be removed from the scene
  44068. * @returns the index where the mesh was in the mesh list
  44069. */
  44070. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44071. /**
  44072. * Add a transform node to the list of scene's transform nodes
  44073. * @param newTransformNode defines the transform node to add
  44074. */
  44075. addTransformNode(newTransformNode: TransformNode): void;
  44076. /**
  44077. * Remove a transform node for the list of scene's transform nodes
  44078. * @param toRemove defines the transform node to remove
  44079. * @returns the index where the transform node was in the transform node list
  44080. */
  44081. removeTransformNode(toRemove: TransformNode): number;
  44082. /**
  44083. * Remove a skeleton for the list of scene's skeletons
  44084. * @param toRemove defines the skeleton to remove
  44085. * @returns the index where the skeleton was in the skeleton list
  44086. */
  44087. removeSkeleton(toRemove: Skeleton): number;
  44088. /**
  44089. * Remove a morph target for the list of scene's morph targets
  44090. * @param toRemove defines the morph target to remove
  44091. * @returns the index where the morph target was in the morph target list
  44092. */
  44093. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44094. /**
  44095. * Remove a light for the list of scene's lights
  44096. * @param toRemove defines the light to remove
  44097. * @returns the index where the light was in the light list
  44098. */
  44099. removeLight(toRemove: Light): number;
  44100. /**
  44101. * Remove a camera for the list of scene's cameras
  44102. * @param toRemove defines the camera to remove
  44103. * @returns the index where the camera was in the camera list
  44104. */
  44105. removeCamera(toRemove: Camera): number;
  44106. /**
  44107. * Remove a particle system for the list of scene's particle systems
  44108. * @param toRemove defines the particle system to remove
  44109. * @returns the index where the particle system was in the particle system list
  44110. */
  44111. removeParticleSystem(toRemove: IParticleSystem): number;
  44112. /**
  44113. * Remove a animation for the list of scene's animations
  44114. * @param toRemove defines the animation to remove
  44115. * @returns the index where the animation was in the animation list
  44116. */
  44117. removeAnimation(toRemove: Animation): number;
  44118. /**
  44119. * Will stop the animation of the given target
  44120. * @param target - the target
  44121. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44122. * @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)
  44123. */
  44124. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44125. /**
  44126. * Removes the given animation group from this scene.
  44127. * @param toRemove The animation group to remove
  44128. * @returns The index of the removed animation group
  44129. */
  44130. removeAnimationGroup(toRemove: AnimationGroup): number;
  44131. /**
  44132. * Removes the given multi-material from this scene.
  44133. * @param toRemove The multi-material to remove
  44134. * @returns The index of the removed multi-material
  44135. */
  44136. removeMultiMaterial(toRemove: MultiMaterial): number;
  44137. /**
  44138. * Removes the given material from this scene.
  44139. * @param toRemove The material to remove
  44140. * @returns The index of the removed material
  44141. */
  44142. removeMaterial(toRemove: Material): number;
  44143. /**
  44144. * Removes the given action manager from this scene.
  44145. * @param toRemove The action manager to remove
  44146. * @returns The index of the removed action manager
  44147. */
  44148. removeActionManager(toRemove: AbstractActionManager): number;
  44149. /**
  44150. * Removes the given texture from this scene.
  44151. * @param toRemove The texture to remove
  44152. * @returns The index of the removed texture
  44153. */
  44154. removeTexture(toRemove: BaseTexture): number;
  44155. /**
  44156. * Adds the given light to this scene
  44157. * @param newLight The light to add
  44158. */
  44159. addLight(newLight: Light): void;
  44160. /**
  44161. * Sorts the list list based on light priorities
  44162. */
  44163. sortLightsByPriority(): void;
  44164. /**
  44165. * Adds the given camera to this scene
  44166. * @param newCamera The camera to add
  44167. */
  44168. addCamera(newCamera: Camera): void;
  44169. /**
  44170. * Adds the given skeleton to this scene
  44171. * @param newSkeleton The skeleton to add
  44172. */
  44173. addSkeleton(newSkeleton: Skeleton): void;
  44174. /**
  44175. * Adds the given particle system to this scene
  44176. * @param newParticleSystem The particle system to add
  44177. */
  44178. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44179. /**
  44180. * Adds the given animation to this scene
  44181. * @param newAnimation The animation to add
  44182. */
  44183. addAnimation(newAnimation: Animation): void;
  44184. /**
  44185. * Adds the given animation group to this scene.
  44186. * @param newAnimationGroup The animation group to add
  44187. */
  44188. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44189. /**
  44190. * Adds the given multi-material to this scene
  44191. * @param newMultiMaterial The multi-material to add
  44192. */
  44193. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44194. /**
  44195. * Adds the given material to this scene
  44196. * @param newMaterial The material to add
  44197. */
  44198. addMaterial(newMaterial: Material): void;
  44199. /**
  44200. * Adds the given morph target to this scene
  44201. * @param newMorphTargetManager The morph target to add
  44202. */
  44203. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44204. /**
  44205. * Adds the given geometry to this scene
  44206. * @param newGeometry The geometry to add
  44207. */
  44208. addGeometry(newGeometry: Geometry): void;
  44209. /**
  44210. * Adds the given action manager to this scene
  44211. * @param newActionManager The action manager to add
  44212. */
  44213. addActionManager(newActionManager: AbstractActionManager): void;
  44214. /**
  44215. * Adds the given texture to this scene.
  44216. * @param newTexture The texture to add
  44217. */
  44218. addTexture(newTexture: BaseTexture): void;
  44219. /**
  44220. * Switch active camera
  44221. * @param newCamera defines the new active camera
  44222. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44223. */
  44224. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44225. /**
  44226. * sets the active camera of the scene using its ID
  44227. * @param id defines the camera's ID
  44228. * @return the new active camera or null if none found.
  44229. */
  44230. setActiveCameraByID(id: string): Nullable<Camera>;
  44231. /**
  44232. * sets the active camera of the scene using its name
  44233. * @param name defines the camera's name
  44234. * @returns the new active camera or null if none found.
  44235. */
  44236. setActiveCameraByName(name: string): Nullable<Camera>;
  44237. /**
  44238. * get an animation group using its name
  44239. * @param name defines the material's name
  44240. * @return the animation group or null if none found.
  44241. */
  44242. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44243. /**
  44244. * Get a material using its unique id
  44245. * @param uniqueId defines the material's unique id
  44246. * @return the material or null if none found.
  44247. */
  44248. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44249. /**
  44250. * get a material using its id
  44251. * @param id defines the material's ID
  44252. * @return the material or null if none found.
  44253. */
  44254. getMaterialByID(id: string): Nullable<Material>;
  44255. /**
  44256. * Gets a the last added material using a given id
  44257. * @param id defines the material's ID
  44258. * @return the last material with the given id or null if none found.
  44259. */
  44260. getLastMaterialByID(id: string): Nullable<Material>;
  44261. /**
  44262. * Gets a material using its name
  44263. * @param name defines the material's name
  44264. * @return the material or null if none found.
  44265. */
  44266. getMaterialByName(name: string): Nullable<Material>;
  44267. /**
  44268. * Get a texture using its unique id
  44269. * @param uniqueId defines the texture's unique id
  44270. * @return the texture or null if none found.
  44271. */
  44272. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44273. /**
  44274. * Gets a camera using its id
  44275. * @param id defines the id to look for
  44276. * @returns the camera or null if not found
  44277. */
  44278. getCameraByID(id: string): Nullable<Camera>;
  44279. /**
  44280. * Gets a camera using its unique id
  44281. * @param uniqueId defines the unique id to look for
  44282. * @returns the camera or null if not found
  44283. */
  44284. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44285. /**
  44286. * Gets a camera using its name
  44287. * @param name defines the camera's name
  44288. * @return the camera or null if none found.
  44289. */
  44290. getCameraByName(name: string): Nullable<Camera>;
  44291. /**
  44292. * Gets a bone using its id
  44293. * @param id defines the bone's id
  44294. * @return the bone or null if not found
  44295. */
  44296. getBoneByID(id: string): Nullable<Bone>;
  44297. /**
  44298. * Gets a bone using its id
  44299. * @param name defines the bone's name
  44300. * @return the bone or null if not found
  44301. */
  44302. getBoneByName(name: string): Nullable<Bone>;
  44303. /**
  44304. * Gets a light node using its name
  44305. * @param name defines the the light's name
  44306. * @return the light or null if none found.
  44307. */
  44308. getLightByName(name: string): Nullable<Light>;
  44309. /**
  44310. * Gets a light node using its id
  44311. * @param id defines the light's id
  44312. * @return the light or null if none found.
  44313. */
  44314. getLightByID(id: string): Nullable<Light>;
  44315. /**
  44316. * Gets a light node using its scene-generated unique ID
  44317. * @param uniqueId defines the light's unique id
  44318. * @return the light or null if none found.
  44319. */
  44320. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44321. /**
  44322. * Gets a particle system by id
  44323. * @param id defines the particle system id
  44324. * @return the corresponding system or null if none found
  44325. */
  44326. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44327. /**
  44328. * Gets a geometry using its ID
  44329. * @param id defines the geometry's id
  44330. * @return the geometry or null if none found.
  44331. */
  44332. getGeometryByID(id: string): Nullable<Geometry>;
  44333. private _getGeometryByUniqueID;
  44334. /**
  44335. * Add a new geometry to this scene
  44336. * @param geometry defines the geometry to be added to the scene.
  44337. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44338. * @return a boolean defining if the geometry was added or not
  44339. */
  44340. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44341. /**
  44342. * Removes an existing geometry
  44343. * @param geometry defines the geometry to be removed from the scene
  44344. * @return a boolean defining if the geometry was removed or not
  44345. */
  44346. removeGeometry(geometry: Geometry): boolean;
  44347. /**
  44348. * Gets the list of geometries attached to the scene
  44349. * @returns an array of Geometry
  44350. */
  44351. getGeometries(): Geometry[];
  44352. /**
  44353. * Gets the first added mesh found of a given ID
  44354. * @param id defines the id to search for
  44355. * @return the mesh found or null if not found at all
  44356. */
  44357. getMeshByID(id: string): Nullable<AbstractMesh>;
  44358. /**
  44359. * Gets a list of meshes using their id
  44360. * @param id defines the id to search for
  44361. * @returns a list of meshes
  44362. */
  44363. getMeshesByID(id: string): Array<AbstractMesh>;
  44364. /**
  44365. * Gets the first added transform node found of a given ID
  44366. * @param id defines the id to search for
  44367. * @return the found transform node or null if not found at all.
  44368. */
  44369. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44370. /**
  44371. * Gets a transform node with its auto-generated unique id
  44372. * @param uniqueId efines the unique id to search for
  44373. * @return the found transform node or null if not found at all.
  44374. */
  44375. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44376. /**
  44377. * Gets a list of transform nodes using their id
  44378. * @param id defines the id to search for
  44379. * @returns a list of transform nodes
  44380. */
  44381. getTransformNodesByID(id: string): Array<TransformNode>;
  44382. /**
  44383. * Gets a mesh with its auto-generated unique id
  44384. * @param uniqueId defines the unique id to search for
  44385. * @return the found mesh or null if not found at all.
  44386. */
  44387. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44388. /**
  44389. * Gets a the last added mesh using a given id
  44390. * @param id defines the id to search for
  44391. * @return the found mesh or null if not found at all.
  44392. */
  44393. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44394. /**
  44395. * Gets a the last added 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. getLastEntryByID(id: string): Nullable<Node>;
  44400. /**
  44401. * Gets a node (Mesh, Camera, Light) using a given id
  44402. * @param id defines the id to search for
  44403. * @return the found node or null if not found at all
  44404. */
  44405. getNodeByID(id: string): Nullable<Node>;
  44406. /**
  44407. * Gets a node (Mesh, Camera, Light) using a given name
  44408. * @param name defines the name to search for
  44409. * @return the found node or null if not found at all.
  44410. */
  44411. getNodeByName(name: string): Nullable<Node>;
  44412. /**
  44413. * Gets a mesh using a given name
  44414. * @param name defines the name to search for
  44415. * @return the found mesh or null if not found at all.
  44416. */
  44417. getMeshByName(name: string): Nullable<AbstractMesh>;
  44418. /**
  44419. * Gets a transform node using a given name
  44420. * @param name defines the name to search for
  44421. * @return the found transform node or null if not found at all.
  44422. */
  44423. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44424. /**
  44425. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44426. * @param id defines the id to search for
  44427. * @return the found skeleton or null if not found at all.
  44428. */
  44429. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44430. /**
  44431. * Gets a skeleton using a given auto generated unique id
  44432. * @param uniqueId defines the unique id to search for
  44433. * @return the found skeleton or null if not found at all.
  44434. */
  44435. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44436. /**
  44437. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44438. * @param id defines the id to search for
  44439. * @return the found skeleton or null if not found at all.
  44440. */
  44441. getSkeletonById(id: string): Nullable<Skeleton>;
  44442. /**
  44443. * Gets a skeleton using a given name
  44444. * @param name defines the name to search for
  44445. * @return the found skeleton or null if not found at all.
  44446. */
  44447. getSkeletonByName(name: string): Nullable<Skeleton>;
  44448. /**
  44449. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44450. * @param id defines the id to search for
  44451. * @return the found morph target manager or null if not found at all.
  44452. */
  44453. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44454. /**
  44455. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44456. * @param id defines the id to search for
  44457. * @return the found morph target or null if not found at all.
  44458. */
  44459. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44460. /**
  44461. * Gets a morph target 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 morph target or null if not found at all.
  44464. */
  44465. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44466. /**
  44467. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44468. * @param name defines the name to search for
  44469. * @return the found post process or null if not found at all.
  44470. */
  44471. getPostProcessByName(name: string): Nullable<PostProcess>;
  44472. /**
  44473. * Gets a boolean indicating if the given mesh is active
  44474. * @param mesh defines the mesh to look for
  44475. * @returns true if the mesh is in the active list
  44476. */
  44477. isActiveMesh(mesh: AbstractMesh): boolean;
  44478. /**
  44479. * Return a unique id as a string which can serve as an identifier for the scene
  44480. */
  44481. get uid(): string;
  44482. /**
  44483. * Add an externaly attached data from its key.
  44484. * This method call will fail and return false, if such key already exists.
  44485. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44486. * @param key the unique key that identifies the data
  44487. * @param data the data object to associate to the key for this Engine instance
  44488. * @return true if no such key were already present and the data was added successfully, false otherwise
  44489. */
  44490. addExternalData<T>(key: string, data: T): boolean;
  44491. /**
  44492. * Get an externaly attached data from its key
  44493. * @param key the unique key that identifies the data
  44494. * @return the associated data, if present (can be null), or undefined if not present
  44495. */
  44496. getExternalData<T>(key: string): Nullable<T>;
  44497. /**
  44498. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44499. * @param key the unique key that identifies the data
  44500. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44501. * @return the associated data, can be null if the factory returned null.
  44502. */
  44503. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44504. /**
  44505. * Remove an externaly attached data from the Engine instance
  44506. * @param key the unique key that identifies the data
  44507. * @return true if the data was successfully removed, false if it doesn't exist
  44508. */
  44509. removeExternalData(key: string): boolean;
  44510. private _evaluateSubMesh;
  44511. /**
  44512. * Clear the processed materials smart array preventing retention point in material dispose.
  44513. */
  44514. freeProcessedMaterials(): void;
  44515. private _preventFreeActiveMeshesAndRenderingGroups;
  44516. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44517. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44518. * when disposing several meshes in a row or a hierarchy of meshes.
  44519. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44520. */
  44521. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44522. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44523. /**
  44524. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44525. */
  44526. freeActiveMeshes(): void;
  44527. /**
  44528. * Clear the info related to rendering groups preventing retention points during dispose.
  44529. */
  44530. freeRenderingGroups(): void;
  44531. /** @hidden */
  44532. _isInIntermediateRendering(): boolean;
  44533. /**
  44534. * Lambda returning the list of potentially active meshes.
  44535. */
  44536. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44537. /**
  44538. * Lambda returning the list of potentially active sub meshes.
  44539. */
  44540. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44541. /**
  44542. * Lambda returning the list of potentially intersecting sub meshes.
  44543. */
  44544. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44545. /**
  44546. * Lambda returning the list of potentially colliding sub meshes.
  44547. */
  44548. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44549. /** @hidden */
  44550. _activeMeshesFrozen: boolean;
  44551. private _skipEvaluateActiveMeshesCompletely;
  44552. /**
  44553. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44554. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44555. * @param onSuccess optional success callback
  44556. * @param onError optional error callback
  44557. * @returns the current scene
  44558. */
  44559. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44560. /**
  44561. * Use this function to restart evaluating active meshes on every frame
  44562. * @returns the current scene
  44563. */
  44564. unfreezeActiveMeshes(): Scene;
  44565. private _evaluateActiveMeshes;
  44566. private _activeMesh;
  44567. /**
  44568. * Update the transform matrix to update from the current active camera
  44569. * @param force defines a boolean used to force the update even if cache is up to date
  44570. */
  44571. updateTransformMatrix(force?: boolean): void;
  44572. private _bindFrameBuffer;
  44573. /** @hidden */
  44574. _allowPostProcessClearColor: boolean;
  44575. /** @hidden */
  44576. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44577. private _processSubCameras;
  44578. private _checkIntersections;
  44579. /** @hidden */
  44580. _advancePhysicsEngineStep(step: number): void;
  44581. /**
  44582. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44583. */
  44584. getDeterministicFrameTime: () => number;
  44585. /** @hidden */
  44586. _animate(): void;
  44587. /** Execute all animations (for a frame) */
  44588. animate(): void;
  44589. /**
  44590. * Render the scene
  44591. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44592. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44593. */
  44594. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44595. /**
  44596. * Freeze all materials
  44597. * A frozen material will not be updatable but should be faster to render
  44598. */
  44599. freezeMaterials(): void;
  44600. /**
  44601. * Unfreeze all materials
  44602. * A frozen material will not be updatable but should be faster to render
  44603. */
  44604. unfreezeMaterials(): void;
  44605. /**
  44606. * Releases all held ressources
  44607. */
  44608. dispose(): void;
  44609. /**
  44610. * Gets if the scene is already disposed
  44611. */
  44612. get isDisposed(): boolean;
  44613. /**
  44614. * Call this function to reduce memory footprint of the scene.
  44615. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44616. */
  44617. clearCachedVertexData(): void;
  44618. /**
  44619. * This function will remove the local cached buffer data from texture.
  44620. * It will save memory but will prevent the texture from being rebuilt
  44621. */
  44622. cleanCachedTextureBuffer(): void;
  44623. /**
  44624. * Get the world extend vectors with an optional filter
  44625. *
  44626. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44627. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44628. */
  44629. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44630. min: Vector3;
  44631. max: Vector3;
  44632. };
  44633. /**
  44634. * Creates a ray that can be used to pick in the scene
  44635. * @param x defines the x coordinate of the origin (on-screen)
  44636. * @param y defines the y coordinate of the origin (on-screen)
  44637. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44638. * @param camera defines the camera to use for the picking
  44639. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44640. * @returns a Ray
  44641. */
  44642. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44643. /**
  44644. * Creates a ray that can be used to pick in the scene
  44645. * @param x defines the x coordinate of the origin (on-screen)
  44646. * @param y defines the y coordinate of the origin (on-screen)
  44647. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44648. * @param result defines the ray where to store the picking ray
  44649. * @param camera defines the camera to use for the picking
  44650. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44651. * @returns the current scene
  44652. */
  44653. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44654. /**
  44655. * Creates a ray that can be used to pick in the scene
  44656. * @param x defines the x coordinate of the origin (on-screen)
  44657. * @param y defines the y coordinate of the origin (on-screen)
  44658. * @param camera defines the camera to use for the picking
  44659. * @returns a Ray
  44660. */
  44661. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44662. /**
  44663. * Creates a ray that can be used to pick in the scene
  44664. * @param x defines the x coordinate of the origin (on-screen)
  44665. * @param y defines the y coordinate of the origin (on-screen)
  44666. * @param result defines the ray where to store the picking ray
  44667. * @param camera defines the camera to use for the picking
  44668. * @returns the current scene
  44669. */
  44670. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44671. /** Launch a ray to try to pick a mesh in the scene
  44672. * @param x position on screen
  44673. * @param y position on screen
  44674. * @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
  44675. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44676. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44677. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44678. * @returns a PickingInfo
  44679. */
  44680. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44681. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44682. * @param x position on screen
  44683. * @param y position on screen
  44684. * @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
  44685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44686. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44687. * @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)
  44688. */
  44689. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44690. /** Use the given ray to pick a mesh in the scene
  44691. * @param ray The ray to use to pick meshes
  44692. * @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
  44693. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44695. * @returns a PickingInfo
  44696. */
  44697. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44698. /**
  44699. * Launch a ray to try to pick a mesh in the scene
  44700. * @param x X position on screen
  44701. * @param y Y position on screen
  44702. * @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
  44703. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44704. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44705. * @returns an array of PickingInfo
  44706. */
  44707. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44708. /**
  44709. * Launch a ray to try to pick a mesh in the scene
  44710. * @param ray Ray to use
  44711. * @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
  44712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44713. * @returns an array of PickingInfo
  44714. */
  44715. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44716. /**
  44717. * Force the value of meshUnderPointer
  44718. * @param mesh defines the mesh to use
  44719. * @param pointerId optional pointer id when using more than one pointer
  44720. */
  44721. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44722. /**
  44723. * Gets the mesh under the pointer
  44724. * @returns a Mesh or null if no mesh is under the pointer
  44725. */
  44726. getPointerOverMesh(): Nullable<AbstractMesh>;
  44727. /** @hidden */
  44728. _rebuildGeometries(): void;
  44729. /** @hidden */
  44730. _rebuildTextures(): void;
  44731. private _getByTags;
  44732. /**
  44733. * Get a list of meshes by tags
  44734. * @param tagsQuery defines the tags query to use
  44735. * @param forEach defines a predicate used to filter results
  44736. * @returns an array of Mesh
  44737. */
  44738. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44739. /**
  44740. * Get a list of cameras by tags
  44741. * @param tagsQuery defines the tags query to use
  44742. * @param forEach defines a predicate used to filter results
  44743. * @returns an array of Camera
  44744. */
  44745. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44746. /**
  44747. * Get a list of lights by tags
  44748. * @param tagsQuery defines the tags query to use
  44749. * @param forEach defines a predicate used to filter results
  44750. * @returns an array of Light
  44751. */
  44752. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44753. /**
  44754. * Get a list of materials by tags
  44755. * @param tagsQuery defines the tags query to use
  44756. * @param forEach defines a predicate used to filter results
  44757. * @returns an array of Material
  44758. */
  44759. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44760. /**
  44761. * Get a list of transform nodes by tags
  44762. * @param tagsQuery defines the tags query to use
  44763. * @param forEach defines a predicate used to filter results
  44764. * @returns an array of TransformNode
  44765. */
  44766. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44767. /**
  44768. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44769. * This allowed control for front to back rendering or reversly depending of the special needs.
  44770. *
  44771. * @param renderingGroupId The rendering group id corresponding to its index
  44772. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44773. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44774. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44775. */
  44776. 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;
  44777. /**
  44778. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44779. *
  44780. * @param renderingGroupId The rendering group id corresponding to its index
  44781. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44782. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44783. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44784. */
  44785. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44786. /**
  44787. * Gets the current auto clear configuration for one rendering group of the rendering
  44788. * manager.
  44789. * @param index the rendering group index to get the information for
  44790. * @returns The auto clear setup for the requested rendering group
  44791. */
  44792. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44793. private _blockMaterialDirtyMechanism;
  44794. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44795. get blockMaterialDirtyMechanism(): boolean;
  44796. set blockMaterialDirtyMechanism(value: boolean);
  44797. /**
  44798. * Will flag all materials as dirty to trigger new shader compilation
  44799. * @param flag defines the flag used to specify which material part must be marked as dirty
  44800. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44801. */
  44802. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44803. /** @hidden */
  44804. _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;
  44805. /** @hidden */
  44806. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44807. /** @hidden */
  44808. _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;
  44809. /** @hidden */
  44810. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44811. /** @hidden */
  44812. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44813. /** @hidden */
  44814. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44815. }
  44816. }
  44817. declare module BABYLON {
  44818. /**
  44819. * Set of assets to keep when moving a scene into an asset container.
  44820. */
  44821. export class KeepAssets extends AbstractScene {
  44822. }
  44823. /**
  44824. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44825. */
  44826. export class InstantiatedEntries {
  44827. /**
  44828. * List of new root nodes (eg. nodes with no parent)
  44829. */
  44830. rootNodes: TransformNode[];
  44831. /**
  44832. * List of new skeletons
  44833. */
  44834. skeletons: Skeleton[];
  44835. /**
  44836. * List of new animation groups
  44837. */
  44838. animationGroups: AnimationGroup[];
  44839. }
  44840. /**
  44841. * Container with a set of assets that can be added or removed from a scene.
  44842. */
  44843. export class AssetContainer extends AbstractScene {
  44844. private _wasAddedToScene;
  44845. /**
  44846. * The scene the AssetContainer belongs to.
  44847. */
  44848. scene: Scene;
  44849. /**
  44850. * Instantiates an AssetContainer.
  44851. * @param scene The scene the AssetContainer belongs to.
  44852. */
  44853. constructor(scene: Scene);
  44854. /**
  44855. * Instantiate or clone all meshes and add the new ones to the scene.
  44856. * Skeletons and animation groups will all be cloned
  44857. * @param nameFunction defines an optional function used to get new names for clones
  44858. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44859. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44860. */
  44861. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44862. /**
  44863. * Adds all the assets from the container to the scene.
  44864. */
  44865. addAllToScene(): void;
  44866. /**
  44867. * Removes all the assets in the container from the scene
  44868. */
  44869. removeAllFromScene(): void;
  44870. /**
  44871. * Disposes all the assets in the container
  44872. */
  44873. dispose(): void;
  44874. private _moveAssets;
  44875. /**
  44876. * Removes all the assets contained in the scene and adds them to the container.
  44877. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44878. */
  44879. moveAllFromScene(keepAssets?: KeepAssets): void;
  44880. /**
  44881. * 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.
  44882. * @returns the root mesh
  44883. */
  44884. createRootMesh(): Mesh;
  44885. /**
  44886. * Merge animations (direct and animation groups) from this asset container into a scene
  44887. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44888. * @param animatables set of animatables to retarget to a node from the scene
  44889. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44890. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44891. */
  44892. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44893. }
  44894. }
  44895. declare module BABYLON {
  44896. /**
  44897. * Defines how the parser contract is defined.
  44898. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44899. */
  44900. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44901. /**
  44902. * Defines how the individual parser contract is defined.
  44903. * These parser can parse an individual asset
  44904. */
  44905. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44906. /**
  44907. * Base class of the scene acting as a container for the different elements composing a scene.
  44908. * This class is dynamically extended by the different components of the scene increasing
  44909. * flexibility and reducing coupling
  44910. */
  44911. export abstract class AbstractScene {
  44912. /**
  44913. * Stores the list of available parsers in the application.
  44914. */
  44915. private static _BabylonFileParsers;
  44916. /**
  44917. * Stores the list of available individual parsers in the application.
  44918. */
  44919. private static _IndividualBabylonFileParsers;
  44920. /**
  44921. * Adds a parser in the list of available ones
  44922. * @param name Defines the name of the parser
  44923. * @param parser Defines the parser to add
  44924. */
  44925. static AddParser(name: string, parser: BabylonFileParser): void;
  44926. /**
  44927. * Gets a general parser from the list of avaialble ones
  44928. * @param name Defines the name of the parser
  44929. * @returns the requested parser or null
  44930. */
  44931. static GetParser(name: string): Nullable<BabylonFileParser>;
  44932. /**
  44933. * Adds n individual parser in the list of available ones
  44934. * @param name Defines the name of the parser
  44935. * @param parser Defines the parser to add
  44936. */
  44937. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44938. /**
  44939. * Gets an individual parser from the list of avaialble ones
  44940. * @param name Defines the name of the parser
  44941. * @returns the requested parser or null
  44942. */
  44943. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44944. /**
  44945. * Parser json data and populate both a scene and its associated container object
  44946. * @param jsonData Defines the data to parse
  44947. * @param scene Defines the scene to parse the data for
  44948. * @param container Defines the container attached to the parsing sequence
  44949. * @param rootUrl Defines the root url of the data
  44950. */
  44951. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44952. /**
  44953. * Gets the list of root nodes (ie. nodes with no parent)
  44954. */
  44955. rootNodes: Node[];
  44956. /** All of the cameras added to this scene
  44957. * @see https://doc.babylonjs.com/babylon101/cameras
  44958. */
  44959. cameras: Camera[];
  44960. /**
  44961. * All of the lights added to this scene
  44962. * @see https://doc.babylonjs.com/babylon101/lights
  44963. */
  44964. lights: Light[];
  44965. /**
  44966. * All of the (abstract) meshes added to this scene
  44967. */
  44968. meshes: AbstractMesh[];
  44969. /**
  44970. * The list of skeletons added to the scene
  44971. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44972. */
  44973. skeletons: Skeleton[];
  44974. /**
  44975. * All of the particle systems added to this scene
  44976. * @see https://doc.babylonjs.com/babylon101/particles
  44977. */
  44978. particleSystems: IParticleSystem[];
  44979. /**
  44980. * Gets a list of Animations associated with the scene
  44981. */
  44982. animations: Animation[];
  44983. /**
  44984. * All of the animation groups added to this scene
  44985. * @see https://doc.babylonjs.com/how_to/group
  44986. */
  44987. animationGroups: AnimationGroup[];
  44988. /**
  44989. * All of the multi-materials added to this scene
  44990. * @see https://doc.babylonjs.com/how_to/multi_materials
  44991. */
  44992. multiMaterials: MultiMaterial[];
  44993. /**
  44994. * All of the materials added to this scene
  44995. * In the context of a Scene, it is not supposed to be modified manually.
  44996. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44997. * Note also that the order of the Material within the array is not significant and might change.
  44998. * @see https://doc.babylonjs.com/babylon101/materials
  44999. */
  45000. materials: Material[];
  45001. /**
  45002. * The list of morph target managers added to the scene
  45003. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  45004. */
  45005. morphTargetManagers: MorphTargetManager[];
  45006. /**
  45007. * The list of geometries used in the scene.
  45008. */
  45009. geometries: Geometry[];
  45010. /**
  45011. * All of the tranform nodes added to this scene
  45012. * In the context of a Scene, it is not supposed to be modified manually.
  45013. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45014. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45015. * @see https://doc.babylonjs.com/how_to/transformnode
  45016. */
  45017. transformNodes: TransformNode[];
  45018. /**
  45019. * ActionManagers available on the scene.
  45020. */
  45021. actionManagers: AbstractActionManager[];
  45022. /**
  45023. * Textures to keep.
  45024. */
  45025. textures: BaseTexture[];
  45026. /** @hidden */
  45027. protected _environmentTexture: Nullable<BaseTexture>;
  45028. /**
  45029. * Texture used in all pbr material as the reflection texture.
  45030. * As in the majority of the scene they are the same (exception for multi room and so on),
  45031. * this is easier to reference from here than from all the materials.
  45032. */
  45033. get environmentTexture(): Nullable<BaseTexture>;
  45034. set environmentTexture(value: Nullable<BaseTexture>);
  45035. /**
  45036. * The list of postprocesses added to the scene
  45037. */
  45038. postProcesses: PostProcess[];
  45039. /**
  45040. * @returns all meshes, lights, cameras, transformNodes and bones
  45041. */
  45042. getNodes(): Array<Node>;
  45043. }
  45044. }
  45045. declare module BABYLON {
  45046. /**
  45047. * Interface used to define options for Sound class
  45048. */
  45049. export interface ISoundOptions {
  45050. /**
  45051. * Does the sound autoplay once loaded.
  45052. */
  45053. autoplay?: boolean;
  45054. /**
  45055. * Does the sound loop after it finishes playing once.
  45056. */
  45057. loop?: boolean;
  45058. /**
  45059. * Sound's volume
  45060. */
  45061. volume?: number;
  45062. /**
  45063. * Is it a spatial sound?
  45064. */
  45065. spatialSound?: boolean;
  45066. /**
  45067. * Maximum distance to hear that sound
  45068. */
  45069. maxDistance?: number;
  45070. /**
  45071. * Uses user defined attenuation function
  45072. */
  45073. useCustomAttenuation?: boolean;
  45074. /**
  45075. * Define the roll off factor of spatial sounds.
  45076. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45077. */
  45078. rolloffFactor?: number;
  45079. /**
  45080. * Define the reference distance the sound should be heard perfectly.
  45081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45082. */
  45083. refDistance?: number;
  45084. /**
  45085. * Define the distance attenuation model the sound will follow.
  45086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45087. */
  45088. distanceModel?: string;
  45089. /**
  45090. * Defines the playback speed (1 by default)
  45091. */
  45092. playbackRate?: number;
  45093. /**
  45094. * Defines if the sound is from a streaming source
  45095. */
  45096. streaming?: boolean;
  45097. /**
  45098. * Defines an optional length (in seconds) inside the sound file
  45099. */
  45100. length?: number;
  45101. /**
  45102. * Defines an optional offset (in seconds) inside the sound file
  45103. */
  45104. offset?: number;
  45105. /**
  45106. * If true, URLs will not be required to state the audio file codec to use.
  45107. */
  45108. skipCodecCheck?: boolean;
  45109. }
  45110. }
  45111. declare module BABYLON {
  45112. /**
  45113. * Defines a sound that can be played in the application.
  45114. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45116. */
  45117. export class Sound {
  45118. /**
  45119. * The name of the sound in the scene.
  45120. */
  45121. name: string;
  45122. /**
  45123. * Does the sound autoplay once loaded.
  45124. */
  45125. autoplay: boolean;
  45126. /**
  45127. * Does the sound loop after it finishes playing once.
  45128. */
  45129. loop: boolean;
  45130. /**
  45131. * Does the sound use a custom attenuation curve to simulate the falloff
  45132. * happening when the source gets further away from the camera.
  45133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45134. */
  45135. useCustomAttenuation: boolean;
  45136. /**
  45137. * The sound track id this sound belongs to.
  45138. */
  45139. soundTrackId: number;
  45140. /**
  45141. * Is this sound currently played.
  45142. */
  45143. isPlaying: boolean;
  45144. /**
  45145. * Is this sound currently paused.
  45146. */
  45147. isPaused: boolean;
  45148. /**
  45149. * Does this sound enables spatial sound.
  45150. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45151. */
  45152. spatialSound: boolean;
  45153. /**
  45154. * Define the reference distance the sound should be heard perfectly.
  45155. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45156. */
  45157. refDistance: number;
  45158. /**
  45159. * Define the roll off factor of spatial sounds.
  45160. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45161. */
  45162. rolloffFactor: number;
  45163. /**
  45164. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45165. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45166. */
  45167. maxDistance: number;
  45168. /**
  45169. * Define the distance attenuation model the sound will follow.
  45170. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45171. */
  45172. distanceModel: string;
  45173. /**
  45174. * @hidden
  45175. * Back Compat
  45176. **/
  45177. onended: () => any;
  45178. /**
  45179. * Gets or sets an object used to store user defined information for the sound.
  45180. */
  45181. metadata: any;
  45182. /**
  45183. * Observable event when the current playing sound finishes.
  45184. */
  45185. onEndedObservable: Observable<Sound>;
  45186. /**
  45187. * Gets the current time for the sound.
  45188. */
  45189. get currentTime(): number;
  45190. private _panningModel;
  45191. private _playbackRate;
  45192. private _streaming;
  45193. private _startTime;
  45194. private _startOffset;
  45195. private _position;
  45196. /** @hidden */
  45197. _positionInEmitterSpace: boolean;
  45198. private _localDirection;
  45199. private _volume;
  45200. private _isReadyToPlay;
  45201. private _isDirectional;
  45202. private _readyToPlayCallback;
  45203. private _audioBuffer;
  45204. private _soundSource;
  45205. private _streamingSource;
  45206. private _soundPanner;
  45207. private _soundGain;
  45208. private _inputAudioNode;
  45209. private _outputAudioNode;
  45210. private _coneInnerAngle;
  45211. private _coneOuterAngle;
  45212. private _coneOuterGain;
  45213. private _scene;
  45214. private _connectedTransformNode;
  45215. private _customAttenuationFunction;
  45216. private _registerFunc;
  45217. private _isOutputConnected;
  45218. private _htmlAudioElement;
  45219. private _urlType;
  45220. private _length?;
  45221. private _offset?;
  45222. /** @hidden */
  45223. static _SceneComponentInitialization: (scene: Scene) => void;
  45224. /**
  45225. * Create a sound and attach it to a scene
  45226. * @param name Name of your sound
  45227. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45228. * @param scene defines the scene the sound belongs to
  45229. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45230. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45231. */
  45232. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45233. /**
  45234. * Release the sound and its associated resources
  45235. */
  45236. dispose(): void;
  45237. /**
  45238. * Gets if the sounds is ready to be played or not.
  45239. * @returns true if ready, otherwise false
  45240. */
  45241. isReady(): boolean;
  45242. private _soundLoaded;
  45243. /**
  45244. * Sets the data of the sound from an audiobuffer
  45245. * @param audioBuffer The audioBuffer containing the data
  45246. */
  45247. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45248. /**
  45249. * Updates the current sounds options such as maxdistance, loop...
  45250. * @param options A JSON object containing values named as the object properties
  45251. */
  45252. updateOptions(options: ISoundOptions): void;
  45253. private _createSpatialParameters;
  45254. private _updateSpatialParameters;
  45255. /**
  45256. * Switch the panning model to HRTF:
  45257. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45259. */
  45260. switchPanningModelToHRTF(): void;
  45261. /**
  45262. * Switch the panning model to Equal Power:
  45263. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45265. */
  45266. switchPanningModelToEqualPower(): void;
  45267. private _switchPanningModel;
  45268. /**
  45269. * Connect this sound to a sound track audio node like gain...
  45270. * @param soundTrackAudioNode the sound track audio node to connect to
  45271. */
  45272. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45273. /**
  45274. * Transform this sound into a directional source
  45275. * @param coneInnerAngle Size of the inner cone in degree
  45276. * @param coneOuterAngle Size of the outer cone in degree
  45277. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45278. */
  45279. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45280. /**
  45281. * Gets or sets the inner angle for the directional cone.
  45282. */
  45283. get directionalConeInnerAngle(): number;
  45284. /**
  45285. * Gets or sets the inner angle for the directional cone.
  45286. */
  45287. set directionalConeInnerAngle(value: number);
  45288. /**
  45289. * Gets or sets the outer angle for the directional cone.
  45290. */
  45291. get directionalConeOuterAngle(): number;
  45292. /**
  45293. * Gets or sets the outer angle for the directional cone.
  45294. */
  45295. set directionalConeOuterAngle(value: number);
  45296. /**
  45297. * Sets the position of the emitter if spatial sound is enabled
  45298. * @param newPosition Defines the new posisiton
  45299. */
  45300. setPosition(newPosition: Vector3): void;
  45301. /**
  45302. * Sets the local direction of the emitter if spatial sound is enabled
  45303. * @param newLocalDirection Defines the new local direction
  45304. */
  45305. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45306. private _updateDirection;
  45307. /** @hidden */
  45308. updateDistanceFromListener(): void;
  45309. /**
  45310. * Sets a new custom attenuation function for the sound.
  45311. * @param callback Defines the function used for the attenuation
  45312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45313. */
  45314. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45315. /**
  45316. * Play the sound
  45317. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45318. * @param offset (optional) Start the sound at a specific time in seconds
  45319. * @param length (optional) Sound duration (in seconds)
  45320. */
  45321. play(time?: number, offset?: number, length?: number): void;
  45322. private _onended;
  45323. /**
  45324. * Stop the sound
  45325. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45326. */
  45327. stop(time?: number): void;
  45328. /**
  45329. * Put the sound in pause
  45330. */
  45331. pause(): void;
  45332. /**
  45333. * Sets a dedicated volume for this sounds
  45334. * @param newVolume Define the new volume of the sound
  45335. * @param time Define time for gradual change to new volume
  45336. */
  45337. setVolume(newVolume: number, time?: number): void;
  45338. /**
  45339. * Set the sound play back rate
  45340. * @param newPlaybackRate Define the playback rate the sound should be played at
  45341. */
  45342. setPlaybackRate(newPlaybackRate: number): void;
  45343. /**
  45344. * Gets the volume of the sound.
  45345. * @returns the volume of the sound
  45346. */
  45347. getVolume(): number;
  45348. /**
  45349. * Attach the sound to a dedicated mesh
  45350. * @param transformNode The transform node to connect the sound with
  45351. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45352. */
  45353. attachToMesh(transformNode: TransformNode): void;
  45354. /**
  45355. * Detach the sound from the previously attached mesh
  45356. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45357. */
  45358. detachFromMesh(): void;
  45359. private _onRegisterAfterWorldMatrixUpdate;
  45360. /**
  45361. * Clone the current sound in the scene.
  45362. * @returns the new sound clone
  45363. */
  45364. clone(): Nullable<Sound>;
  45365. /**
  45366. * Gets the current underlying audio buffer containing the data
  45367. * @returns the audio buffer
  45368. */
  45369. getAudioBuffer(): Nullable<AudioBuffer>;
  45370. /**
  45371. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45372. * @returns the source node
  45373. */
  45374. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45375. /**
  45376. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45377. * @returns the gain node
  45378. */
  45379. getSoundGain(): Nullable<GainNode>;
  45380. /**
  45381. * Serializes the Sound in a JSON representation
  45382. * @returns the JSON representation of the sound
  45383. */
  45384. serialize(): any;
  45385. /**
  45386. * Parse a JSON representation of a sound to innstantiate in a given scene
  45387. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45388. * @param scene Define the scene the new parsed sound should be created in
  45389. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45390. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45391. * @returns the newly parsed sound
  45392. */
  45393. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45394. }
  45395. }
  45396. declare module BABYLON {
  45397. /**
  45398. * This defines an action helpful to play a defined sound on a triggered action.
  45399. */
  45400. export class PlaySoundAction extends Action {
  45401. private _sound;
  45402. /**
  45403. * Instantiate the action
  45404. * @param triggerOptions defines the trigger options
  45405. * @param sound defines the sound to play
  45406. * @param condition defines the trigger related conditions
  45407. */
  45408. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45409. /** @hidden */
  45410. _prepare(): void;
  45411. /**
  45412. * Execute the action and play the sound.
  45413. */
  45414. execute(): void;
  45415. /**
  45416. * Serializes the actions and its related information.
  45417. * @param parent defines the object to serialize in
  45418. * @returns the serialized object
  45419. */
  45420. serialize(parent: any): any;
  45421. }
  45422. /**
  45423. * This defines an action helpful to stop a defined sound on a triggered action.
  45424. */
  45425. export class StopSoundAction extends Action {
  45426. private _sound;
  45427. /**
  45428. * Instantiate the action
  45429. * @param triggerOptions defines the trigger options
  45430. * @param sound defines the sound to stop
  45431. * @param condition defines the trigger related conditions
  45432. */
  45433. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45434. /** @hidden */
  45435. _prepare(): void;
  45436. /**
  45437. * Execute the action and stop the sound.
  45438. */
  45439. execute(): void;
  45440. /**
  45441. * Serializes the actions and its related information.
  45442. * @param parent defines the object to serialize in
  45443. * @returns the serialized object
  45444. */
  45445. serialize(parent: any): any;
  45446. }
  45447. }
  45448. declare module BABYLON {
  45449. /**
  45450. * This defines an action responsible to change the value of a property
  45451. * by interpolating between its current value and the newly set one once triggered.
  45452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45453. */
  45454. export class InterpolateValueAction extends Action {
  45455. /**
  45456. * Defines the path of the property where the value should be interpolated
  45457. */
  45458. propertyPath: string;
  45459. /**
  45460. * Defines the target value at the end of the interpolation.
  45461. */
  45462. value: any;
  45463. /**
  45464. * Defines the time it will take for the property to interpolate to the value.
  45465. */
  45466. duration: number;
  45467. /**
  45468. * Defines if the other scene animations should be stopped when the action has been triggered
  45469. */
  45470. stopOtherAnimations?: boolean;
  45471. /**
  45472. * Defines a callback raised once the interpolation animation has been done.
  45473. */
  45474. onInterpolationDone?: () => void;
  45475. /**
  45476. * Observable triggered once the interpolation animation has been done.
  45477. */
  45478. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45479. private _target;
  45480. private _effectiveTarget;
  45481. private _property;
  45482. /**
  45483. * Instantiate the action
  45484. * @param triggerOptions defines the trigger options
  45485. * @param target defines the object containing the value to interpolate
  45486. * @param propertyPath defines the path to the property in the target object
  45487. * @param value defines the target value at the end of the interpolation
  45488. * @param duration deines the time it will take for the property to interpolate to the value.
  45489. * @param condition defines the trigger related conditions
  45490. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45491. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45492. */
  45493. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45494. /** @hidden */
  45495. _prepare(): void;
  45496. /**
  45497. * Execute the action starts the value interpolation.
  45498. */
  45499. execute(): void;
  45500. /**
  45501. * Serializes the actions and its related information.
  45502. * @param parent defines the object to serialize in
  45503. * @returns the serialized object
  45504. */
  45505. serialize(parent: any): any;
  45506. }
  45507. }
  45508. declare module BABYLON {
  45509. /**
  45510. * This represents the default audio engine used in babylon.
  45511. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45512. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45513. */
  45514. export class AudioEngine implements IAudioEngine {
  45515. private _audioContext;
  45516. private _audioContextInitialized;
  45517. private _muteButton;
  45518. private _hostElement;
  45519. /**
  45520. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45521. */
  45522. canUseWebAudio: boolean;
  45523. /**
  45524. * The master gain node defines the global audio volume of your audio engine.
  45525. */
  45526. masterGain: GainNode;
  45527. /**
  45528. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45529. * @ignoreNaming
  45530. */
  45531. WarnedWebAudioUnsupported: boolean;
  45532. /**
  45533. * Gets whether or not mp3 are supported by your browser.
  45534. */
  45535. isMP3supported: boolean;
  45536. /**
  45537. * Gets whether or not ogg are supported by your browser.
  45538. */
  45539. isOGGsupported: boolean;
  45540. /**
  45541. * Gets whether audio has been unlocked on the device.
  45542. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45543. * a user interaction has happened.
  45544. */
  45545. unlocked: boolean;
  45546. /**
  45547. * Defines if the audio engine relies on a custom unlocked button.
  45548. * In this case, the embedded button will not be displayed.
  45549. */
  45550. useCustomUnlockedButton: boolean;
  45551. /**
  45552. * Event raised when audio has been unlocked on the browser.
  45553. */
  45554. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45555. /**
  45556. * Event raised when audio has been locked on the browser.
  45557. */
  45558. onAudioLockedObservable: Observable<IAudioEngine>;
  45559. /**
  45560. * Gets the current AudioContext if available.
  45561. */
  45562. get audioContext(): Nullable<AudioContext>;
  45563. private _connectedAnalyser;
  45564. /**
  45565. * Instantiates a new audio engine.
  45566. *
  45567. * There should be only one per page as some browsers restrict the number
  45568. * of audio contexts you can create.
  45569. * @param hostElement defines the host element where to display the mute icon if necessary
  45570. */
  45571. constructor(hostElement?: Nullable<HTMLElement>);
  45572. /**
  45573. * Flags the audio engine in Locked state.
  45574. * This happens due to new browser policies preventing audio to autoplay.
  45575. */
  45576. lock(): void;
  45577. /**
  45578. * Unlocks the audio engine once a user action has been done on the dom.
  45579. * This is helpful to resume play once browser policies have been satisfied.
  45580. */
  45581. unlock(): void;
  45582. private _resumeAudioContext;
  45583. private _initializeAudioContext;
  45584. private _tryToRun;
  45585. private _triggerRunningState;
  45586. private _triggerSuspendedState;
  45587. private _displayMuteButton;
  45588. private _moveButtonToTopLeft;
  45589. private _onResize;
  45590. private _hideMuteButton;
  45591. /**
  45592. * Destroy and release the resources associated with the audio ccontext.
  45593. */
  45594. dispose(): void;
  45595. /**
  45596. * Gets the global volume sets on the master gain.
  45597. * @returns the global volume if set or -1 otherwise
  45598. */
  45599. getGlobalVolume(): number;
  45600. /**
  45601. * Sets the global volume of your experience (sets on the master gain).
  45602. * @param newVolume Defines the new global volume of the application
  45603. */
  45604. setGlobalVolume(newVolume: number): void;
  45605. /**
  45606. * Connect the audio engine to an audio analyser allowing some amazing
  45607. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45608. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45609. * @param analyser The analyser to connect to the engine
  45610. */
  45611. connectToAnalyser(analyser: Analyser): void;
  45612. }
  45613. }
  45614. declare module BABYLON {
  45615. /**
  45616. * Options allowed during the creation of a sound track.
  45617. */
  45618. export interface ISoundTrackOptions {
  45619. /**
  45620. * The volume the sound track should take during creation
  45621. */
  45622. volume?: number;
  45623. /**
  45624. * Define if the sound track is the main sound track of the scene
  45625. */
  45626. mainTrack?: boolean;
  45627. }
  45628. /**
  45629. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45630. * It will be also used in a future release to apply effects on a specific track.
  45631. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45632. */
  45633. export class SoundTrack {
  45634. /**
  45635. * The unique identifier of the sound track in the scene.
  45636. */
  45637. id: number;
  45638. /**
  45639. * The list of sounds included in the sound track.
  45640. */
  45641. soundCollection: Array<Sound>;
  45642. private _outputAudioNode;
  45643. private _scene;
  45644. private _connectedAnalyser;
  45645. private _options;
  45646. private _isInitialized;
  45647. /**
  45648. * Creates a new sound track.
  45649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45650. * @param scene Define the scene the sound track belongs to
  45651. * @param options
  45652. */
  45653. constructor(scene: Scene, options?: ISoundTrackOptions);
  45654. private _initializeSoundTrackAudioGraph;
  45655. /**
  45656. * Release the sound track and its associated resources
  45657. */
  45658. dispose(): void;
  45659. /**
  45660. * Adds a sound to this sound track
  45661. * @param sound define the cound to add
  45662. * @ignoreNaming
  45663. */
  45664. addSound(sound: Sound): void;
  45665. /**
  45666. * Removes a sound to this sound track
  45667. * @param sound define the cound to remove
  45668. * @ignoreNaming
  45669. */
  45670. removeSound(sound: Sound): void;
  45671. /**
  45672. * Set a global volume for the full sound track.
  45673. * @param newVolume Define the new volume of the sound track
  45674. */
  45675. setVolume(newVolume: number): void;
  45676. /**
  45677. * Switch the panning model to HRTF:
  45678. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45679. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45680. */
  45681. switchPanningModelToHRTF(): void;
  45682. /**
  45683. * Switch the panning model to Equal Power:
  45684. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45686. */
  45687. switchPanningModelToEqualPower(): void;
  45688. /**
  45689. * Connect the sound track to an audio analyser allowing some amazing
  45690. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45692. * @param analyser The analyser to connect to the engine
  45693. */
  45694. connectToAnalyser(analyser: Analyser): void;
  45695. }
  45696. }
  45697. declare module BABYLON {
  45698. interface AbstractScene {
  45699. /**
  45700. * The list of sounds used in the scene.
  45701. */
  45702. sounds: Nullable<Array<Sound>>;
  45703. }
  45704. interface Scene {
  45705. /**
  45706. * @hidden
  45707. * Backing field
  45708. */
  45709. _mainSoundTrack: SoundTrack;
  45710. /**
  45711. * The main sound track played by the scene.
  45712. * It cotains your primary collection of sounds.
  45713. */
  45714. mainSoundTrack: SoundTrack;
  45715. /**
  45716. * The list of sound tracks added to the scene
  45717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45718. */
  45719. soundTracks: Nullable<Array<SoundTrack>>;
  45720. /**
  45721. * Gets a sound using a given name
  45722. * @param name defines the name to search for
  45723. * @return the found sound or null if not found at all.
  45724. */
  45725. getSoundByName(name: string): Nullable<Sound>;
  45726. /**
  45727. * Gets or sets if audio support is enabled
  45728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45729. */
  45730. audioEnabled: boolean;
  45731. /**
  45732. * Gets or sets if audio will be output to headphones
  45733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45734. */
  45735. headphone: boolean;
  45736. /**
  45737. * Gets or sets custom audio listener position provider
  45738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45739. */
  45740. audioListenerPositionProvider: Nullable<() => Vector3>;
  45741. /**
  45742. * Gets or sets a refresh rate when using 3D audio positioning
  45743. */
  45744. audioPositioningRefreshRate: number;
  45745. }
  45746. /**
  45747. * Defines the sound scene component responsible to manage any sounds
  45748. * in a given scene.
  45749. */
  45750. export class AudioSceneComponent implements ISceneSerializableComponent {
  45751. private static _CameraDirectionLH;
  45752. private static _CameraDirectionRH;
  45753. /**
  45754. * The component name helpfull to identify the component in the list of scene components.
  45755. */
  45756. readonly name: string;
  45757. /**
  45758. * The scene the component belongs to.
  45759. */
  45760. scene: Scene;
  45761. private _audioEnabled;
  45762. /**
  45763. * Gets whether audio is enabled or not.
  45764. * Please use related enable/disable method to switch state.
  45765. */
  45766. get audioEnabled(): boolean;
  45767. private _headphone;
  45768. /**
  45769. * Gets whether audio is outputing to headphone or not.
  45770. * Please use the according Switch methods to change output.
  45771. */
  45772. get headphone(): boolean;
  45773. /**
  45774. * Gets or sets a refresh rate when using 3D audio positioning
  45775. */
  45776. audioPositioningRefreshRate: number;
  45777. private _audioListenerPositionProvider;
  45778. /**
  45779. * Gets the current audio listener position provider
  45780. */
  45781. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45782. /**
  45783. * Sets a custom listener position for all sounds in the scene
  45784. * By default, this is the position of the first active camera
  45785. */
  45786. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45787. /**
  45788. * Creates a new instance of the component for the given scene
  45789. * @param scene Defines the scene to register the component in
  45790. */
  45791. constructor(scene: Scene);
  45792. /**
  45793. * Registers the component in a given scene
  45794. */
  45795. register(): void;
  45796. /**
  45797. * Rebuilds the elements related to this component in case of
  45798. * context lost for instance.
  45799. */
  45800. rebuild(): void;
  45801. /**
  45802. * Serializes the component data to the specified json object
  45803. * @param serializationObject The object to serialize to
  45804. */
  45805. serialize(serializationObject: any): void;
  45806. /**
  45807. * Adds all the elements from the container to the scene
  45808. * @param container the container holding the elements
  45809. */
  45810. addFromContainer(container: AbstractScene): void;
  45811. /**
  45812. * Removes all the elements in the container from the scene
  45813. * @param container contains the elements to remove
  45814. * @param dispose if the removed element should be disposed (default: false)
  45815. */
  45816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45817. /**
  45818. * Disposes the component and the associated ressources.
  45819. */
  45820. dispose(): void;
  45821. /**
  45822. * Disables audio in the associated scene.
  45823. */
  45824. disableAudio(): void;
  45825. /**
  45826. * Enables audio in the associated scene.
  45827. */
  45828. enableAudio(): void;
  45829. /**
  45830. * Switch audio to headphone output.
  45831. */
  45832. switchAudioModeForHeadphones(): void;
  45833. /**
  45834. * Switch audio to normal speakers.
  45835. */
  45836. switchAudioModeForNormalSpeakers(): void;
  45837. private _cachedCameraDirection;
  45838. private _cachedCameraPosition;
  45839. private _lastCheck;
  45840. private _afterRender;
  45841. }
  45842. }
  45843. declare module BABYLON {
  45844. /**
  45845. * Wraps one or more Sound objects and selects one with random weight for playback.
  45846. */
  45847. export class WeightedSound {
  45848. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45849. loop: boolean;
  45850. private _coneInnerAngle;
  45851. private _coneOuterAngle;
  45852. private _volume;
  45853. /** A Sound is currently playing. */
  45854. isPlaying: boolean;
  45855. /** A Sound is currently paused. */
  45856. isPaused: boolean;
  45857. private _sounds;
  45858. private _weights;
  45859. private _currentIndex?;
  45860. /**
  45861. * Creates a new WeightedSound from the list of sounds given.
  45862. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45863. * @param sounds Array of Sounds that will be selected from.
  45864. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45865. */
  45866. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45867. /**
  45868. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45869. */
  45870. get directionalConeInnerAngle(): number;
  45871. /**
  45872. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45873. */
  45874. set directionalConeInnerAngle(value: number);
  45875. /**
  45876. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45877. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45878. */
  45879. get directionalConeOuterAngle(): number;
  45880. /**
  45881. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45882. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45883. */
  45884. set directionalConeOuterAngle(value: number);
  45885. /**
  45886. * Playback volume.
  45887. */
  45888. get volume(): number;
  45889. /**
  45890. * Playback volume.
  45891. */
  45892. set volume(value: number);
  45893. private _onended;
  45894. /**
  45895. * Suspend playback
  45896. */
  45897. pause(): void;
  45898. /**
  45899. * Stop playback
  45900. */
  45901. stop(): void;
  45902. /**
  45903. * Start playback.
  45904. * @param startOffset Position the clip head at a specific time in seconds.
  45905. */
  45906. play(startOffset?: number): void;
  45907. }
  45908. }
  45909. declare module BABYLON {
  45910. /**
  45911. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45912. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45913. */
  45914. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45915. /**
  45916. * Gets the name of the behavior.
  45917. */
  45918. get name(): string;
  45919. /**
  45920. * The easing function used by animations
  45921. */
  45922. static EasingFunction: BackEase;
  45923. /**
  45924. * The easing mode used by animations
  45925. */
  45926. static EasingMode: number;
  45927. /**
  45928. * The duration of the animation, in milliseconds
  45929. */
  45930. transitionDuration: number;
  45931. /**
  45932. * Length of the distance animated by the transition when lower radius is reached
  45933. */
  45934. lowerRadiusTransitionRange: number;
  45935. /**
  45936. * Length of the distance animated by the transition when upper radius is reached
  45937. */
  45938. upperRadiusTransitionRange: number;
  45939. private _autoTransitionRange;
  45940. /**
  45941. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45942. */
  45943. get autoTransitionRange(): boolean;
  45944. /**
  45945. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45946. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45947. */
  45948. set autoTransitionRange(value: boolean);
  45949. private _attachedCamera;
  45950. private _onAfterCheckInputsObserver;
  45951. private _onMeshTargetChangedObserver;
  45952. /**
  45953. * Initializes the behavior.
  45954. */
  45955. init(): void;
  45956. /**
  45957. * Attaches the behavior to its arc rotate camera.
  45958. * @param camera Defines the camera to attach the behavior to
  45959. */
  45960. attach(camera: ArcRotateCamera): void;
  45961. /**
  45962. * Detaches the behavior from its current arc rotate camera.
  45963. */
  45964. detach(): void;
  45965. private _radiusIsAnimating;
  45966. private _radiusBounceTransition;
  45967. private _animatables;
  45968. private _cachedWheelPrecision;
  45969. /**
  45970. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45971. * @param radiusLimit The limit to check against.
  45972. * @return Bool to indicate if at limit.
  45973. */
  45974. private _isRadiusAtLimit;
  45975. /**
  45976. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45977. * @param radiusDelta The delta by which to animate to. Can be negative.
  45978. */
  45979. private _applyBoundRadiusAnimation;
  45980. /**
  45981. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45982. */
  45983. protected _clearAnimationLocks(): void;
  45984. /**
  45985. * Stops and removes all animations that have been applied to the camera
  45986. */
  45987. stopAllAnimations(): void;
  45988. }
  45989. }
  45990. declare module BABYLON {
  45991. /**
  45992. * 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.
  45993. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45994. */
  45995. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45996. /**
  45997. * Gets the name of the behavior.
  45998. */
  45999. get name(): string;
  46000. private _mode;
  46001. private _radiusScale;
  46002. private _positionScale;
  46003. private _defaultElevation;
  46004. private _elevationReturnTime;
  46005. private _elevationReturnWaitTime;
  46006. private _zoomStopsAnimation;
  46007. private _framingTime;
  46008. /**
  46009. * The easing function used by animations
  46010. */
  46011. static EasingFunction: ExponentialEase;
  46012. /**
  46013. * The easing mode used by animations
  46014. */
  46015. static EasingMode: number;
  46016. /**
  46017. * Sets the current mode used by the behavior
  46018. */
  46019. set mode(mode: number);
  46020. /**
  46021. * Gets current mode used by the behavior.
  46022. */
  46023. get mode(): number;
  46024. /**
  46025. * Sets the scale applied to the radius (1 by default)
  46026. */
  46027. set radiusScale(radius: number);
  46028. /**
  46029. * Gets the scale applied to the radius
  46030. */
  46031. get radiusScale(): number;
  46032. /**
  46033. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46034. */
  46035. set positionScale(scale: number);
  46036. /**
  46037. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46038. */
  46039. get positionScale(): number;
  46040. /**
  46041. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46042. * behaviour is triggered, in radians.
  46043. */
  46044. set defaultElevation(elevation: number);
  46045. /**
  46046. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46047. * behaviour is triggered, in radians.
  46048. */
  46049. get defaultElevation(): number;
  46050. /**
  46051. * Sets the time (in milliseconds) taken to return to the default beta position.
  46052. * Negative value indicates camera should not return to default.
  46053. */
  46054. set elevationReturnTime(speed: number);
  46055. /**
  46056. * Gets the time (in milliseconds) taken to return to the default beta position.
  46057. * Negative value indicates camera should not return to default.
  46058. */
  46059. get elevationReturnTime(): number;
  46060. /**
  46061. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46062. */
  46063. set elevationReturnWaitTime(time: number);
  46064. /**
  46065. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46066. */
  46067. get elevationReturnWaitTime(): number;
  46068. /**
  46069. * Sets the flag that indicates if user zooming should stop animation.
  46070. */
  46071. set zoomStopsAnimation(flag: boolean);
  46072. /**
  46073. * Gets the flag that indicates if user zooming should stop animation.
  46074. */
  46075. get zoomStopsAnimation(): boolean;
  46076. /**
  46077. * Sets the transition time when framing the mesh, in milliseconds
  46078. */
  46079. set framingTime(time: number);
  46080. /**
  46081. * Gets the transition time when framing the mesh, in milliseconds
  46082. */
  46083. get framingTime(): number;
  46084. /**
  46085. * Define if the behavior should automatically change the configured
  46086. * camera limits and sensibilities.
  46087. */
  46088. autoCorrectCameraLimitsAndSensibility: boolean;
  46089. private _onPrePointerObservableObserver;
  46090. private _onAfterCheckInputsObserver;
  46091. private _onMeshTargetChangedObserver;
  46092. private _attachedCamera;
  46093. private _isPointerDown;
  46094. private _lastInteractionTime;
  46095. /**
  46096. * Initializes the behavior.
  46097. */
  46098. init(): void;
  46099. /**
  46100. * Attaches the behavior to its arc rotate camera.
  46101. * @param camera Defines the camera to attach the behavior to
  46102. */
  46103. attach(camera: ArcRotateCamera): void;
  46104. /**
  46105. * Detaches the behavior from its current arc rotate camera.
  46106. */
  46107. detach(): void;
  46108. private _animatables;
  46109. private _betaIsAnimating;
  46110. private _betaTransition;
  46111. private _radiusTransition;
  46112. private _vectorTransition;
  46113. /**
  46114. * Targets the given mesh and updates zoom level accordingly.
  46115. * @param mesh The mesh to target.
  46116. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46117. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46118. */
  46119. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46120. /**
  46121. * Targets the given mesh with its children and updates zoom level accordingly.
  46122. * @param mesh The mesh to target.
  46123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46125. */
  46126. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46127. /**
  46128. * Targets the given meshes with their children and updates zoom level accordingly.
  46129. * @param meshes The mesh to target.
  46130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46132. */
  46133. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46134. /**
  46135. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46136. * @param minimumWorld Determines the smaller position of the bounding box extend
  46137. * @param maximumWorld Determines the bigger position of the bounding box extend
  46138. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46139. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46140. */
  46141. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46142. /**
  46143. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46144. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46145. * frustum width.
  46146. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46147. * to fully enclose the mesh in the viewing frustum.
  46148. */
  46149. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46150. /**
  46151. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46152. * is automatically returned to its default position (expected to be above ground plane).
  46153. */
  46154. private _maintainCameraAboveGround;
  46155. /**
  46156. * Returns the frustum slope based on the canvas ratio and camera FOV
  46157. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46158. */
  46159. private _getFrustumSlope;
  46160. /**
  46161. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46162. */
  46163. private _clearAnimationLocks;
  46164. /**
  46165. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46166. */
  46167. private _applyUserInteraction;
  46168. /**
  46169. * Stops and removes all animations that have been applied to the camera
  46170. */
  46171. stopAllAnimations(): void;
  46172. /**
  46173. * Gets a value indicating if the user is moving the camera
  46174. */
  46175. get isUserIsMoving(): boolean;
  46176. /**
  46177. * The camera can move all the way towards the mesh.
  46178. */
  46179. static IgnoreBoundsSizeMode: number;
  46180. /**
  46181. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46182. */
  46183. static FitFrustumSidesMode: number;
  46184. }
  46185. }
  46186. declare module BABYLON {
  46187. /**
  46188. * Base class for Camera Pointer Inputs.
  46189. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46190. * for example usage.
  46191. */
  46192. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46193. /**
  46194. * Defines the camera the input is attached to.
  46195. */
  46196. abstract camera: Camera;
  46197. /**
  46198. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46199. */
  46200. protected _altKey: boolean;
  46201. protected _ctrlKey: boolean;
  46202. protected _metaKey: boolean;
  46203. protected _shiftKey: boolean;
  46204. /**
  46205. * Which mouse buttons were pressed at time of last mouse event.
  46206. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46207. */
  46208. protected _buttonsPressed: number;
  46209. /**
  46210. * Defines the buttons associated with the input to handle camera move.
  46211. */
  46212. buttons: number[];
  46213. /**
  46214. * Attach the input controls to a specific dom element to get the input from.
  46215. * @param element Defines the element the controls should be listened from
  46216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46217. */
  46218. attachControl(noPreventDefault?: boolean): void;
  46219. /**
  46220. * Detach the current controls from the specified dom element.
  46221. */
  46222. detachControl(): void;
  46223. /**
  46224. * Gets the class name of the current input.
  46225. * @returns the class name
  46226. */
  46227. getClassName(): string;
  46228. /**
  46229. * Get the friendly name associated with the input class.
  46230. * @returns the input friendly name
  46231. */
  46232. getSimpleName(): string;
  46233. /**
  46234. * Called on pointer POINTERDOUBLETAP event.
  46235. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46236. */
  46237. protected onDoubleTap(type: string): void;
  46238. /**
  46239. * Called on pointer POINTERMOVE event if only a single touch is active.
  46240. * Override this method to provide functionality.
  46241. */
  46242. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46243. /**
  46244. * Called on pointer POINTERMOVE event if multiple touches are active.
  46245. * Override this method to provide functionality.
  46246. */
  46247. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46248. /**
  46249. * Called on JS contextmenu event.
  46250. * Override this method to provide functionality.
  46251. */
  46252. protected onContextMenu(evt: PointerEvent): void;
  46253. /**
  46254. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46255. * press.
  46256. * Override this method to provide functionality.
  46257. */
  46258. protected onButtonDown(evt: PointerEvent): void;
  46259. /**
  46260. * Called each time a new POINTERUP event occurs. Ie, for each button
  46261. * release.
  46262. * Override this method to provide functionality.
  46263. */
  46264. protected onButtonUp(evt: PointerEvent): void;
  46265. /**
  46266. * Called when window becomes inactive.
  46267. * Override this method to provide functionality.
  46268. */
  46269. protected onLostFocus(): void;
  46270. private _pointerInput;
  46271. private _observer;
  46272. private _onLostFocus;
  46273. private pointA;
  46274. private pointB;
  46275. }
  46276. }
  46277. declare module BABYLON {
  46278. /**
  46279. * Manage the pointers inputs to control an arc rotate camera.
  46280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46281. */
  46282. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46283. /**
  46284. * Defines the camera the input is attached to.
  46285. */
  46286. camera: ArcRotateCamera;
  46287. /**
  46288. * Gets the class name of the current input.
  46289. * @returns the class name
  46290. */
  46291. getClassName(): string;
  46292. /**
  46293. * Defines the buttons associated with the input to handle camera move.
  46294. */
  46295. buttons: number[];
  46296. /**
  46297. * Defines the pointer angular sensibility along the X axis or how fast is
  46298. * the camera rotating.
  46299. */
  46300. angularSensibilityX: number;
  46301. /**
  46302. * Defines the pointer angular sensibility along the Y axis or how fast is
  46303. * the camera rotating.
  46304. */
  46305. angularSensibilityY: number;
  46306. /**
  46307. * Defines the pointer pinch precision or how fast is the camera zooming.
  46308. */
  46309. pinchPrecision: number;
  46310. /**
  46311. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46312. * from 0.
  46313. * It defines the percentage of current camera.radius to use as delta when
  46314. * pinch zoom is used.
  46315. */
  46316. pinchDeltaPercentage: number;
  46317. /**
  46318. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46319. * that any object in the plane at the camera's target point will scale
  46320. * perfectly with finger motion.
  46321. * Overrides pinchDeltaPercentage and pinchPrecision.
  46322. */
  46323. useNaturalPinchZoom: boolean;
  46324. /**
  46325. * Defines the pointer panning sensibility or how fast is the camera moving.
  46326. */
  46327. panningSensibility: number;
  46328. /**
  46329. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46330. */
  46331. multiTouchPanning: boolean;
  46332. /**
  46333. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46334. * zoom (pinch) through multitouch.
  46335. */
  46336. multiTouchPanAndZoom: boolean;
  46337. /**
  46338. * Revers pinch action direction.
  46339. */
  46340. pinchInwards: boolean;
  46341. private _isPanClick;
  46342. private _twoFingerActivityCount;
  46343. private _isPinching;
  46344. /**
  46345. * Called on pointer POINTERMOVE event if only a single touch is active.
  46346. */
  46347. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46348. /**
  46349. * Called on pointer POINTERDOUBLETAP event.
  46350. */
  46351. protected onDoubleTap(type: string): void;
  46352. /**
  46353. * Called on pointer POINTERMOVE event if multiple touches are active.
  46354. */
  46355. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46356. /**
  46357. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46358. * press.
  46359. */
  46360. protected onButtonDown(evt: PointerEvent): void;
  46361. /**
  46362. * Called each time a new POINTERUP event occurs. Ie, for each button
  46363. * release.
  46364. */
  46365. protected onButtonUp(evt: PointerEvent): void;
  46366. /**
  46367. * Called when window becomes inactive.
  46368. */
  46369. protected onLostFocus(): void;
  46370. }
  46371. }
  46372. declare module BABYLON {
  46373. /**
  46374. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46375. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46376. */
  46377. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46378. /**
  46379. * Defines the camera the input is attached to.
  46380. */
  46381. camera: ArcRotateCamera;
  46382. /**
  46383. * Defines the list of key codes associated with the up action (increase alpha)
  46384. */
  46385. keysUp: number[];
  46386. /**
  46387. * Defines the list of key codes associated with the down action (decrease alpha)
  46388. */
  46389. keysDown: number[];
  46390. /**
  46391. * Defines the list of key codes associated with the left action (increase beta)
  46392. */
  46393. keysLeft: number[];
  46394. /**
  46395. * Defines the list of key codes associated with the right action (decrease beta)
  46396. */
  46397. keysRight: number[];
  46398. /**
  46399. * Defines the list of key codes associated with the reset action.
  46400. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46401. */
  46402. keysReset: number[];
  46403. /**
  46404. * Defines the panning sensibility of the inputs.
  46405. * (How fast is the camera panning)
  46406. */
  46407. panningSensibility: number;
  46408. /**
  46409. * Defines the zooming sensibility of the inputs.
  46410. * (How fast is the camera zooming)
  46411. */
  46412. zoomingSensibility: number;
  46413. /**
  46414. * Defines whether maintaining the alt key down switch the movement mode from
  46415. * orientation to zoom.
  46416. */
  46417. useAltToZoom: boolean;
  46418. /**
  46419. * Rotation speed of the camera
  46420. */
  46421. angularSpeed: number;
  46422. private _keys;
  46423. private _ctrlPressed;
  46424. private _altPressed;
  46425. private _onCanvasBlurObserver;
  46426. private _onKeyboardObserver;
  46427. private _engine;
  46428. private _scene;
  46429. /**
  46430. * Attach the input controls to a specific dom element to get the input from.
  46431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46432. */
  46433. attachControl(noPreventDefault?: boolean): void;
  46434. /**
  46435. * Detach the current controls from the specified dom element.
  46436. */
  46437. detachControl(): void;
  46438. /**
  46439. * Update the current camera state depending on the inputs that have been used this frame.
  46440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46441. */
  46442. checkInputs(): void;
  46443. /**
  46444. * Gets the class name of the current intput.
  46445. * @returns the class name
  46446. */
  46447. getClassName(): string;
  46448. /**
  46449. * Get the friendly name associated with the input class.
  46450. * @returns the input friendly name
  46451. */
  46452. getSimpleName(): string;
  46453. }
  46454. }
  46455. declare module BABYLON {
  46456. /**
  46457. * Manage the mouse wheel inputs to control an arc rotate camera.
  46458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46459. */
  46460. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46461. /**
  46462. * Defines the camera the input is attached to.
  46463. */
  46464. camera: ArcRotateCamera;
  46465. /**
  46466. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46467. */
  46468. wheelPrecision: number;
  46469. /**
  46470. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46471. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46472. */
  46473. wheelDeltaPercentage: number;
  46474. private _wheel;
  46475. private _observer;
  46476. private computeDeltaFromMouseWheelLegacyEvent;
  46477. /**
  46478. * Attach the input controls to a specific dom element to get the input from.
  46479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46480. */
  46481. attachControl(noPreventDefault?: boolean): void;
  46482. /**
  46483. * Detach the current controls from the specified dom element.
  46484. */
  46485. detachControl(): void;
  46486. /**
  46487. * Gets the class name of the current intput.
  46488. * @returns the class name
  46489. */
  46490. getClassName(): string;
  46491. /**
  46492. * Get the friendly name associated with the input class.
  46493. * @returns the input friendly name
  46494. */
  46495. getSimpleName(): string;
  46496. }
  46497. }
  46498. declare module BABYLON {
  46499. /**
  46500. * Default Inputs manager for the ArcRotateCamera.
  46501. * It groups all the default supported inputs for ease of use.
  46502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46503. */
  46504. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46505. /**
  46506. * Instantiates a new ArcRotateCameraInputsManager.
  46507. * @param camera Defines the camera the inputs belong to
  46508. */
  46509. constructor(camera: ArcRotateCamera);
  46510. /**
  46511. * Add mouse wheel input support to the input manager.
  46512. * @returns the current input manager
  46513. */
  46514. addMouseWheel(): ArcRotateCameraInputsManager;
  46515. /**
  46516. * Add pointers input support to the input manager.
  46517. * @returns the current input manager
  46518. */
  46519. addPointers(): ArcRotateCameraInputsManager;
  46520. /**
  46521. * Add keyboard input support to the input manager.
  46522. * @returns the current input manager
  46523. */
  46524. addKeyboard(): ArcRotateCameraInputsManager;
  46525. }
  46526. }
  46527. declare module BABYLON {
  46528. /**
  46529. * This represents an orbital type of camera.
  46530. *
  46531. * 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.
  46532. * 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.
  46533. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46534. */
  46535. export class ArcRotateCamera extends TargetCamera {
  46536. /**
  46537. * Defines the rotation angle of the camera along the longitudinal axis.
  46538. */
  46539. alpha: number;
  46540. /**
  46541. * Defines the rotation angle of the camera along the latitudinal axis.
  46542. */
  46543. beta: number;
  46544. /**
  46545. * Defines the radius of the camera from it s target point.
  46546. */
  46547. radius: number;
  46548. protected _target: Vector3;
  46549. protected _targetHost: Nullable<AbstractMesh>;
  46550. /**
  46551. * Defines the target point of the camera.
  46552. * The camera looks towards it form the radius distance.
  46553. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46554. */
  46555. get target(): Vector3;
  46556. set target(value: Vector3);
  46557. /**
  46558. * Define the current local position of the camera in the scene
  46559. */
  46560. get position(): Vector3;
  46561. set position(newPosition: Vector3);
  46562. protected _upToYMatrix: Matrix;
  46563. protected _YToUpMatrix: Matrix;
  46564. /**
  46565. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46566. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46567. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46568. */
  46569. set upVector(vec: Vector3);
  46570. get upVector(): Vector3;
  46571. /**
  46572. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46573. */
  46574. setMatUp(): void;
  46575. /**
  46576. * Current inertia value on the longitudinal axis.
  46577. * The bigger this number the longer it will take for the camera to stop.
  46578. */
  46579. inertialAlphaOffset: number;
  46580. /**
  46581. * Current inertia value on the latitudinal axis.
  46582. * The bigger this number the longer it will take for the camera to stop.
  46583. */
  46584. inertialBetaOffset: number;
  46585. /**
  46586. * Current inertia value on the radius axis.
  46587. * The bigger this number the longer it will take for the camera to stop.
  46588. */
  46589. inertialRadiusOffset: number;
  46590. /**
  46591. * Minimum allowed angle on the longitudinal axis.
  46592. * This can help limiting how the Camera is able to move in the scene.
  46593. */
  46594. lowerAlphaLimit: Nullable<number>;
  46595. /**
  46596. * Maximum allowed angle on the longitudinal axis.
  46597. * This can help limiting how the Camera is able to move in the scene.
  46598. */
  46599. upperAlphaLimit: Nullable<number>;
  46600. /**
  46601. * Minimum allowed angle on the latitudinal axis.
  46602. * This can help limiting how the Camera is able to move in the scene.
  46603. */
  46604. lowerBetaLimit: number;
  46605. /**
  46606. * Maximum allowed angle on the latitudinal axis.
  46607. * This can help limiting how the Camera is able to move in the scene.
  46608. */
  46609. upperBetaLimit: number;
  46610. /**
  46611. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46612. * This can help limiting how the Camera is able to move in the scene.
  46613. */
  46614. lowerRadiusLimit: Nullable<number>;
  46615. /**
  46616. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46617. * This can help limiting how the Camera is able to move in the scene.
  46618. */
  46619. upperRadiusLimit: Nullable<number>;
  46620. /**
  46621. * Defines the current inertia value used during panning of the camera along the X axis.
  46622. */
  46623. inertialPanningX: number;
  46624. /**
  46625. * Defines the current inertia value used during panning of the camera along the Y axis.
  46626. */
  46627. inertialPanningY: number;
  46628. /**
  46629. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46630. * Basically if your fingers moves away from more than this distance you will be considered
  46631. * in pinch mode.
  46632. */
  46633. pinchToPanMaxDistance: number;
  46634. /**
  46635. * Defines the maximum distance the camera can pan.
  46636. * This could help keeping the cammera always in your scene.
  46637. */
  46638. panningDistanceLimit: Nullable<number>;
  46639. /**
  46640. * Defines the target of the camera before paning.
  46641. */
  46642. panningOriginTarget: Vector3;
  46643. /**
  46644. * Defines the value of the inertia used during panning.
  46645. * 0 would mean stop inertia and one would mean no decelleration at all.
  46646. */
  46647. panningInertia: number;
  46648. /**
  46649. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46650. */
  46651. get angularSensibilityX(): number;
  46652. set angularSensibilityX(value: number);
  46653. /**
  46654. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46655. */
  46656. get angularSensibilityY(): number;
  46657. set angularSensibilityY(value: number);
  46658. /**
  46659. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46660. */
  46661. get pinchPrecision(): number;
  46662. set pinchPrecision(value: number);
  46663. /**
  46664. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46665. * It will be used instead of pinchDeltaPrecision if different from 0.
  46666. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46667. */
  46668. get pinchDeltaPercentage(): number;
  46669. set pinchDeltaPercentage(value: number);
  46670. /**
  46671. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46672. * and pinch delta percentage.
  46673. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46674. * that any object in the plane at the camera's target point will scale
  46675. * perfectly with finger motion.
  46676. */
  46677. get useNaturalPinchZoom(): boolean;
  46678. set useNaturalPinchZoom(value: boolean);
  46679. /**
  46680. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46681. */
  46682. get panningSensibility(): number;
  46683. set panningSensibility(value: number);
  46684. /**
  46685. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46686. */
  46687. get keysUp(): number[];
  46688. set keysUp(value: number[]);
  46689. /**
  46690. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46691. */
  46692. get keysDown(): number[];
  46693. set keysDown(value: number[]);
  46694. /**
  46695. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46696. */
  46697. get keysLeft(): number[];
  46698. set keysLeft(value: number[]);
  46699. /**
  46700. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46701. */
  46702. get keysRight(): number[];
  46703. set keysRight(value: number[]);
  46704. /**
  46705. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46706. */
  46707. get wheelPrecision(): number;
  46708. set wheelPrecision(value: number);
  46709. /**
  46710. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46711. * It will be used instead of pinchDeltaPrecision if different from 0.
  46712. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46713. */
  46714. get wheelDeltaPercentage(): number;
  46715. set wheelDeltaPercentage(value: number);
  46716. /**
  46717. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46718. */
  46719. zoomOnFactor: number;
  46720. /**
  46721. * Defines a screen offset for the camera position.
  46722. */
  46723. targetScreenOffset: Vector2;
  46724. /**
  46725. * Allows the camera to be completely reversed.
  46726. * If false the camera can not arrive upside down.
  46727. */
  46728. allowUpsideDown: boolean;
  46729. /**
  46730. * Define if double tap/click is used to restore the previously saved state of the camera.
  46731. */
  46732. useInputToRestoreState: boolean;
  46733. /** @hidden */
  46734. _viewMatrix: Matrix;
  46735. /** @hidden */
  46736. _useCtrlForPanning: boolean;
  46737. /** @hidden */
  46738. _panningMouseButton: number;
  46739. /**
  46740. * Defines the input associated to the camera.
  46741. */
  46742. inputs: ArcRotateCameraInputsManager;
  46743. /** @hidden */
  46744. _reset: () => void;
  46745. /**
  46746. * Defines the allowed panning axis.
  46747. */
  46748. panningAxis: Vector3;
  46749. protected _localDirection: Vector3;
  46750. protected _transformedDirection: Vector3;
  46751. private _bouncingBehavior;
  46752. /**
  46753. * Gets the bouncing behavior of the camera if it has been enabled.
  46754. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46755. */
  46756. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46757. /**
  46758. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46759. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46760. */
  46761. get useBouncingBehavior(): boolean;
  46762. set useBouncingBehavior(value: boolean);
  46763. private _framingBehavior;
  46764. /**
  46765. * Gets the framing behavior of the camera if it has been enabled.
  46766. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46767. */
  46768. get framingBehavior(): Nullable<FramingBehavior>;
  46769. /**
  46770. * Defines if the framing behavior of the camera is enabled on the camera.
  46771. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46772. */
  46773. get useFramingBehavior(): boolean;
  46774. set useFramingBehavior(value: boolean);
  46775. private _autoRotationBehavior;
  46776. /**
  46777. * Gets the auto rotation behavior of the camera if it has been enabled.
  46778. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46779. */
  46780. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46781. /**
  46782. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46783. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46784. */
  46785. get useAutoRotationBehavior(): boolean;
  46786. set useAutoRotationBehavior(value: boolean);
  46787. /**
  46788. * Observable triggered when the mesh target has been changed on the camera.
  46789. */
  46790. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46791. /**
  46792. * Event raised when the camera is colliding with a mesh.
  46793. */
  46794. onCollide: (collidedMesh: AbstractMesh) => void;
  46795. /**
  46796. * Defines whether the camera should check collision with the objects oh the scene.
  46797. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46798. */
  46799. checkCollisions: boolean;
  46800. /**
  46801. * Defines the collision radius of the camera.
  46802. * This simulates a sphere around the camera.
  46803. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46804. */
  46805. collisionRadius: Vector3;
  46806. protected _collider: Collider;
  46807. protected _previousPosition: Vector3;
  46808. protected _collisionVelocity: Vector3;
  46809. protected _newPosition: Vector3;
  46810. protected _previousAlpha: number;
  46811. protected _previousBeta: number;
  46812. protected _previousRadius: number;
  46813. protected _collisionTriggered: boolean;
  46814. protected _targetBoundingCenter: Nullable<Vector3>;
  46815. private _computationVector;
  46816. /**
  46817. * Instantiates a new ArcRotateCamera in a given scene
  46818. * @param name Defines the name of the camera
  46819. * @param alpha Defines the camera rotation along the logitudinal axis
  46820. * @param beta Defines the camera rotation along the latitudinal axis
  46821. * @param radius Defines the camera distance from its target
  46822. * @param target Defines the camera target
  46823. * @param scene Defines the scene the camera belongs to
  46824. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46825. */
  46826. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46827. /** @hidden */
  46828. _initCache(): void;
  46829. /** @hidden */
  46830. _updateCache(ignoreParentClass?: boolean): void;
  46831. protected _getTargetPosition(): Vector3;
  46832. private _storedAlpha;
  46833. private _storedBeta;
  46834. private _storedRadius;
  46835. private _storedTarget;
  46836. private _storedTargetScreenOffset;
  46837. /**
  46838. * Stores the current state of the camera (alpha, beta, radius and target)
  46839. * @returns the camera itself
  46840. */
  46841. storeState(): Camera;
  46842. /**
  46843. * @hidden
  46844. * Restored camera state. You must call storeState() first
  46845. */
  46846. _restoreStateValues(): boolean;
  46847. /** @hidden */
  46848. _isSynchronizedViewMatrix(): boolean;
  46849. /**
  46850. * Attach the input controls to a specific dom element to get the input from.
  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(noPreventDefault?: boolean): void;
  46854. /**
  46855. * Attach the input controls to a specific dom element to get the input from.
  46856. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46858. */
  46859. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46860. /**
  46861. * Attached controls to the current camera.
  46862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46863. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46864. */
  46865. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46866. /**
  46867. * Attached controls to the current camera.
  46868. * @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
  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. */
  46872. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46873. /**
  46874. * Attached controls to the current camera.
  46875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46876. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46877. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46878. */
  46879. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46880. /**
  46881. * Detach the current controls from the specified dom element.
  46882. */
  46883. detachControl(): void;
  46884. /**
  46885. * Detach the current controls from the specified dom element.
  46886. * @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
  46887. */
  46888. detachControl(ignored: any): void;
  46889. /** @hidden */
  46890. _checkInputs(): void;
  46891. protected _checkLimits(): void;
  46892. /**
  46893. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46894. */
  46895. rebuildAnglesAndRadius(): void;
  46896. /**
  46897. * Use a position to define the current camera related information like alpha, beta and radius
  46898. * @param position Defines the position to set the camera at
  46899. */
  46900. setPosition(position: Vector3): void;
  46901. /**
  46902. * Defines the target the camera should look at.
  46903. * This will automatically adapt alpha beta and radius to fit within the new target.
  46904. * @param target Defines the new target as a Vector or a mesh
  46905. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46906. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46907. */
  46908. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46909. /** @hidden */
  46910. _getViewMatrix(): Matrix;
  46911. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46912. /**
  46913. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46914. * @param meshes Defines the mesh to zoom on
  46915. * @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)
  46916. */
  46917. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46918. /**
  46919. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46920. * The target will be changed but the radius
  46921. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46922. * @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)
  46923. */
  46924. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46925. min: Vector3;
  46926. max: Vector3;
  46927. distance: number;
  46928. }, doNotUpdateMaxZ?: boolean): void;
  46929. /**
  46930. * @override
  46931. * Override Camera.createRigCamera
  46932. */
  46933. createRigCamera(name: string, cameraIndex: number): Camera;
  46934. /**
  46935. * @hidden
  46936. * @override
  46937. * Override Camera._updateRigCameras
  46938. */
  46939. _updateRigCameras(): void;
  46940. /**
  46941. * Destroy the camera and release the current resources hold by it.
  46942. */
  46943. dispose(): void;
  46944. /**
  46945. * Gets the current object class name.
  46946. * @return the class name
  46947. */
  46948. getClassName(): string;
  46949. }
  46950. }
  46951. declare module BABYLON {
  46952. /**
  46953. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46954. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46955. */
  46956. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46957. /**
  46958. * Gets the name of the behavior.
  46959. */
  46960. get name(): string;
  46961. private _zoomStopsAnimation;
  46962. private _idleRotationSpeed;
  46963. private _idleRotationWaitTime;
  46964. private _idleRotationSpinupTime;
  46965. /**
  46966. * Sets the flag that indicates if user zooming should stop animation.
  46967. */
  46968. set zoomStopsAnimation(flag: boolean);
  46969. /**
  46970. * Gets the flag that indicates if user zooming should stop animation.
  46971. */
  46972. get zoomStopsAnimation(): boolean;
  46973. /**
  46974. * Sets the default speed at which the camera rotates around the model.
  46975. */
  46976. set idleRotationSpeed(speed: number);
  46977. /**
  46978. * Gets the default speed at which the camera rotates around the model.
  46979. */
  46980. get idleRotationSpeed(): number;
  46981. /**
  46982. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46983. */
  46984. set idleRotationWaitTime(time: number);
  46985. /**
  46986. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46987. */
  46988. get idleRotationWaitTime(): number;
  46989. /**
  46990. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46991. */
  46992. set idleRotationSpinupTime(time: number);
  46993. /**
  46994. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46995. */
  46996. get idleRotationSpinupTime(): number;
  46997. /**
  46998. * Gets a value indicating if the camera is currently rotating because of this behavior
  46999. */
  47000. get rotationInProgress(): boolean;
  47001. private _onPrePointerObservableObserver;
  47002. private _onAfterCheckInputsObserver;
  47003. private _attachedCamera;
  47004. private _isPointerDown;
  47005. private _lastFrameTime;
  47006. private _lastInteractionTime;
  47007. private _cameraRotationSpeed;
  47008. /**
  47009. * Initializes the behavior.
  47010. */
  47011. init(): void;
  47012. /**
  47013. * Attaches the behavior to its arc rotate camera.
  47014. * @param camera Defines the camera to attach the behavior to
  47015. */
  47016. attach(camera: ArcRotateCamera): void;
  47017. /**
  47018. * Detaches the behavior from its current arc rotate camera.
  47019. */
  47020. detach(): void;
  47021. /**
  47022. * Returns true if user is scrolling.
  47023. * @return true if user is scrolling.
  47024. */
  47025. private _userIsZooming;
  47026. private _lastFrameRadius;
  47027. private _shouldAnimationStopForInteraction;
  47028. /**
  47029. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47030. */
  47031. private _applyUserInteraction;
  47032. private _userIsMoving;
  47033. }
  47034. }
  47035. declare module BABYLON {
  47036. /**
  47037. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47038. */
  47039. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47040. private ui;
  47041. /**
  47042. * The name of the behavior
  47043. */
  47044. name: string;
  47045. /**
  47046. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47047. */
  47048. distanceAwayFromFace: number;
  47049. /**
  47050. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47051. */
  47052. distanceAwayFromBottomOfFace: number;
  47053. private _faceVectors;
  47054. private _target;
  47055. private _scene;
  47056. private _onRenderObserver;
  47057. private _tmpMatrix;
  47058. private _tmpVector;
  47059. /**
  47060. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47061. * @param ui The transform node that should be attched to the mesh
  47062. */
  47063. constructor(ui: TransformNode);
  47064. /**
  47065. * Initializes the behavior
  47066. */
  47067. init(): void;
  47068. private _closestFace;
  47069. private _zeroVector;
  47070. private _lookAtTmpMatrix;
  47071. private _lookAtToRef;
  47072. /**
  47073. * Attaches the AttachToBoxBehavior to the passed in mesh
  47074. * @param target The mesh that the specified node will be attached to
  47075. */
  47076. attach(target: Mesh): void;
  47077. /**
  47078. * Detaches the behavior from the mesh
  47079. */
  47080. detach(): void;
  47081. }
  47082. }
  47083. declare module BABYLON {
  47084. /**
  47085. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47086. */
  47087. export class FadeInOutBehavior implements Behavior<Mesh> {
  47088. /**
  47089. * Time in milliseconds to delay before fading in (Default: 0)
  47090. */
  47091. delay: number;
  47092. /**
  47093. * Time in milliseconds for the mesh to fade in (Default: 300)
  47094. */
  47095. fadeInTime: number;
  47096. private _millisecondsPerFrame;
  47097. private _hovered;
  47098. private _hoverValue;
  47099. private _ownerNode;
  47100. /**
  47101. * Instatiates the FadeInOutBehavior
  47102. */
  47103. constructor();
  47104. /**
  47105. * The name of the behavior
  47106. */
  47107. get name(): string;
  47108. /**
  47109. * Initializes the behavior
  47110. */
  47111. init(): void;
  47112. /**
  47113. * Attaches the fade behavior on the passed in mesh
  47114. * @param ownerNode The mesh that will be faded in/out once attached
  47115. */
  47116. attach(ownerNode: Mesh): void;
  47117. /**
  47118. * Detaches the behavior from the mesh
  47119. */
  47120. detach(): void;
  47121. /**
  47122. * Triggers the mesh to begin fading in or out
  47123. * @param value if the object should fade in or out (true to fade in)
  47124. */
  47125. fadeIn(value: boolean): void;
  47126. private _update;
  47127. private _setAllVisibility;
  47128. }
  47129. }
  47130. declare module BABYLON {
  47131. /**
  47132. * Class containing a set of static utilities functions for managing Pivots
  47133. * @hidden
  47134. */
  47135. export class PivotTools {
  47136. private static _PivotCached;
  47137. private static _OldPivotPoint;
  47138. private static _PivotTranslation;
  47139. private static _PivotTmpVector;
  47140. private static _PivotPostMultiplyPivotMatrix;
  47141. /** @hidden */
  47142. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47143. /** @hidden */
  47144. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47145. }
  47146. }
  47147. declare module BABYLON {
  47148. /**
  47149. * Class containing static functions to help procedurally build meshes
  47150. */
  47151. export class PlaneBuilder {
  47152. /**
  47153. * Creates a plane mesh
  47154. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47155. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47156. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47158. * * 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
  47159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47160. * @param name defines the name of the mesh
  47161. * @param options defines the options used to create the mesh
  47162. * @param scene defines the hosting scene
  47163. * @returns the plane mesh
  47164. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47165. */
  47166. static CreatePlane(name: string, options: {
  47167. size?: number;
  47168. width?: number;
  47169. height?: number;
  47170. sideOrientation?: number;
  47171. frontUVs?: Vector4;
  47172. backUVs?: Vector4;
  47173. updatable?: boolean;
  47174. sourcePlane?: Plane;
  47175. }, scene?: Nullable<Scene>): Mesh;
  47176. }
  47177. }
  47178. declare module BABYLON {
  47179. /**
  47180. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47181. */
  47182. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47183. private static _AnyMouseID;
  47184. /**
  47185. * Abstract mesh the behavior is set on
  47186. */
  47187. attachedNode: AbstractMesh;
  47188. private _dragPlane;
  47189. private _scene;
  47190. private _pointerObserver;
  47191. private _beforeRenderObserver;
  47192. private static _planeScene;
  47193. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47194. /**
  47195. * 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)
  47196. */
  47197. maxDragAngle: number;
  47198. /**
  47199. * @hidden
  47200. */
  47201. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47202. /**
  47203. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47204. */
  47205. currentDraggingPointerID: number;
  47206. /**
  47207. * The last position where the pointer hit the drag plane in world space
  47208. */
  47209. lastDragPosition: Vector3;
  47210. /**
  47211. * If the behavior is currently in a dragging state
  47212. */
  47213. dragging: boolean;
  47214. /**
  47215. * 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)
  47216. */
  47217. dragDeltaRatio: number;
  47218. /**
  47219. * If the drag plane orientation should be updated during the dragging (Default: true)
  47220. */
  47221. updateDragPlane: boolean;
  47222. private _debugMode;
  47223. private _moving;
  47224. /**
  47225. * Fires each time the attached mesh is dragged with the pointer
  47226. * * delta between last drag position and current drag position in world space
  47227. * * dragDistance along the drag axis
  47228. * * dragPlaneNormal normal of the current drag plane used during the drag
  47229. * * dragPlanePoint in world space where the drag intersects the drag plane
  47230. */
  47231. onDragObservable: Observable<{
  47232. delta: Vector3;
  47233. dragPlanePoint: Vector3;
  47234. dragPlaneNormal: Vector3;
  47235. dragDistance: number;
  47236. pointerId: number;
  47237. }>;
  47238. /**
  47239. * Fires each time a drag begins (eg. mouse down on mesh)
  47240. */
  47241. onDragStartObservable: Observable<{
  47242. dragPlanePoint: Vector3;
  47243. pointerId: number;
  47244. }>;
  47245. /**
  47246. * Fires each time a drag ends (eg. mouse release after drag)
  47247. */
  47248. onDragEndObservable: Observable<{
  47249. dragPlanePoint: Vector3;
  47250. pointerId: number;
  47251. }>;
  47252. /**
  47253. * If the attached mesh should be moved when dragged
  47254. */
  47255. moveAttached: boolean;
  47256. /**
  47257. * If the drag behavior will react to drag events (Default: true)
  47258. */
  47259. enabled: boolean;
  47260. /**
  47261. * If pointer events should start and release the drag (Default: true)
  47262. */
  47263. startAndReleaseDragOnPointerEvents: boolean;
  47264. /**
  47265. * If camera controls should be detached during the drag
  47266. */
  47267. detachCameraControls: boolean;
  47268. /**
  47269. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47270. */
  47271. useObjectOrientationForDragging: boolean;
  47272. private _options;
  47273. /**
  47274. * Gets the options used by the behavior
  47275. */
  47276. get options(): {
  47277. dragAxis?: Vector3;
  47278. dragPlaneNormal?: Vector3;
  47279. };
  47280. /**
  47281. * Sets the options used by the behavior
  47282. */
  47283. set options(options: {
  47284. dragAxis?: Vector3;
  47285. dragPlaneNormal?: Vector3;
  47286. });
  47287. /**
  47288. * Creates a pointer drag behavior that can be attached to a mesh
  47289. * @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)
  47290. */
  47291. constructor(options?: {
  47292. dragAxis?: Vector3;
  47293. dragPlaneNormal?: Vector3;
  47294. });
  47295. /**
  47296. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47297. */
  47298. validateDrag: (targetPosition: Vector3) => boolean;
  47299. /**
  47300. * The name of the behavior
  47301. */
  47302. get name(): string;
  47303. /**
  47304. * Initializes the behavior
  47305. */
  47306. init(): void;
  47307. private _tmpVector;
  47308. private _alternatePickedPoint;
  47309. private _worldDragAxis;
  47310. private _targetPosition;
  47311. private _attachedToElement;
  47312. /**
  47313. * Attaches the drag behavior the passed in mesh
  47314. * @param ownerNode The mesh that will be dragged around once attached
  47315. * @param predicate Predicate to use for pick filtering
  47316. */
  47317. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47318. /**
  47319. * Force relase the drag action by code.
  47320. */
  47321. releaseDrag(): void;
  47322. private _startDragRay;
  47323. private _lastPointerRay;
  47324. /**
  47325. * Simulates the start of a pointer drag event on the behavior
  47326. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47327. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47328. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47329. */
  47330. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47331. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47332. private _dragDelta;
  47333. protected _moveDrag(ray: Ray): void;
  47334. private _pickWithRayOnDragPlane;
  47335. private _pointA;
  47336. private _pointC;
  47337. private _localAxis;
  47338. private _lookAt;
  47339. private _updateDragPlanePosition;
  47340. /**
  47341. * Detaches the behavior from the mesh
  47342. */
  47343. detach(): void;
  47344. }
  47345. }
  47346. declare module BABYLON {
  47347. /**
  47348. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47349. */
  47350. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47351. private _dragBehaviorA;
  47352. private _dragBehaviorB;
  47353. private _startDistance;
  47354. private _initialScale;
  47355. private _targetScale;
  47356. private _ownerNode;
  47357. private _sceneRenderObserver;
  47358. /**
  47359. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47360. */
  47361. constructor();
  47362. /**
  47363. * The name of the behavior
  47364. */
  47365. get name(): string;
  47366. /**
  47367. * Initializes the behavior
  47368. */
  47369. init(): void;
  47370. private _getCurrentDistance;
  47371. /**
  47372. * Attaches the scale behavior the passed in mesh
  47373. * @param ownerNode The mesh that will be scaled around once attached
  47374. */
  47375. attach(ownerNode: Mesh): void;
  47376. /**
  47377. * Detaches the behavior from the mesh
  47378. */
  47379. detach(): void;
  47380. }
  47381. }
  47382. declare module BABYLON {
  47383. /**
  47384. * 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
  47385. */
  47386. export class SixDofDragBehavior implements Behavior<Mesh> {
  47387. private static _virtualScene;
  47388. private _ownerNode;
  47389. private _sceneRenderObserver;
  47390. private _scene;
  47391. private _targetPosition;
  47392. private _virtualOriginMesh;
  47393. private _virtualDragMesh;
  47394. private _pointerObserver;
  47395. private _moving;
  47396. private _startingOrientation;
  47397. private _attachedToElement;
  47398. /**
  47399. * 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)
  47400. */
  47401. private zDragFactor;
  47402. /**
  47403. * If the object should rotate to face the drag origin
  47404. */
  47405. rotateDraggedObject: boolean;
  47406. /**
  47407. * If the behavior is currently in a dragging state
  47408. */
  47409. dragging: boolean;
  47410. /**
  47411. * 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)
  47412. */
  47413. dragDeltaRatio: number;
  47414. /**
  47415. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47416. */
  47417. currentDraggingPointerID: number;
  47418. /**
  47419. * If camera controls should be detached during the drag
  47420. */
  47421. detachCameraControls: boolean;
  47422. /**
  47423. * Fires each time a drag starts
  47424. */
  47425. onDragStartObservable: Observable<{}>;
  47426. /**
  47427. * Fires each time a drag happens
  47428. */
  47429. onDragObservable: Observable<void>;
  47430. /**
  47431. * Fires each time a drag ends (eg. mouse release after drag)
  47432. */
  47433. onDragEndObservable: Observable<{}>;
  47434. /**
  47435. * 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
  47436. */
  47437. constructor();
  47438. /**
  47439. * The name of the behavior
  47440. */
  47441. get name(): string;
  47442. /**
  47443. * Initializes the behavior
  47444. */
  47445. init(): void;
  47446. /**
  47447. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47448. */
  47449. private get _pointerCamera();
  47450. /**
  47451. * Attaches the scale behavior the passed in mesh
  47452. * @param ownerNode The mesh that will be scaled around once attached
  47453. */
  47454. attach(ownerNode: Mesh): void;
  47455. /**
  47456. * Detaches the behavior from the mesh
  47457. */
  47458. detach(): void;
  47459. }
  47460. }
  47461. declare module BABYLON {
  47462. /**
  47463. * Class used to apply inverse kinematics to bones
  47464. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47465. */
  47466. export class BoneIKController {
  47467. private static _tmpVecs;
  47468. private static _tmpQuat;
  47469. private static _tmpMats;
  47470. /**
  47471. * Gets or sets the target mesh
  47472. */
  47473. targetMesh: AbstractMesh;
  47474. /** Gets or sets the mesh used as pole */
  47475. poleTargetMesh: AbstractMesh;
  47476. /**
  47477. * Gets or sets the bone used as pole
  47478. */
  47479. poleTargetBone: Nullable<Bone>;
  47480. /**
  47481. * Gets or sets the target position
  47482. */
  47483. targetPosition: Vector3;
  47484. /**
  47485. * Gets or sets the pole target position
  47486. */
  47487. poleTargetPosition: Vector3;
  47488. /**
  47489. * Gets or sets the pole target local offset
  47490. */
  47491. poleTargetLocalOffset: Vector3;
  47492. /**
  47493. * Gets or sets the pole angle
  47494. */
  47495. poleAngle: number;
  47496. /**
  47497. * Gets or sets the mesh associated with the controller
  47498. */
  47499. mesh: AbstractMesh;
  47500. /**
  47501. * 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)
  47502. */
  47503. slerpAmount: number;
  47504. private _bone1Quat;
  47505. private _bone1Mat;
  47506. private _bone2Ang;
  47507. private _bone1;
  47508. private _bone2;
  47509. private _bone1Length;
  47510. private _bone2Length;
  47511. private _maxAngle;
  47512. private _maxReach;
  47513. private _rightHandedSystem;
  47514. private _bendAxis;
  47515. private _slerping;
  47516. private _adjustRoll;
  47517. /**
  47518. * Gets or sets maximum allowed angle
  47519. */
  47520. get maxAngle(): number;
  47521. set maxAngle(value: number);
  47522. /**
  47523. * Creates a new BoneIKController
  47524. * @param mesh defines the mesh to control
  47525. * @param bone defines the bone to control
  47526. * @param options defines options to set up the controller
  47527. */
  47528. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47529. targetMesh?: AbstractMesh;
  47530. poleTargetMesh?: AbstractMesh;
  47531. poleTargetBone?: Bone;
  47532. poleTargetLocalOffset?: Vector3;
  47533. poleAngle?: number;
  47534. bendAxis?: Vector3;
  47535. maxAngle?: number;
  47536. slerpAmount?: number;
  47537. });
  47538. private _setMaxAngle;
  47539. /**
  47540. * Force the controller to update the bones
  47541. */
  47542. update(): void;
  47543. }
  47544. }
  47545. declare module BABYLON {
  47546. /**
  47547. * Class used to make a bone look toward a point in space
  47548. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47549. */
  47550. export class BoneLookController {
  47551. private static _tmpVecs;
  47552. private static _tmpQuat;
  47553. private static _tmpMats;
  47554. /**
  47555. * The target Vector3 that the bone will look at
  47556. */
  47557. target: Vector3;
  47558. /**
  47559. * The mesh that the bone is attached to
  47560. */
  47561. mesh: AbstractMesh;
  47562. /**
  47563. * The bone that will be looking to the target
  47564. */
  47565. bone: Bone;
  47566. /**
  47567. * The up axis of the coordinate system that is used when the bone is rotated
  47568. */
  47569. upAxis: Vector3;
  47570. /**
  47571. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47572. */
  47573. upAxisSpace: Space;
  47574. /**
  47575. * Used to make an adjustment to the yaw of the bone
  47576. */
  47577. adjustYaw: number;
  47578. /**
  47579. * Used to make an adjustment to the pitch of the bone
  47580. */
  47581. adjustPitch: number;
  47582. /**
  47583. * Used to make an adjustment to the roll of the bone
  47584. */
  47585. adjustRoll: number;
  47586. /**
  47587. * 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)
  47588. */
  47589. slerpAmount: number;
  47590. private _minYaw;
  47591. private _maxYaw;
  47592. private _minPitch;
  47593. private _maxPitch;
  47594. private _minYawSin;
  47595. private _minYawCos;
  47596. private _maxYawSin;
  47597. private _maxYawCos;
  47598. private _midYawConstraint;
  47599. private _minPitchTan;
  47600. private _maxPitchTan;
  47601. private _boneQuat;
  47602. private _slerping;
  47603. private _transformYawPitch;
  47604. private _transformYawPitchInv;
  47605. private _firstFrameSkipped;
  47606. private _yawRange;
  47607. private _fowardAxis;
  47608. /**
  47609. * Gets or sets the minimum yaw angle that the bone can look to
  47610. */
  47611. get minYaw(): number;
  47612. set minYaw(value: number);
  47613. /**
  47614. * Gets or sets the maximum yaw angle that the bone can look to
  47615. */
  47616. get maxYaw(): number;
  47617. set maxYaw(value: number);
  47618. /**
  47619. * Gets or sets the minimum pitch angle that the bone can look to
  47620. */
  47621. get minPitch(): number;
  47622. set minPitch(value: number);
  47623. /**
  47624. * Gets or sets the maximum pitch angle that the bone can look to
  47625. */
  47626. get maxPitch(): number;
  47627. set maxPitch(value: number);
  47628. /**
  47629. * Create a BoneLookController
  47630. * @param mesh the mesh that the bone belongs to
  47631. * @param bone the bone that will be looking to the target
  47632. * @param target the target Vector3 to look at
  47633. * @param options optional settings:
  47634. * * maxYaw: the maximum angle the bone will yaw to
  47635. * * minYaw: the minimum angle the bone will yaw to
  47636. * * maxPitch: the maximum angle the bone will pitch to
  47637. * * minPitch: the minimum angle the bone will yaw to
  47638. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47639. * * upAxis: the up axis of the coordinate system
  47640. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47641. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47642. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47643. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47644. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47645. * * adjustRoll: used to make an adjustment to the roll of the bone
  47646. **/
  47647. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47648. maxYaw?: number;
  47649. minYaw?: number;
  47650. maxPitch?: number;
  47651. minPitch?: number;
  47652. slerpAmount?: number;
  47653. upAxis?: Vector3;
  47654. upAxisSpace?: Space;
  47655. yawAxis?: Vector3;
  47656. pitchAxis?: Vector3;
  47657. adjustYaw?: number;
  47658. adjustPitch?: number;
  47659. adjustRoll?: number;
  47660. });
  47661. /**
  47662. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47663. */
  47664. update(): void;
  47665. private _getAngleDiff;
  47666. private _getAngleBetween;
  47667. private _isAngleBetween;
  47668. }
  47669. }
  47670. declare module BABYLON {
  47671. /**
  47672. * Manage the gamepad inputs to control an arc rotate camera.
  47673. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47674. */
  47675. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47676. /**
  47677. * Defines the camera the input is attached to.
  47678. */
  47679. camera: ArcRotateCamera;
  47680. /**
  47681. * Defines the gamepad the input is gathering event from.
  47682. */
  47683. gamepad: Nullable<Gamepad>;
  47684. /**
  47685. * Defines the gamepad rotation sensiblity.
  47686. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47687. */
  47688. gamepadRotationSensibility: number;
  47689. /**
  47690. * Defines the gamepad move sensiblity.
  47691. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47692. */
  47693. gamepadMoveSensibility: number;
  47694. private _yAxisScale;
  47695. /**
  47696. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47697. */
  47698. get invertYAxis(): boolean;
  47699. set invertYAxis(value: boolean);
  47700. private _onGamepadConnectedObserver;
  47701. private _onGamepadDisconnectedObserver;
  47702. /**
  47703. * Attach the input controls to a specific dom element to get the input from.
  47704. */
  47705. attachControl(): void;
  47706. /**
  47707. * Detach the current controls from the specified dom element.
  47708. */
  47709. detachControl(): void;
  47710. /**
  47711. * Update the current camera state depending on the inputs that have been used this frame.
  47712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47713. */
  47714. checkInputs(): void;
  47715. /**
  47716. * Gets the class name of the current intput.
  47717. * @returns the class name
  47718. */
  47719. getClassName(): string;
  47720. /**
  47721. * Get the friendly name associated with the input class.
  47722. * @returns the input friendly name
  47723. */
  47724. getSimpleName(): string;
  47725. }
  47726. }
  47727. declare module BABYLON {
  47728. interface ArcRotateCameraInputsManager {
  47729. /**
  47730. * Add orientation input support to the input manager.
  47731. * @returns the current input manager
  47732. */
  47733. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47734. }
  47735. /**
  47736. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47737. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47738. */
  47739. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47740. /**
  47741. * Defines the camera the input is attached to.
  47742. */
  47743. camera: ArcRotateCamera;
  47744. /**
  47745. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47746. */
  47747. alphaCorrection: number;
  47748. /**
  47749. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47750. */
  47751. gammaCorrection: number;
  47752. private _alpha;
  47753. private _gamma;
  47754. private _dirty;
  47755. private _deviceOrientationHandler;
  47756. /**
  47757. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47758. */
  47759. constructor();
  47760. /**
  47761. * Attach the input controls to a specific dom element to get the input from.
  47762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47763. */
  47764. attachControl(noPreventDefault?: boolean): void;
  47765. /** @hidden */
  47766. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47767. /**
  47768. * Update the current camera state depending on the inputs that have been used this frame.
  47769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47770. */
  47771. checkInputs(): void;
  47772. /**
  47773. * Detach the current controls from the specified dom element.
  47774. */
  47775. detachControl(): void;
  47776. /**
  47777. * Gets the class name of the current intput.
  47778. * @returns the class name
  47779. */
  47780. getClassName(): string;
  47781. /**
  47782. * Get the friendly name associated with the input class.
  47783. * @returns the input friendly name
  47784. */
  47785. getSimpleName(): string;
  47786. }
  47787. }
  47788. declare module BABYLON {
  47789. /**
  47790. * Listen to mouse events to control the camera.
  47791. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47792. */
  47793. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47794. /**
  47795. * Defines the camera the input is attached to.
  47796. */
  47797. camera: FlyCamera;
  47798. /**
  47799. * Defines if touch is enabled. (Default is true.)
  47800. */
  47801. touchEnabled: boolean;
  47802. /**
  47803. * Defines the buttons associated with the input to handle camera rotation.
  47804. */
  47805. buttons: number[];
  47806. /**
  47807. * Assign buttons for Yaw control.
  47808. */
  47809. buttonsYaw: number[];
  47810. /**
  47811. * Assign buttons for Pitch control.
  47812. */
  47813. buttonsPitch: number[];
  47814. /**
  47815. * Assign buttons for Roll control.
  47816. */
  47817. buttonsRoll: number[];
  47818. /**
  47819. * Detect if any button is being pressed while mouse is moved.
  47820. * -1 = Mouse locked.
  47821. * 0 = Left button.
  47822. * 1 = Middle Button.
  47823. * 2 = Right Button.
  47824. */
  47825. activeButton: number;
  47826. /**
  47827. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47828. * Higher values reduce its sensitivity.
  47829. */
  47830. angularSensibility: number;
  47831. private _observer;
  47832. private _rollObserver;
  47833. private previousPosition;
  47834. private noPreventDefault;
  47835. private element;
  47836. /**
  47837. * Listen to mouse events to control the camera.
  47838. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47840. */
  47841. constructor(touchEnabled?: boolean);
  47842. /**
  47843. * Attach the mouse control to the HTML DOM element.
  47844. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47845. */
  47846. attachControl(noPreventDefault?: boolean): void;
  47847. /**
  47848. * Detach the current controls from the specified dom element.
  47849. */
  47850. detachControl(): void;
  47851. /**
  47852. * Gets the class name of the current input.
  47853. * @returns the class name.
  47854. */
  47855. getClassName(): string;
  47856. /**
  47857. * Get the friendly name associated with the input class.
  47858. * @returns the input's friendly name.
  47859. */
  47860. getSimpleName(): string;
  47861. private _pointerInput;
  47862. private _onMouseMove;
  47863. /**
  47864. * Rotate camera by mouse offset.
  47865. */
  47866. private rotateCamera;
  47867. }
  47868. }
  47869. declare module BABYLON {
  47870. /**
  47871. * Default Inputs manager for the FlyCamera.
  47872. * It groups all the default supported inputs for ease of use.
  47873. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47874. */
  47875. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47876. /**
  47877. * Instantiates a new FlyCameraInputsManager.
  47878. * @param camera Defines the camera the inputs belong to.
  47879. */
  47880. constructor(camera: FlyCamera);
  47881. /**
  47882. * Add keyboard input support to the input manager.
  47883. * @returns the new FlyCameraKeyboardMoveInput().
  47884. */
  47885. addKeyboard(): FlyCameraInputsManager;
  47886. /**
  47887. * Add mouse input support to the input manager.
  47888. * @param touchEnabled Enable touch screen support.
  47889. * @returns the new FlyCameraMouseInput().
  47890. */
  47891. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47892. }
  47893. }
  47894. declare module BABYLON {
  47895. /**
  47896. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47897. * such as in a 3D Space Shooter or a Flight Simulator.
  47898. */
  47899. export class FlyCamera extends TargetCamera {
  47900. /**
  47901. * Define the collision ellipsoid of the camera.
  47902. * This is helpful for simulating a camera body, like a player's body.
  47903. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47904. */
  47905. ellipsoid: Vector3;
  47906. /**
  47907. * Define an offset for the position of the ellipsoid around the camera.
  47908. * This can be helpful if the camera is attached away from the player's body center,
  47909. * such as at its head.
  47910. */
  47911. ellipsoidOffset: Vector3;
  47912. /**
  47913. * Enable or disable collisions of the camera with the rest of the scene objects.
  47914. */
  47915. checkCollisions: boolean;
  47916. /**
  47917. * Enable or disable gravity on the camera.
  47918. */
  47919. applyGravity: boolean;
  47920. /**
  47921. * Define the current direction the camera is moving to.
  47922. */
  47923. cameraDirection: Vector3;
  47924. /**
  47925. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47926. * This overrides and empties cameraRotation.
  47927. */
  47928. rotationQuaternion: Quaternion;
  47929. /**
  47930. * Track Roll to maintain the wanted Rolling when looking around.
  47931. */
  47932. _trackRoll: number;
  47933. /**
  47934. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47935. */
  47936. rollCorrect: number;
  47937. /**
  47938. * Mimic a banked turn, Rolling the camera when Yawing.
  47939. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47940. */
  47941. bankedTurn: boolean;
  47942. /**
  47943. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47944. */
  47945. bankedTurnLimit: number;
  47946. /**
  47947. * Value of 0 disables the banked Roll.
  47948. * Value of 1 is equal to the Yaw angle in radians.
  47949. */
  47950. bankedTurnMultiplier: number;
  47951. /**
  47952. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47953. */
  47954. inputs: FlyCameraInputsManager;
  47955. /**
  47956. * Gets the input sensibility for mouse input.
  47957. * Higher values reduce sensitivity.
  47958. */
  47959. get angularSensibility(): number;
  47960. /**
  47961. * Sets the input sensibility for a mouse input.
  47962. * Higher values reduce sensitivity.
  47963. */
  47964. set angularSensibility(value: number);
  47965. /**
  47966. * Get the keys for camera movement forward.
  47967. */
  47968. get keysForward(): number[];
  47969. /**
  47970. * Set the keys for camera movement forward.
  47971. */
  47972. set keysForward(value: number[]);
  47973. /**
  47974. * Get the keys for camera movement backward.
  47975. */
  47976. get keysBackward(): number[];
  47977. set keysBackward(value: number[]);
  47978. /**
  47979. * Get the keys for camera movement up.
  47980. */
  47981. get keysUp(): number[];
  47982. /**
  47983. * Set the keys for camera movement up.
  47984. */
  47985. set keysUp(value: number[]);
  47986. /**
  47987. * Get the keys for camera movement down.
  47988. */
  47989. get keysDown(): number[];
  47990. /**
  47991. * Set the keys for camera movement down.
  47992. */
  47993. set keysDown(value: number[]);
  47994. /**
  47995. * Get the keys for camera movement left.
  47996. */
  47997. get keysLeft(): number[];
  47998. /**
  47999. * Set the keys for camera movement left.
  48000. */
  48001. set keysLeft(value: number[]);
  48002. /**
  48003. * Set the keys for camera movement right.
  48004. */
  48005. get keysRight(): number[];
  48006. /**
  48007. * Set the keys for camera movement right.
  48008. */
  48009. set keysRight(value: number[]);
  48010. /**
  48011. * Event raised when the camera collides with a mesh in the scene.
  48012. */
  48013. onCollide: (collidedMesh: AbstractMesh) => void;
  48014. private _collider;
  48015. private _needMoveForGravity;
  48016. private _oldPosition;
  48017. private _diffPosition;
  48018. private _newPosition;
  48019. /** @hidden */
  48020. _localDirection: Vector3;
  48021. /** @hidden */
  48022. _transformedDirection: Vector3;
  48023. /**
  48024. * Instantiates a FlyCamera.
  48025. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48026. * such as in a 3D Space Shooter or a Flight Simulator.
  48027. * @param name Define the name of the camera in the scene.
  48028. * @param position Define the starting position of the camera in the scene.
  48029. * @param scene Define the scene the camera belongs to.
  48030. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  48031. */
  48032. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48033. /**
  48034. * Attach the input controls to a specific dom element to get the input from.
  48035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48036. */
  48037. attachControl(noPreventDefault?: boolean): void;
  48038. /**
  48039. * Detach a control from the HTML DOM element.
  48040. * The camera will stop reacting to that input.
  48041. */
  48042. detachControl(): void;
  48043. private _collisionMask;
  48044. /**
  48045. * Get the mask that the camera ignores in collision events.
  48046. */
  48047. get collisionMask(): number;
  48048. /**
  48049. * Set the mask that the camera ignores in collision events.
  48050. */
  48051. set collisionMask(mask: number);
  48052. /** @hidden */
  48053. _collideWithWorld(displacement: Vector3): void;
  48054. /** @hidden */
  48055. private _onCollisionPositionChange;
  48056. /** @hidden */
  48057. _checkInputs(): void;
  48058. /** @hidden */
  48059. _decideIfNeedsToMove(): boolean;
  48060. /** @hidden */
  48061. _updatePosition(): void;
  48062. /**
  48063. * Restore the Roll to its target value at the rate specified.
  48064. * @param rate - Higher means slower restoring.
  48065. * @hidden
  48066. */
  48067. restoreRoll(rate: number): void;
  48068. /**
  48069. * Destroy the camera and release the current resources held by it.
  48070. */
  48071. dispose(): void;
  48072. /**
  48073. * Get the current object class name.
  48074. * @returns the class name.
  48075. */
  48076. getClassName(): string;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * Listen to keyboard events to control the camera.
  48082. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48083. */
  48084. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48085. /**
  48086. * Defines the camera the input is attached to.
  48087. */
  48088. camera: FlyCamera;
  48089. /**
  48090. * The list of keyboard keys used to control the forward move of the camera.
  48091. */
  48092. keysForward: number[];
  48093. /**
  48094. * The list of keyboard keys used to control the backward move of the camera.
  48095. */
  48096. keysBackward: number[];
  48097. /**
  48098. * The list of keyboard keys used to control the forward move of the camera.
  48099. */
  48100. keysUp: number[];
  48101. /**
  48102. * The list of keyboard keys used to control the backward move of the camera.
  48103. */
  48104. keysDown: number[];
  48105. /**
  48106. * The list of keyboard keys used to control the right strafe move of the camera.
  48107. */
  48108. keysRight: number[];
  48109. /**
  48110. * The list of keyboard keys used to control the left strafe move of the camera.
  48111. */
  48112. keysLeft: number[];
  48113. private _keys;
  48114. private _onCanvasBlurObserver;
  48115. private _onKeyboardObserver;
  48116. private _engine;
  48117. private _scene;
  48118. /**
  48119. * Attach the input controls to a specific dom element to get the input from.
  48120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48121. */
  48122. attachControl(noPreventDefault?: boolean): void;
  48123. /**
  48124. * Detach the current controls from the specified dom element.
  48125. */
  48126. detachControl(): void;
  48127. /**
  48128. * Gets the class name of the current intput.
  48129. * @returns the class name
  48130. */
  48131. getClassName(): string;
  48132. /** @hidden */
  48133. _onLostFocus(e: FocusEvent): void;
  48134. /**
  48135. * Get the friendly name associated with the input class.
  48136. * @returns the input friendly name
  48137. */
  48138. getSimpleName(): string;
  48139. /**
  48140. * Update the current camera state depending on the inputs that have been used this frame.
  48141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48142. */
  48143. checkInputs(): void;
  48144. }
  48145. }
  48146. declare module BABYLON {
  48147. /**
  48148. * Manage the mouse wheel inputs to control a follow camera.
  48149. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48150. */
  48151. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48152. /**
  48153. * Defines the camera the input is attached to.
  48154. */
  48155. camera: FollowCamera;
  48156. /**
  48157. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48158. */
  48159. axisControlRadius: boolean;
  48160. /**
  48161. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48162. */
  48163. axisControlHeight: boolean;
  48164. /**
  48165. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48166. */
  48167. axisControlRotation: boolean;
  48168. /**
  48169. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48170. * relation to mouseWheel events.
  48171. */
  48172. wheelPrecision: number;
  48173. /**
  48174. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48175. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48176. */
  48177. wheelDeltaPercentage: number;
  48178. private _wheel;
  48179. private _observer;
  48180. /**
  48181. * Attach the input controls to a specific dom element to get the input from.
  48182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48183. */
  48184. attachControl(noPreventDefault?: boolean): void;
  48185. /**
  48186. * Detach the current controls from the specified dom element.
  48187. */
  48188. detachControl(): void;
  48189. /**
  48190. * Gets the class name of the current intput.
  48191. * @returns the class name
  48192. */
  48193. getClassName(): string;
  48194. /**
  48195. * Get the friendly name associated with the input class.
  48196. * @returns the input friendly name
  48197. */
  48198. getSimpleName(): string;
  48199. }
  48200. }
  48201. declare module BABYLON {
  48202. /**
  48203. * Manage the pointers inputs to control an follow camera.
  48204. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48205. */
  48206. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48207. /**
  48208. * Defines the camera the input is attached to.
  48209. */
  48210. camera: FollowCamera;
  48211. /**
  48212. * Gets the class name of the current input.
  48213. * @returns the class name
  48214. */
  48215. getClassName(): string;
  48216. /**
  48217. * Defines the pointer angular sensibility along the X axis or how fast is
  48218. * the camera rotating.
  48219. * A negative number will reverse the axis direction.
  48220. */
  48221. angularSensibilityX: number;
  48222. /**
  48223. * Defines the pointer angular sensibility along the Y axis or how fast is
  48224. * the camera rotating.
  48225. * A negative number will reverse the axis direction.
  48226. */
  48227. angularSensibilityY: number;
  48228. /**
  48229. * Defines the pointer pinch precision or how fast is the camera zooming.
  48230. * A negative number will reverse the axis direction.
  48231. */
  48232. pinchPrecision: number;
  48233. /**
  48234. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48235. * from 0.
  48236. * It defines the percentage of current camera.radius to use as delta when
  48237. * pinch zoom is used.
  48238. */
  48239. pinchDeltaPercentage: number;
  48240. /**
  48241. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48242. */
  48243. axisXControlRadius: boolean;
  48244. /**
  48245. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48246. */
  48247. axisXControlHeight: boolean;
  48248. /**
  48249. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48250. */
  48251. axisXControlRotation: boolean;
  48252. /**
  48253. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48254. */
  48255. axisYControlRadius: boolean;
  48256. /**
  48257. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48258. */
  48259. axisYControlHeight: boolean;
  48260. /**
  48261. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48262. */
  48263. axisYControlRotation: boolean;
  48264. /**
  48265. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48266. */
  48267. axisPinchControlRadius: boolean;
  48268. /**
  48269. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48270. */
  48271. axisPinchControlHeight: boolean;
  48272. /**
  48273. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48274. */
  48275. axisPinchControlRotation: boolean;
  48276. /**
  48277. * Log error messages if basic misconfiguration has occurred.
  48278. */
  48279. warningEnable: boolean;
  48280. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48281. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48282. private _warningCounter;
  48283. private _warning;
  48284. }
  48285. }
  48286. declare module BABYLON {
  48287. /**
  48288. * Default Inputs manager for the FollowCamera.
  48289. * It groups all the default supported inputs for ease of use.
  48290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48291. */
  48292. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48293. /**
  48294. * Instantiates a new FollowCameraInputsManager.
  48295. * @param camera Defines the camera the inputs belong to
  48296. */
  48297. constructor(camera: FollowCamera);
  48298. /**
  48299. * Add keyboard input support to the input manager.
  48300. * @returns the current input manager
  48301. */
  48302. addKeyboard(): FollowCameraInputsManager;
  48303. /**
  48304. * Add mouse wheel input support to the input manager.
  48305. * @returns the current input manager
  48306. */
  48307. addMouseWheel(): FollowCameraInputsManager;
  48308. /**
  48309. * Add pointers input support to the input manager.
  48310. * @returns the current input manager
  48311. */
  48312. addPointers(): FollowCameraInputsManager;
  48313. /**
  48314. * Add orientation input support to the input manager.
  48315. * @returns the current input manager
  48316. */
  48317. addVRDeviceOrientation(): FollowCameraInputsManager;
  48318. }
  48319. }
  48320. declare module BABYLON {
  48321. /**
  48322. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48323. * an arc rotate version arcFollowCamera are available.
  48324. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48325. */
  48326. export class FollowCamera extends TargetCamera {
  48327. /**
  48328. * Distance the follow camera should follow an object at
  48329. */
  48330. radius: number;
  48331. /**
  48332. * Minimum allowed distance of the camera to the axis of rotation
  48333. * (The camera can not get closer).
  48334. * This can help limiting how the Camera is able to move in the scene.
  48335. */
  48336. lowerRadiusLimit: Nullable<number>;
  48337. /**
  48338. * Maximum allowed distance of the camera to the axis of rotation
  48339. * (The camera can not get further).
  48340. * This can help limiting how the Camera is able to move in the scene.
  48341. */
  48342. upperRadiusLimit: Nullable<number>;
  48343. /**
  48344. * Define a rotation offset between the camera and the object it follows
  48345. */
  48346. rotationOffset: number;
  48347. /**
  48348. * Minimum allowed angle to camera position relative to target object.
  48349. * This can help limiting how the Camera is able to move in the scene.
  48350. */
  48351. lowerRotationOffsetLimit: Nullable<number>;
  48352. /**
  48353. * Maximum allowed angle to camera position relative to target object.
  48354. * This can help limiting how the Camera is able to move in the scene.
  48355. */
  48356. upperRotationOffsetLimit: Nullable<number>;
  48357. /**
  48358. * Define a height offset between the camera and the object it follows.
  48359. * It can help following an object from the top (like a car chaing a plane)
  48360. */
  48361. heightOffset: number;
  48362. /**
  48363. * Minimum allowed height of camera position relative to target object.
  48364. * This can help limiting how the Camera is able to move in the scene.
  48365. */
  48366. lowerHeightOffsetLimit: Nullable<number>;
  48367. /**
  48368. * Maximum allowed height of camera position relative to target object.
  48369. * This can help limiting how the Camera is able to move in the scene.
  48370. */
  48371. upperHeightOffsetLimit: Nullable<number>;
  48372. /**
  48373. * Define how fast the camera can accelerate to follow it s target.
  48374. */
  48375. cameraAcceleration: number;
  48376. /**
  48377. * Define the speed limit of the camera following an object.
  48378. */
  48379. maxCameraSpeed: number;
  48380. /**
  48381. * Define the target of the camera.
  48382. */
  48383. lockedTarget: Nullable<AbstractMesh>;
  48384. /**
  48385. * Defines the input associated with the camera.
  48386. */
  48387. inputs: FollowCameraInputsManager;
  48388. /**
  48389. * Instantiates the follow camera.
  48390. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48391. * @param name Define the name of the camera in the scene
  48392. * @param position Define the position of the camera
  48393. * @param scene Define the scene the camera belong to
  48394. * @param lockedTarget Define the target of the camera
  48395. */
  48396. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48397. private _follow;
  48398. /**
  48399. * Attach the input controls to a specific dom element to get the input from.
  48400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48401. */
  48402. attachControl(noPreventDefault?: boolean): void;
  48403. /**
  48404. * Detach the current controls from the specified dom element.
  48405. */
  48406. detachControl(): void;
  48407. /** @hidden */
  48408. _checkInputs(): void;
  48409. private _checkLimits;
  48410. /**
  48411. * Gets the camera class name.
  48412. * @returns the class name
  48413. */
  48414. getClassName(): string;
  48415. }
  48416. /**
  48417. * Arc Rotate version of the follow camera.
  48418. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48419. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48420. */
  48421. export class ArcFollowCamera extends TargetCamera {
  48422. /** The longitudinal angle of the camera */
  48423. alpha: number;
  48424. /** The latitudinal angle of the camera */
  48425. beta: number;
  48426. /** The radius of the camera from its target */
  48427. radius: number;
  48428. private _cartesianCoordinates;
  48429. /** Define the camera target (the mesh it should follow) */
  48430. private _meshTarget;
  48431. /**
  48432. * Instantiates a new ArcFollowCamera
  48433. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48434. * @param name Define the name of the camera
  48435. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48436. * @param beta Define the rotation angle of the camera around the elevation axis
  48437. * @param radius Define the radius of the camera from its target point
  48438. * @param target Define the target of the camera
  48439. * @param scene Define the scene the camera belongs to
  48440. */
  48441. constructor(name: string,
  48442. /** The longitudinal angle of the camera */
  48443. alpha: number,
  48444. /** The latitudinal angle of the camera */
  48445. beta: number,
  48446. /** The radius of the camera from its target */
  48447. radius: number,
  48448. /** Define the camera target (the mesh it should follow) */
  48449. target: Nullable<AbstractMesh>, scene: Scene);
  48450. private _follow;
  48451. /** @hidden */
  48452. _checkInputs(): void;
  48453. /**
  48454. * Returns the class name of the object.
  48455. * It is mostly used internally for serialization purposes.
  48456. */
  48457. getClassName(): string;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Manage the keyboard inputs to control the movement of a follow camera.
  48463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48464. */
  48465. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48466. /**
  48467. * Defines the camera the input is attached to.
  48468. */
  48469. camera: FollowCamera;
  48470. /**
  48471. * Defines the list of key codes associated with the up action (increase heightOffset)
  48472. */
  48473. keysHeightOffsetIncr: number[];
  48474. /**
  48475. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48476. */
  48477. keysHeightOffsetDecr: number[];
  48478. /**
  48479. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48480. */
  48481. keysHeightOffsetModifierAlt: boolean;
  48482. /**
  48483. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48484. */
  48485. keysHeightOffsetModifierCtrl: boolean;
  48486. /**
  48487. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48488. */
  48489. keysHeightOffsetModifierShift: boolean;
  48490. /**
  48491. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48492. */
  48493. keysRotationOffsetIncr: number[];
  48494. /**
  48495. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48496. */
  48497. keysRotationOffsetDecr: number[];
  48498. /**
  48499. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48500. */
  48501. keysRotationOffsetModifierAlt: boolean;
  48502. /**
  48503. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48504. */
  48505. keysRotationOffsetModifierCtrl: boolean;
  48506. /**
  48507. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48508. */
  48509. keysRotationOffsetModifierShift: boolean;
  48510. /**
  48511. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48512. */
  48513. keysRadiusIncr: number[];
  48514. /**
  48515. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48516. */
  48517. keysRadiusDecr: number[];
  48518. /**
  48519. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48520. */
  48521. keysRadiusModifierAlt: boolean;
  48522. /**
  48523. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48524. */
  48525. keysRadiusModifierCtrl: boolean;
  48526. /**
  48527. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48528. */
  48529. keysRadiusModifierShift: boolean;
  48530. /**
  48531. * Defines the rate of change of heightOffset.
  48532. */
  48533. heightSensibility: number;
  48534. /**
  48535. * Defines the rate of change of rotationOffset.
  48536. */
  48537. rotationSensibility: number;
  48538. /**
  48539. * Defines the rate of change of radius.
  48540. */
  48541. radiusSensibility: number;
  48542. private _keys;
  48543. private _ctrlPressed;
  48544. private _altPressed;
  48545. private _shiftPressed;
  48546. private _onCanvasBlurObserver;
  48547. private _onKeyboardObserver;
  48548. private _engine;
  48549. private _scene;
  48550. /**
  48551. * Attach the input controls to a specific dom element to get the input from.
  48552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48553. */
  48554. attachControl(noPreventDefault?: boolean): void;
  48555. /**
  48556. * Detach the current controls from the specified dom element.
  48557. */
  48558. detachControl(): void;
  48559. /**
  48560. * Update the current camera state depending on the inputs that have been used this frame.
  48561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48562. */
  48563. checkInputs(): void;
  48564. /**
  48565. * Gets the class name of the current input.
  48566. * @returns the class name
  48567. */
  48568. getClassName(): string;
  48569. /**
  48570. * Get the friendly name associated with the input class.
  48571. * @returns the input friendly name
  48572. */
  48573. getSimpleName(): string;
  48574. /**
  48575. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48576. * allow modification of the heightOffset value.
  48577. */
  48578. private _modifierHeightOffset;
  48579. /**
  48580. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48581. * allow modification of the rotationOffset value.
  48582. */
  48583. private _modifierRotationOffset;
  48584. /**
  48585. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48586. * allow modification of the radius value.
  48587. */
  48588. private _modifierRadius;
  48589. }
  48590. }
  48591. declare module BABYLON {
  48592. interface FreeCameraInputsManager {
  48593. /**
  48594. * @hidden
  48595. */
  48596. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48597. /**
  48598. * Add orientation input support to the input manager.
  48599. * @returns the current input manager
  48600. */
  48601. addDeviceOrientation(): FreeCameraInputsManager;
  48602. }
  48603. /**
  48604. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48605. * Screen rotation is taken into account.
  48606. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48607. */
  48608. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48609. private _camera;
  48610. private _screenOrientationAngle;
  48611. private _constantTranform;
  48612. private _screenQuaternion;
  48613. private _alpha;
  48614. private _beta;
  48615. private _gamma;
  48616. /**
  48617. * Can be used to detect if a device orientation sensor is available on a device
  48618. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48619. * @returns a promise that will resolve on orientation change
  48620. */
  48621. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48622. /**
  48623. * @hidden
  48624. */
  48625. _onDeviceOrientationChangedObservable: Observable<void>;
  48626. /**
  48627. * Instantiates a new input
  48628. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48629. */
  48630. constructor();
  48631. /**
  48632. * Define the camera controlled by the input.
  48633. */
  48634. get camera(): FreeCamera;
  48635. set camera(camera: FreeCamera);
  48636. /**
  48637. * Attach the input controls to a specific dom element to get the input from.
  48638. */
  48639. attachControl(): void;
  48640. private _orientationChanged;
  48641. private _deviceOrientation;
  48642. /**
  48643. * Detach the current controls from the specified dom element.
  48644. */
  48645. detachControl(): void;
  48646. /**
  48647. * Update the current camera state depending on the inputs that have been used this frame.
  48648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48649. */
  48650. checkInputs(): void;
  48651. /**
  48652. * Gets the class name of the current intput.
  48653. * @returns the class name
  48654. */
  48655. getClassName(): string;
  48656. /**
  48657. * Get the friendly name associated with the input class.
  48658. * @returns the input friendly name
  48659. */
  48660. getSimpleName(): string;
  48661. }
  48662. }
  48663. declare module BABYLON {
  48664. /**
  48665. * Manage the gamepad inputs to control a free camera.
  48666. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48667. */
  48668. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48669. /**
  48670. * Define the camera the input is attached to.
  48671. */
  48672. camera: FreeCamera;
  48673. /**
  48674. * Define the Gamepad controlling the input
  48675. */
  48676. gamepad: Nullable<Gamepad>;
  48677. /**
  48678. * Defines the gamepad rotation sensiblity.
  48679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48680. */
  48681. gamepadAngularSensibility: number;
  48682. /**
  48683. * Defines the gamepad move sensiblity.
  48684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48685. */
  48686. gamepadMoveSensibility: number;
  48687. private _yAxisScale;
  48688. /**
  48689. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48690. */
  48691. get invertYAxis(): boolean;
  48692. set invertYAxis(value: boolean);
  48693. private _onGamepadConnectedObserver;
  48694. private _onGamepadDisconnectedObserver;
  48695. private _cameraTransform;
  48696. private _deltaTransform;
  48697. private _vector3;
  48698. private _vector2;
  48699. /**
  48700. * Attach the input controls to a specific dom element to get the input from.
  48701. */
  48702. attachControl(): void;
  48703. /**
  48704. * Detach the current controls from the specified dom element.
  48705. */
  48706. detachControl(): void;
  48707. /**
  48708. * Update the current camera state depending on the inputs that have been used this frame.
  48709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48710. */
  48711. checkInputs(): void;
  48712. /**
  48713. * Gets the class name of the current intput.
  48714. * @returns the class name
  48715. */
  48716. getClassName(): string;
  48717. /**
  48718. * Get the friendly name associated with the input class.
  48719. * @returns the input friendly name
  48720. */
  48721. getSimpleName(): string;
  48722. }
  48723. }
  48724. declare module BABYLON {
  48725. /**
  48726. * Defines the potential axis of a Joystick
  48727. */
  48728. export enum JoystickAxis {
  48729. /** X axis */
  48730. X = 0,
  48731. /** Y axis */
  48732. Y = 1,
  48733. /** Z axis */
  48734. Z = 2
  48735. }
  48736. /**
  48737. * Represents the different customization options available
  48738. * for VirtualJoystick
  48739. */
  48740. interface VirtualJoystickCustomizations {
  48741. /**
  48742. * Size of the joystick's puck
  48743. */
  48744. puckSize: number;
  48745. /**
  48746. * Size of the joystick's container
  48747. */
  48748. containerSize: number;
  48749. /**
  48750. * Color of the joystick && puck
  48751. */
  48752. color: string;
  48753. /**
  48754. * Image URL for the joystick's puck
  48755. */
  48756. puckImage?: string;
  48757. /**
  48758. * Image URL for the joystick's container
  48759. */
  48760. containerImage?: string;
  48761. /**
  48762. * Defines the unmoving position of the joystick container
  48763. */
  48764. position?: {
  48765. x: number;
  48766. y: number;
  48767. };
  48768. /**
  48769. * Defines whether or not the joystick container is always visible
  48770. */
  48771. alwaysVisible: boolean;
  48772. /**
  48773. * Defines whether or not to limit the movement of the puck to the joystick's container
  48774. */
  48775. limitToContainer: boolean;
  48776. }
  48777. /**
  48778. * Class used to define virtual joystick (used in touch mode)
  48779. */
  48780. export class VirtualJoystick {
  48781. /**
  48782. * Gets or sets a boolean indicating that left and right values must be inverted
  48783. */
  48784. reverseLeftRight: boolean;
  48785. /**
  48786. * Gets or sets a boolean indicating that up and down values must be inverted
  48787. */
  48788. reverseUpDown: boolean;
  48789. /**
  48790. * Gets the offset value for the position (ie. the change of the position value)
  48791. */
  48792. deltaPosition: Vector3;
  48793. /**
  48794. * Gets a boolean indicating if the virtual joystick was pressed
  48795. */
  48796. pressed: boolean;
  48797. /**
  48798. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48799. */
  48800. static Canvas: Nullable<HTMLCanvasElement>;
  48801. /**
  48802. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48803. */
  48804. limitToContainer: boolean;
  48805. private static _globalJoystickIndex;
  48806. private static _alwaysVisibleSticks;
  48807. private static vjCanvasContext;
  48808. private static vjCanvasWidth;
  48809. private static vjCanvasHeight;
  48810. private static halfWidth;
  48811. private static _GetDefaultOptions;
  48812. private _action;
  48813. private _axisTargetedByLeftAndRight;
  48814. private _axisTargetedByUpAndDown;
  48815. private _joystickSensibility;
  48816. private _inversedSensibility;
  48817. private _joystickPointerID;
  48818. private _joystickColor;
  48819. private _joystickPointerPos;
  48820. private _joystickPreviousPointerPos;
  48821. private _joystickPointerStartPos;
  48822. private _deltaJoystickVector;
  48823. private _leftJoystick;
  48824. private _touches;
  48825. private _joystickPosition;
  48826. private _alwaysVisible;
  48827. private _puckImage;
  48828. private _containerImage;
  48829. private _joystickPuckSize;
  48830. private _joystickContainerSize;
  48831. private _clearPuckSize;
  48832. private _clearContainerSize;
  48833. private _clearPuckSizeOffset;
  48834. private _clearContainerSizeOffset;
  48835. private _onPointerDownHandlerRef;
  48836. private _onPointerMoveHandlerRef;
  48837. private _onPointerUpHandlerRef;
  48838. private _onResize;
  48839. /**
  48840. * Creates a new virtual joystick
  48841. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48842. * @param customizations Defines the options we want to customize the VirtualJoystick
  48843. */
  48844. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48845. /**
  48846. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48847. * @param newJoystickSensibility defines the new sensibility
  48848. */
  48849. setJoystickSensibility(newJoystickSensibility: number): void;
  48850. private _onPointerDown;
  48851. private _onPointerMove;
  48852. private _onPointerUp;
  48853. /**
  48854. * Change the color of the virtual joystick
  48855. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48856. */
  48857. setJoystickColor(newColor: string): void;
  48858. /**
  48859. * Size of the joystick's container
  48860. */
  48861. set containerSize(newSize: number);
  48862. get containerSize(): number;
  48863. /**
  48864. * Size of the joystick's puck
  48865. */
  48866. set puckSize(newSize: number);
  48867. get puckSize(): number;
  48868. /**
  48869. * Clears the set position of the joystick
  48870. */
  48871. clearPosition(): void;
  48872. /**
  48873. * Defines whether or not the joystick container is always visible
  48874. */
  48875. set alwaysVisible(value: boolean);
  48876. get alwaysVisible(): boolean;
  48877. /**
  48878. * Sets the constant position of the Joystick container
  48879. * @param x X axis coordinate
  48880. * @param y Y axis coordinate
  48881. */
  48882. setPosition(x: number, y: number): void;
  48883. /**
  48884. * Defines a callback to call when the joystick is touched
  48885. * @param action defines the callback
  48886. */
  48887. setActionOnTouch(action: () => any): void;
  48888. /**
  48889. * Defines which axis you'd like to control for left & right
  48890. * @param axis defines the axis to use
  48891. */
  48892. setAxisForLeftRight(axis: JoystickAxis): void;
  48893. /**
  48894. * Defines which axis you'd like to control for up & down
  48895. * @param axis defines the axis to use
  48896. */
  48897. setAxisForUpDown(axis: JoystickAxis): void;
  48898. /**
  48899. * Clears the canvas from the previous puck / container draw
  48900. */
  48901. private _clearPreviousDraw;
  48902. /**
  48903. * Loads `urlPath` to be used for the container's image
  48904. * @param urlPath defines the urlPath of an image to use
  48905. */
  48906. setContainerImage(urlPath: string): void;
  48907. /**
  48908. * Loads `urlPath` to be used for the puck's image
  48909. * @param urlPath defines the urlPath of an image to use
  48910. */
  48911. setPuckImage(urlPath: string): void;
  48912. /**
  48913. * Draws the Virtual Joystick's container
  48914. */
  48915. private _drawContainer;
  48916. /**
  48917. * Draws the Virtual Joystick's puck
  48918. */
  48919. private _drawPuck;
  48920. private _drawVirtualJoystick;
  48921. /**
  48922. * Release internal HTML canvas
  48923. */
  48924. releaseCanvas(): void;
  48925. }
  48926. }
  48927. declare module BABYLON {
  48928. interface FreeCameraInputsManager {
  48929. /**
  48930. * Add virtual joystick input support to the input manager.
  48931. * @returns the current input manager
  48932. */
  48933. addVirtualJoystick(): FreeCameraInputsManager;
  48934. }
  48935. /**
  48936. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48937. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48938. */
  48939. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48940. /**
  48941. * Defines the camera the input is attached to.
  48942. */
  48943. camera: FreeCamera;
  48944. private _leftjoystick;
  48945. private _rightjoystick;
  48946. /**
  48947. * Gets the left stick of the virtual joystick.
  48948. * @returns The virtual Joystick
  48949. */
  48950. getLeftJoystick(): VirtualJoystick;
  48951. /**
  48952. * Gets the right stick of the virtual joystick.
  48953. * @returns The virtual Joystick
  48954. */
  48955. getRightJoystick(): VirtualJoystick;
  48956. /**
  48957. * Update the current camera state depending on the inputs that have been used this frame.
  48958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48959. */
  48960. checkInputs(): void;
  48961. /**
  48962. * Attach the input controls to a specific dom element to get the input from.
  48963. */
  48964. attachControl(): void;
  48965. /**
  48966. * Detach the current controls from the specified dom element.
  48967. */
  48968. detachControl(): void;
  48969. /**
  48970. * Gets the class name of the current intput.
  48971. * @returns the class name
  48972. */
  48973. getClassName(): string;
  48974. /**
  48975. * Get the friendly name associated with the input class.
  48976. * @returns the input friendly name
  48977. */
  48978. getSimpleName(): string;
  48979. }
  48980. }
  48981. declare module BABYLON {
  48982. /**
  48983. * This represents a FPS type of camera controlled by touch.
  48984. * This is like a universal camera minus the Gamepad controls.
  48985. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48986. */
  48987. export class TouchCamera extends FreeCamera {
  48988. /**
  48989. * Defines the touch sensibility for rotation.
  48990. * The higher the faster.
  48991. */
  48992. get touchAngularSensibility(): number;
  48993. set touchAngularSensibility(value: number);
  48994. /**
  48995. * Defines the touch sensibility for move.
  48996. * The higher the faster.
  48997. */
  48998. get touchMoveSensibility(): number;
  48999. set touchMoveSensibility(value: number);
  49000. /**
  49001. * Instantiates a new touch camera.
  49002. * This represents a FPS type of camera controlled by touch.
  49003. * This is like a universal camera minus the Gamepad controls.
  49004. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49005. * @param name Define the name of the camera in the scene
  49006. * @param position Define the start position of the camera in the scene
  49007. * @param scene Define the scene the camera belongs to
  49008. */
  49009. constructor(name: string, position: Vector3, scene: Scene);
  49010. /**
  49011. * Gets the current object class name.
  49012. * @return the class name
  49013. */
  49014. getClassName(): string;
  49015. /** @hidden */
  49016. _setupInputs(): void;
  49017. }
  49018. }
  49019. declare module BABYLON {
  49020. /**
  49021. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  49022. * being tilted forward or back and left or right.
  49023. */
  49024. export class DeviceOrientationCamera extends FreeCamera {
  49025. private _initialQuaternion;
  49026. private _quaternionCache;
  49027. private _tmpDragQuaternion;
  49028. private _disablePointerInputWhenUsingDeviceOrientation;
  49029. /**
  49030. * Creates a new device orientation camera
  49031. * @param name The name of the camera
  49032. * @param position The start position camera
  49033. * @param scene The scene the camera belongs to
  49034. */
  49035. constructor(name: string, position: Vector3, scene: Scene);
  49036. /**
  49037. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  49038. */
  49039. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  49040. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  49041. private _dragFactor;
  49042. /**
  49043. * Enabled turning on the y axis when the orientation sensor is active
  49044. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49045. */
  49046. enableHorizontalDragging(dragFactor?: number): void;
  49047. /**
  49048. * Gets the current instance class name ("DeviceOrientationCamera").
  49049. * This helps avoiding instanceof at run time.
  49050. * @returns the class name
  49051. */
  49052. getClassName(): string;
  49053. /**
  49054. * @hidden
  49055. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49056. */
  49057. _checkInputs(): void;
  49058. /**
  49059. * Reset the camera to its default orientation on the specified axis only.
  49060. * @param axis The axis to reset
  49061. */
  49062. resetToCurrentRotation(axis?: Axis): void;
  49063. }
  49064. }
  49065. declare module BABYLON {
  49066. /**
  49067. * Defines supported buttons for XBox360 compatible gamepads
  49068. */
  49069. export enum Xbox360Button {
  49070. /** A */
  49071. A = 0,
  49072. /** B */
  49073. B = 1,
  49074. /** X */
  49075. X = 2,
  49076. /** Y */
  49077. Y = 3,
  49078. /** Left button */
  49079. LB = 4,
  49080. /** Right button */
  49081. RB = 5,
  49082. /** Back */
  49083. Back = 8,
  49084. /** Start */
  49085. Start = 9,
  49086. /** Left stick */
  49087. LeftStick = 10,
  49088. /** Right stick */
  49089. RightStick = 11
  49090. }
  49091. /** Defines values for XBox360 DPad */
  49092. export enum Xbox360Dpad {
  49093. /** Up */
  49094. Up = 12,
  49095. /** Down */
  49096. Down = 13,
  49097. /** Left */
  49098. Left = 14,
  49099. /** Right */
  49100. Right = 15
  49101. }
  49102. /**
  49103. * Defines a XBox360 gamepad
  49104. */
  49105. export class Xbox360Pad extends Gamepad {
  49106. private _leftTrigger;
  49107. private _rightTrigger;
  49108. private _onlefttriggerchanged;
  49109. private _onrighttriggerchanged;
  49110. private _onbuttondown;
  49111. private _onbuttonup;
  49112. private _ondpaddown;
  49113. private _ondpadup;
  49114. /** Observable raised when a button is pressed */
  49115. onButtonDownObservable: Observable<Xbox360Button>;
  49116. /** Observable raised when a button is released */
  49117. onButtonUpObservable: Observable<Xbox360Button>;
  49118. /** Observable raised when a pad is pressed */
  49119. onPadDownObservable: Observable<Xbox360Dpad>;
  49120. /** Observable raised when a pad is released */
  49121. onPadUpObservable: Observable<Xbox360Dpad>;
  49122. private _buttonA;
  49123. private _buttonB;
  49124. private _buttonX;
  49125. private _buttonY;
  49126. private _buttonBack;
  49127. private _buttonStart;
  49128. private _buttonLB;
  49129. private _buttonRB;
  49130. private _buttonLeftStick;
  49131. private _buttonRightStick;
  49132. private _dPadUp;
  49133. private _dPadDown;
  49134. private _dPadLeft;
  49135. private _dPadRight;
  49136. private _isXboxOnePad;
  49137. /**
  49138. * Creates a new XBox360 gamepad object
  49139. * @param id defines the id of this gamepad
  49140. * @param index defines its index
  49141. * @param gamepad defines the internal HTML gamepad object
  49142. * @param xboxOne defines if it is a XBox One gamepad
  49143. */
  49144. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49145. /**
  49146. * Defines the callback to call when left trigger is pressed
  49147. * @param callback defines the callback to use
  49148. */
  49149. onlefttriggerchanged(callback: (value: number) => void): void;
  49150. /**
  49151. * Defines the callback to call when right trigger is pressed
  49152. * @param callback defines the callback to use
  49153. */
  49154. onrighttriggerchanged(callback: (value: number) => void): void;
  49155. /**
  49156. * Gets the left trigger value
  49157. */
  49158. get leftTrigger(): number;
  49159. /**
  49160. * Sets the left trigger value
  49161. */
  49162. set leftTrigger(newValue: number);
  49163. /**
  49164. * Gets the right trigger value
  49165. */
  49166. get rightTrigger(): number;
  49167. /**
  49168. * Sets the right trigger value
  49169. */
  49170. set rightTrigger(newValue: number);
  49171. /**
  49172. * Defines the callback to call when a button is pressed
  49173. * @param callback defines the callback to use
  49174. */
  49175. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49176. /**
  49177. * Defines the callback to call when a button is released
  49178. * @param callback defines the callback to use
  49179. */
  49180. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49181. /**
  49182. * Defines the callback to call when a pad is pressed
  49183. * @param callback defines the callback to use
  49184. */
  49185. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49186. /**
  49187. * Defines the callback to call when a pad is released
  49188. * @param callback defines the callback to use
  49189. */
  49190. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49191. private _setButtonValue;
  49192. private _setDPadValue;
  49193. /**
  49194. * Gets the value of the `A` button
  49195. */
  49196. get buttonA(): number;
  49197. /**
  49198. * Sets the value of the `A` button
  49199. */
  49200. set buttonA(value: number);
  49201. /**
  49202. * Gets the value of the `B` button
  49203. */
  49204. get buttonB(): number;
  49205. /**
  49206. * Sets the value of the `B` button
  49207. */
  49208. set buttonB(value: number);
  49209. /**
  49210. * Gets the value of the `X` button
  49211. */
  49212. get buttonX(): number;
  49213. /**
  49214. * Sets the value of the `X` button
  49215. */
  49216. set buttonX(value: number);
  49217. /**
  49218. * Gets the value of the `Y` button
  49219. */
  49220. get buttonY(): number;
  49221. /**
  49222. * Sets the value of the `Y` button
  49223. */
  49224. set buttonY(value: number);
  49225. /**
  49226. * Gets the value of the `Start` button
  49227. */
  49228. get buttonStart(): number;
  49229. /**
  49230. * Sets the value of the `Start` button
  49231. */
  49232. set buttonStart(value: number);
  49233. /**
  49234. * Gets the value of the `Back` button
  49235. */
  49236. get buttonBack(): number;
  49237. /**
  49238. * Sets the value of the `Back` button
  49239. */
  49240. set buttonBack(value: number);
  49241. /**
  49242. * Gets the value of the `Left` button
  49243. */
  49244. get buttonLB(): number;
  49245. /**
  49246. * Sets the value of the `Left` button
  49247. */
  49248. set buttonLB(value: number);
  49249. /**
  49250. * Gets the value of the `Right` button
  49251. */
  49252. get buttonRB(): number;
  49253. /**
  49254. * Sets the value of the `Right` button
  49255. */
  49256. set buttonRB(value: number);
  49257. /**
  49258. * Gets the value of the Left joystick
  49259. */
  49260. get buttonLeftStick(): number;
  49261. /**
  49262. * Sets the value of the Left joystick
  49263. */
  49264. set buttonLeftStick(value: number);
  49265. /**
  49266. * Gets the value of the Right joystick
  49267. */
  49268. get buttonRightStick(): number;
  49269. /**
  49270. * Sets the value of the Right joystick
  49271. */
  49272. set buttonRightStick(value: number);
  49273. /**
  49274. * Gets the value of D-pad up
  49275. */
  49276. get dPadUp(): number;
  49277. /**
  49278. * Sets the value of D-pad up
  49279. */
  49280. set dPadUp(value: number);
  49281. /**
  49282. * Gets the value of D-pad down
  49283. */
  49284. get dPadDown(): number;
  49285. /**
  49286. * Sets the value of D-pad down
  49287. */
  49288. set dPadDown(value: number);
  49289. /**
  49290. * Gets the value of D-pad left
  49291. */
  49292. get dPadLeft(): number;
  49293. /**
  49294. * Sets the value of D-pad left
  49295. */
  49296. set dPadLeft(value: number);
  49297. /**
  49298. * Gets the value of D-pad right
  49299. */
  49300. get dPadRight(): number;
  49301. /**
  49302. * Sets the value of D-pad right
  49303. */
  49304. set dPadRight(value: number);
  49305. /**
  49306. * Force the gamepad to synchronize with device values
  49307. */
  49308. update(): void;
  49309. /**
  49310. * Disposes the gamepad
  49311. */
  49312. dispose(): void;
  49313. }
  49314. }
  49315. declare module BABYLON {
  49316. /**
  49317. * Defines supported buttons for DualShock compatible gamepads
  49318. */
  49319. export enum DualShockButton {
  49320. /** Cross */
  49321. Cross = 0,
  49322. /** Circle */
  49323. Circle = 1,
  49324. /** Square */
  49325. Square = 2,
  49326. /** Triangle */
  49327. Triangle = 3,
  49328. /** L1 */
  49329. L1 = 4,
  49330. /** R1 */
  49331. R1 = 5,
  49332. /** Share */
  49333. Share = 8,
  49334. /** Options */
  49335. Options = 9,
  49336. /** Left stick */
  49337. LeftStick = 10,
  49338. /** Right stick */
  49339. RightStick = 11
  49340. }
  49341. /** Defines values for DualShock DPad */
  49342. export enum DualShockDpad {
  49343. /** Up */
  49344. Up = 12,
  49345. /** Down */
  49346. Down = 13,
  49347. /** Left */
  49348. Left = 14,
  49349. /** Right */
  49350. Right = 15
  49351. }
  49352. /**
  49353. * Defines a DualShock gamepad
  49354. */
  49355. export class DualShockPad extends Gamepad {
  49356. private _leftTrigger;
  49357. private _rightTrigger;
  49358. private _onlefttriggerchanged;
  49359. private _onrighttriggerchanged;
  49360. private _onbuttondown;
  49361. private _onbuttonup;
  49362. private _ondpaddown;
  49363. private _ondpadup;
  49364. /** Observable raised when a button is pressed */
  49365. onButtonDownObservable: Observable<DualShockButton>;
  49366. /** Observable raised when a button is released */
  49367. onButtonUpObservable: Observable<DualShockButton>;
  49368. /** Observable raised when a pad is pressed */
  49369. onPadDownObservable: Observable<DualShockDpad>;
  49370. /** Observable raised when a pad is released */
  49371. onPadUpObservable: Observable<DualShockDpad>;
  49372. private _buttonCross;
  49373. private _buttonCircle;
  49374. private _buttonSquare;
  49375. private _buttonTriangle;
  49376. private _buttonShare;
  49377. private _buttonOptions;
  49378. private _buttonL1;
  49379. private _buttonR1;
  49380. private _buttonLeftStick;
  49381. private _buttonRightStick;
  49382. private _dPadUp;
  49383. private _dPadDown;
  49384. private _dPadLeft;
  49385. private _dPadRight;
  49386. /**
  49387. * Creates a new DualShock gamepad object
  49388. * @param id defines the id of this gamepad
  49389. * @param index defines its index
  49390. * @param gamepad defines the internal HTML gamepad object
  49391. */
  49392. constructor(id: string, index: number, gamepad: any);
  49393. /**
  49394. * Defines the callback to call when left trigger is pressed
  49395. * @param callback defines the callback to use
  49396. */
  49397. onlefttriggerchanged(callback: (value: number) => void): void;
  49398. /**
  49399. * Defines the callback to call when right trigger is pressed
  49400. * @param callback defines the callback to use
  49401. */
  49402. onrighttriggerchanged(callback: (value: number) => void): void;
  49403. /**
  49404. * Gets the left trigger value
  49405. */
  49406. get leftTrigger(): number;
  49407. /**
  49408. * Sets the left trigger value
  49409. */
  49410. set leftTrigger(newValue: number);
  49411. /**
  49412. * Gets the right trigger value
  49413. */
  49414. get rightTrigger(): number;
  49415. /**
  49416. * Sets the right trigger value
  49417. */
  49418. set rightTrigger(newValue: number);
  49419. /**
  49420. * Defines the callback to call when a button is pressed
  49421. * @param callback defines the callback to use
  49422. */
  49423. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49424. /**
  49425. * Defines the callback to call when a button is released
  49426. * @param callback defines the callback to use
  49427. */
  49428. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49429. /**
  49430. * Defines the callback to call when a pad is pressed
  49431. * @param callback defines the callback to use
  49432. */
  49433. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49434. /**
  49435. * Defines the callback to call when a pad is released
  49436. * @param callback defines the callback to use
  49437. */
  49438. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49439. private _setButtonValue;
  49440. private _setDPadValue;
  49441. /**
  49442. * Gets the value of the `Cross` button
  49443. */
  49444. get buttonCross(): number;
  49445. /**
  49446. * Sets the value of the `Cross` button
  49447. */
  49448. set buttonCross(value: number);
  49449. /**
  49450. * Gets the value of the `Circle` button
  49451. */
  49452. get buttonCircle(): number;
  49453. /**
  49454. * Sets the value of the `Circle` button
  49455. */
  49456. set buttonCircle(value: number);
  49457. /**
  49458. * Gets the value of the `Square` button
  49459. */
  49460. get buttonSquare(): number;
  49461. /**
  49462. * Sets the value of the `Square` button
  49463. */
  49464. set buttonSquare(value: number);
  49465. /**
  49466. * Gets the value of the `Triangle` button
  49467. */
  49468. get buttonTriangle(): number;
  49469. /**
  49470. * Sets the value of the `Triangle` button
  49471. */
  49472. set buttonTriangle(value: number);
  49473. /**
  49474. * Gets the value of the `Options` button
  49475. */
  49476. get buttonOptions(): number;
  49477. /**
  49478. * Sets the value of the `Options` button
  49479. */
  49480. set buttonOptions(value: number);
  49481. /**
  49482. * Gets the value of the `Share` button
  49483. */
  49484. get buttonShare(): number;
  49485. /**
  49486. * Sets the value of the `Share` button
  49487. */
  49488. set buttonShare(value: number);
  49489. /**
  49490. * Gets the value of the `L1` button
  49491. */
  49492. get buttonL1(): number;
  49493. /**
  49494. * Sets the value of the `L1` button
  49495. */
  49496. set buttonL1(value: number);
  49497. /**
  49498. * Gets the value of the `R1` button
  49499. */
  49500. get buttonR1(): number;
  49501. /**
  49502. * Sets the value of the `R1` button
  49503. */
  49504. set buttonR1(value: number);
  49505. /**
  49506. * Gets the value of the Left joystick
  49507. */
  49508. get buttonLeftStick(): number;
  49509. /**
  49510. * Sets the value of the Left joystick
  49511. */
  49512. set buttonLeftStick(value: number);
  49513. /**
  49514. * Gets the value of the Right joystick
  49515. */
  49516. get buttonRightStick(): number;
  49517. /**
  49518. * Sets the value of the Right joystick
  49519. */
  49520. set buttonRightStick(value: number);
  49521. /**
  49522. * Gets the value of D-pad up
  49523. */
  49524. get dPadUp(): number;
  49525. /**
  49526. * Sets the value of D-pad up
  49527. */
  49528. set dPadUp(value: number);
  49529. /**
  49530. * Gets the value of D-pad down
  49531. */
  49532. get dPadDown(): number;
  49533. /**
  49534. * Sets the value of D-pad down
  49535. */
  49536. set dPadDown(value: number);
  49537. /**
  49538. * Gets the value of D-pad left
  49539. */
  49540. get dPadLeft(): number;
  49541. /**
  49542. * Sets the value of D-pad left
  49543. */
  49544. set dPadLeft(value: number);
  49545. /**
  49546. * Gets the value of D-pad right
  49547. */
  49548. get dPadRight(): number;
  49549. /**
  49550. * Sets the value of D-pad right
  49551. */
  49552. set dPadRight(value: number);
  49553. /**
  49554. * Force the gamepad to synchronize with device values
  49555. */
  49556. update(): void;
  49557. /**
  49558. * Disposes the gamepad
  49559. */
  49560. dispose(): void;
  49561. }
  49562. }
  49563. declare module BABYLON {
  49564. /**
  49565. * Manager for handling gamepads
  49566. */
  49567. export class GamepadManager {
  49568. private _scene?;
  49569. private _babylonGamepads;
  49570. private _oneGamepadConnected;
  49571. /** @hidden */
  49572. _isMonitoring: boolean;
  49573. private _gamepadEventSupported;
  49574. private _gamepadSupport?;
  49575. /**
  49576. * observable to be triggered when the gamepad controller has been connected
  49577. */
  49578. onGamepadConnectedObservable: Observable<Gamepad>;
  49579. /**
  49580. * observable to be triggered when the gamepad controller has been disconnected
  49581. */
  49582. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49583. private _onGamepadConnectedEvent;
  49584. private _onGamepadDisconnectedEvent;
  49585. /**
  49586. * Initializes the gamepad manager
  49587. * @param _scene BabylonJS scene
  49588. */
  49589. constructor(_scene?: Scene | undefined);
  49590. /**
  49591. * The gamepads in the game pad manager
  49592. */
  49593. get gamepads(): Gamepad[];
  49594. /**
  49595. * Get the gamepad controllers based on type
  49596. * @param type The type of gamepad controller
  49597. * @returns Nullable gamepad
  49598. */
  49599. getGamepadByType(type?: number): Nullable<Gamepad>;
  49600. /**
  49601. * Disposes the gamepad manager
  49602. */
  49603. dispose(): void;
  49604. private _addNewGamepad;
  49605. private _startMonitoringGamepads;
  49606. private _stopMonitoringGamepads;
  49607. /** @hidden */
  49608. _checkGamepadsStatus(): void;
  49609. private _updateGamepadObjects;
  49610. }
  49611. }
  49612. declare module BABYLON {
  49613. interface Scene {
  49614. /** @hidden */
  49615. _gamepadManager: Nullable<GamepadManager>;
  49616. /**
  49617. * Gets the gamepad manager associated with the scene
  49618. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49619. */
  49620. gamepadManager: GamepadManager;
  49621. }
  49622. /**
  49623. * Interface representing a free camera inputs manager
  49624. */
  49625. interface FreeCameraInputsManager {
  49626. /**
  49627. * Adds gamepad input support to the FreeCameraInputsManager.
  49628. * @returns the FreeCameraInputsManager
  49629. */
  49630. addGamepad(): FreeCameraInputsManager;
  49631. }
  49632. /**
  49633. * Interface representing an arc rotate camera inputs manager
  49634. */
  49635. interface ArcRotateCameraInputsManager {
  49636. /**
  49637. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49638. * @returns the camera inputs manager
  49639. */
  49640. addGamepad(): ArcRotateCameraInputsManager;
  49641. }
  49642. /**
  49643. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49644. */
  49645. export class GamepadSystemSceneComponent implements ISceneComponent {
  49646. /**
  49647. * The component name helpfull to identify the component in the list of scene components.
  49648. */
  49649. readonly name: string;
  49650. /**
  49651. * The scene the component belongs to.
  49652. */
  49653. scene: Scene;
  49654. /**
  49655. * Creates a new instance of the component for the given scene
  49656. * @param scene Defines the scene to register the component in
  49657. */
  49658. constructor(scene: Scene);
  49659. /**
  49660. * Registers the component in a given scene
  49661. */
  49662. register(): void;
  49663. /**
  49664. * Rebuilds the elements related to this component in case of
  49665. * context lost for instance.
  49666. */
  49667. rebuild(): void;
  49668. /**
  49669. * Disposes the component and the associated ressources
  49670. */
  49671. dispose(): void;
  49672. private _beforeCameraUpdate;
  49673. }
  49674. }
  49675. declare module BABYLON {
  49676. /**
  49677. * 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,
  49678. * which still works and will still be found in many Playgrounds.
  49679. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49680. */
  49681. export class UniversalCamera extends TouchCamera {
  49682. /**
  49683. * Defines the gamepad rotation sensiblity.
  49684. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49685. */
  49686. get gamepadAngularSensibility(): number;
  49687. set gamepadAngularSensibility(value: number);
  49688. /**
  49689. * Defines the gamepad move sensiblity.
  49690. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49691. */
  49692. get gamepadMoveSensibility(): number;
  49693. set gamepadMoveSensibility(value: number);
  49694. /**
  49695. * 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,
  49696. * which still works and will still be found in many Playgrounds.
  49697. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49698. * @param name Define the name of the camera in the scene
  49699. * @param position Define the start position of the camera in the scene
  49700. * @param scene Define the scene the camera belongs to
  49701. */
  49702. constructor(name: string, position: Vector3, scene: Scene);
  49703. /**
  49704. * Gets the current object class name.
  49705. * @return the class name
  49706. */
  49707. getClassName(): string;
  49708. }
  49709. }
  49710. declare module BABYLON {
  49711. /**
  49712. * This represents a FPS type of camera. This is only here for back compat purpose.
  49713. * Please use the UniversalCamera instead as both are identical.
  49714. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49715. */
  49716. export class GamepadCamera extends UniversalCamera {
  49717. /**
  49718. * Instantiates a new Gamepad Camera
  49719. * This represents a FPS type of camera. This is only here for back compat purpose.
  49720. * Please use the UniversalCamera instead as both are identical.
  49721. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49722. * @param name Define the name of the camera in the scene
  49723. * @param position Define the start position of the camera in the scene
  49724. * @param scene Define the scene the camera belongs to
  49725. */
  49726. constructor(name: string, position: Vector3, scene: Scene);
  49727. /**
  49728. * Gets the current object class name.
  49729. * @return the class name
  49730. */
  49731. getClassName(): string;
  49732. }
  49733. }
  49734. declare module BABYLON {
  49735. /** @hidden */
  49736. export var passPixelShader: {
  49737. name: string;
  49738. shader: string;
  49739. };
  49740. }
  49741. declare module BABYLON {
  49742. /** @hidden */
  49743. export var passCubePixelShader: {
  49744. name: string;
  49745. shader: string;
  49746. };
  49747. }
  49748. declare module BABYLON {
  49749. /**
  49750. * PassPostProcess which produces an output the same as it's input
  49751. */
  49752. export class PassPostProcess extends PostProcess {
  49753. /**
  49754. * Gets a string identifying the name of the class
  49755. * @returns "PassPostProcess" string
  49756. */
  49757. getClassName(): string;
  49758. /**
  49759. * Creates the PassPostProcess
  49760. * @param name The name of the effect.
  49761. * @param options The required width/height ratio to downsize to before computing the render pass.
  49762. * @param camera The camera to apply the render pass to.
  49763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49764. * @param engine The engine which the post process will be applied. (default: current engine)
  49765. * @param reusable If the post process can be reused on the same frame. (default: false)
  49766. * @param textureType The type of texture to be used when performing the post processing.
  49767. * @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)
  49768. */
  49769. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49770. /** @hidden */
  49771. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49772. }
  49773. /**
  49774. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49775. */
  49776. export class PassCubePostProcess extends PostProcess {
  49777. private _face;
  49778. /**
  49779. * Gets or sets the cube face to display.
  49780. * * 0 is +X
  49781. * * 1 is -X
  49782. * * 2 is +Y
  49783. * * 3 is -Y
  49784. * * 4 is +Z
  49785. * * 5 is -Z
  49786. */
  49787. get face(): number;
  49788. set face(value: number);
  49789. /**
  49790. * Gets a string identifying the name of the class
  49791. * @returns "PassCubePostProcess" string
  49792. */
  49793. getClassName(): string;
  49794. /**
  49795. * Creates the PassCubePostProcess
  49796. * @param name The name of the effect.
  49797. * @param options The required width/height ratio to downsize to before computing the render pass.
  49798. * @param camera The camera to apply the render pass to.
  49799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49800. * @param engine The engine which the post process will be applied. (default: current engine)
  49801. * @param reusable If the post process can be reused on the same frame. (default: false)
  49802. * @param textureType The type of texture to be used when performing the post processing.
  49803. * @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)
  49804. */
  49805. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49806. /** @hidden */
  49807. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49808. }
  49809. }
  49810. declare module BABYLON {
  49811. /** @hidden */
  49812. export var anaglyphPixelShader: {
  49813. name: string;
  49814. shader: string;
  49815. };
  49816. }
  49817. declare module BABYLON {
  49818. /**
  49819. * Postprocess used to generate anaglyphic rendering
  49820. */
  49821. export class AnaglyphPostProcess extends PostProcess {
  49822. private _passedProcess;
  49823. /**
  49824. * Gets a string identifying the name of the class
  49825. * @returns "AnaglyphPostProcess" string
  49826. */
  49827. getClassName(): string;
  49828. /**
  49829. * Creates a new AnaglyphPostProcess
  49830. * @param name defines postprocess name
  49831. * @param options defines creation options or target ratio scale
  49832. * @param rigCameras defines cameras using this postprocess
  49833. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49834. * @param engine defines hosting engine
  49835. * @param reusable defines if the postprocess will be reused multiple times per frame
  49836. */
  49837. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49838. }
  49839. }
  49840. declare module BABYLON {
  49841. /**
  49842. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49843. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49844. */
  49845. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49846. /**
  49847. * Creates a new AnaglyphArcRotateCamera
  49848. * @param name defines camera name
  49849. * @param alpha defines alpha angle (in radians)
  49850. * @param beta defines beta angle (in radians)
  49851. * @param radius defines radius
  49852. * @param target defines camera target
  49853. * @param interaxialDistance defines distance between each color axis
  49854. * @param scene defines the hosting scene
  49855. */
  49856. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49857. /**
  49858. * Gets camera class name
  49859. * @returns AnaglyphArcRotateCamera
  49860. */
  49861. getClassName(): string;
  49862. }
  49863. }
  49864. declare module BABYLON {
  49865. /**
  49866. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49867. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49868. */
  49869. export class AnaglyphFreeCamera extends FreeCamera {
  49870. /**
  49871. * Creates a new AnaglyphFreeCamera
  49872. * @param name defines camera name
  49873. * @param position defines initial position
  49874. * @param interaxialDistance defines distance between each color axis
  49875. * @param scene defines the hosting scene
  49876. */
  49877. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49878. /**
  49879. * Gets camera class name
  49880. * @returns AnaglyphFreeCamera
  49881. */
  49882. getClassName(): string;
  49883. }
  49884. }
  49885. declare module BABYLON {
  49886. /**
  49887. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49888. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49889. */
  49890. export class AnaglyphGamepadCamera extends GamepadCamera {
  49891. /**
  49892. * Creates a new AnaglyphGamepadCamera
  49893. * @param name defines camera name
  49894. * @param position defines initial position
  49895. * @param interaxialDistance defines distance between each color axis
  49896. * @param scene defines the hosting scene
  49897. */
  49898. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49899. /**
  49900. * Gets camera class name
  49901. * @returns AnaglyphGamepadCamera
  49902. */
  49903. getClassName(): string;
  49904. }
  49905. }
  49906. declare module BABYLON {
  49907. /**
  49908. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49909. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49910. */
  49911. export class AnaglyphUniversalCamera extends UniversalCamera {
  49912. /**
  49913. * Creates a new AnaglyphUniversalCamera
  49914. * @param name defines camera name
  49915. * @param position defines initial position
  49916. * @param interaxialDistance defines distance between each color axis
  49917. * @param scene defines the hosting scene
  49918. */
  49919. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49920. /**
  49921. * Gets camera class name
  49922. * @returns AnaglyphUniversalCamera
  49923. */
  49924. getClassName(): string;
  49925. }
  49926. }
  49927. declare module BABYLON {
  49928. /**
  49929. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49930. * @see https://doc.babylonjs.com/features/cameras
  49931. */
  49932. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49933. /**
  49934. * Creates a new StereoscopicArcRotateCamera
  49935. * @param name defines camera name
  49936. * @param alpha defines alpha angle (in radians)
  49937. * @param beta defines beta angle (in radians)
  49938. * @param radius defines radius
  49939. * @param target defines camera target
  49940. * @param interaxialDistance defines distance between each color axis
  49941. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49942. * @param scene defines the hosting scene
  49943. */
  49944. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49945. /**
  49946. * Gets camera class name
  49947. * @returns StereoscopicArcRotateCamera
  49948. */
  49949. getClassName(): string;
  49950. }
  49951. }
  49952. declare module BABYLON {
  49953. /**
  49954. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49955. * @see https://doc.babylonjs.com/features/cameras
  49956. */
  49957. export class StereoscopicFreeCamera extends FreeCamera {
  49958. /**
  49959. * Creates a new StereoscopicFreeCamera
  49960. * @param name defines camera name
  49961. * @param position defines initial position
  49962. * @param interaxialDistance defines distance between each color axis
  49963. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49964. * @param scene defines the hosting scene
  49965. */
  49966. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49967. /**
  49968. * Gets camera class name
  49969. * @returns StereoscopicFreeCamera
  49970. */
  49971. getClassName(): string;
  49972. }
  49973. }
  49974. declare module BABYLON {
  49975. /**
  49976. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49977. * @see https://doc.babylonjs.com/features/cameras
  49978. */
  49979. export class StereoscopicGamepadCamera extends GamepadCamera {
  49980. /**
  49981. * Creates a new StereoscopicGamepadCamera
  49982. * @param name defines camera name
  49983. * @param position defines initial position
  49984. * @param interaxialDistance defines distance between each color axis
  49985. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49986. * @param scene defines the hosting scene
  49987. */
  49988. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49989. /**
  49990. * Gets camera class name
  49991. * @returns StereoscopicGamepadCamera
  49992. */
  49993. getClassName(): string;
  49994. }
  49995. }
  49996. declare module BABYLON {
  49997. /**
  49998. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49999. * @see https://doc.babylonjs.com/features/cameras
  50000. */
  50001. export class StereoscopicUniversalCamera extends UniversalCamera {
  50002. /**
  50003. * Creates a new StereoscopicUniversalCamera
  50004. * @param name defines camera name
  50005. * @param position defines initial position
  50006. * @param interaxialDistance defines distance between each color axis
  50007. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  50008. * @param scene defines the hosting scene
  50009. */
  50010. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  50011. /**
  50012. * Gets camera class name
  50013. * @returns StereoscopicUniversalCamera
  50014. */
  50015. getClassName(): string;
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. /**
  50020. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  50021. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50022. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50023. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50024. */
  50025. export class VirtualJoysticksCamera extends FreeCamera {
  50026. /**
  50027. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  50028. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50029. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50030. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50031. * @param name Define the name of the camera in the scene
  50032. * @param position Define the start position of the camera in the scene
  50033. * @param scene Define the scene the camera belongs to
  50034. */
  50035. constructor(name: string, position: Vector3, scene: Scene);
  50036. /**
  50037. * Gets the current object class name.
  50038. * @return the class name
  50039. */
  50040. getClassName(): string;
  50041. }
  50042. }
  50043. declare module BABYLON {
  50044. /**
  50045. * This represents all the required metrics to create a VR camera.
  50046. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50047. */
  50048. export class VRCameraMetrics {
  50049. /**
  50050. * Define the horizontal resolution off the screen.
  50051. */
  50052. hResolution: number;
  50053. /**
  50054. * Define the vertical resolution off the screen.
  50055. */
  50056. vResolution: number;
  50057. /**
  50058. * Define the horizontal screen size.
  50059. */
  50060. hScreenSize: number;
  50061. /**
  50062. * Define the vertical screen size.
  50063. */
  50064. vScreenSize: number;
  50065. /**
  50066. * Define the vertical screen center position.
  50067. */
  50068. vScreenCenter: number;
  50069. /**
  50070. * Define the distance of the eyes to the screen.
  50071. */
  50072. eyeToScreenDistance: number;
  50073. /**
  50074. * Define the distance between both lenses
  50075. */
  50076. lensSeparationDistance: number;
  50077. /**
  50078. * Define the distance between both viewer's eyes.
  50079. */
  50080. interpupillaryDistance: number;
  50081. /**
  50082. * Define the distortion factor of the VR postprocess.
  50083. * Please, touch with care.
  50084. */
  50085. distortionK: number[];
  50086. /**
  50087. * Define the chromatic aberration correction factors for the VR post process.
  50088. */
  50089. chromaAbCorrection: number[];
  50090. /**
  50091. * Define the scale factor of the post process.
  50092. * The smaller the better but the slower.
  50093. */
  50094. postProcessScaleFactor: number;
  50095. /**
  50096. * Define an offset for the lens center.
  50097. */
  50098. lensCenterOffset: number;
  50099. /**
  50100. * Define if the current vr camera should compensate the distortion of the lense or not.
  50101. */
  50102. compensateDistortion: boolean;
  50103. /**
  50104. * Defines if multiview should be enabled when rendering (Default: false)
  50105. */
  50106. multiviewEnabled: boolean;
  50107. /**
  50108. * Gets the rendering aspect ratio based on the provided resolutions.
  50109. */
  50110. get aspectRatio(): number;
  50111. /**
  50112. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50113. */
  50114. get aspectRatioFov(): number;
  50115. /**
  50116. * @hidden
  50117. */
  50118. get leftHMatrix(): Matrix;
  50119. /**
  50120. * @hidden
  50121. */
  50122. get rightHMatrix(): Matrix;
  50123. /**
  50124. * @hidden
  50125. */
  50126. get leftPreViewMatrix(): Matrix;
  50127. /**
  50128. * @hidden
  50129. */
  50130. get rightPreViewMatrix(): Matrix;
  50131. /**
  50132. * Get the default VRMetrics based on the most generic setup.
  50133. * @returns the default vr metrics
  50134. */
  50135. static GetDefault(): VRCameraMetrics;
  50136. }
  50137. }
  50138. declare module BABYLON {
  50139. /** @hidden */
  50140. export var vrDistortionCorrectionPixelShader: {
  50141. name: string;
  50142. shader: string;
  50143. };
  50144. }
  50145. declare module BABYLON {
  50146. /**
  50147. * VRDistortionCorrectionPostProcess used for mobile VR
  50148. */
  50149. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50150. private _isRightEye;
  50151. private _distortionFactors;
  50152. private _postProcessScaleFactor;
  50153. private _lensCenterOffset;
  50154. private _scaleIn;
  50155. private _scaleFactor;
  50156. private _lensCenter;
  50157. /**
  50158. * Gets a string identifying the name of the class
  50159. * @returns "VRDistortionCorrectionPostProcess" string
  50160. */
  50161. getClassName(): string;
  50162. /**
  50163. * Initializes the VRDistortionCorrectionPostProcess
  50164. * @param name The name of the effect.
  50165. * @param camera The camera to apply the render pass to.
  50166. * @param isRightEye If this is for the right eye distortion
  50167. * @param vrMetrics All the required metrics for the VR camera
  50168. */
  50169. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50170. }
  50171. }
  50172. declare module BABYLON {
  50173. /**
  50174. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50175. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50176. */
  50177. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50178. /**
  50179. * Creates a new VRDeviceOrientationArcRotateCamera
  50180. * @param name defines camera name
  50181. * @param alpha defines the camera rotation along the logitudinal axis
  50182. * @param beta defines the camera rotation along the latitudinal axis
  50183. * @param radius defines the camera distance from its target
  50184. * @param target defines the camera target
  50185. * @param scene defines the scene the camera belongs to
  50186. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50187. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50188. */
  50189. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50190. /**
  50191. * Gets camera class name
  50192. * @returns VRDeviceOrientationArcRotateCamera
  50193. */
  50194. getClassName(): string;
  50195. }
  50196. }
  50197. declare module BABYLON {
  50198. /**
  50199. * Camera used to simulate VR rendering (based on FreeCamera)
  50200. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50201. */
  50202. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50203. /**
  50204. * Creates a new VRDeviceOrientationFreeCamera
  50205. * @param name defines camera name
  50206. * @param position defines the start position of the camera
  50207. * @param scene defines the scene the camera belongs to
  50208. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50209. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50210. */
  50211. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50212. /**
  50213. * Gets camera class name
  50214. * @returns VRDeviceOrientationFreeCamera
  50215. */
  50216. getClassName(): string;
  50217. }
  50218. }
  50219. declare module BABYLON {
  50220. /**
  50221. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50222. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50223. */
  50224. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50225. /**
  50226. * Creates a new VRDeviceOrientationGamepadCamera
  50227. * @param name defines camera name
  50228. * @param position defines the start position of the camera
  50229. * @param scene defines the scene the camera belongs to
  50230. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50231. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50232. */
  50233. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50234. /**
  50235. * Gets camera class name
  50236. * @returns VRDeviceOrientationGamepadCamera
  50237. */
  50238. getClassName(): string;
  50239. }
  50240. }
  50241. declare module BABYLON {
  50242. /**
  50243. * A class extending Texture allowing drawing on a texture
  50244. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50245. */
  50246. export class DynamicTexture extends Texture {
  50247. private _generateMipMaps;
  50248. private _canvas;
  50249. private _context;
  50250. /**
  50251. * Creates a DynamicTexture
  50252. * @param name defines the name of the texture
  50253. * @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
  50254. * @param scene defines the scene where you want the texture
  50255. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50256. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50257. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50258. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50259. */
  50260. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50261. /**
  50262. * Get the current class name of the texture useful for serialization or dynamic coding.
  50263. * @returns "DynamicTexture"
  50264. */
  50265. getClassName(): string;
  50266. /**
  50267. * Gets the current state of canRescale
  50268. */
  50269. get canRescale(): boolean;
  50270. private _recreate;
  50271. /**
  50272. * Scales the texture
  50273. * @param ratio the scale factor to apply to both width and height
  50274. */
  50275. scale(ratio: number): void;
  50276. /**
  50277. * Resizes the texture
  50278. * @param width the new width
  50279. * @param height the new height
  50280. */
  50281. scaleTo(width: number, height: number): void;
  50282. /**
  50283. * Gets the context of the canvas used by the texture
  50284. * @returns the canvas context of the dynamic texture
  50285. */
  50286. getContext(): CanvasRenderingContext2D;
  50287. /**
  50288. * Clears the texture
  50289. */
  50290. clear(): void;
  50291. /**
  50292. * Updates the texture
  50293. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50294. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50295. */
  50296. update(invertY?: boolean, premulAlpha?: boolean): void;
  50297. /**
  50298. * Draws text onto the texture
  50299. * @param text defines the text to be drawn
  50300. * @param x defines the placement of the text from the left
  50301. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50302. * @param font defines the font to be used with font-style, font-size, font-name
  50303. * @param color defines the color used for the text
  50304. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50305. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50306. * @param update defines whether texture is immediately update (default is true)
  50307. */
  50308. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50309. /**
  50310. * Clones the texture
  50311. * @returns the clone of the texture.
  50312. */
  50313. clone(): DynamicTexture;
  50314. /**
  50315. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50316. * @returns a serialized dynamic texture object
  50317. */
  50318. serialize(): any;
  50319. private _IsCanvasElement;
  50320. /** @hidden */
  50321. _rebuild(): void;
  50322. }
  50323. }
  50324. declare module BABYLON {
  50325. /**
  50326. * Class containing static functions to help procedurally build meshes
  50327. */
  50328. export class GroundBuilder {
  50329. /**
  50330. * Creates a ground mesh
  50331. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50332. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50334. * @param name defines the name of the mesh
  50335. * @param options defines the options used to create the mesh
  50336. * @param scene defines the hosting scene
  50337. * @returns the ground mesh
  50338. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50339. */
  50340. static CreateGround(name: string, options: {
  50341. width?: number;
  50342. height?: number;
  50343. subdivisions?: number;
  50344. subdivisionsX?: number;
  50345. subdivisionsY?: number;
  50346. updatable?: boolean;
  50347. }, scene: any): Mesh;
  50348. /**
  50349. * Creates a tiled ground mesh
  50350. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50351. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50352. * * 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
  50353. * * 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
  50354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50355. * @param name defines the name of the mesh
  50356. * @param options defines the options used to create the mesh
  50357. * @param scene defines the hosting scene
  50358. * @returns the tiled ground mesh
  50359. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50360. */
  50361. static CreateTiledGround(name: string, options: {
  50362. xmin: number;
  50363. zmin: number;
  50364. xmax: number;
  50365. zmax: number;
  50366. subdivisions?: {
  50367. w: number;
  50368. h: number;
  50369. };
  50370. precision?: {
  50371. w: number;
  50372. h: number;
  50373. };
  50374. updatable?: boolean;
  50375. }, scene?: Nullable<Scene>): Mesh;
  50376. /**
  50377. * Creates a ground mesh from a height map
  50378. * * The parameter `url` sets the URL of the height map image resource.
  50379. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50380. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50381. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50382. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50383. * * 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.
  50384. * * 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).
  50385. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50387. * @param name defines the name of the mesh
  50388. * @param url defines the url to the height map
  50389. * @param options defines the options used to create the mesh
  50390. * @param scene defines the hosting scene
  50391. * @returns the ground mesh
  50392. * @see https://doc.babylonjs.com/babylon101/height_map
  50393. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50394. */
  50395. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50396. width?: number;
  50397. height?: number;
  50398. subdivisions?: number;
  50399. minHeight?: number;
  50400. maxHeight?: number;
  50401. colorFilter?: Color3;
  50402. alphaFilter?: number;
  50403. updatable?: boolean;
  50404. onReady?: (mesh: GroundMesh) => void;
  50405. }, scene?: Nullable<Scene>): GroundMesh;
  50406. }
  50407. }
  50408. declare module BABYLON {
  50409. /**
  50410. * Class containing static functions to help procedurally build meshes
  50411. */
  50412. export class TorusBuilder {
  50413. /**
  50414. * Creates a torus mesh
  50415. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50416. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50417. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50419. * * 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
  50420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50421. * @param name defines the name of the mesh
  50422. * @param options defines the options used to create the mesh
  50423. * @param scene defines the hosting scene
  50424. * @returns the torus mesh
  50425. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50426. */
  50427. static CreateTorus(name: string, options: {
  50428. diameter?: number;
  50429. thickness?: number;
  50430. tessellation?: number;
  50431. updatable?: boolean;
  50432. sideOrientation?: number;
  50433. frontUVs?: Vector4;
  50434. backUVs?: Vector4;
  50435. }, scene: any): Mesh;
  50436. }
  50437. }
  50438. declare module BABYLON {
  50439. /**
  50440. * Class containing static functions to help procedurally build meshes
  50441. */
  50442. export class CylinderBuilder {
  50443. /**
  50444. * Creates a cylinder or a cone mesh
  50445. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50446. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50447. * * 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.
  50448. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50449. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50450. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50451. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50452. * * 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).
  50453. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50454. * * 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).
  50455. * * 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
  50456. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50457. * * 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
  50458. * * 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.
  50459. * * If `enclose` is false, a ring surface is one element.
  50460. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50461. * * 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
  50462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50463. * * 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
  50464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50465. * @param name defines the name of the mesh
  50466. * @param options defines the options used to create the mesh
  50467. * @param scene defines the hosting scene
  50468. * @returns the cylinder mesh
  50469. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50470. */
  50471. static CreateCylinder(name: string, options: {
  50472. height?: number;
  50473. diameterTop?: number;
  50474. diameterBottom?: number;
  50475. diameter?: number;
  50476. tessellation?: number;
  50477. subdivisions?: number;
  50478. arc?: number;
  50479. faceColors?: Color4[];
  50480. faceUV?: Vector4[];
  50481. updatable?: boolean;
  50482. hasRings?: boolean;
  50483. enclose?: boolean;
  50484. cap?: number;
  50485. sideOrientation?: number;
  50486. frontUVs?: Vector4;
  50487. backUVs?: Vector4;
  50488. }, scene: any): Mesh;
  50489. }
  50490. }
  50491. declare module BABYLON {
  50492. /**
  50493. * States of the webXR experience
  50494. */
  50495. export enum WebXRState {
  50496. /**
  50497. * Transitioning to being in XR mode
  50498. */
  50499. ENTERING_XR = 0,
  50500. /**
  50501. * Transitioning to non XR mode
  50502. */
  50503. EXITING_XR = 1,
  50504. /**
  50505. * In XR mode and presenting
  50506. */
  50507. IN_XR = 2,
  50508. /**
  50509. * Not entered XR mode
  50510. */
  50511. NOT_IN_XR = 3
  50512. }
  50513. /**
  50514. * The state of the XR camera's tracking
  50515. */
  50516. export enum WebXRTrackingState {
  50517. /**
  50518. * No transformation received, device is not being tracked
  50519. */
  50520. NOT_TRACKING = 0,
  50521. /**
  50522. * Tracking lost - using emulated position
  50523. */
  50524. TRACKING_LOST = 1,
  50525. /**
  50526. * Transformation tracking works normally
  50527. */
  50528. TRACKING = 2
  50529. }
  50530. /**
  50531. * Abstraction of the XR render target
  50532. */
  50533. export interface WebXRRenderTarget extends IDisposable {
  50534. /**
  50535. * xrpresent context of the canvas which can be used to display/mirror xr content
  50536. */
  50537. canvasContext: WebGLRenderingContext;
  50538. /**
  50539. * xr layer for the canvas
  50540. */
  50541. xrLayer: Nullable<XRWebGLLayer>;
  50542. /**
  50543. * Initializes the xr layer for the session
  50544. * @param xrSession xr session
  50545. * @returns a promise that will resolve once the XR Layer has been created
  50546. */
  50547. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50548. }
  50549. }
  50550. declare module BABYLON {
  50551. /**
  50552. * COnfiguration object for WebXR output canvas
  50553. */
  50554. export class WebXRManagedOutputCanvasOptions {
  50555. /**
  50556. * An optional canvas in case you wish to create it yourself and provide it here.
  50557. * If not provided, a new canvas will be created
  50558. */
  50559. canvasElement?: HTMLCanvasElement;
  50560. /**
  50561. * Options for this XR Layer output
  50562. */
  50563. canvasOptions?: XRWebGLLayerInit;
  50564. /**
  50565. * CSS styling for a newly created canvas (if not provided)
  50566. */
  50567. newCanvasCssStyle?: string;
  50568. /**
  50569. * Get the default values of the configuration object
  50570. * @param engine defines the engine to use (can be null)
  50571. * @returns default values of this configuration object
  50572. */
  50573. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50574. }
  50575. /**
  50576. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50577. */
  50578. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50579. private _options;
  50580. private _canvas;
  50581. private _engine;
  50582. private _originalCanvasSize;
  50583. /**
  50584. * Rendering context of the canvas which can be used to display/mirror xr content
  50585. */
  50586. canvasContext: WebGLRenderingContext;
  50587. /**
  50588. * xr layer for the canvas
  50589. */
  50590. xrLayer: Nullable<XRWebGLLayer>;
  50591. /**
  50592. * Obseervers registered here will be triggered when the xr layer was initialized
  50593. */
  50594. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50595. /**
  50596. * Initializes the canvas to be added/removed upon entering/exiting xr
  50597. * @param _xrSessionManager The XR Session manager
  50598. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50599. */
  50600. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50601. /**
  50602. * Disposes of the object
  50603. */
  50604. dispose(): void;
  50605. /**
  50606. * Initializes the xr layer for the session
  50607. * @param xrSession xr session
  50608. * @returns a promise that will resolve once the XR Layer has been created
  50609. */
  50610. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50611. private _addCanvas;
  50612. private _removeCanvas;
  50613. private _setCanvasSize;
  50614. private _setManagedOutputCanvas;
  50615. }
  50616. }
  50617. declare module BABYLON {
  50618. /**
  50619. * Manages an XRSession to work with Babylon's engine
  50620. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50621. */
  50622. export class WebXRSessionManager implements IDisposable {
  50623. /** The scene which the session should be created for */
  50624. scene: Scene;
  50625. private _referenceSpace;
  50626. private _rttProvider;
  50627. private _sessionEnded;
  50628. private _xrNavigator;
  50629. private baseLayer;
  50630. /**
  50631. * The base reference space from which the session started. good if you want to reset your
  50632. * reference space
  50633. */
  50634. baseReferenceSpace: XRReferenceSpace;
  50635. /**
  50636. * Current XR frame
  50637. */
  50638. currentFrame: Nullable<XRFrame>;
  50639. /** WebXR timestamp updated every frame */
  50640. currentTimestamp: number;
  50641. /**
  50642. * Used just in case of a failure to initialize an immersive session.
  50643. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50644. */
  50645. defaultHeightCompensation: number;
  50646. /**
  50647. * Fires every time a new xrFrame arrives which can be used to update the camera
  50648. */
  50649. onXRFrameObservable: Observable<XRFrame>;
  50650. /**
  50651. * Fires when the reference space changed
  50652. */
  50653. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50654. /**
  50655. * Fires when the xr session is ended either by the device or manually done
  50656. */
  50657. onXRSessionEnded: Observable<any>;
  50658. /**
  50659. * Fires when the xr session is ended either by the device or manually done
  50660. */
  50661. onXRSessionInit: Observable<XRSession>;
  50662. /**
  50663. * Underlying xr session
  50664. */
  50665. session: XRSession;
  50666. /**
  50667. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50668. * or get the offset the player is currently at.
  50669. */
  50670. viewerReferenceSpace: XRReferenceSpace;
  50671. /**
  50672. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50673. * @param scene The scene which the session should be created for
  50674. */
  50675. constructor(
  50676. /** The scene which the session should be created for */
  50677. scene: Scene);
  50678. /**
  50679. * The current reference space used in this session. This reference space can constantly change!
  50680. * It is mainly used to offset the camera's position.
  50681. */
  50682. get referenceSpace(): XRReferenceSpace;
  50683. /**
  50684. * Set a new reference space and triggers the observable
  50685. */
  50686. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50687. /**
  50688. * Disposes of the session manager
  50689. */
  50690. dispose(): void;
  50691. /**
  50692. * Stops the xrSession and restores the render loop
  50693. * @returns Promise which resolves after it exits XR
  50694. */
  50695. exitXRAsync(): Promise<void>;
  50696. /**
  50697. * Gets the correct render target texture to be rendered this frame for this eye
  50698. * @param eye the eye for which to get the render target
  50699. * @returns the render target for the specified eye
  50700. */
  50701. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50702. /**
  50703. * Creates a WebXRRenderTarget object for the XR session
  50704. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50705. * @param options optional options to provide when creating a new render target
  50706. * @returns a WebXR render target to which the session can render
  50707. */
  50708. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50709. /**
  50710. * Initializes the manager
  50711. * After initialization enterXR can be called to start an XR session
  50712. * @returns Promise which resolves after it is initialized
  50713. */
  50714. initializeAsync(): Promise<void>;
  50715. /**
  50716. * Initializes an xr session
  50717. * @param xrSessionMode mode to initialize
  50718. * @param xrSessionInit defines optional and required values to pass to the session builder
  50719. * @returns a promise which will resolve once the session has been initialized
  50720. */
  50721. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50722. /**
  50723. * Checks if a session would be supported for the creation options specified
  50724. * @param sessionMode session mode to check if supported eg. immersive-vr
  50725. * @returns A Promise that resolves to true if supported and false if not
  50726. */
  50727. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50728. /**
  50729. * Resets the reference space to the one started the session
  50730. */
  50731. resetReferenceSpace(): void;
  50732. /**
  50733. * Starts rendering to the xr layer
  50734. */
  50735. runXRRenderLoop(): void;
  50736. /**
  50737. * Sets the reference space on the xr session
  50738. * @param referenceSpaceType space to set
  50739. * @returns a promise that will resolve once the reference space has been set
  50740. */
  50741. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50742. /**
  50743. * Updates the render state of the session
  50744. * @param state state to set
  50745. * @returns a promise that resolves once the render state has been updated
  50746. */
  50747. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50748. /**
  50749. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50750. * @param sessionMode defines the session to test
  50751. * @returns a promise with boolean as final value
  50752. */
  50753. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50754. private _createRenderTargetTexture;
  50755. }
  50756. }
  50757. declare module BABYLON {
  50758. /**
  50759. * WebXR Camera which holds the views for the xrSession
  50760. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50761. */
  50762. export class WebXRCamera extends FreeCamera {
  50763. private _xrSessionManager;
  50764. private _firstFrame;
  50765. private _referenceQuaternion;
  50766. private _referencedPosition;
  50767. private _xrInvPositionCache;
  50768. private _xrInvQuaternionCache;
  50769. private _trackingState;
  50770. /**
  50771. * Observable raised before camera teleportation
  50772. */
  50773. onBeforeCameraTeleport: Observable<Vector3>;
  50774. /**
  50775. * Observable raised after camera teleportation
  50776. */
  50777. onAfterCameraTeleport: Observable<Vector3>;
  50778. /**
  50779. * Notifies when the camera's tracking state has changed.
  50780. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50781. */
  50782. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50783. /**
  50784. * Should position compensation execute on first frame.
  50785. * This is used when copying the position from a native (non XR) camera
  50786. */
  50787. compensateOnFirstFrame: boolean;
  50788. /**
  50789. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50790. * @param name the name of the camera
  50791. * @param scene the scene to add the camera to
  50792. * @param _xrSessionManager a constructed xr session manager
  50793. */
  50794. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50795. /**
  50796. * Get the current XR tracking state of the camera
  50797. */
  50798. get trackingState(): WebXRTrackingState;
  50799. private _setTrackingState;
  50800. /**
  50801. * Return the user's height, unrelated to the current ground.
  50802. * This will be the y position of this camera, when ground level is 0.
  50803. */
  50804. get realWorldHeight(): number;
  50805. /** @hidden */
  50806. _updateForDualEyeDebugging(): void;
  50807. /**
  50808. * Sets this camera's transformation based on a non-vr camera
  50809. * @param otherCamera the non-vr camera to copy the transformation from
  50810. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50811. */
  50812. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50813. /**
  50814. * Gets the current instance class name ("WebXRCamera").
  50815. * @returns the class name
  50816. */
  50817. getClassName(): string;
  50818. private _rotate180;
  50819. private _updateFromXRSession;
  50820. private _updateNumberOfRigCameras;
  50821. private _updateReferenceSpace;
  50822. private _updateReferenceSpaceOffset;
  50823. }
  50824. }
  50825. declare module BABYLON {
  50826. /**
  50827. * Defining the interface required for a (webxr) feature
  50828. */
  50829. export interface IWebXRFeature extends IDisposable {
  50830. /**
  50831. * Is this feature attached
  50832. */
  50833. attached: boolean;
  50834. /**
  50835. * Should auto-attach be disabled?
  50836. */
  50837. disableAutoAttach: boolean;
  50838. /**
  50839. * Attach the feature to the session
  50840. * Will usually be called by the features manager
  50841. *
  50842. * @param force should attachment be forced (even when already attached)
  50843. * @returns true if successful.
  50844. */
  50845. attach(force?: boolean): boolean;
  50846. /**
  50847. * Detach the feature from the session
  50848. * Will usually be called by the features manager
  50849. *
  50850. * @returns true if successful.
  50851. */
  50852. detach(): boolean;
  50853. /**
  50854. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50855. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50856. *
  50857. * @returns whether or not the feature is compatible in this environment
  50858. */
  50859. isCompatible(): boolean;
  50860. /**
  50861. * Was this feature disposed;
  50862. */
  50863. isDisposed: boolean;
  50864. /**
  50865. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50866. */
  50867. xrNativeFeatureName?: string;
  50868. /**
  50869. * A list of (Babylon WebXR) features this feature depends on
  50870. */
  50871. dependsOn?: string[];
  50872. }
  50873. /**
  50874. * A list of the currently available features without referencing them
  50875. */
  50876. export class WebXRFeatureName {
  50877. /**
  50878. * The name of the anchor system feature
  50879. */
  50880. static readonly ANCHOR_SYSTEM: string;
  50881. /**
  50882. * The name of the background remover feature
  50883. */
  50884. static readonly BACKGROUND_REMOVER: string;
  50885. /**
  50886. * The name of the hit test feature
  50887. */
  50888. static readonly HIT_TEST: string;
  50889. /**
  50890. * physics impostors for xr controllers feature
  50891. */
  50892. static readonly PHYSICS_CONTROLLERS: string;
  50893. /**
  50894. * The name of the plane detection feature
  50895. */
  50896. static readonly PLANE_DETECTION: string;
  50897. /**
  50898. * The name of the pointer selection feature
  50899. */
  50900. static readonly POINTER_SELECTION: string;
  50901. /**
  50902. * The name of the teleportation feature
  50903. */
  50904. static readonly TELEPORTATION: string;
  50905. /**
  50906. * The name of the feature points feature.
  50907. */
  50908. static readonly FEATURE_POINTS: string;
  50909. /**
  50910. * The name of the hand tracking feature.
  50911. */
  50912. static readonly HAND_TRACKING: string;
  50913. }
  50914. /**
  50915. * Defining the constructor of a feature. Used to register the modules.
  50916. */
  50917. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50918. /**
  50919. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50920. * It is mainly used in AR sessions.
  50921. *
  50922. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50923. */
  50924. export class WebXRFeaturesManager implements IDisposable {
  50925. private _xrSessionManager;
  50926. private static readonly _AvailableFeatures;
  50927. private _features;
  50928. /**
  50929. * constructs a new features manages.
  50930. *
  50931. * @param _xrSessionManager an instance of WebXRSessionManager
  50932. */
  50933. constructor(_xrSessionManager: WebXRSessionManager);
  50934. /**
  50935. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50936. * Mainly used internally.
  50937. *
  50938. * @param featureName the name of the feature to register
  50939. * @param constructorFunction the function used to construct the module
  50940. * @param version the (babylon) version of the module
  50941. * @param stable is that a stable version of this module
  50942. */
  50943. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50944. /**
  50945. * Returns a constructor of a specific feature.
  50946. *
  50947. * @param featureName the name of the feature to construct
  50948. * @param version the version of the feature to load
  50949. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50950. * @param options optional options provided to the module.
  50951. * @returns a function that, when called, will return a new instance of this feature
  50952. */
  50953. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50954. /**
  50955. * Can be used to return the list of features currently registered
  50956. *
  50957. * @returns an Array of available features
  50958. */
  50959. static GetAvailableFeatures(): string[];
  50960. /**
  50961. * Gets the versions available for a specific feature
  50962. * @param featureName the name of the feature
  50963. * @returns an array with the available versions
  50964. */
  50965. static GetAvailableVersions(featureName: string): string[];
  50966. /**
  50967. * Return the latest unstable 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 GetLatestVersionOfFeature(featureName: string): number;
  50972. /**
  50973. * Return the latest stable version of this feature
  50974. * @param featureName the name of the feature to search
  50975. * @returns the version number. if not found will return -1
  50976. */
  50977. static GetStableVersionOfFeature(featureName: string): number;
  50978. /**
  50979. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50980. * Can be used during a session to start a feature
  50981. * @param featureName the name of feature to attach
  50982. */
  50983. attachFeature(featureName: string): void;
  50984. /**
  50985. * Can be used inside a session or when the session ends to detach a specific feature
  50986. * @param featureName the name of the feature to detach
  50987. */
  50988. detachFeature(featureName: string): void;
  50989. /**
  50990. * Used to disable an already-enabled feature
  50991. * The feature will be disposed and will be recreated once enabled.
  50992. * @param featureName the feature to disable
  50993. * @returns true if disable was successful
  50994. */
  50995. disableFeature(featureName: string | {
  50996. Name: string;
  50997. }): boolean;
  50998. /**
  50999. * dispose this features manager
  51000. */
  51001. dispose(): void;
  51002. /**
  51003. * 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.
  51004. * 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.
  51005. *
  51006. * @param featureName the name of the feature to load or the class of the feature
  51007. * @param version optional version to load. if not provided the latest version will be enabled
  51008. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  51009. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  51010. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  51011. * @returns a new constructed feature or throws an error if feature not found.
  51012. */
  51013. enableFeature(featureName: string | {
  51014. Name: string;
  51015. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  51016. /**
  51017. * get the implementation of an enabled feature.
  51018. * @param featureName the name of the feature to load
  51019. * @returns the feature class, if found
  51020. */
  51021. getEnabledFeature(featureName: string): IWebXRFeature;
  51022. /**
  51023. * Get the list of enabled features
  51024. * @returns an array of enabled features
  51025. */
  51026. getEnabledFeatures(): string[];
  51027. /**
  51028. * This function will exten the session creation configuration object with enabled features.
  51029. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  51030. * according to the defined "required" variable, provided during enableFeature call
  51031. * @param xrSessionInit the xr Session init object to extend
  51032. *
  51033. * @returns an extended XRSessionInit object
  51034. */
  51035. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  51036. }
  51037. }
  51038. declare module BABYLON {
  51039. /**
  51040. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  51041. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  51042. */
  51043. export class WebXRExperienceHelper implements IDisposable {
  51044. private scene;
  51045. private _nonVRCamera;
  51046. private _originalSceneAutoClear;
  51047. private _supported;
  51048. /**
  51049. * Camera used to render xr content
  51050. */
  51051. camera: WebXRCamera;
  51052. /** A features manager for this xr session */
  51053. featuresManager: WebXRFeaturesManager;
  51054. /**
  51055. * Observers registered here will be triggered after the camera's initial transformation is set
  51056. * This can be used to set a different ground level or an extra rotation.
  51057. *
  51058. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51059. * to the position set after this observable is done executing.
  51060. */
  51061. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51062. /**
  51063. * Fires when the state of the experience helper has changed
  51064. */
  51065. onStateChangedObservable: Observable<WebXRState>;
  51066. /** Session manager used to keep track of xr session */
  51067. sessionManager: WebXRSessionManager;
  51068. /**
  51069. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51070. */
  51071. state: WebXRState;
  51072. /**
  51073. * Creates a WebXRExperienceHelper
  51074. * @param scene The scene the helper should be created in
  51075. */
  51076. private constructor();
  51077. /**
  51078. * Creates the experience helper
  51079. * @param scene the scene to attach the experience helper to
  51080. * @returns a promise for the experience helper
  51081. */
  51082. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51083. /**
  51084. * Disposes of the experience helper
  51085. */
  51086. dispose(): void;
  51087. /**
  51088. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51089. * @param sessionMode options for the XR session
  51090. * @param referenceSpaceType frame of reference of the XR session
  51091. * @param renderTarget the output canvas that will be used to enter XR mode
  51092. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51093. * @returns promise that resolves after xr mode has entered
  51094. */
  51095. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51096. /**
  51097. * Exits XR mode and returns the scene to its original state
  51098. * @returns promise that resolves after xr mode has exited
  51099. */
  51100. exitXRAsync(): Promise<void>;
  51101. private _nonXRToXRCamera;
  51102. private _setState;
  51103. }
  51104. }
  51105. declare module BABYLON {
  51106. /**
  51107. * X-Y values for axes in WebXR
  51108. */
  51109. export interface IWebXRMotionControllerAxesValue {
  51110. /**
  51111. * The value of the x axis
  51112. */
  51113. x: number;
  51114. /**
  51115. * The value of the y-axis
  51116. */
  51117. y: number;
  51118. }
  51119. /**
  51120. * changed / previous values for the values of this component
  51121. */
  51122. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51123. /**
  51124. * current (this frame) value
  51125. */
  51126. current: T;
  51127. /**
  51128. * previous (last change) value
  51129. */
  51130. previous: T;
  51131. }
  51132. /**
  51133. * Represents changes in the component between current frame and last values recorded
  51134. */
  51135. export interface IWebXRMotionControllerComponentChanges {
  51136. /**
  51137. * will be populated with previous and current values if axes changed
  51138. */
  51139. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51140. /**
  51141. * will be populated with previous and current values if pressed changed
  51142. */
  51143. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51144. /**
  51145. * will be populated with previous and current values if touched changed
  51146. */
  51147. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51148. /**
  51149. * will be populated with previous and current values if value changed
  51150. */
  51151. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51152. }
  51153. /**
  51154. * This class represents a single component (for example button or thumbstick) of a motion controller
  51155. */
  51156. export class WebXRControllerComponent implements IDisposable {
  51157. /**
  51158. * the id of this component
  51159. */
  51160. id: string;
  51161. /**
  51162. * the type of the component
  51163. */
  51164. type: MotionControllerComponentType;
  51165. private _buttonIndex;
  51166. private _axesIndices;
  51167. private _axes;
  51168. private _changes;
  51169. private _currentValue;
  51170. private _hasChanges;
  51171. private _pressed;
  51172. private _touched;
  51173. /**
  51174. * button component type
  51175. */
  51176. static BUTTON_TYPE: MotionControllerComponentType;
  51177. /**
  51178. * squeeze component type
  51179. */
  51180. static SQUEEZE_TYPE: MotionControllerComponentType;
  51181. /**
  51182. * Thumbstick component type
  51183. */
  51184. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51185. /**
  51186. * Touchpad component type
  51187. */
  51188. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51189. /**
  51190. * trigger component type
  51191. */
  51192. static TRIGGER_TYPE: MotionControllerComponentType;
  51193. /**
  51194. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51195. * the axes data changes
  51196. */
  51197. onAxisValueChangedObservable: Observable<{
  51198. x: number;
  51199. y: number;
  51200. }>;
  51201. /**
  51202. * Observers registered here will be triggered when the state of a button changes
  51203. * State change is either pressed / touched / value
  51204. */
  51205. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51206. /**
  51207. * Creates a new component for a motion controller.
  51208. * It is created by the motion controller itself
  51209. *
  51210. * @param id the id of this component
  51211. * @param type the type of the component
  51212. * @param _buttonIndex index in the buttons array of the gamepad
  51213. * @param _axesIndices indices of the values in the axes array of the gamepad
  51214. */
  51215. constructor(
  51216. /**
  51217. * the id of this component
  51218. */
  51219. id: string,
  51220. /**
  51221. * the type of the component
  51222. */
  51223. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51224. /**
  51225. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51226. */
  51227. get axes(): IWebXRMotionControllerAxesValue;
  51228. /**
  51229. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51230. */
  51231. get changes(): IWebXRMotionControllerComponentChanges;
  51232. /**
  51233. * Return whether or not the component changed the last frame
  51234. */
  51235. get hasChanges(): boolean;
  51236. /**
  51237. * is the button currently pressed
  51238. */
  51239. get pressed(): boolean;
  51240. /**
  51241. * is the button currently touched
  51242. */
  51243. get touched(): boolean;
  51244. /**
  51245. * Get the current value of this component
  51246. */
  51247. get value(): number;
  51248. /**
  51249. * Dispose this component
  51250. */
  51251. dispose(): void;
  51252. /**
  51253. * Are there axes correlating to this component
  51254. * @return true is axes data is available
  51255. */
  51256. isAxes(): boolean;
  51257. /**
  51258. * Is this component a button (hence - pressable)
  51259. * @returns true if can be pressed
  51260. */
  51261. isButton(): boolean;
  51262. /**
  51263. * update this component using the gamepad object it is in. Called on every frame
  51264. * @param nativeController the native gamepad controller object
  51265. */
  51266. update(nativeController: IMinimalMotionControllerObject): void;
  51267. }
  51268. }
  51269. declare module BABYLON {
  51270. /**
  51271. * Type used for the success callback of ImportMesh
  51272. */
  51273. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51274. /**
  51275. * Interface used for the result of ImportMeshAsync
  51276. */
  51277. export interface ISceneLoaderAsyncResult {
  51278. /**
  51279. * The array of loaded meshes
  51280. */
  51281. readonly meshes: AbstractMesh[];
  51282. /**
  51283. * The array of loaded particle systems
  51284. */
  51285. readonly particleSystems: IParticleSystem[];
  51286. /**
  51287. * The array of loaded skeletons
  51288. */
  51289. readonly skeletons: Skeleton[];
  51290. /**
  51291. * The array of loaded animation groups
  51292. */
  51293. readonly animationGroups: AnimationGroup[];
  51294. /**
  51295. * The array of loaded transform nodes
  51296. */
  51297. readonly transformNodes: TransformNode[];
  51298. /**
  51299. * The array of loaded geometries
  51300. */
  51301. readonly geometries: Geometry[];
  51302. /**
  51303. * The array of loaded lights
  51304. */
  51305. readonly lights: Light[];
  51306. }
  51307. /**
  51308. * Interface used to represent data loading progression
  51309. */
  51310. export interface ISceneLoaderProgressEvent {
  51311. /**
  51312. * Defines if data length to load can be evaluated
  51313. */
  51314. readonly lengthComputable: boolean;
  51315. /**
  51316. * Defines the loaded data length
  51317. */
  51318. readonly loaded: number;
  51319. /**
  51320. * Defines the data length to load
  51321. */
  51322. readonly total: number;
  51323. }
  51324. /**
  51325. * Interface used by SceneLoader plugins to define supported file extensions
  51326. */
  51327. export interface ISceneLoaderPluginExtensions {
  51328. /**
  51329. * Defines the list of supported extensions
  51330. */
  51331. [extension: string]: {
  51332. isBinary: boolean;
  51333. };
  51334. }
  51335. /**
  51336. * Interface used by SceneLoader plugin factory
  51337. */
  51338. export interface ISceneLoaderPluginFactory {
  51339. /**
  51340. * Defines the name of the factory
  51341. */
  51342. name: string;
  51343. /**
  51344. * Function called to create a new plugin
  51345. * @return the new plugin
  51346. */
  51347. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51348. /**
  51349. * The callback that returns true if the data can be directly loaded.
  51350. * @param data string containing the file data
  51351. * @returns if the data can be loaded directly
  51352. */
  51353. canDirectLoad?(data: string): boolean;
  51354. }
  51355. /**
  51356. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51357. */
  51358. export interface ISceneLoaderPluginBase {
  51359. /**
  51360. * The friendly name of this plugin.
  51361. */
  51362. name: string;
  51363. /**
  51364. * The file extensions supported by this plugin.
  51365. */
  51366. extensions: string | ISceneLoaderPluginExtensions;
  51367. /**
  51368. * The callback called when loading from a url.
  51369. * @param scene scene loading this url
  51370. * @param url url to load
  51371. * @param onSuccess callback called when the file successfully loads
  51372. * @param onProgress callback called while file is loading (if the server supports this mode)
  51373. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51374. * @param onError callback called when the file fails to load
  51375. * @returns a file request object
  51376. */
  51377. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51378. /**
  51379. * The callback called when loading from a file object.
  51380. * @param scene scene loading this file
  51381. * @param file defines the file to load
  51382. * @param onSuccess defines the callback to call when data is loaded
  51383. * @param onProgress defines the callback to call during loading process
  51384. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51385. * @param onError defines the callback to call when an error occurs
  51386. * @returns a file request object
  51387. */
  51388. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51389. /**
  51390. * The callback that returns true if the data can be directly loaded.
  51391. * @param data string containing the file data
  51392. * @returns if the data can be loaded directly
  51393. */
  51394. canDirectLoad?(data: string): boolean;
  51395. /**
  51396. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51397. * @param scene scene loading this data
  51398. * @param data string containing the data
  51399. * @returns data to pass to the plugin
  51400. */
  51401. directLoad?(scene: Scene, data: string): any;
  51402. /**
  51403. * The callback that allows custom handling of the root url based on the response url.
  51404. * @param rootUrl the original root url
  51405. * @param responseURL the response url if available
  51406. * @returns the new root url
  51407. */
  51408. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51409. }
  51410. /**
  51411. * Interface used to define a SceneLoader plugin
  51412. */
  51413. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51414. /**
  51415. * Import meshes into a scene.
  51416. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51417. * @param scene The scene to import into
  51418. * @param data The data to import
  51419. * @param rootUrl The root url for scene and resources
  51420. * @param meshes The meshes array to import into
  51421. * @param particleSystems The particle systems array to import into
  51422. * @param skeletons The skeletons array to import into
  51423. * @param onError The callback when import fails
  51424. * @returns True if successful or false otherwise
  51425. */
  51426. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51427. /**
  51428. * Load into a scene.
  51429. * @param scene The scene to load into
  51430. * @param data The data to import
  51431. * @param rootUrl The root url for scene and resources
  51432. * @param onError The callback when import fails
  51433. * @returns True if successful or false otherwise
  51434. */
  51435. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51436. /**
  51437. * Load into an asset container.
  51438. * @param scene The scene to load into
  51439. * @param data The data to import
  51440. * @param rootUrl The root url for scene and resources
  51441. * @param onError The callback when import fails
  51442. * @returns The loaded asset container
  51443. */
  51444. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51445. }
  51446. /**
  51447. * Interface used to define an async SceneLoader plugin
  51448. */
  51449. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51450. /**
  51451. * Import meshes into a scene.
  51452. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51453. * @param scene The scene to import into
  51454. * @param data The data to import
  51455. * @param rootUrl The root url for scene and resources
  51456. * @param onProgress The callback when the load progresses
  51457. * @param fileName Defines the name of the file to load
  51458. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51459. */
  51460. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51461. /**
  51462. * Load into a scene.
  51463. * @param scene The scene to load into
  51464. * @param data The data to import
  51465. * @param rootUrl The root url for scene and resources
  51466. * @param onProgress The callback when the load progresses
  51467. * @param fileName Defines the name of the file to load
  51468. * @returns Nothing
  51469. */
  51470. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51471. /**
  51472. * Load into an asset container.
  51473. * @param scene The scene to load into
  51474. * @param data The data to import
  51475. * @param rootUrl The root url for scene and resources
  51476. * @param onProgress The callback when the load progresses
  51477. * @param fileName Defines the name of the file to load
  51478. * @returns The loaded asset container
  51479. */
  51480. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51481. }
  51482. /**
  51483. * Mode that determines how to handle old animation groups before loading new ones.
  51484. */
  51485. export enum SceneLoaderAnimationGroupLoadingMode {
  51486. /**
  51487. * Reset all old animations to initial state then dispose them.
  51488. */
  51489. Clean = 0,
  51490. /**
  51491. * Stop all old animations.
  51492. */
  51493. Stop = 1,
  51494. /**
  51495. * Restart old animations from first frame.
  51496. */
  51497. Sync = 2,
  51498. /**
  51499. * Old animations remains untouched.
  51500. */
  51501. NoSync = 3
  51502. }
  51503. /**
  51504. * Defines a plugin registered by the SceneLoader
  51505. */
  51506. interface IRegisteredPlugin {
  51507. /**
  51508. * Defines the plugin to use
  51509. */
  51510. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51511. /**
  51512. * Defines if the plugin supports binary data
  51513. */
  51514. isBinary: boolean;
  51515. }
  51516. /**
  51517. * Class used to load scene from various file formats using registered plugins
  51518. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51519. */
  51520. export class SceneLoader {
  51521. /**
  51522. * No logging while loading
  51523. */
  51524. static readonly NO_LOGGING: number;
  51525. /**
  51526. * Minimal logging while loading
  51527. */
  51528. static readonly MINIMAL_LOGGING: number;
  51529. /**
  51530. * Summary logging while loading
  51531. */
  51532. static readonly SUMMARY_LOGGING: number;
  51533. /**
  51534. * Detailled logging while loading
  51535. */
  51536. static readonly DETAILED_LOGGING: number;
  51537. /**
  51538. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51539. */
  51540. static get ForceFullSceneLoadingForIncremental(): boolean;
  51541. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51542. /**
  51543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51544. */
  51545. static get ShowLoadingScreen(): boolean;
  51546. static set ShowLoadingScreen(value: boolean);
  51547. /**
  51548. * Defines the current logging level (while loading the scene)
  51549. * @ignorenaming
  51550. */
  51551. static get loggingLevel(): number;
  51552. static set loggingLevel(value: number);
  51553. /**
  51554. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51555. */
  51556. static get CleanBoneMatrixWeights(): boolean;
  51557. static set CleanBoneMatrixWeights(value: boolean);
  51558. /**
  51559. * Event raised when a plugin is used to load a scene
  51560. */
  51561. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51562. private static _registeredPlugins;
  51563. private static _showingLoadingScreen;
  51564. /**
  51565. * Gets the default plugin (used to load Babylon files)
  51566. * @returns the .babylon plugin
  51567. */
  51568. static GetDefaultPlugin(): IRegisteredPlugin;
  51569. private static _GetPluginForExtension;
  51570. private static _GetPluginForDirectLoad;
  51571. private static _GetPluginForFilename;
  51572. private static _GetDirectLoad;
  51573. private static _LoadData;
  51574. private static _GetFileInfo;
  51575. /**
  51576. * Gets a plugin that can load the given extension
  51577. * @param extension defines the extension to load
  51578. * @returns a plugin or null if none works
  51579. */
  51580. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51581. /**
  51582. * Gets a boolean indicating that the given extension can be loaded
  51583. * @param extension defines the extension to load
  51584. * @returns true if the extension is supported
  51585. */
  51586. static IsPluginForExtensionAvailable(extension: string): boolean;
  51587. /**
  51588. * Adds a new plugin to the list of registered plugins
  51589. * @param plugin defines the plugin to add
  51590. */
  51591. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51592. /**
  51593. * Import meshes into a scene
  51594. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51595. * @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)
  51596. * @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)
  51597. * @param scene the instance of BABYLON.Scene to append to
  51598. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51599. * @param onProgress a callback with a progress event for each file being loaded
  51600. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51601. * @param pluginExtension the extension used to determine the plugin
  51602. * @returns The loaded plugin
  51603. */
  51604. 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>;
  51605. /**
  51606. * Import meshes into a scene
  51607. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51608. * @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)
  51609. * @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)
  51610. * @param scene the instance of BABYLON.Scene to append to
  51611. * @param onProgress a callback with a progress event for each file being loaded
  51612. * @param pluginExtension the extension used to determine the plugin
  51613. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51614. */
  51615. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51616. /**
  51617. * Load a scene
  51618. * @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)
  51619. * @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)
  51620. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51621. * @param onSuccess a callback with the scene when import succeeds
  51622. * @param onProgress a callback with a progress event for each file being loaded
  51623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51624. * @param pluginExtension the extension used to determine the plugin
  51625. * @returns The loaded plugin
  51626. */
  51627. 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>;
  51628. /**
  51629. * Load a scene
  51630. * @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)
  51631. * @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)
  51632. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51633. * @param onProgress a callback with a progress event for each file being loaded
  51634. * @param pluginExtension the extension used to determine the plugin
  51635. * @returns The loaded scene
  51636. */
  51637. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51638. /**
  51639. * Append a scene
  51640. * @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)
  51641. * @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)
  51642. * @param scene is the instance of BABYLON.Scene to append to
  51643. * @param onSuccess a callback with the scene when import succeeds
  51644. * @param onProgress a callback with a progress event for each file being loaded
  51645. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51646. * @param pluginExtension the extension used to determine the plugin
  51647. * @returns The loaded plugin
  51648. */
  51649. 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>;
  51650. /**
  51651. * Append a scene
  51652. * @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)
  51653. * @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)
  51654. * @param scene is the instance of BABYLON.Scene to append to
  51655. * @param onProgress a callback with a progress event for each file being loaded
  51656. * @param pluginExtension the extension used to determine the plugin
  51657. * @returns The given scene
  51658. */
  51659. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51660. /**
  51661. * Load a scene into an asset container
  51662. * @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)
  51663. * @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)
  51664. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51665. * @param onSuccess a callback with the scene when import succeeds
  51666. * @param onProgress a callback with a progress event for each file being loaded
  51667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51668. * @param pluginExtension the extension used to determine the plugin
  51669. * @returns The loaded plugin
  51670. */
  51671. 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>;
  51672. /**
  51673. * Load a scene into an asset container
  51674. * @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)
  51675. * @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)
  51676. * @param scene is the instance of Scene to append to
  51677. * @param onProgress a callback with a progress event for each file being loaded
  51678. * @param pluginExtension the extension used to determine the plugin
  51679. * @returns The loaded asset container
  51680. */
  51681. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51682. /**
  51683. * Import animations from a file into a scene
  51684. * @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)
  51685. * @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)
  51686. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51687. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51688. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51689. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51690. * @param onSuccess a callback with the scene when import succeeds
  51691. * @param onProgress a callback with a progress event for each file being loaded
  51692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51693. * @param pluginExtension the extension used to determine the plugin
  51694. */
  51695. 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;
  51696. /**
  51697. * Import animations from a file into a scene
  51698. * @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)
  51699. * @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)
  51700. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51701. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51702. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51703. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51704. * @param onSuccess a callback with the scene when import succeeds
  51705. * @param onProgress a callback with a progress event for each file being loaded
  51706. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51707. * @param pluginExtension the extension used to determine the plugin
  51708. * @returns the updated scene with imported animations
  51709. */
  51710. 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>;
  51711. }
  51712. }
  51713. declare module BABYLON {
  51714. /**
  51715. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51716. */
  51717. export type MotionControllerHandedness = "none" | "left" | "right";
  51718. /**
  51719. * The type of components available in motion controllers.
  51720. * This is not the name of the component.
  51721. */
  51722. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51723. /**
  51724. * The state of a controller component
  51725. */
  51726. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51727. /**
  51728. * The schema of motion controller layout.
  51729. * No object will be initialized using this interface
  51730. * This is used just to define the profile.
  51731. */
  51732. export interface IMotionControllerLayout {
  51733. /**
  51734. * Path to load the assets. Usually relative to the base path
  51735. */
  51736. assetPath: string;
  51737. /**
  51738. * Available components (unsorted)
  51739. */
  51740. components: {
  51741. /**
  51742. * A map of component Ids
  51743. */
  51744. [componentId: string]: {
  51745. /**
  51746. * The type of input the component outputs
  51747. */
  51748. type: MotionControllerComponentType;
  51749. /**
  51750. * The indices of this component in the gamepad object
  51751. */
  51752. gamepadIndices: {
  51753. /**
  51754. * Index of button
  51755. */
  51756. button?: number;
  51757. /**
  51758. * If available, index of x-axis
  51759. */
  51760. xAxis?: number;
  51761. /**
  51762. * If available, index of y-axis
  51763. */
  51764. yAxis?: number;
  51765. };
  51766. /**
  51767. * The mesh's root node name
  51768. */
  51769. rootNodeName: string;
  51770. /**
  51771. * Animation definitions for this model
  51772. */
  51773. visualResponses: {
  51774. [stateKey: string]: {
  51775. /**
  51776. * What property will be animated
  51777. */
  51778. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51779. /**
  51780. * What states influence this visual response
  51781. */
  51782. states: MotionControllerComponentStateType[];
  51783. /**
  51784. * Type of animation - movement or visibility
  51785. */
  51786. valueNodeProperty: "transform" | "visibility";
  51787. /**
  51788. * Base node name to move. Its position will be calculated according to the min and max nodes
  51789. */
  51790. valueNodeName?: string;
  51791. /**
  51792. * Minimum movement node
  51793. */
  51794. minNodeName?: string;
  51795. /**
  51796. * Max movement node
  51797. */
  51798. maxNodeName?: string;
  51799. };
  51800. };
  51801. /**
  51802. * If touch enabled, what is the name of node to display user feedback
  51803. */
  51804. touchPointNodeName?: string;
  51805. };
  51806. };
  51807. /**
  51808. * Is it xr standard mapping or not
  51809. */
  51810. gamepadMapping: "" | "xr-standard";
  51811. /**
  51812. * Base root node of this entire model
  51813. */
  51814. rootNodeName: string;
  51815. /**
  51816. * Defines the main button component id
  51817. */
  51818. selectComponentId: string;
  51819. }
  51820. /**
  51821. * A definition for the layout map in the input profile
  51822. */
  51823. export interface IMotionControllerLayoutMap {
  51824. /**
  51825. * Layouts with handedness type as a key
  51826. */
  51827. [handedness: string]: IMotionControllerLayout;
  51828. }
  51829. /**
  51830. * The XR Input profile schema
  51831. * Profiles can be found here:
  51832. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51833. */
  51834. export interface IMotionControllerProfile {
  51835. /**
  51836. * fallback profiles for this profileId
  51837. */
  51838. fallbackProfileIds: string[];
  51839. /**
  51840. * The layout map, with handedness as key
  51841. */
  51842. layouts: IMotionControllerLayoutMap;
  51843. /**
  51844. * The id of this profile
  51845. * correlates to the profile(s) in the xrInput.profiles array
  51846. */
  51847. profileId: string;
  51848. }
  51849. /**
  51850. * A helper-interface for the 3 meshes needed for controller button animation
  51851. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51852. */
  51853. export interface IMotionControllerButtonMeshMap {
  51854. /**
  51855. * the mesh that defines the pressed value mesh position.
  51856. * This is used to find the max-position of this button
  51857. */
  51858. pressedMesh: AbstractMesh;
  51859. /**
  51860. * the mesh that defines the unpressed value mesh position.
  51861. * This is used to find the min (or initial) position of this button
  51862. */
  51863. unpressedMesh: AbstractMesh;
  51864. /**
  51865. * The mesh that will be changed when value changes
  51866. */
  51867. valueMesh: AbstractMesh;
  51868. }
  51869. /**
  51870. * A helper-interface for the 3 meshes needed for controller axis animation.
  51871. * This will be expanded when touchpad animations are fully supported
  51872. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51873. */
  51874. export interface IMotionControllerMeshMap {
  51875. /**
  51876. * the mesh that defines the maximum value mesh position.
  51877. */
  51878. maxMesh?: AbstractMesh;
  51879. /**
  51880. * the mesh that defines the minimum value mesh position.
  51881. */
  51882. minMesh?: AbstractMesh;
  51883. /**
  51884. * The mesh that will be changed when axis value changes
  51885. */
  51886. valueMesh?: AbstractMesh;
  51887. }
  51888. /**
  51889. * The elements needed for change-detection of the gamepad objects in motion controllers
  51890. */
  51891. export interface IMinimalMotionControllerObject {
  51892. /**
  51893. * Available axes of this controller
  51894. */
  51895. axes: number[];
  51896. /**
  51897. * An array of available buttons
  51898. */
  51899. buttons: Array<{
  51900. /**
  51901. * Value of the button/trigger
  51902. */
  51903. value: number;
  51904. /**
  51905. * If the button/trigger is currently touched
  51906. */
  51907. touched: boolean;
  51908. /**
  51909. * If the button/trigger is currently pressed
  51910. */
  51911. pressed: boolean;
  51912. }>;
  51913. /**
  51914. * EXPERIMENTAL haptic support.
  51915. */
  51916. hapticActuators?: Array<{
  51917. pulse: (value: number, duration: number) => Promise<boolean>;
  51918. }>;
  51919. }
  51920. /**
  51921. * An Abstract Motion controller
  51922. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51923. * Each component has an observable to check for changes in value and state
  51924. */
  51925. export abstract class WebXRAbstractMotionController implements IDisposable {
  51926. protected scene: Scene;
  51927. protected layout: IMotionControllerLayout;
  51928. /**
  51929. * The gamepad object correlating to this controller
  51930. */
  51931. gamepadObject: IMinimalMotionControllerObject;
  51932. /**
  51933. * handedness (left/right/none) of this controller
  51934. */
  51935. handedness: MotionControllerHandedness;
  51936. private _initComponent;
  51937. private _modelReady;
  51938. /**
  51939. * A map of components (WebXRControllerComponent) in this motion controller
  51940. * Components have a ComponentType and can also have both button and axis definitions
  51941. */
  51942. readonly components: {
  51943. [id: string]: WebXRControllerComponent;
  51944. };
  51945. /**
  51946. * Disable the model's animation. Can be set at any time.
  51947. */
  51948. disableAnimation: boolean;
  51949. /**
  51950. * Observers registered here will be triggered when the model of this controller is done loading
  51951. */
  51952. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51953. /**
  51954. * The profile id of this motion controller
  51955. */
  51956. abstract profileId: string;
  51957. /**
  51958. * The root mesh of the model. It is null if the model was not yet initialized
  51959. */
  51960. rootMesh: Nullable<AbstractMesh>;
  51961. /**
  51962. * constructs a new abstract motion controller
  51963. * @param scene the scene to which the model of the controller will be added
  51964. * @param layout The profile layout to load
  51965. * @param gamepadObject The gamepad object correlating to this controller
  51966. * @param handedness handedness (left/right/none) of this controller
  51967. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51968. */
  51969. constructor(scene: Scene, layout: IMotionControllerLayout,
  51970. /**
  51971. * The gamepad object correlating to this controller
  51972. */
  51973. gamepadObject: IMinimalMotionControllerObject,
  51974. /**
  51975. * handedness (left/right/none) of this controller
  51976. */
  51977. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51978. /**
  51979. * Dispose this controller, the model mesh and all its components
  51980. */
  51981. dispose(): void;
  51982. /**
  51983. * Returns all components of specific type
  51984. * @param type the type to search for
  51985. * @return an array of components with this type
  51986. */
  51987. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51988. /**
  51989. * get a component based an its component id as defined in layout.components
  51990. * @param id the id of the component
  51991. * @returns the component correlates to the id or undefined if not found
  51992. */
  51993. getComponent(id: string): WebXRControllerComponent;
  51994. /**
  51995. * Get the list of components available in this motion controller
  51996. * @returns an array of strings correlating to available components
  51997. */
  51998. getComponentIds(): string[];
  51999. /**
  52000. * Get the first component of specific type
  52001. * @param type type of component to find
  52002. * @return a controller component or null if not found
  52003. */
  52004. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  52005. /**
  52006. * Get the main (Select) component of this controller as defined in the layout
  52007. * @returns the main component of this controller
  52008. */
  52009. getMainComponent(): WebXRControllerComponent;
  52010. /**
  52011. * Loads the model correlating to this controller
  52012. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  52013. * @returns A promise fulfilled with the result of the model loading
  52014. */
  52015. loadModel(): Promise<boolean>;
  52016. /**
  52017. * Update this model using the current XRFrame
  52018. * @param xrFrame the current xr frame to use and update the model
  52019. */
  52020. updateFromXRFrame(xrFrame: XRFrame): void;
  52021. /**
  52022. * Backwards compatibility due to a deeply-integrated typo
  52023. */
  52024. get handness(): XREye;
  52025. /**
  52026. * Pulse (vibrate) this controller
  52027. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  52028. * Consecutive calls to this function will cancel the last pulse call
  52029. *
  52030. * @param value the strength of the pulse in 0.0...1.0 range
  52031. * @param duration Duration of the pulse in milliseconds
  52032. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  52033. * @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
  52034. */
  52035. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  52036. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52037. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52038. /**
  52039. * Moves the axis on the controller mesh based on its current state
  52040. * @param axis the index of the axis
  52041. * @param axisValue the value of the axis which determines the meshes new position
  52042. * @hidden
  52043. */
  52044. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52045. /**
  52046. * Update the model itself with the current frame data
  52047. * @param xrFrame the frame to use for updating the model mesh
  52048. */
  52049. protected updateModel(xrFrame: XRFrame): void;
  52050. /**
  52051. * Get the filename and path for this controller's model
  52052. * @returns a map of filename and path
  52053. */
  52054. protected abstract _getFilenameAndPath(): {
  52055. filename: string;
  52056. path: string;
  52057. };
  52058. /**
  52059. * This function is called before the mesh is loaded. It checks for loading constraints.
  52060. * For example, this function can check if the GLB loader is available
  52061. * If this function returns false, the generic controller will be loaded instead
  52062. * @returns Is the client ready to load the mesh
  52063. */
  52064. protected abstract _getModelLoadingConstraints(): boolean;
  52065. /**
  52066. * This function will be called after the model was successfully loaded and can be used
  52067. * for mesh transformations before it is available for the user
  52068. * @param meshes the loaded meshes
  52069. */
  52070. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52071. /**
  52072. * Set the root mesh for this controller. Important for the WebXR controller class
  52073. * @param meshes the loaded meshes
  52074. */
  52075. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52076. /**
  52077. * A function executed each frame that updates the mesh (if needed)
  52078. * @param xrFrame the current xrFrame
  52079. */
  52080. protected abstract _updateModel(xrFrame: XRFrame): void;
  52081. private _getGenericFilenameAndPath;
  52082. private _getGenericParentMesh;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * A generic trigger-only motion controller for WebXR
  52088. */
  52089. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52090. /**
  52091. * Static version of the profile id of this controller
  52092. */
  52093. static ProfileId: string;
  52094. profileId: string;
  52095. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52096. protected _getFilenameAndPath(): {
  52097. filename: string;
  52098. path: string;
  52099. };
  52100. protected _getModelLoadingConstraints(): boolean;
  52101. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52102. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52103. protected _updateModel(): void;
  52104. }
  52105. }
  52106. declare module BABYLON {
  52107. /**
  52108. * Class containing static functions to help procedurally build meshes
  52109. */
  52110. export class SphereBuilder {
  52111. /**
  52112. * Creates a sphere mesh
  52113. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52114. * * 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`)
  52115. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52116. * * 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
  52117. * * 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)
  52118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52119. * * 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
  52120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52121. * @param name defines the name of the mesh
  52122. * @param options defines the options used to create the mesh
  52123. * @param scene defines the hosting scene
  52124. * @returns the sphere mesh
  52125. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52126. */
  52127. static CreateSphere(name: string, options: {
  52128. segments?: number;
  52129. diameter?: number;
  52130. diameterX?: number;
  52131. diameterY?: number;
  52132. diameterZ?: number;
  52133. arc?: number;
  52134. slice?: number;
  52135. sideOrientation?: number;
  52136. frontUVs?: Vector4;
  52137. backUVs?: Vector4;
  52138. updatable?: boolean;
  52139. }, scene?: Nullable<Scene>): Mesh;
  52140. }
  52141. }
  52142. declare module BABYLON {
  52143. /**
  52144. * A profiled motion controller has its profile loaded from an online repository.
  52145. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52146. */
  52147. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52148. private _repositoryUrl;
  52149. private _buttonMeshMapping;
  52150. private _touchDots;
  52151. /**
  52152. * The profile ID of this controller. Will be populated when the controller initializes.
  52153. */
  52154. profileId: string;
  52155. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52156. dispose(): void;
  52157. protected _getFilenameAndPath(): {
  52158. filename: string;
  52159. path: string;
  52160. };
  52161. protected _getModelLoadingConstraints(): boolean;
  52162. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52163. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52164. protected _updateModel(_xrFrame: XRFrame): void;
  52165. }
  52166. }
  52167. declare module BABYLON {
  52168. /**
  52169. * A construction function type to create a new controller based on an xrInput object
  52170. */
  52171. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52172. /**
  52173. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52174. *
  52175. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52176. * it should be replaced with auto-loaded controllers.
  52177. *
  52178. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52179. */
  52180. export class WebXRMotionControllerManager {
  52181. private static _AvailableControllers;
  52182. private static _Fallbacks;
  52183. private static _ProfileLoadingPromises;
  52184. private static _ProfilesList;
  52185. /**
  52186. * The base URL of the online controller repository. Can be changed at any time.
  52187. */
  52188. static BaseRepositoryUrl: string;
  52189. /**
  52190. * Which repository gets priority - local or online
  52191. */
  52192. static PrioritizeOnlineRepository: boolean;
  52193. /**
  52194. * Use the online repository, or use only locally-defined controllers
  52195. */
  52196. static UseOnlineRepository: boolean;
  52197. /**
  52198. * Clear the cache used for profile loading and reload when requested again
  52199. */
  52200. static ClearProfilesCache(): void;
  52201. /**
  52202. * Register the default fallbacks.
  52203. * This function is called automatically when this file is imported.
  52204. */
  52205. static DefaultFallbacks(): void;
  52206. /**
  52207. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52208. * @param profileId the profile to which a fallback needs to be found
  52209. * @return an array with corresponding fallback profiles
  52210. */
  52211. static FindFallbackWithProfileId(profileId: string): string[];
  52212. /**
  52213. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52214. * The order of search:
  52215. *
  52216. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52217. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52218. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52219. * 4) return the generic trigger controller if none were found
  52220. *
  52221. * @param xrInput the xrInput to which a new controller is initialized
  52222. * @param scene the scene to which the model will be added
  52223. * @param forceProfile force a certain profile for this controller
  52224. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52225. */
  52226. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52227. /**
  52228. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52229. *
  52230. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52231. *
  52232. * @param type the profile type to register
  52233. * @param constructFunction the function to be called when loading this profile
  52234. */
  52235. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52236. /**
  52237. * Register a fallback to a specific profile.
  52238. * @param profileId the profileId that will receive the fallbacks
  52239. * @param fallbacks A list of fallback profiles
  52240. */
  52241. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52242. /**
  52243. * Will update the list of profiles available in the repository
  52244. * @return a promise that resolves to a map of profiles available online
  52245. */
  52246. static UpdateProfilesList(): Promise<{
  52247. [profile: string]: string;
  52248. }>;
  52249. private static _LoadProfileFromRepository;
  52250. private static _LoadProfilesFromAvailableControllers;
  52251. }
  52252. }
  52253. declare module BABYLON {
  52254. /**
  52255. * Configuration options for the WebXR controller creation
  52256. */
  52257. export interface IWebXRControllerOptions {
  52258. /**
  52259. * Should the controller mesh be animated when a user interacts with it
  52260. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52261. */
  52262. disableMotionControllerAnimation?: boolean;
  52263. /**
  52264. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52265. */
  52266. doNotLoadControllerMesh?: boolean;
  52267. /**
  52268. * Force a specific controller type for this controller.
  52269. * This can be used when creating your own profile or when testing different controllers
  52270. */
  52271. forceControllerProfile?: string;
  52272. /**
  52273. * Defines a rendering group ID for meshes that will be loaded.
  52274. * This is for the default controllers only.
  52275. */
  52276. renderingGroupId?: number;
  52277. }
  52278. /**
  52279. * Represents an XR controller
  52280. */
  52281. export class WebXRInputSource {
  52282. private _scene;
  52283. /** The underlying input source for the controller */
  52284. inputSource: XRInputSource;
  52285. private _options;
  52286. private _tmpVector;
  52287. private _uniqueId;
  52288. private _disposed;
  52289. /**
  52290. * 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
  52291. */
  52292. grip?: AbstractMesh;
  52293. /**
  52294. * If available, this is the gamepad object related to this controller.
  52295. * Using this object it is possible to get click events and trackpad changes of the
  52296. * webxr controller that is currently being used.
  52297. */
  52298. motionController?: WebXRAbstractMotionController;
  52299. /**
  52300. * Event that fires when the controller is removed/disposed.
  52301. * The object provided as event data is this controller, after associated assets were disposed.
  52302. * uniqueId is still available.
  52303. */
  52304. onDisposeObservable: Observable<WebXRInputSource>;
  52305. /**
  52306. * Will be triggered when the mesh associated with the motion controller is done loading.
  52307. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52308. * A shortened version of controller -> motion controller -> on mesh loaded.
  52309. */
  52310. onMeshLoadedObservable: Observable<AbstractMesh>;
  52311. /**
  52312. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52313. */
  52314. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52315. /**
  52316. * Pointer which can be used to select objects or attach a visible laser to
  52317. */
  52318. pointer: AbstractMesh;
  52319. /**
  52320. * Creates the input source object
  52321. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52322. * @param _scene the scene which the controller should be associated to
  52323. * @param inputSource the underlying input source for the controller
  52324. * @param _options options for this controller creation
  52325. */
  52326. constructor(_scene: Scene,
  52327. /** The underlying input source for the controller */
  52328. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52329. /**
  52330. * Get this controllers unique id
  52331. */
  52332. get uniqueId(): string;
  52333. /**
  52334. * Disposes of the object
  52335. */
  52336. dispose(): void;
  52337. /**
  52338. * Gets a world space ray coming from the pointer or grip
  52339. * @param result the resulting ray
  52340. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52341. */
  52342. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52343. /**
  52344. * Updates the controller pose based on the given XRFrame
  52345. * @param xrFrame xr frame to update the pose with
  52346. * @param referenceSpace reference space to use
  52347. */
  52348. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52349. }
  52350. }
  52351. declare module BABYLON {
  52352. /**
  52353. * The schema for initialization options of the XR Input class
  52354. */
  52355. export interface IWebXRInputOptions {
  52356. /**
  52357. * If set to true no model will be automatically loaded
  52358. */
  52359. doNotLoadControllerMeshes?: boolean;
  52360. /**
  52361. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52362. * If not found, the xr input profile data will be used.
  52363. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52364. */
  52365. forceInputProfile?: string;
  52366. /**
  52367. * Do not send a request to the controller repository to load the profile.
  52368. *
  52369. * Instead, use the controllers available in babylon itself.
  52370. */
  52371. disableOnlineControllerRepository?: boolean;
  52372. /**
  52373. * A custom URL for the controllers repository
  52374. */
  52375. customControllersRepositoryURL?: string;
  52376. /**
  52377. * Should the controller model's components not move according to the user input
  52378. */
  52379. disableControllerAnimation?: boolean;
  52380. /**
  52381. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52382. */
  52383. controllerOptions?: IWebXRControllerOptions;
  52384. }
  52385. /**
  52386. * XR input used to track XR inputs such as controllers/rays
  52387. */
  52388. export class WebXRInput implements IDisposable {
  52389. /**
  52390. * the xr session manager for this session
  52391. */
  52392. xrSessionManager: WebXRSessionManager;
  52393. /**
  52394. * the WebXR camera for this session. Mainly used for teleportation
  52395. */
  52396. xrCamera: WebXRCamera;
  52397. private readonly options;
  52398. /**
  52399. * XR controllers being tracked
  52400. */
  52401. controllers: Array<WebXRInputSource>;
  52402. private _frameObserver;
  52403. private _sessionEndedObserver;
  52404. private _sessionInitObserver;
  52405. /**
  52406. * Event when a controller has been connected/added
  52407. */
  52408. onControllerAddedObservable: Observable<WebXRInputSource>;
  52409. /**
  52410. * Event when a controller has been removed/disconnected
  52411. */
  52412. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52413. /**
  52414. * Initializes the WebXRInput
  52415. * @param xrSessionManager the xr session manager for this session
  52416. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52417. * @param options = initialization options for this xr input
  52418. */
  52419. constructor(
  52420. /**
  52421. * the xr session manager for this session
  52422. */
  52423. xrSessionManager: WebXRSessionManager,
  52424. /**
  52425. * the WebXR camera for this session. Mainly used for teleportation
  52426. */
  52427. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52428. private _onInputSourcesChange;
  52429. private _addAndRemoveControllers;
  52430. /**
  52431. * Disposes of the object
  52432. */
  52433. dispose(): void;
  52434. }
  52435. }
  52436. declare module BABYLON {
  52437. /**
  52438. * This is the base class for all WebXR features.
  52439. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52440. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52441. */
  52442. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52443. protected _xrSessionManager: WebXRSessionManager;
  52444. private _attached;
  52445. private _removeOnDetach;
  52446. /**
  52447. * Is this feature disposed?
  52448. */
  52449. isDisposed: boolean;
  52450. /**
  52451. * Should auto-attach be disabled?
  52452. */
  52453. disableAutoAttach: boolean;
  52454. /**
  52455. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52456. */
  52457. xrNativeFeatureName: string;
  52458. /**
  52459. * Construct a new (abstract) WebXR feature
  52460. * @param _xrSessionManager the xr session manager for this feature
  52461. */
  52462. constructor(_xrSessionManager: WebXRSessionManager);
  52463. /**
  52464. * Is this feature attached
  52465. */
  52466. get attached(): boolean;
  52467. /**
  52468. * attach this feature
  52469. *
  52470. * @param force should attachment be forced (even when already attached)
  52471. * @returns true if successful, false is failed or already attached
  52472. */
  52473. attach(force?: boolean): boolean;
  52474. /**
  52475. * detach this feature.
  52476. *
  52477. * @returns true if successful, false if failed or already detached
  52478. */
  52479. detach(): boolean;
  52480. /**
  52481. * Dispose this feature and all of the resources attached
  52482. */
  52483. dispose(): void;
  52484. /**
  52485. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52486. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52487. *
  52488. * @returns whether or not the feature is compatible in this environment
  52489. */
  52490. isCompatible(): boolean;
  52491. /**
  52492. * This is used to register callbacks that will automatically be removed when detach is called.
  52493. * @param observable the observable to which the observer will be attached
  52494. * @param callback the callback to register
  52495. */
  52496. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52497. /**
  52498. * Code in this function will be executed on each xrFrame received from the browser.
  52499. * This function will not execute after the feature is detached.
  52500. * @param _xrFrame the current frame
  52501. */
  52502. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /**
  52507. * Renders a layer on top of an existing scene
  52508. */
  52509. export class UtilityLayerRenderer implements IDisposable {
  52510. /** the original scene that will be rendered on top of */
  52511. originalScene: Scene;
  52512. private _pointerCaptures;
  52513. private _lastPointerEvents;
  52514. private static _DefaultUtilityLayer;
  52515. private static _DefaultKeepDepthUtilityLayer;
  52516. private _sharedGizmoLight;
  52517. private _renderCamera;
  52518. /**
  52519. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52520. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52521. * @returns the camera that is used when rendering the utility layer
  52522. */
  52523. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52524. /**
  52525. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52526. * @param cam the camera that should be used when rendering the utility layer
  52527. */
  52528. setRenderCamera(cam: Nullable<Camera>): void;
  52529. /**
  52530. * @hidden
  52531. * Light which used by gizmos to get light shading
  52532. */
  52533. _getSharedGizmoLight(): HemisphericLight;
  52534. /**
  52535. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52536. */
  52537. pickUtilitySceneFirst: boolean;
  52538. /**
  52539. * 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)
  52540. */
  52541. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52542. /**
  52543. * 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)
  52544. */
  52545. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52546. /**
  52547. * The scene that is rendered on top of the original scene
  52548. */
  52549. utilityLayerScene: Scene;
  52550. /**
  52551. * If the utility layer should automatically be rendered on top of existing scene
  52552. */
  52553. shouldRender: boolean;
  52554. /**
  52555. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52556. */
  52557. onlyCheckPointerDownEvents: boolean;
  52558. /**
  52559. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52560. */
  52561. processAllEvents: boolean;
  52562. /**
  52563. * Observable raised when the pointer move from the utility layer scene to the main scene
  52564. */
  52565. onPointerOutObservable: Observable<number>;
  52566. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52567. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52568. private _afterRenderObserver;
  52569. private _sceneDisposeObserver;
  52570. private _originalPointerObserver;
  52571. /**
  52572. * Instantiates a UtilityLayerRenderer
  52573. * @param originalScene the original scene that will be rendered on top of
  52574. * @param handleEvents boolean indicating if the utility layer should handle events
  52575. */
  52576. constructor(
  52577. /** the original scene that will be rendered on top of */
  52578. originalScene: Scene, handleEvents?: boolean);
  52579. private _notifyObservers;
  52580. /**
  52581. * Renders the utility layers scene on top of the original scene
  52582. */
  52583. render(): void;
  52584. /**
  52585. * Disposes of the renderer
  52586. */
  52587. dispose(): void;
  52588. private _updateCamera;
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. /**
  52593. * Options interface for the pointer selection module
  52594. */
  52595. export interface IWebXRControllerPointerSelectionOptions {
  52596. /**
  52597. * if provided, this scene will be used to render meshes.
  52598. */
  52599. customUtilityLayerScene?: Scene;
  52600. /**
  52601. * 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)
  52602. * If not disabled, the last picked point will be used to execute a pointer up event
  52603. * If disabled, pointer up event will be triggered right after the pointer down event.
  52604. * Used in screen and gaze target ray mode only
  52605. */
  52606. disablePointerUpOnTouchOut: boolean;
  52607. /**
  52608. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52609. */
  52610. forceGazeMode: boolean;
  52611. /**
  52612. * 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
  52613. * to start a new countdown to the pointer down event.
  52614. * Defaults to 1.
  52615. */
  52616. gazeModePointerMovedFactor?: number;
  52617. /**
  52618. * Different button type to use instead of the main component
  52619. */
  52620. overrideButtonId?: string;
  52621. /**
  52622. * use this rendering group id for the meshes (optional)
  52623. */
  52624. renderingGroupId?: number;
  52625. /**
  52626. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52627. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52628. * 3000 means 3 seconds between pointing at something and selecting it
  52629. */
  52630. timeToSelect?: number;
  52631. /**
  52632. * Should meshes created here be added to a utility layer or the main scene
  52633. */
  52634. useUtilityLayer?: boolean;
  52635. /**
  52636. * Optional WebXR camera to be used for gaze selection
  52637. */
  52638. gazeCamera?: WebXRCamera;
  52639. /**
  52640. * the xr input to use with this pointer selection
  52641. */
  52642. xrInput: WebXRInput;
  52643. /**
  52644. * Should the scene pointerX and pointerY update be disabled
  52645. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52646. * Disable in VR, if not needed.
  52647. * The first rig camera (left eye) will be used to calculate the projection
  52648. */
  52649. disableScenePointerVectorUpdate: boolean;
  52650. /**
  52651. * Enable pointer selection on all controllers instead of switching between them
  52652. */
  52653. enablePointerSelectionOnAllControllers?: boolean;
  52654. /**
  52655. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52656. * If switch is enabled, it will still allow the user to switch between the different controllers
  52657. */
  52658. preferredHandedness?: XRHandedness;
  52659. /**
  52660. * Disable switching the pointer selection from one controller to the other.
  52661. * 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
  52662. */
  52663. disableSwitchOnClick?: boolean;
  52664. /**
  52665. * The maximum distance of the pointer selection feature. Defaults to 100.
  52666. */
  52667. maxPointerDistance?: number;
  52668. }
  52669. /**
  52670. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52671. */
  52672. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52673. private readonly _options;
  52674. private static _idCounter;
  52675. private _attachController;
  52676. private _controllers;
  52677. private _scene;
  52678. private _tmpVectorForPickCompare;
  52679. private _attachedController;
  52680. /**
  52681. * The module's name
  52682. */
  52683. static readonly Name: string;
  52684. /**
  52685. * The (Babylon) version of this module.
  52686. * This is an integer representing the implementation version.
  52687. * This number does not correspond to the WebXR specs version
  52688. */
  52689. static readonly Version: number;
  52690. /**
  52691. * Disable lighting on the laser pointer (so it will always be visible)
  52692. */
  52693. disablePointerLighting: boolean;
  52694. /**
  52695. * Disable lighting on the selection mesh (so it will always be visible)
  52696. */
  52697. disableSelectionMeshLighting: boolean;
  52698. /**
  52699. * Should the laser pointer be displayed
  52700. */
  52701. displayLaserPointer: boolean;
  52702. /**
  52703. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52704. */
  52705. displaySelectionMesh: boolean;
  52706. /**
  52707. * This color will be set to the laser pointer when selection is triggered
  52708. */
  52709. laserPointerPickedColor: Color3;
  52710. /**
  52711. * Default color of the laser pointer
  52712. */
  52713. laserPointerDefaultColor: Color3;
  52714. /**
  52715. * default color of the selection ring
  52716. */
  52717. selectionMeshDefaultColor: Color3;
  52718. /**
  52719. * This color will be applied to the selection ring when selection is triggered
  52720. */
  52721. selectionMeshPickedColor: Color3;
  52722. /**
  52723. * Optional filter to be used for ray selection. This predicate shares behavior with
  52724. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52725. */
  52726. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52727. /**
  52728. * constructs a new background remover module
  52729. * @param _xrSessionManager the session manager for this module
  52730. * @param _options read-only options to be used in this module
  52731. */
  52732. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52733. /**
  52734. * attach this feature
  52735. * Will usually be called by the features manager
  52736. *
  52737. * @returns true if successful.
  52738. */
  52739. attach(): boolean;
  52740. /**
  52741. * detach this feature.
  52742. * Will usually be called by the features manager
  52743. *
  52744. * @returns true if successful.
  52745. */
  52746. detach(): boolean;
  52747. /**
  52748. * Will get the mesh under a specific pointer.
  52749. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52750. * @param controllerId the controllerId to check
  52751. * @returns The mesh under pointer or null if no mesh is under the pointer
  52752. */
  52753. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52754. /**
  52755. * Get the xr controller that correlates to the pointer id in the pointer event
  52756. *
  52757. * @param id the pointer id to search for
  52758. * @returns the controller that correlates to this id or null if not found
  52759. */
  52760. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52761. private _identityMatrix;
  52762. private _screenCoordinatesRef;
  52763. private _viewportRef;
  52764. protected _onXRFrame(_xrFrame: XRFrame): void;
  52765. private _attachGazeMode;
  52766. private _attachScreenRayMode;
  52767. private _attachTrackedPointerRayMode;
  52768. private _convertNormalToDirectionOfRay;
  52769. private _detachController;
  52770. private _generateNewMeshPair;
  52771. private _pickingMoved;
  52772. private _updatePointerDistance;
  52773. /** @hidden */
  52774. get lasterPointerDefaultColor(): Color3;
  52775. }
  52776. }
  52777. declare module BABYLON {
  52778. /**
  52779. * Button which can be used to enter a different mode of XR
  52780. */
  52781. export class WebXREnterExitUIButton {
  52782. /** button element */
  52783. element: HTMLElement;
  52784. /** XR initialization options for the button */
  52785. sessionMode: XRSessionMode;
  52786. /** Reference space type */
  52787. referenceSpaceType: XRReferenceSpaceType;
  52788. /**
  52789. * Creates a WebXREnterExitUIButton
  52790. * @param element button element
  52791. * @param sessionMode XR initialization session mode
  52792. * @param referenceSpaceType the type of reference space to be used
  52793. */
  52794. constructor(
  52795. /** button element */
  52796. element: HTMLElement,
  52797. /** XR initialization options for the button */
  52798. sessionMode: XRSessionMode,
  52799. /** Reference space type */
  52800. referenceSpaceType: XRReferenceSpaceType);
  52801. /**
  52802. * Extendable function which can be used to update the button's visuals when the state changes
  52803. * @param activeButton the current active button in the UI
  52804. */
  52805. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52806. }
  52807. /**
  52808. * Options to create the webXR UI
  52809. */
  52810. export class WebXREnterExitUIOptions {
  52811. /**
  52812. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52813. */
  52814. customButtons?: Array<WebXREnterExitUIButton>;
  52815. /**
  52816. * A reference space type to use when creating the default button.
  52817. * Default is local-floor
  52818. */
  52819. referenceSpaceType?: XRReferenceSpaceType;
  52820. /**
  52821. * Context to enter xr with
  52822. */
  52823. renderTarget?: Nullable<WebXRRenderTarget>;
  52824. /**
  52825. * A session mode to use when creating the default button.
  52826. * Default is immersive-vr
  52827. */
  52828. sessionMode?: XRSessionMode;
  52829. /**
  52830. * A list of optional features to init the session with
  52831. */
  52832. optionalFeatures?: string[];
  52833. /**
  52834. * A list of optional features to init the session with
  52835. */
  52836. requiredFeatures?: string[];
  52837. /**
  52838. * If defined, this function will be executed if the UI encounters an error when entering XR
  52839. */
  52840. onError?: (error: any) => void;
  52841. }
  52842. /**
  52843. * UI to allow the user to enter/exit XR mode
  52844. */
  52845. export class WebXREnterExitUI implements IDisposable {
  52846. private scene;
  52847. /** version of the options passed to this UI */
  52848. options: WebXREnterExitUIOptions;
  52849. private _activeButton;
  52850. private _buttons;
  52851. /**
  52852. * The HTML Div Element to which buttons are added.
  52853. */
  52854. readonly overlay: HTMLDivElement;
  52855. /**
  52856. * Fired every time the active button is changed.
  52857. *
  52858. * When xr is entered via a button that launches xr that button will be the callback parameter
  52859. *
  52860. * When exiting xr the callback parameter will be null)
  52861. */
  52862. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52863. /**
  52864. *
  52865. * @param scene babylon scene object to use
  52866. * @param options (read-only) version of the options passed to this UI
  52867. */
  52868. private constructor();
  52869. /**
  52870. * Creates UI to allow the user to enter/exit XR mode
  52871. * @param scene the scene to add the ui to
  52872. * @param helper the xr experience helper to enter/exit xr with
  52873. * @param options options to configure the UI
  52874. * @returns the created ui
  52875. */
  52876. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52877. /**
  52878. * Disposes of the XR UI component
  52879. */
  52880. dispose(): void;
  52881. private _updateButtons;
  52882. }
  52883. }
  52884. declare module BABYLON {
  52885. /**
  52886. * Class containing static functions to help procedurally build meshes
  52887. */
  52888. export class LinesBuilder {
  52889. /**
  52890. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52891. * * 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
  52892. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52893. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52894. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52895. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52896. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52897. * * 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
  52898. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52901. * @param name defines the name of the new line system
  52902. * @param options defines the options used to create the line system
  52903. * @param scene defines the hosting scene
  52904. * @returns a new line system mesh
  52905. */
  52906. static CreateLineSystem(name: string, options: {
  52907. lines: Vector3[][];
  52908. updatable?: boolean;
  52909. instance?: Nullable<LinesMesh>;
  52910. colors?: Nullable<Color4[][]>;
  52911. useVertexAlpha?: boolean;
  52912. }, scene: Nullable<Scene>): LinesMesh;
  52913. /**
  52914. * Creates a line mesh
  52915. * 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
  52916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52917. * * The parameter `points` is an array successive Vector3
  52918. * * 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
  52919. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52920. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52921. * * When updating an instance, remember that only point positions can change, not the number of points
  52922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52924. * @param name defines the name of the new line system
  52925. * @param options defines the options used to create the line system
  52926. * @param scene defines the hosting scene
  52927. * @returns a new line mesh
  52928. */
  52929. static CreateLines(name: string, options: {
  52930. points: Vector3[];
  52931. updatable?: boolean;
  52932. instance?: Nullable<LinesMesh>;
  52933. colors?: Color4[];
  52934. useVertexAlpha?: boolean;
  52935. }, scene?: Nullable<Scene>): LinesMesh;
  52936. /**
  52937. * Creates a dashed line mesh
  52938. * * 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
  52939. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52940. * * The parameter `points` is an array successive Vector3
  52941. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52942. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52943. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52944. * * 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
  52945. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52946. * * When updating an instance, remember that only point positions can change, not the number of points
  52947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52948. * @param name defines the name of the mesh
  52949. * @param options defines the options used to create the mesh
  52950. * @param scene defines the hosting scene
  52951. * @returns the dashed line mesh
  52952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52953. */
  52954. static CreateDashedLines(name: string, options: {
  52955. points: Vector3[];
  52956. dashSize?: number;
  52957. gapSize?: number;
  52958. dashNb?: number;
  52959. updatable?: boolean;
  52960. instance?: LinesMesh;
  52961. useVertexAlpha?: boolean;
  52962. }, scene?: Nullable<Scene>): LinesMesh;
  52963. }
  52964. }
  52965. declare module BABYLON {
  52966. /**
  52967. * Construction options for a timer
  52968. */
  52969. export interface ITimerOptions<T> {
  52970. /**
  52971. * Time-to-end
  52972. */
  52973. timeout: number;
  52974. /**
  52975. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52976. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52977. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52978. */
  52979. contextObservable: Observable<T>;
  52980. /**
  52981. * Optional parameters when adding an observer to the observable
  52982. */
  52983. observableParameters?: {
  52984. mask?: number;
  52985. insertFirst?: boolean;
  52986. scope?: any;
  52987. };
  52988. /**
  52989. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52990. */
  52991. breakCondition?: (data?: ITimerData<T>) => boolean;
  52992. /**
  52993. * Will be triggered when the time condition has met
  52994. */
  52995. onEnded?: (data: ITimerData<any>) => void;
  52996. /**
  52997. * Will be triggered when the break condition has met (prematurely ended)
  52998. */
  52999. onAborted?: (data: ITimerData<any>) => void;
  53000. /**
  53001. * Optional function to execute on each tick (or count)
  53002. */
  53003. onTick?: (data: ITimerData<any>) => void;
  53004. }
  53005. /**
  53006. * An interface defining the data sent by the timer
  53007. */
  53008. export interface ITimerData<T> {
  53009. /**
  53010. * When did it start
  53011. */
  53012. startTime: number;
  53013. /**
  53014. * Time now
  53015. */
  53016. currentTime: number;
  53017. /**
  53018. * Time passed since started
  53019. */
  53020. deltaTime: number;
  53021. /**
  53022. * How much is completed, in [0.0...1.0].
  53023. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  53024. */
  53025. completeRate: number;
  53026. /**
  53027. * What the registered observable sent in the last count
  53028. */
  53029. payload: T;
  53030. }
  53031. /**
  53032. * The current state of the timer
  53033. */
  53034. export enum TimerState {
  53035. /**
  53036. * Timer initialized, not yet started
  53037. */
  53038. INIT = 0,
  53039. /**
  53040. * Timer started and counting
  53041. */
  53042. STARTED = 1,
  53043. /**
  53044. * Timer ended (whether aborted or time reached)
  53045. */
  53046. ENDED = 2
  53047. }
  53048. /**
  53049. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53050. *
  53051. * @param options options with which to initialize this timer
  53052. */
  53053. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53054. /**
  53055. * An advanced implementation of a timer class
  53056. */
  53057. export class AdvancedTimer<T = any> implements IDisposable {
  53058. /**
  53059. * Will notify each time the timer calculates the remaining time
  53060. */
  53061. onEachCountObservable: Observable<ITimerData<T>>;
  53062. /**
  53063. * Will trigger when the timer was aborted due to the break condition
  53064. */
  53065. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53066. /**
  53067. * Will trigger when the timer ended successfully
  53068. */
  53069. onTimerEndedObservable: Observable<ITimerData<T>>;
  53070. /**
  53071. * Will trigger when the timer state has changed
  53072. */
  53073. onStateChangedObservable: Observable<TimerState>;
  53074. private _observer;
  53075. private _contextObservable;
  53076. private _observableParameters;
  53077. private _startTime;
  53078. private _timer;
  53079. private _state;
  53080. private _breakCondition;
  53081. private _timeToEnd;
  53082. private _breakOnNextTick;
  53083. /**
  53084. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53085. * @param options construction options for this advanced timer
  53086. */
  53087. constructor(options: ITimerOptions<T>);
  53088. /**
  53089. * set a breaking condition for this timer. Default is to never break during count
  53090. * @param predicate the new break condition. Returns true to break, false otherwise
  53091. */
  53092. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53093. /**
  53094. * Reset ALL associated observables in this advanced timer
  53095. */
  53096. clearObservables(): void;
  53097. /**
  53098. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53099. *
  53100. * @param timeToEnd how much time to measure until timer ended
  53101. */
  53102. start(timeToEnd?: number): void;
  53103. /**
  53104. * Will force a stop on the next tick.
  53105. */
  53106. stop(): void;
  53107. /**
  53108. * Dispose this timer, clearing all resources
  53109. */
  53110. dispose(): void;
  53111. private _setState;
  53112. private _tick;
  53113. private _stop;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /**
  53118. * The options container for the teleportation module
  53119. */
  53120. export interface IWebXRTeleportationOptions {
  53121. /**
  53122. * if provided, this scene will be used to render meshes.
  53123. */
  53124. customUtilityLayerScene?: Scene;
  53125. /**
  53126. * Values to configure the default target mesh
  53127. */
  53128. defaultTargetMeshOptions?: {
  53129. /**
  53130. * Fill color of the teleportation area
  53131. */
  53132. teleportationFillColor?: string;
  53133. /**
  53134. * Border color for the teleportation area
  53135. */
  53136. teleportationBorderColor?: string;
  53137. /**
  53138. * Disable the mesh's animation sequence
  53139. */
  53140. disableAnimation?: boolean;
  53141. /**
  53142. * Disable lighting on the material or the ring and arrow
  53143. */
  53144. disableLighting?: boolean;
  53145. /**
  53146. * Override the default material of the torus and arrow
  53147. */
  53148. torusArrowMaterial?: Material;
  53149. };
  53150. /**
  53151. * A list of meshes to use as floor meshes.
  53152. * Meshes can be added and removed after initializing the feature using the
  53153. * addFloorMesh and removeFloorMesh functions
  53154. * If empty, rotation will still work
  53155. */
  53156. floorMeshes?: AbstractMesh[];
  53157. /**
  53158. * use this rendering group id for the meshes (optional)
  53159. */
  53160. renderingGroupId?: number;
  53161. /**
  53162. * Should teleportation move only to snap points
  53163. */
  53164. snapPointsOnly?: boolean;
  53165. /**
  53166. * An array of points to which the teleportation will snap to.
  53167. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53168. */
  53169. snapPositions?: Vector3[];
  53170. /**
  53171. * How close should the teleportation ray be in order to snap to position.
  53172. * Default to 0.8 units (meters)
  53173. */
  53174. snapToPositionRadius?: number;
  53175. /**
  53176. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53177. * If you want to support rotation, make sure your mesh has a direction indicator.
  53178. *
  53179. * When left untouched, the default mesh will be initialized.
  53180. */
  53181. teleportationTargetMesh?: AbstractMesh;
  53182. /**
  53183. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53184. */
  53185. timeToTeleport?: number;
  53186. /**
  53187. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53188. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53189. */
  53190. useMainComponentOnly?: boolean;
  53191. /**
  53192. * Should meshes created here be added to a utility layer or the main scene
  53193. */
  53194. useUtilityLayer?: boolean;
  53195. /**
  53196. * Babylon XR Input class for controller
  53197. */
  53198. xrInput: WebXRInput;
  53199. /**
  53200. * Meshes that the teleportation ray cannot go through
  53201. */
  53202. pickBlockerMeshes?: AbstractMesh[];
  53203. /**
  53204. * Should teleport work only on a specific hand?
  53205. */
  53206. forceHandedness?: XRHandedness;
  53207. /**
  53208. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53209. */
  53210. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53211. }
  53212. /**
  53213. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53214. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53215. * the input of the attached controllers.
  53216. */
  53217. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53218. private _options;
  53219. private _controllers;
  53220. private _currentTeleportationControllerId;
  53221. private _floorMeshes;
  53222. private _quadraticBezierCurve;
  53223. private _selectionFeature;
  53224. private _snapToPositions;
  53225. private _snappedToPoint;
  53226. private _teleportationRingMaterial?;
  53227. private _tmpRay;
  53228. private _tmpVector;
  53229. private _tmpQuaternion;
  53230. /**
  53231. * The module's name
  53232. */
  53233. static readonly Name: string;
  53234. /**
  53235. * The (Babylon) version of this module.
  53236. * This is an integer representing the implementation version.
  53237. * This number does not correspond to the webxr specs version
  53238. */
  53239. static readonly Version: number;
  53240. /**
  53241. * Is movement backwards enabled
  53242. */
  53243. backwardsMovementEnabled: boolean;
  53244. /**
  53245. * Distance to travel when moving backwards
  53246. */
  53247. backwardsTeleportationDistance: number;
  53248. /**
  53249. * The distance from the user to the inspection point in the direction of the controller
  53250. * A higher number will allow the user to move further
  53251. * defaults to 5 (meters, in xr units)
  53252. */
  53253. parabolicCheckRadius: number;
  53254. /**
  53255. * Should the module support parabolic ray on top of direct ray
  53256. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53257. * Very helpful when moving between floors / different heights
  53258. */
  53259. parabolicRayEnabled: boolean;
  53260. /**
  53261. * The second type of ray - straight line.
  53262. * Should it be enabled or should the parabolic line be the only one.
  53263. */
  53264. straightRayEnabled: boolean;
  53265. /**
  53266. * How much rotation should be applied when rotating right and left
  53267. */
  53268. rotationAngle: number;
  53269. private _rotationEnabled;
  53270. /**
  53271. * Is rotation enabled when moving forward?
  53272. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53273. */
  53274. get rotationEnabled(): boolean;
  53275. /**
  53276. * Sets wether rotation is enabled or not
  53277. * @param enabled is rotation enabled when teleportation is shown
  53278. */
  53279. set rotationEnabled(enabled: boolean);
  53280. /**
  53281. * Exposes the currently set teleportation target mesh.
  53282. */
  53283. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53284. /**
  53285. * constructs a new anchor system
  53286. * @param _xrSessionManager an instance of WebXRSessionManager
  53287. * @param _options configuration object for this feature
  53288. */
  53289. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53290. /**
  53291. * Get the snapPointsOnly flag
  53292. */
  53293. get snapPointsOnly(): boolean;
  53294. /**
  53295. * Sets the snapPointsOnly flag
  53296. * @param snapToPoints should teleportation be exclusively to snap points
  53297. */
  53298. set snapPointsOnly(snapToPoints: boolean);
  53299. /**
  53300. * Add a new mesh to the floor meshes array
  53301. * @param mesh the mesh to use as floor mesh
  53302. */
  53303. addFloorMesh(mesh: AbstractMesh): void;
  53304. /**
  53305. * Add a new snap-to point to fix teleportation to this position
  53306. * @param newSnapPoint The new Snap-To point
  53307. */
  53308. addSnapPoint(newSnapPoint: Vector3): void;
  53309. attach(): boolean;
  53310. detach(): boolean;
  53311. dispose(): void;
  53312. /**
  53313. * Remove a mesh from the floor meshes array
  53314. * @param mesh the mesh to remove
  53315. */
  53316. removeFloorMesh(mesh: AbstractMesh): void;
  53317. /**
  53318. * Remove a mesh from the floor meshes array using its name
  53319. * @param name the mesh name to remove
  53320. */
  53321. removeFloorMeshByName(name: string): void;
  53322. /**
  53323. * 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
  53324. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53325. * @returns was the point found and removed or not
  53326. */
  53327. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53328. /**
  53329. * This function sets a selection feature that will be disabled when
  53330. * the forward ray is shown and will be reattached when hidden.
  53331. * This is used to remove the selection rays when moving.
  53332. * @param selectionFeature the feature to disable when forward movement is enabled
  53333. */
  53334. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53335. protected _onXRFrame(_xrFrame: XRFrame): void;
  53336. private _attachController;
  53337. private _createDefaultTargetMesh;
  53338. private _detachController;
  53339. private _findClosestSnapPointWithRadius;
  53340. private _setTargetMeshPosition;
  53341. private _setTargetMeshVisibility;
  53342. private _showParabolicPath;
  53343. private _teleportForward;
  53344. }
  53345. }
  53346. declare module BABYLON {
  53347. /**
  53348. * Options for the default xr helper
  53349. */
  53350. export class WebXRDefaultExperienceOptions {
  53351. /**
  53352. * Enable or disable default UI to enter XR
  53353. */
  53354. disableDefaultUI?: boolean;
  53355. /**
  53356. * Should teleportation not initialize. defaults to false.
  53357. */
  53358. disableTeleportation?: boolean;
  53359. /**
  53360. * Floor meshes that will be used for teleport
  53361. */
  53362. floorMeshes?: Array<AbstractMesh>;
  53363. /**
  53364. * If set to true, the first frame will not be used to reset position
  53365. * The first frame is mainly used when copying transformation from the old camera
  53366. * Mainly used in AR
  53367. */
  53368. ignoreNativeCameraTransformation?: boolean;
  53369. /**
  53370. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53371. */
  53372. inputOptions?: IWebXRInputOptions;
  53373. /**
  53374. * optional configuration for the output canvas
  53375. */
  53376. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53377. /**
  53378. * optional UI options. This can be used among other to change session mode and reference space type
  53379. */
  53380. uiOptions?: WebXREnterExitUIOptions;
  53381. /**
  53382. * When loading teleportation and pointer select, use stable versions instead of latest.
  53383. */
  53384. useStablePlugins?: boolean;
  53385. /**
  53386. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53387. */
  53388. renderingGroupId?: number;
  53389. /**
  53390. * A list of optional features to init the session with
  53391. * If set to true, all features we support will be added
  53392. */
  53393. optionalFeatures?: boolean | string[];
  53394. }
  53395. /**
  53396. * Default experience which provides a similar setup to the previous webVRExperience
  53397. */
  53398. export class WebXRDefaultExperience {
  53399. /**
  53400. * Base experience
  53401. */
  53402. baseExperience: WebXRExperienceHelper;
  53403. /**
  53404. * Enables ui for entering/exiting xr
  53405. */
  53406. enterExitUI: WebXREnterExitUI;
  53407. /**
  53408. * Input experience extension
  53409. */
  53410. input: WebXRInput;
  53411. /**
  53412. * Enables laser pointer and selection
  53413. */
  53414. pointerSelection: WebXRControllerPointerSelection;
  53415. /**
  53416. * Default target xr should render to
  53417. */
  53418. renderTarget: WebXRRenderTarget;
  53419. /**
  53420. * Enables teleportation
  53421. */
  53422. teleportation: WebXRMotionControllerTeleportation;
  53423. private constructor();
  53424. /**
  53425. * Creates the default xr experience
  53426. * @param scene scene
  53427. * @param options options for basic configuration
  53428. * @returns resulting WebXRDefaultExperience
  53429. */
  53430. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53431. /**
  53432. * DIsposes of the experience helper
  53433. */
  53434. dispose(): void;
  53435. }
  53436. }
  53437. declare module BABYLON {
  53438. /**
  53439. * Options to modify the vr teleportation behavior.
  53440. */
  53441. export interface VRTeleportationOptions {
  53442. /**
  53443. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53444. */
  53445. floorMeshName?: string;
  53446. /**
  53447. * A list of meshes to be used as the teleportation floor. (default: empty)
  53448. */
  53449. floorMeshes?: Mesh[];
  53450. /**
  53451. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53452. */
  53453. teleportationMode?: number;
  53454. /**
  53455. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53456. */
  53457. teleportationTime?: number;
  53458. /**
  53459. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53460. */
  53461. teleportationSpeed?: number;
  53462. /**
  53463. * The easing function used in the animation or null for Linear. (default CircleEase)
  53464. */
  53465. easingFunction?: EasingFunction;
  53466. }
  53467. /**
  53468. * Options to modify the vr experience helper's behavior.
  53469. */
  53470. export interface VRExperienceHelperOptions extends WebVROptions {
  53471. /**
  53472. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53473. */
  53474. createDeviceOrientationCamera?: boolean;
  53475. /**
  53476. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53477. */
  53478. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53479. /**
  53480. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53481. */
  53482. laserToggle?: boolean;
  53483. /**
  53484. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53485. */
  53486. floorMeshes?: Mesh[];
  53487. /**
  53488. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53489. */
  53490. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53491. /**
  53492. * Defines if WebXR should be used instead of WebVR (if available)
  53493. */
  53494. useXR?: boolean;
  53495. }
  53496. /**
  53497. * Event containing information after VR has been entered
  53498. */
  53499. export class OnAfterEnteringVRObservableEvent {
  53500. /**
  53501. * If entering vr was successful
  53502. */
  53503. success: boolean;
  53504. }
  53505. /**
  53506. * Helps to quickly add VR support to an existing scene.
  53507. * See https://doc.babylonjs.com/how_to/webvr_helper
  53508. */
  53509. export class VRExperienceHelper {
  53510. /** Options to modify the vr experience helper's behavior. */
  53511. webVROptions: VRExperienceHelperOptions;
  53512. private _scene;
  53513. private _position;
  53514. private _btnVR;
  53515. private _btnVRDisplayed;
  53516. private _webVRsupported;
  53517. private _webVRready;
  53518. private _webVRrequesting;
  53519. private _webVRpresenting;
  53520. private _hasEnteredVR;
  53521. private _fullscreenVRpresenting;
  53522. private _inputElement;
  53523. private _webVRCamera;
  53524. private _vrDeviceOrientationCamera;
  53525. private _deviceOrientationCamera;
  53526. private _existingCamera;
  53527. private _onKeyDown;
  53528. private _onVrDisplayPresentChange;
  53529. private _onVRDisplayChanged;
  53530. private _onVRRequestPresentStart;
  53531. private _onVRRequestPresentComplete;
  53532. /**
  53533. * 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)
  53534. */
  53535. enableGazeEvenWhenNoPointerLock: boolean;
  53536. /**
  53537. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53538. */
  53539. exitVROnDoubleTap: boolean;
  53540. /**
  53541. * Observable raised right before entering VR.
  53542. */
  53543. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53544. /**
  53545. * Observable raised when entering VR has completed.
  53546. */
  53547. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53548. /**
  53549. * Observable raised when exiting VR.
  53550. */
  53551. onExitingVRObservable: Observable<VRExperienceHelper>;
  53552. /**
  53553. * Observable raised when controller mesh is loaded.
  53554. */
  53555. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53556. /** Return this.onEnteringVRObservable
  53557. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53558. */
  53559. get onEnteringVR(): Observable<VRExperienceHelper>;
  53560. /** Return this.onExitingVRObservable
  53561. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53562. */
  53563. get onExitingVR(): Observable<VRExperienceHelper>;
  53564. /** Return this.onControllerMeshLoadedObservable
  53565. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53566. */
  53567. get onControllerMeshLoaded(): Observable<WebVRController>;
  53568. private _rayLength;
  53569. private _useCustomVRButton;
  53570. private _teleportationRequested;
  53571. private _teleportActive;
  53572. private _floorMeshName;
  53573. private _floorMeshesCollection;
  53574. private _teleportationMode;
  53575. private _teleportationTime;
  53576. private _teleportationSpeed;
  53577. private _teleportationEasing;
  53578. private _rotationAllowed;
  53579. private _teleportBackwardsVector;
  53580. private _teleportationTarget;
  53581. private _isDefaultTeleportationTarget;
  53582. private _postProcessMove;
  53583. private _teleportationFillColor;
  53584. private _teleportationBorderColor;
  53585. private _rotationAngle;
  53586. private _haloCenter;
  53587. private _cameraGazer;
  53588. private _padSensibilityUp;
  53589. private _padSensibilityDown;
  53590. private _leftController;
  53591. private _rightController;
  53592. private _gazeColor;
  53593. private _laserColor;
  53594. private _pickedLaserColor;
  53595. private _pickedGazeColor;
  53596. /**
  53597. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53598. */
  53599. onNewMeshSelected: Observable<AbstractMesh>;
  53600. /**
  53601. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53602. * This observable will provide the mesh and the controller used to select the mesh
  53603. */
  53604. onMeshSelectedWithController: Observable<{
  53605. mesh: AbstractMesh;
  53606. controller: WebVRController;
  53607. }>;
  53608. /**
  53609. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53610. */
  53611. onNewMeshPicked: Observable<PickingInfo>;
  53612. private _circleEase;
  53613. /**
  53614. * Observable raised before camera teleportation
  53615. */
  53616. onBeforeCameraTeleport: Observable<Vector3>;
  53617. /**
  53618. * Observable raised after camera teleportation
  53619. */
  53620. onAfterCameraTeleport: Observable<Vector3>;
  53621. /**
  53622. * Observable raised when current selected mesh gets unselected
  53623. */
  53624. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53625. private _raySelectionPredicate;
  53626. /**
  53627. * To be optionaly changed by user to define custom ray selection
  53628. */
  53629. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53630. /**
  53631. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53632. */
  53633. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53634. /**
  53635. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53636. */
  53637. teleportationEnabled: boolean;
  53638. private _defaultHeight;
  53639. private _teleportationInitialized;
  53640. private _interactionsEnabled;
  53641. private _interactionsRequested;
  53642. private _displayGaze;
  53643. private _displayLaserPointer;
  53644. /**
  53645. * The mesh used to display where the user is going to teleport.
  53646. */
  53647. get teleportationTarget(): Mesh;
  53648. /**
  53649. * Sets the mesh to be used to display where the user is going to teleport.
  53650. */
  53651. set teleportationTarget(value: Mesh);
  53652. /**
  53653. * 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
  53654. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53655. * See https://doc.babylonjs.com/resources/baking_transformations
  53656. */
  53657. get gazeTrackerMesh(): Mesh;
  53658. set gazeTrackerMesh(value: Mesh);
  53659. /**
  53660. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53661. */
  53662. updateGazeTrackerScale: boolean;
  53663. /**
  53664. * If the gaze trackers color should be updated when selecting meshes
  53665. */
  53666. updateGazeTrackerColor: boolean;
  53667. /**
  53668. * If the controller laser color should be updated when selecting meshes
  53669. */
  53670. updateControllerLaserColor: boolean;
  53671. /**
  53672. * The gaze tracking mesh corresponding to the left controller
  53673. */
  53674. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53675. /**
  53676. * The gaze tracking mesh corresponding to the right controller
  53677. */
  53678. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53679. /**
  53680. * If the ray of the gaze should be displayed.
  53681. */
  53682. get displayGaze(): boolean;
  53683. /**
  53684. * Sets if the ray of the gaze should be displayed.
  53685. */
  53686. set displayGaze(value: boolean);
  53687. /**
  53688. * If the ray of the LaserPointer should be displayed.
  53689. */
  53690. get displayLaserPointer(): boolean;
  53691. /**
  53692. * Sets if the ray of the LaserPointer should be displayed.
  53693. */
  53694. set displayLaserPointer(value: boolean);
  53695. /**
  53696. * The deviceOrientationCamera used as the camera when not in VR.
  53697. */
  53698. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53699. /**
  53700. * Based on the current WebVR support, returns the current VR camera used.
  53701. */
  53702. get currentVRCamera(): Nullable<Camera>;
  53703. /**
  53704. * The webVRCamera which is used when in VR.
  53705. */
  53706. get webVRCamera(): WebVRFreeCamera;
  53707. /**
  53708. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53709. */
  53710. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53711. /**
  53712. * The html button that is used to trigger entering into VR.
  53713. */
  53714. get vrButton(): Nullable<HTMLButtonElement>;
  53715. private get _teleportationRequestInitiated();
  53716. /**
  53717. * Defines whether or not Pointer lock should be requested when switching to
  53718. * full screen.
  53719. */
  53720. requestPointerLockOnFullScreen: boolean;
  53721. /**
  53722. * If asking to force XR, this will be populated with the default xr experience
  53723. */
  53724. xr: WebXRDefaultExperience;
  53725. /**
  53726. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53727. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53728. */
  53729. xrTestDone: boolean;
  53730. /**
  53731. * Instantiates a VRExperienceHelper.
  53732. * Helps to quickly add VR support to an existing scene.
  53733. * @param scene The scene the VRExperienceHelper belongs to.
  53734. * @param webVROptions Options to modify the vr experience helper's behavior.
  53735. */
  53736. constructor(scene: Scene,
  53737. /** Options to modify the vr experience helper's behavior. */
  53738. webVROptions?: VRExperienceHelperOptions);
  53739. private completeVRInit;
  53740. private _onDefaultMeshLoaded;
  53741. private _onResize;
  53742. private _onFullscreenChange;
  53743. /**
  53744. * Gets a value indicating if we are currently in VR mode.
  53745. */
  53746. get isInVRMode(): boolean;
  53747. private onVrDisplayPresentChange;
  53748. private onVRDisplayChanged;
  53749. private moveButtonToBottomRight;
  53750. private displayVRButton;
  53751. private updateButtonVisibility;
  53752. private _cachedAngularSensibility;
  53753. /**
  53754. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53755. * Otherwise, will use the fullscreen API.
  53756. */
  53757. enterVR(): void;
  53758. /**
  53759. * Attempt to exit VR, or fullscreen.
  53760. */
  53761. exitVR(): void;
  53762. /**
  53763. * The position of the vr experience helper.
  53764. */
  53765. get position(): Vector3;
  53766. /**
  53767. * Sets the position of the vr experience helper.
  53768. */
  53769. set position(value: Vector3);
  53770. /**
  53771. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53772. */
  53773. enableInteractions(): void;
  53774. private get _noControllerIsActive();
  53775. private beforeRender;
  53776. private _isTeleportationFloor;
  53777. /**
  53778. * Adds a floor mesh to be used for teleportation.
  53779. * @param floorMesh the mesh to be used for teleportation.
  53780. */
  53781. addFloorMesh(floorMesh: Mesh): void;
  53782. /**
  53783. * Removes a floor mesh from being used for teleportation.
  53784. * @param floorMesh the mesh to be removed.
  53785. */
  53786. removeFloorMesh(floorMesh: Mesh): void;
  53787. /**
  53788. * Enables interactions and teleportation using the VR controllers and gaze.
  53789. * @param vrTeleportationOptions options to modify teleportation behavior.
  53790. */
  53791. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53792. private _onNewGamepadConnected;
  53793. private _tryEnableInteractionOnController;
  53794. private _onNewGamepadDisconnected;
  53795. private _enableInteractionOnController;
  53796. private _checkTeleportWithRay;
  53797. private _checkRotate;
  53798. private _checkTeleportBackwards;
  53799. private _enableTeleportationOnController;
  53800. private _createTeleportationCircles;
  53801. private _displayTeleportationTarget;
  53802. private _hideTeleportationTarget;
  53803. private _rotateCamera;
  53804. private _moveTeleportationSelectorTo;
  53805. private _workingVector;
  53806. private _workingQuaternion;
  53807. private _workingMatrix;
  53808. /**
  53809. * Time Constant Teleportation Mode
  53810. */
  53811. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53812. /**
  53813. * Speed Constant Teleportation Mode
  53814. */
  53815. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53816. /**
  53817. * Teleports the users feet to the desired location
  53818. * @param location The location where the user's feet should be placed
  53819. */
  53820. teleportCamera(location: Vector3): void;
  53821. private _convertNormalToDirectionOfRay;
  53822. private _castRayAndSelectObject;
  53823. private _notifySelectedMeshUnselected;
  53824. /**
  53825. * Permanently set new colors for the laser pointer
  53826. * @param color the new laser color
  53827. * @param pickedColor the new laser color when picked mesh detected
  53828. */
  53829. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53830. /**
  53831. * Set lighting enabled / disabled on the laser pointer of both controllers
  53832. * @param enabled should the lighting be enabled on the laser pointer
  53833. */
  53834. setLaserLightingState(enabled?: boolean): void;
  53835. /**
  53836. * Permanently set new colors for the gaze pointer
  53837. * @param color the new gaze color
  53838. * @param pickedColor the new gaze color when picked mesh detected
  53839. */
  53840. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53841. /**
  53842. * Sets the color of the laser ray from the vr controllers.
  53843. * @param color new color for the ray.
  53844. */
  53845. changeLaserColor(color: Color3): void;
  53846. /**
  53847. * Sets the color of the ray from the vr headsets gaze.
  53848. * @param color new color for the ray.
  53849. */
  53850. changeGazeColor(color: Color3): void;
  53851. /**
  53852. * Exits VR and disposes of the vr experience helper
  53853. */
  53854. dispose(): void;
  53855. /**
  53856. * Gets the name of the VRExperienceHelper class
  53857. * @returns "VRExperienceHelper"
  53858. */
  53859. getClassName(): string;
  53860. }
  53861. }
  53862. declare module BABYLON {
  53863. /**
  53864. * Contains an array of blocks representing the octree
  53865. */
  53866. export interface IOctreeContainer<T> {
  53867. /**
  53868. * Blocks within the octree
  53869. */
  53870. blocks: Array<OctreeBlock<T>>;
  53871. }
  53872. /**
  53873. * Class used to store a cell in an octree
  53874. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53875. */
  53876. export class OctreeBlock<T> {
  53877. /**
  53878. * Gets the content of the current block
  53879. */
  53880. entries: T[];
  53881. /**
  53882. * Gets the list of block children
  53883. */
  53884. blocks: Array<OctreeBlock<T>>;
  53885. private _depth;
  53886. private _maxDepth;
  53887. private _capacity;
  53888. private _minPoint;
  53889. private _maxPoint;
  53890. private _boundingVectors;
  53891. private _creationFunc;
  53892. /**
  53893. * Creates a new block
  53894. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53895. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53896. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53897. * @param depth defines the current depth of this block in the octree
  53898. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53899. * @param creationFunc defines a callback to call when an element is added to the block
  53900. */
  53901. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53902. /**
  53903. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53904. */
  53905. get capacity(): number;
  53906. /**
  53907. * Gets the minimum vector (in world space) of the block's bounding box
  53908. */
  53909. get minPoint(): Vector3;
  53910. /**
  53911. * Gets the maximum vector (in world space) of the block's bounding box
  53912. */
  53913. get maxPoint(): Vector3;
  53914. /**
  53915. * Add a new element to this block
  53916. * @param entry defines the element to add
  53917. */
  53918. addEntry(entry: T): void;
  53919. /**
  53920. * Remove an element from this block
  53921. * @param entry defines the element to remove
  53922. */
  53923. removeEntry(entry: T): void;
  53924. /**
  53925. * Add an array of elements to this block
  53926. * @param entries defines the array of elements to add
  53927. */
  53928. addEntries(entries: T[]): void;
  53929. /**
  53930. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53931. * @param frustumPlanes defines the frustum planes to test
  53932. * @param selection defines the array to store current content if selection is positive
  53933. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53934. */
  53935. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53936. /**
  53937. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53938. * @param sphereCenter defines the bounding sphere center
  53939. * @param sphereRadius defines the bounding sphere radius
  53940. * @param selection defines the array to store current content if selection is positive
  53941. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53942. */
  53943. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53944. /**
  53945. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53946. * @param ray defines the ray to test with
  53947. * @param selection defines the array to store current content if selection is positive
  53948. */
  53949. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53950. /**
  53951. * Subdivide the content into child blocks (this block will then be empty)
  53952. */
  53953. createInnerBlocks(): void;
  53954. /**
  53955. * @hidden
  53956. */
  53957. 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;
  53958. }
  53959. }
  53960. declare module BABYLON {
  53961. /**
  53962. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53963. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53964. */
  53965. export class Octree<T> {
  53966. /** 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.) */
  53967. maxDepth: number;
  53968. /**
  53969. * Blocks within the octree containing objects
  53970. */
  53971. blocks: Array<OctreeBlock<T>>;
  53972. /**
  53973. * Content stored in the octree
  53974. */
  53975. dynamicContent: T[];
  53976. private _maxBlockCapacity;
  53977. private _selectionContent;
  53978. private _creationFunc;
  53979. /**
  53980. * Creates a octree
  53981. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53982. * @param creationFunc function to be used to instatiate the octree
  53983. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53984. * @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.)
  53985. */
  53986. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53987. /** 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.) */
  53988. maxDepth?: number);
  53989. /**
  53990. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53991. * @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);
  53992. * @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);
  53993. * @param entries meshes to be added to the octree blocks
  53994. */
  53995. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53996. /**
  53997. * Adds a mesh to the octree
  53998. * @param entry Mesh to add to the octree
  53999. */
  54000. addMesh(entry: T): void;
  54001. /**
  54002. * Remove an element from the octree
  54003. * @param entry defines the element to remove
  54004. */
  54005. removeMesh(entry: T): void;
  54006. /**
  54007. * Selects an array of meshes within the frustum
  54008. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  54009. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  54010. * @returns array of meshes within the frustum
  54011. */
  54012. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  54013. /**
  54014. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  54015. * @param sphereCenter defines the bounding sphere center
  54016. * @param sphereRadius defines the bounding sphere radius
  54017. * @param allowDuplicate defines if the selection array can contains duplicated entries
  54018. * @returns an array of objects that intersect the sphere
  54019. */
  54020. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  54021. /**
  54022. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  54023. * @param ray defines the ray to test with
  54024. * @returns array of intersected objects
  54025. */
  54026. intersectsRay(ray: Ray): SmartArray<T>;
  54027. /**
  54028. * Adds a mesh into the octree block if it intersects the block
  54029. */
  54030. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  54031. /**
  54032. * Adds a submesh into the octree block if it intersects the block
  54033. */
  54034. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  54035. }
  54036. }
  54037. declare module BABYLON {
  54038. interface Scene {
  54039. /**
  54040. * @hidden
  54041. * Backing Filed
  54042. */
  54043. _selectionOctree: Octree<AbstractMesh>;
  54044. /**
  54045. * Gets the octree used to boost mesh selection (picking)
  54046. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54047. */
  54048. selectionOctree: Octree<AbstractMesh>;
  54049. /**
  54050. * Creates or updates the octree used to boost selection (picking)
  54051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54052. * @param maxCapacity defines the maximum capacity per leaf
  54053. * @param maxDepth defines the maximum depth of the octree
  54054. * @returns an octree of AbstractMesh
  54055. */
  54056. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54057. }
  54058. interface AbstractMesh {
  54059. /**
  54060. * @hidden
  54061. * Backing Field
  54062. */
  54063. _submeshesOctree: Octree<SubMesh>;
  54064. /**
  54065. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54066. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54067. * @param maxCapacity defines the maximum size of each block (64 by default)
  54068. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54069. * @returns the new octree
  54070. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54071. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54072. */
  54073. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54074. }
  54075. /**
  54076. * Defines the octree scene component responsible to manage any octrees
  54077. * in a given scene.
  54078. */
  54079. export class OctreeSceneComponent {
  54080. /**
  54081. * The component name help to identify the component in the list of scene components.
  54082. */
  54083. readonly name: string;
  54084. /**
  54085. * The scene the component belongs to.
  54086. */
  54087. scene: Scene;
  54088. /**
  54089. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54090. */
  54091. readonly checksIsEnabled: boolean;
  54092. /**
  54093. * Creates a new instance of the component for the given scene
  54094. * @param scene Defines the scene to register the component in
  54095. */
  54096. constructor(scene: Scene);
  54097. /**
  54098. * Registers the component in a given scene
  54099. */
  54100. register(): void;
  54101. /**
  54102. * Return the list of active meshes
  54103. * @returns the list of active meshes
  54104. */
  54105. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54106. /**
  54107. * Return the list of active sub meshes
  54108. * @param mesh The mesh to get the candidates sub meshes from
  54109. * @returns the list of active sub meshes
  54110. */
  54111. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54112. private _tempRay;
  54113. /**
  54114. * Return the list of sub meshes intersecting with a given local ray
  54115. * @param mesh defines the mesh to find the submesh for
  54116. * @param localRay defines the ray in local space
  54117. * @returns the list of intersecting sub meshes
  54118. */
  54119. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54120. /**
  54121. * Return the list of sub meshes colliding with a collider
  54122. * @param mesh defines the mesh to find the submesh for
  54123. * @param collider defines the collider to evaluate the collision against
  54124. * @returns the list of colliding sub meshes
  54125. */
  54126. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54127. /**
  54128. * Rebuilds the elements related to this component in case of
  54129. * context lost for instance.
  54130. */
  54131. rebuild(): void;
  54132. /**
  54133. * Disposes the component and the associated ressources.
  54134. */
  54135. dispose(): void;
  54136. }
  54137. }
  54138. declare module BABYLON {
  54139. /**
  54140. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54141. */
  54142. export interface GizmoAxisCache {
  54143. /** Mesh used to runder the Gizmo */
  54144. gizmoMeshes: Mesh[];
  54145. /** Mesh used to detect user interaction with Gizmo */
  54146. colliderMeshes: Mesh[];
  54147. /** Material used to inicate color of gizmo mesh */
  54148. material: StandardMaterial;
  54149. /** Material used to inicate hover state of the Gizmo */
  54150. hoverMaterial: StandardMaterial;
  54151. /** Material used to inicate disabled state of the Gizmo */
  54152. disableMaterial: StandardMaterial;
  54153. /** Used to indicate Active state of the Gizmo */
  54154. active: boolean;
  54155. }
  54156. /**
  54157. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54158. */
  54159. export class Gizmo implements IDisposable {
  54160. /** The utility layer the gizmo will be added to */
  54161. gizmoLayer: UtilityLayerRenderer;
  54162. /**
  54163. * The root mesh of the gizmo
  54164. */
  54165. _rootMesh: Mesh;
  54166. private _attachedMesh;
  54167. private _attachedNode;
  54168. /**
  54169. * Ratio for the scale of the gizmo (Default: 1)
  54170. */
  54171. protected _scaleRatio: number;
  54172. /**
  54173. * boolean updated by pointermove when a gizmo mesh is hovered
  54174. */
  54175. protected _isHovered: boolean;
  54176. /**
  54177. * Ratio for the scale of the gizmo (Default: 1)
  54178. */
  54179. set scaleRatio(value: number);
  54180. get scaleRatio(): number;
  54181. /**
  54182. * True when the mouse pointer is hovered a gizmo mesh
  54183. */
  54184. get isHovered(): boolean;
  54185. /**
  54186. * If a custom mesh has been set (Default: false)
  54187. */
  54188. protected _customMeshSet: boolean;
  54189. /**
  54190. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54191. * * When set, interactions will be enabled
  54192. */
  54193. get attachedMesh(): Nullable<AbstractMesh>;
  54194. set attachedMesh(value: Nullable<AbstractMesh>);
  54195. /**
  54196. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54197. * * When set, interactions will be enabled
  54198. */
  54199. get attachedNode(): Nullable<Node>;
  54200. set attachedNode(value: Nullable<Node>);
  54201. /**
  54202. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54203. * @param mesh The mesh to replace the default mesh of the gizmo
  54204. */
  54205. setCustomMesh(mesh: Mesh): void;
  54206. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54207. /**
  54208. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54209. */
  54210. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54211. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54212. /**
  54213. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54214. */
  54215. updateGizmoPositionToMatchAttachedMesh: boolean;
  54216. /**
  54217. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54218. */
  54219. updateScale: boolean;
  54220. protected _interactionsEnabled: boolean;
  54221. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54222. private _beforeRenderObserver;
  54223. private _tempQuaternion;
  54224. private _tempVector;
  54225. private _tempVector2;
  54226. private _tempMatrix1;
  54227. private _tempMatrix2;
  54228. private _rightHandtoLeftHandMatrix;
  54229. /**
  54230. * Creates a gizmo
  54231. * @param gizmoLayer The utility layer the gizmo will be added to
  54232. */
  54233. constructor(
  54234. /** The utility layer the gizmo will be added to */
  54235. gizmoLayer?: UtilityLayerRenderer);
  54236. /**
  54237. * Updates the gizmo to match the attached mesh's position/rotation
  54238. */
  54239. protected _update(): void;
  54240. /**
  54241. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54242. * @param value Node, TransformNode or mesh
  54243. */
  54244. protected _matrixChanged(): void;
  54245. /**
  54246. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54247. * @param gizmoLayer The utility layer the gizmo will be added to
  54248. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54249. * @returns {Observer<PointerInfo>} pointerObserver
  54250. */
  54251. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54252. /**
  54253. * Disposes of the gizmo
  54254. */
  54255. dispose(): void;
  54256. }
  54257. }
  54258. declare module BABYLON {
  54259. /**
  54260. * Single plane drag gizmo
  54261. */
  54262. export class PlaneDragGizmo extends Gizmo {
  54263. /**
  54264. * Drag behavior responsible for the gizmos dragging interactions
  54265. */
  54266. dragBehavior: PointerDragBehavior;
  54267. private _pointerObserver;
  54268. /**
  54269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54270. */
  54271. snapDistance: number;
  54272. /**
  54273. * Event that fires each time the gizmo snaps to a new location.
  54274. * * snapDistance is the the change in distance
  54275. */
  54276. onSnapObservable: Observable<{
  54277. snapDistance: number;
  54278. }>;
  54279. private _gizmoMesh;
  54280. private _coloredMaterial;
  54281. private _hoverMaterial;
  54282. private _disableMaterial;
  54283. private _isEnabled;
  54284. private _parent;
  54285. private _dragging;
  54286. /** @hidden */
  54287. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54288. /**
  54289. * Creates a PlaneDragGizmo
  54290. * @param gizmoLayer The utility layer the gizmo will be added to
  54291. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54292. * @param color The color of the gizmo
  54293. */
  54294. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54295. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54296. /**
  54297. * If the gizmo is enabled
  54298. */
  54299. set isEnabled(value: boolean);
  54300. get isEnabled(): boolean;
  54301. /**
  54302. * Disposes of the gizmo
  54303. */
  54304. dispose(): void;
  54305. }
  54306. }
  54307. declare module BABYLON {
  54308. /**
  54309. * Single plane rotation gizmo
  54310. */
  54311. export class PlaneRotationGizmo extends Gizmo {
  54312. /**
  54313. * Drag behavior responsible for the gizmos dragging interactions
  54314. */
  54315. dragBehavior: PointerDragBehavior;
  54316. private _pointerObserver;
  54317. /**
  54318. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54319. */
  54320. snapDistance: number;
  54321. /**
  54322. * Event that fires each time the gizmo snaps to a new location.
  54323. * * snapDistance is the the change in distance
  54324. */
  54325. onSnapObservable: Observable<{
  54326. snapDistance: number;
  54327. }>;
  54328. private _isEnabled;
  54329. private _parent;
  54330. private _coloredMaterial;
  54331. private _hoverMaterial;
  54332. private _disableMaterial;
  54333. private _gizmoMesh;
  54334. private _rotationCircle;
  54335. private _dragging;
  54336. private static _CircleConstants;
  54337. /**
  54338. * Creates a PlaneRotationGizmo
  54339. * @param gizmoLayer The utility layer the gizmo will be added to
  54340. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54341. * @param color The color of the gizmo
  54342. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54343. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54344. * @param thickness display gizmo axis thickness
  54345. */
  54346. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54347. /** Create Geometry for Gizmo */
  54348. private _createGizmoMesh;
  54349. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54350. private setupRotationCircle;
  54351. private updateRotationPath;
  54352. private updateRotationCircle;
  54353. /**
  54354. * If the gizmo is enabled
  54355. */
  54356. set isEnabled(value: boolean);
  54357. get isEnabled(): boolean;
  54358. /**
  54359. * Disposes of the gizmo
  54360. */
  54361. dispose(): void;
  54362. }
  54363. }
  54364. declare module BABYLON {
  54365. /**
  54366. * Gizmo that enables rotating a mesh along 3 axis
  54367. */
  54368. export class RotationGizmo extends Gizmo {
  54369. /**
  54370. * Internal gizmo used for interactions on the x axis
  54371. */
  54372. xGizmo: PlaneRotationGizmo;
  54373. /**
  54374. * Internal gizmo used for interactions on the y axis
  54375. */
  54376. yGizmo: PlaneRotationGizmo;
  54377. /**
  54378. * Internal gizmo used for interactions on the z axis
  54379. */
  54380. zGizmo: PlaneRotationGizmo;
  54381. /** Fires an event when any of it's sub gizmos are dragged */
  54382. onDragStartObservable: Observable<unknown>;
  54383. /** Fires an event when any of it's sub gizmos are released from dragging */
  54384. onDragEndObservable: Observable<unknown>;
  54385. private _meshAttached;
  54386. private _nodeAttached;
  54387. private _observables;
  54388. /** Node Caching for quick lookup */
  54389. private _gizmoAxisCache;
  54390. get attachedMesh(): Nullable<AbstractMesh>;
  54391. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54392. get attachedNode(): Nullable<Node>;
  54393. set attachedNode(node: Nullable<Node>);
  54394. protected _checkBillboardTransform(): void;
  54395. /**
  54396. * True when the mouse pointer is hovering a gizmo mesh
  54397. */
  54398. get isHovered(): boolean;
  54399. /**
  54400. * Creates a RotationGizmo
  54401. * @param gizmoLayer The utility layer the gizmo will be added to
  54402. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54403. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54404. * @param thickness display gizmo axis thickness
  54405. */
  54406. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54407. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54408. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54409. /**
  54410. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54411. */
  54412. set snapDistance(value: number);
  54413. get snapDistance(): number;
  54414. /**
  54415. * Ratio for the scale of the gizmo (Default: 1)
  54416. */
  54417. set scaleRatio(value: number);
  54418. get scaleRatio(): number;
  54419. /**
  54420. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54421. * @param mesh Axis gizmo mesh
  54422. * @param cache Gizmo axis definition used for reactive gizmo UI
  54423. */
  54424. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54425. /**
  54426. * Disposes of the gizmo
  54427. */
  54428. dispose(): void;
  54429. /**
  54430. * CustomMeshes are not supported by this gizmo
  54431. * @param mesh The mesh to replace the default mesh of the gizmo
  54432. */
  54433. setCustomMesh(mesh: Mesh): void;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * Class containing static functions to help procedurally build meshes
  54439. */
  54440. export class PolyhedronBuilder {
  54441. /**
  54442. * Creates a polyhedron mesh
  54443. * * 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
  54444. * * The parameter `size` (positive float, default 1) sets the polygon size
  54445. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54446. * * 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`
  54447. * * 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
  54448. * * 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)`)
  54449. * * 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
  54450. * * 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
  54451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54452. * * 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
  54453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54454. * @param name defines the name of the mesh
  54455. * @param options defines the options used to create the mesh
  54456. * @param scene defines the hosting scene
  54457. * @returns the polyhedron mesh
  54458. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54459. */
  54460. static CreatePolyhedron(name: string, options: {
  54461. type?: number;
  54462. size?: number;
  54463. sizeX?: number;
  54464. sizeY?: number;
  54465. sizeZ?: number;
  54466. custom?: any;
  54467. faceUV?: Vector4[];
  54468. faceColors?: Color4[];
  54469. flat?: boolean;
  54470. updatable?: boolean;
  54471. sideOrientation?: number;
  54472. frontUVs?: Vector4;
  54473. backUVs?: Vector4;
  54474. }, scene?: Nullable<Scene>): Mesh;
  54475. }
  54476. }
  54477. declare module BABYLON {
  54478. /**
  54479. * Class containing static functions to help procedurally build meshes
  54480. */
  54481. export class BoxBuilder {
  54482. /**
  54483. * Creates a box mesh
  54484. * * The parameter `size` sets the size (float) of each box side (default 1)
  54485. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54486. * * 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)
  54487. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54489. * * 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
  54490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54491. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54492. * @param name defines the name of the mesh
  54493. * @param options defines the options used to create the mesh
  54494. * @param scene defines the hosting scene
  54495. * @returns the box mesh
  54496. */
  54497. static CreateBox(name: string, options: {
  54498. size?: number;
  54499. width?: number;
  54500. height?: number;
  54501. depth?: number;
  54502. faceUV?: Vector4[];
  54503. faceColors?: Color4[];
  54504. sideOrientation?: number;
  54505. frontUVs?: Vector4;
  54506. backUVs?: Vector4;
  54507. wrap?: boolean;
  54508. topBaseAt?: number;
  54509. bottomBaseAt?: number;
  54510. updatable?: boolean;
  54511. }, scene?: Nullable<Scene>): Mesh;
  54512. }
  54513. }
  54514. declare module BABYLON {
  54515. /**
  54516. * Single axis scale gizmo
  54517. */
  54518. export class AxisScaleGizmo extends Gizmo {
  54519. /**
  54520. * Drag behavior responsible for the gizmos dragging interactions
  54521. */
  54522. dragBehavior: PointerDragBehavior;
  54523. private _pointerObserver;
  54524. /**
  54525. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54526. */
  54527. snapDistance: number;
  54528. /**
  54529. * Event that fires each time the gizmo snaps to a new location.
  54530. * * snapDistance is the the change in distance
  54531. */
  54532. onSnapObservable: Observable<{
  54533. snapDistance: number;
  54534. }>;
  54535. /**
  54536. * If the scaling operation should be done on all axis (default: false)
  54537. */
  54538. uniformScaling: boolean;
  54539. /**
  54540. * Custom sensitivity value for the drag strength
  54541. */
  54542. sensitivity: number;
  54543. private _isEnabled;
  54544. private _parent;
  54545. private _gizmoMesh;
  54546. private _coloredMaterial;
  54547. private _hoverMaterial;
  54548. private _disableMaterial;
  54549. private _dragging;
  54550. private _tmpVector;
  54551. private _tmpMatrix;
  54552. private _tmpMatrix2;
  54553. /**
  54554. * Creates an AxisScaleGizmo
  54555. * @param gizmoLayer The utility layer the gizmo will be added to
  54556. * @param dragAxis The axis which the gizmo will be able to scale on
  54557. * @param color The color of the gizmo
  54558. * @param thickness display gizmo axis thickness
  54559. */
  54560. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54561. /** Create Geometry for Gizmo */
  54562. private _createGizmoMesh;
  54563. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54564. /**
  54565. * If the gizmo is enabled
  54566. */
  54567. set isEnabled(value: boolean);
  54568. get isEnabled(): boolean;
  54569. /**
  54570. * Disposes of the gizmo
  54571. */
  54572. dispose(): void;
  54573. /**
  54574. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54575. * @param mesh The mesh to replace the default mesh of the gizmo
  54576. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54577. */
  54578. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54579. }
  54580. }
  54581. declare module BABYLON {
  54582. /**
  54583. * Gizmo that enables scaling a mesh along 3 axis
  54584. */
  54585. export class ScaleGizmo extends Gizmo {
  54586. /**
  54587. * Internal gizmo used for interactions on the x axis
  54588. */
  54589. xGizmo: AxisScaleGizmo;
  54590. /**
  54591. * Internal gizmo used for interactions on the y axis
  54592. */
  54593. yGizmo: AxisScaleGizmo;
  54594. /**
  54595. * Internal gizmo used for interactions on the z axis
  54596. */
  54597. zGizmo: AxisScaleGizmo;
  54598. /**
  54599. * Internal gizmo used to scale all axis equally
  54600. */
  54601. uniformScaleGizmo: AxisScaleGizmo;
  54602. private _meshAttached;
  54603. private _nodeAttached;
  54604. private _snapDistance;
  54605. private _uniformScalingMesh;
  54606. private _octahedron;
  54607. private _sensitivity;
  54608. private _coloredMaterial;
  54609. private _hoverMaterial;
  54610. private _disableMaterial;
  54611. private _observables;
  54612. /** Node Caching for quick lookup */
  54613. private _gizmoAxisCache;
  54614. /** Fires an event when any of it's sub gizmos are dragged */
  54615. onDragStartObservable: Observable<unknown>;
  54616. /** Fires an event when any of it's sub gizmos are released from dragging */
  54617. onDragEndObservable: Observable<unknown>;
  54618. get attachedMesh(): Nullable<AbstractMesh>;
  54619. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54620. get attachedNode(): Nullable<Node>;
  54621. set attachedNode(node: Nullable<Node>);
  54622. /**
  54623. * True when the mouse pointer is hovering a gizmo mesh
  54624. */
  54625. get isHovered(): boolean;
  54626. /**
  54627. * Creates a ScaleGizmo
  54628. * @param gizmoLayer The utility layer the gizmo will be added to
  54629. * @param thickness display gizmo axis thickness
  54630. */
  54631. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54632. /** Create Geometry for Gizmo */
  54633. private _createUniformScaleMesh;
  54634. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54635. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54636. /**
  54637. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54638. */
  54639. set snapDistance(value: number);
  54640. get snapDistance(): number;
  54641. /**
  54642. * Ratio for the scale of the gizmo (Default: 1)
  54643. */
  54644. set scaleRatio(value: number);
  54645. get scaleRatio(): number;
  54646. /**
  54647. * Sensitivity factor for dragging (Default: 1)
  54648. */
  54649. set sensitivity(value: number);
  54650. get sensitivity(): number;
  54651. /**
  54652. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54653. * @param mesh Axis gizmo mesh
  54654. * @param cache Gizmo axis definition used for reactive gizmo UI
  54655. */
  54656. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54657. /**
  54658. * Disposes of the gizmo
  54659. */
  54660. dispose(): void;
  54661. }
  54662. }
  54663. declare module BABYLON {
  54664. /**
  54665. * Bounding box gizmo
  54666. */
  54667. export class BoundingBoxGizmo extends Gizmo {
  54668. private _lineBoundingBox;
  54669. private _rotateSpheresParent;
  54670. private _scaleBoxesParent;
  54671. private _boundingDimensions;
  54672. private _renderObserver;
  54673. private _pointerObserver;
  54674. private _scaleDragSpeed;
  54675. private _tmpQuaternion;
  54676. private _tmpVector;
  54677. private _tmpRotationMatrix;
  54678. /**
  54679. * 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)
  54680. */
  54681. ignoreChildren: boolean;
  54682. /**
  54683. * 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)
  54684. */
  54685. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54686. /**
  54687. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54688. */
  54689. rotationSphereSize: number;
  54690. /**
  54691. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54692. */
  54693. scaleBoxSize: number;
  54694. /**
  54695. * 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)
  54696. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54697. */
  54698. fixedDragMeshScreenSize: boolean;
  54699. /**
  54700. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  54701. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54702. */
  54703. fixedDragMeshBoundsSize: boolean;
  54704. /**
  54705. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54706. */
  54707. fixedDragMeshScreenSizeDistanceFactor: number;
  54708. /**
  54709. * Fired when a rotation sphere or scale box is dragged
  54710. */
  54711. onDragStartObservable: Observable<{}>;
  54712. /**
  54713. * Fired when a scale box is dragged
  54714. */
  54715. onScaleBoxDragObservable: Observable<{}>;
  54716. /**
  54717. * Fired when a scale box drag is ended
  54718. */
  54719. onScaleBoxDragEndObservable: Observable<{}>;
  54720. /**
  54721. * Fired when a rotation sphere is dragged
  54722. */
  54723. onRotationSphereDragObservable: Observable<{}>;
  54724. /**
  54725. * Fired when a rotation sphere drag is ended
  54726. */
  54727. onRotationSphereDragEndObservable: Observable<{}>;
  54728. /**
  54729. * 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)
  54730. */
  54731. scalePivot: Nullable<Vector3>;
  54732. /**
  54733. * Mesh used as a pivot to rotate the attached node
  54734. */
  54735. private _anchorMesh;
  54736. private _existingMeshScale;
  54737. private _dragMesh;
  54738. private pointerDragBehavior;
  54739. private coloredMaterial;
  54740. private hoverColoredMaterial;
  54741. /**
  54742. * Sets the color of the bounding box gizmo
  54743. * @param color the color to set
  54744. */
  54745. setColor(color: Color3): void;
  54746. /**
  54747. * Creates an BoundingBoxGizmo
  54748. * @param gizmoLayer The utility layer the gizmo will be added to
  54749. * @param color The color of the gizmo
  54750. */
  54751. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54752. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54753. private _selectNode;
  54754. /**
  54755. * Updates the bounding box information for the Gizmo
  54756. */
  54757. updateBoundingBox(): void;
  54758. private _updateRotationSpheres;
  54759. private _updateScaleBoxes;
  54760. /**
  54761. * Enables rotation on the specified axis and disables rotation on the others
  54762. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54763. */
  54764. setEnabledRotationAxis(axis: string): void;
  54765. /**
  54766. * Enables/disables scaling
  54767. * @param enable if scaling should be enabled
  54768. * @param homogeneousScaling defines if scaling should only be homogeneous
  54769. */
  54770. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54771. private _updateDummy;
  54772. /**
  54773. * Enables a pointer drag behavior on the bounding box of the gizmo
  54774. */
  54775. enableDragBehavior(): void;
  54776. /**
  54777. * Disposes of the gizmo
  54778. */
  54779. dispose(): void;
  54780. /**
  54781. * 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)
  54782. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54783. * @returns the bounding box mesh with the passed in mesh as a child
  54784. */
  54785. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54786. /**
  54787. * CustomMeshes are not supported by this gizmo
  54788. * @param mesh The mesh to replace the default mesh of the gizmo
  54789. */
  54790. setCustomMesh(mesh: Mesh): void;
  54791. }
  54792. }
  54793. declare module BABYLON {
  54794. /**
  54795. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54796. */
  54797. export class GizmoManager implements IDisposable {
  54798. private scene;
  54799. /**
  54800. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54801. */
  54802. gizmos: {
  54803. positionGizmo: Nullable<PositionGizmo>;
  54804. rotationGizmo: Nullable<RotationGizmo>;
  54805. scaleGizmo: Nullable<ScaleGizmo>;
  54806. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54807. };
  54808. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54809. clearGizmoOnEmptyPointerEvent: boolean;
  54810. /** Fires an event when the manager is attached to a mesh */
  54811. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54812. /** Fires an event when the manager is attached to a node */
  54813. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54814. private _gizmosEnabled;
  54815. private _pointerObservers;
  54816. private _attachedMesh;
  54817. private _attachedNode;
  54818. private _boundingBoxColor;
  54819. private _defaultUtilityLayer;
  54820. private _defaultKeepDepthUtilityLayer;
  54821. private _thickness;
  54822. /** Node Caching for quick lookup */
  54823. private _gizmoAxisCache;
  54824. /**
  54825. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54826. */
  54827. boundingBoxDragBehavior: SixDofDragBehavior;
  54828. /**
  54829. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54830. */
  54831. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54832. /**
  54833. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54834. */
  54835. attachableNodes: Nullable<Array<Node>>;
  54836. /**
  54837. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54838. */
  54839. usePointerToAttachGizmos: boolean;
  54840. /**
  54841. * Utility layer that the bounding box gizmo belongs to
  54842. */
  54843. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54844. /**
  54845. * Utility layer that all gizmos besides bounding box belong to
  54846. */
  54847. get utilityLayer(): UtilityLayerRenderer;
  54848. /**
  54849. * True when the mouse pointer is hovering a gizmo mesh
  54850. */
  54851. get isHovered(): boolean;
  54852. /**
  54853. * Instatiates a gizmo manager
  54854. * @param scene the scene to overlay the gizmos on top of
  54855. * @param thickness display gizmo axis thickness
  54856. * @param utilityLayer the layer where gizmos are rendered
  54857. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54858. */
  54859. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54860. /**
  54861. * Subscribes to pointer down events, for attaching and detaching mesh
  54862. * @param scene The sceme layer the observer will be added to
  54863. */
  54864. private _attachToMeshPointerObserver;
  54865. /**
  54866. * Attaches a set of gizmos to the specified mesh
  54867. * @param mesh The mesh the gizmo's should be attached to
  54868. */
  54869. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54870. /**
  54871. * Attaches a set of gizmos to the specified node
  54872. * @param node The node the gizmo's should be attached to
  54873. */
  54874. attachToNode(node: Nullable<Node>): void;
  54875. /**
  54876. * If the position gizmo is enabled
  54877. */
  54878. set positionGizmoEnabled(value: boolean);
  54879. get positionGizmoEnabled(): boolean;
  54880. /**
  54881. * If the rotation gizmo is enabled
  54882. */
  54883. set rotationGizmoEnabled(value: boolean);
  54884. get rotationGizmoEnabled(): boolean;
  54885. /**
  54886. * If the scale gizmo is enabled
  54887. */
  54888. set scaleGizmoEnabled(value: boolean);
  54889. get scaleGizmoEnabled(): boolean;
  54890. /**
  54891. * If the boundingBox gizmo is enabled
  54892. */
  54893. set boundingBoxGizmoEnabled(value: boolean);
  54894. get boundingBoxGizmoEnabled(): boolean;
  54895. /**
  54896. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54897. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54898. */
  54899. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54900. /**
  54901. * Disposes of the gizmo manager
  54902. */
  54903. dispose(): void;
  54904. }
  54905. }
  54906. declare module BABYLON {
  54907. /**
  54908. * Gizmo that enables dragging a mesh along 3 axis
  54909. */
  54910. export class PositionGizmo extends Gizmo {
  54911. /**
  54912. * Internal gizmo used for interactions on the x axis
  54913. */
  54914. xGizmo: AxisDragGizmo;
  54915. /**
  54916. * Internal gizmo used for interactions on the y axis
  54917. */
  54918. yGizmo: AxisDragGizmo;
  54919. /**
  54920. * Internal gizmo used for interactions on the z axis
  54921. */
  54922. zGizmo: AxisDragGizmo;
  54923. /**
  54924. * Internal gizmo used for interactions on the yz plane
  54925. */
  54926. xPlaneGizmo: PlaneDragGizmo;
  54927. /**
  54928. * Internal gizmo used for interactions on the xz plane
  54929. */
  54930. yPlaneGizmo: PlaneDragGizmo;
  54931. /**
  54932. * Internal gizmo used for interactions on the xy plane
  54933. */
  54934. zPlaneGizmo: PlaneDragGizmo;
  54935. /**
  54936. * private variables
  54937. */
  54938. private _meshAttached;
  54939. private _nodeAttached;
  54940. private _snapDistance;
  54941. private _observables;
  54942. /** Node Caching for quick lookup */
  54943. private _gizmoAxisCache;
  54944. /** Fires an event when any of it's sub gizmos are dragged */
  54945. onDragStartObservable: Observable<unknown>;
  54946. /** Fires an event when any of it's sub gizmos are released from dragging */
  54947. onDragEndObservable: Observable<unknown>;
  54948. /**
  54949. * If set to true, planar drag is enabled
  54950. */
  54951. private _planarGizmoEnabled;
  54952. get attachedMesh(): Nullable<AbstractMesh>;
  54953. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54954. get attachedNode(): Nullable<Node>;
  54955. set attachedNode(node: Nullable<Node>);
  54956. /**
  54957. * True when the mouse pointer is hovering a gizmo mesh
  54958. */
  54959. get isHovered(): boolean;
  54960. /**
  54961. * Creates a PositionGizmo
  54962. * @param gizmoLayer The utility layer the gizmo will be added to
  54963. @param thickness display gizmo axis thickness
  54964. */
  54965. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54966. /**
  54967. * If the planar drag gizmo is enabled
  54968. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54969. */
  54970. set planarGizmoEnabled(value: boolean);
  54971. get planarGizmoEnabled(): boolean;
  54972. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54973. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54974. /**
  54975. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54976. */
  54977. set snapDistance(value: number);
  54978. get snapDistance(): number;
  54979. /**
  54980. * Ratio for the scale of the gizmo (Default: 1)
  54981. */
  54982. set scaleRatio(value: number);
  54983. get scaleRatio(): number;
  54984. /**
  54985. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54986. * @param mesh Axis gizmo mesh
  54987. * @param cache Gizmo axis definition used for reactive gizmo UI
  54988. */
  54989. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54990. /**
  54991. * Disposes of the gizmo
  54992. */
  54993. dispose(): void;
  54994. /**
  54995. * CustomMeshes are not supported by this gizmo
  54996. * @param mesh The mesh to replace the default mesh of the gizmo
  54997. */
  54998. setCustomMesh(mesh: Mesh): void;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Single axis drag gizmo
  55004. */
  55005. export class AxisDragGizmo extends Gizmo {
  55006. /**
  55007. * Drag behavior responsible for the gizmos dragging interactions
  55008. */
  55009. dragBehavior: PointerDragBehavior;
  55010. private _pointerObserver;
  55011. /**
  55012. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55013. */
  55014. snapDistance: number;
  55015. /**
  55016. * Event that fires each time the gizmo snaps to a new location.
  55017. * * snapDistance is the the change in distance
  55018. */
  55019. onSnapObservable: Observable<{
  55020. snapDistance: number;
  55021. }>;
  55022. private _isEnabled;
  55023. private _parent;
  55024. private _gizmoMesh;
  55025. private _coloredMaterial;
  55026. private _hoverMaterial;
  55027. private _disableMaterial;
  55028. private _dragging;
  55029. /** @hidden */
  55030. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  55031. /** @hidden */
  55032. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55033. /**
  55034. * Creates an AxisDragGizmo
  55035. * @param gizmoLayer The utility layer the gizmo will be added to
  55036. * @param dragAxis The axis which the gizmo will be able to drag on
  55037. * @param color The color of the gizmo
  55038. * @param thickness display gizmo axis thickness
  55039. */
  55040. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55041. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55042. /**
  55043. * If the gizmo is enabled
  55044. */
  55045. set isEnabled(value: boolean);
  55046. get isEnabled(): boolean;
  55047. /**
  55048. * Disposes of the gizmo
  55049. */
  55050. dispose(): void;
  55051. }
  55052. }
  55053. declare module BABYLON.Debug {
  55054. /**
  55055. * The Axes viewer will show 3 axes in a specific point in space
  55056. */
  55057. export class AxesViewer {
  55058. private _xAxis;
  55059. private _yAxis;
  55060. private _zAxis;
  55061. private _scaleLinesFactor;
  55062. private _instanced;
  55063. /**
  55064. * Gets the hosting scene
  55065. */
  55066. scene: Nullable<Scene>;
  55067. /**
  55068. * Gets or sets a number used to scale line length
  55069. */
  55070. scaleLines: number;
  55071. /** Gets the node hierarchy used to render x-axis */
  55072. get xAxis(): TransformNode;
  55073. /** Gets the node hierarchy used to render y-axis */
  55074. get yAxis(): TransformNode;
  55075. /** Gets the node hierarchy used to render z-axis */
  55076. get zAxis(): TransformNode;
  55077. /**
  55078. * Creates a new AxesViewer
  55079. * @param scene defines the hosting scene
  55080. * @param scaleLines defines a number used to scale line length (1 by default)
  55081. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55082. * @param xAxis defines the node hierarchy used to render the x-axis
  55083. * @param yAxis defines the node hierarchy used to render the y-axis
  55084. * @param zAxis defines the node hierarchy used to render the z-axis
  55085. */
  55086. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55087. /**
  55088. * Force the viewer to update
  55089. * @param position defines the position of the viewer
  55090. * @param xaxis defines the x axis of the viewer
  55091. * @param yaxis defines the y axis of the viewer
  55092. * @param zaxis defines the z axis of the viewer
  55093. */
  55094. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55095. /**
  55096. * Creates an instance of this axes viewer.
  55097. * @returns a new axes viewer with instanced meshes
  55098. */
  55099. createInstance(): AxesViewer;
  55100. /** Releases resources */
  55101. dispose(): void;
  55102. private static _SetRenderingGroupId;
  55103. }
  55104. }
  55105. declare module BABYLON.Debug {
  55106. /**
  55107. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55108. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55109. */
  55110. export class BoneAxesViewer extends AxesViewer {
  55111. /**
  55112. * Gets or sets the target mesh where to display the axes viewer
  55113. */
  55114. mesh: Nullable<Mesh>;
  55115. /**
  55116. * Gets or sets the target bone where to display the axes viewer
  55117. */
  55118. bone: Nullable<Bone>;
  55119. /** Gets current position */
  55120. pos: Vector3;
  55121. /** Gets direction of X axis */
  55122. xaxis: Vector3;
  55123. /** Gets direction of Y axis */
  55124. yaxis: Vector3;
  55125. /** Gets direction of Z axis */
  55126. zaxis: Vector3;
  55127. /**
  55128. * Creates a new BoneAxesViewer
  55129. * @param scene defines the hosting scene
  55130. * @param bone defines the target bone
  55131. * @param mesh defines the target mesh
  55132. * @param scaleLines defines a scaling factor for line length (1 by default)
  55133. */
  55134. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55135. /**
  55136. * Force the viewer to update
  55137. */
  55138. update(): void;
  55139. /** Releases resources */
  55140. dispose(): void;
  55141. }
  55142. }
  55143. declare module BABYLON {
  55144. /**
  55145. * Interface used to define scene explorer extensibility option
  55146. */
  55147. export interface IExplorerExtensibilityOption {
  55148. /**
  55149. * Define the option label
  55150. */
  55151. label: string;
  55152. /**
  55153. * Defines the action to execute on click
  55154. */
  55155. action: (entity: any) => void;
  55156. }
  55157. /**
  55158. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55159. */
  55160. export interface IExplorerExtensibilityGroup {
  55161. /**
  55162. * Defines a predicate to test if a given type mut be extended
  55163. */
  55164. predicate: (entity: any) => boolean;
  55165. /**
  55166. * Gets the list of options added to a type
  55167. */
  55168. entries: IExplorerExtensibilityOption[];
  55169. }
  55170. /**
  55171. * Interface used to define the options to use to create the Inspector
  55172. */
  55173. export interface IInspectorOptions {
  55174. /**
  55175. * Display in overlay mode (default: false)
  55176. */
  55177. overlay?: boolean;
  55178. /**
  55179. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55180. */
  55181. globalRoot?: HTMLElement;
  55182. /**
  55183. * Display the Scene explorer
  55184. */
  55185. showExplorer?: boolean;
  55186. /**
  55187. * Display the property inspector
  55188. */
  55189. showInspector?: boolean;
  55190. /**
  55191. * Display in embed mode (both panes on the right)
  55192. */
  55193. embedMode?: boolean;
  55194. /**
  55195. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55196. */
  55197. handleResize?: boolean;
  55198. /**
  55199. * Allow the panes to popup (default: true)
  55200. */
  55201. enablePopup?: boolean;
  55202. /**
  55203. * Allow the panes to be closed by users (default: true)
  55204. */
  55205. enableClose?: boolean;
  55206. /**
  55207. * Optional list of extensibility entries
  55208. */
  55209. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55210. /**
  55211. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55212. */
  55213. inspectorURL?: string;
  55214. /**
  55215. * Optional initial tab (default to DebugLayerTab.Properties)
  55216. */
  55217. initialTab?: DebugLayerTab;
  55218. }
  55219. interface Scene {
  55220. /**
  55221. * @hidden
  55222. * Backing field
  55223. */
  55224. _debugLayer: DebugLayer;
  55225. /**
  55226. * Gets the debug layer (aka Inspector) associated with the scene
  55227. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55228. */
  55229. debugLayer: DebugLayer;
  55230. }
  55231. /**
  55232. * Enum of inspector action tab
  55233. */
  55234. export enum DebugLayerTab {
  55235. /**
  55236. * Properties tag (default)
  55237. */
  55238. Properties = 0,
  55239. /**
  55240. * Debug tab
  55241. */
  55242. Debug = 1,
  55243. /**
  55244. * Statistics tab
  55245. */
  55246. Statistics = 2,
  55247. /**
  55248. * Tools tab
  55249. */
  55250. Tools = 3,
  55251. /**
  55252. * Settings tab
  55253. */
  55254. Settings = 4
  55255. }
  55256. /**
  55257. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55258. * what is happening in your scene
  55259. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55260. */
  55261. export class DebugLayer {
  55262. /**
  55263. * Define the url to get the inspector script from.
  55264. * By default it uses the babylonjs CDN.
  55265. * @ignoreNaming
  55266. */
  55267. static InspectorURL: string;
  55268. private _scene;
  55269. private BJSINSPECTOR;
  55270. private _onPropertyChangedObservable?;
  55271. /**
  55272. * Observable triggered when a property is changed through the inspector.
  55273. */
  55274. get onPropertyChangedObservable(): any;
  55275. /**
  55276. * Instantiates a new debug layer.
  55277. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55278. * what is happening in your scene
  55279. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55280. * @param scene Defines the scene to inspect
  55281. */
  55282. constructor(scene: Scene);
  55283. /** Creates the inspector window. */
  55284. private _createInspector;
  55285. /**
  55286. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55287. * @param entity defines the entity to select
  55288. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55289. */
  55290. select(entity: any, lineContainerTitles?: string | string[]): void;
  55291. /** Get the inspector from bundle or global */
  55292. private _getGlobalInspector;
  55293. /**
  55294. * Get if the inspector is visible or not.
  55295. * @returns true if visible otherwise, false
  55296. */
  55297. isVisible(): boolean;
  55298. /**
  55299. * Hide the inspector and close its window.
  55300. */
  55301. hide(): void;
  55302. /**
  55303. * Update the scene in the inspector
  55304. */
  55305. setAsActiveScene(): void;
  55306. /**
  55307. * Launch the debugLayer.
  55308. * @param config Define the configuration of the inspector
  55309. * @return a promise fulfilled when the debug layer is visible
  55310. */
  55311. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55312. }
  55313. }
  55314. declare module BABYLON.Debug {
  55315. /**
  55316. * Used to show the physics impostor around the specific mesh
  55317. */
  55318. export class PhysicsViewer {
  55319. /** @hidden */
  55320. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55321. /** @hidden */
  55322. protected _meshes: Array<Nullable<AbstractMesh>>;
  55323. /** @hidden */
  55324. protected _scene: Nullable<Scene>;
  55325. /** @hidden */
  55326. protected _numMeshes: number;
  55327. /** @hidden */
  55328. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55329. private _renderFunction;
  55330. private _utilityLayer;
  55331. private _debugBoxMesh;
  55332. private _debugSphereMesh;
  55333. private _debugCylinderMesh;
  55334. private _debugMaterial;
  55335. private _debugMeshMeshes;
  55336. /**
  55337. * Creates a new PhysicsViewer
  55338. * @param scene defines the hosting scene
  55339. */
  55340. constructor(scene: Scene);
  55341. /** @hidden */
  55342. protected _updateDebugMeshes(): void;
  55343. /**
  55344. * Renders a specified physic impostor
  55345. * @param impostor defines the impostor to render
  55346. * @param targetMesh defines the mesh represented by the impostor
  55347. * @returns the new debug mesh used to render the impostor
  55348. */
  55349. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55350. /**
  55351. * Hides a specified physic impostor
  55352. * @param impostor defines the impostor to hide
  55353. */
  55354. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55355. private _getDebugMaterial;
  55356. private _getDebugBoxMesh;
  55357. private _getDebugSphereMesh;
  55358. private _getDebugCylinderMesh;
  55359. private _getDebugMeshMesh;
  55360. private _getDebugMesh;
  55361. /** Releases all resources */
  55362. dispose(): void;
  55363. }
  55364. }
  55365. declare module BABYLON {
  55366. /**
  55367. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55368. * in order to better appreciate the issue one might have.
  55369. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55370. */
  55371. export class RayHelper {
  55372. /**
  55373. * Defines the ray we are currently tryin to visualize.
  55374. */
  55375. ray: Nullable<Ray>;
  55376. private _renderPoints;
  55377. private _renderLine;
  55378. private _renderFunction;
  55379. private _scene;
  55380. private _onAfterRenderObserver;
  55381. private _onAfterStepObserver;
  55382. private _attachedToMesh;
  55383. private _meshSpaceDirection;
  55384. private _meshSpaceOrigin;
  55385. /**
  55386. * Helper function to create a colored helper in a scene in one line.
  55387. * @param ray Defines the ray we are currently tryin to visualize
  55388. * @param scene Defines the scene the ray is used in
  55389. * @param color Defines the color we want to see the ray in
  55390. * @returns The newly created ray helper.
  55391. */
  55392. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55393. /**
  55394. * Instantiate a new ray helper.
  55395. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55396. * in order to better appreciate the issue one might have.
  55397. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55398. * @param ray Defines the ray we are currently tryin to visualize
  55399. */
  55400. constructor(ray: Ray);
  55401. /**
  55402. * Shows the ray we are willing to debug.
  55403. * @param scene Defines the scene the ray needs to be rendered in
  55404. * @param color Defines the color the ray needs to be rendered in
  55405. */
  55406. show(scene: Scene, color?: Color3): void;
  55407. /**
  55408. * Hides the ray we are debugging.
  55409. */
  55410. hide(): void;
  55411. private _render;
  55412. /**
  55413. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55414. * @param mesh Defines the mesh we want the helper attached to
  55415. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55416. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55417. * @param length Defines the length of the ray
  55418. */
  55419. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55420. /**
  55421. * Detach the ray helper from the mesh it has previously been attached to.
  55422. */
  55423. detachFromMesh(): void;
  55424. private _updateToMesh;
  55425. /**
  55426. * Dispose the helper and release its associated resources.
  55427. */
  55428. dispose(): void;
  55429. }
  55430. }
  55431. declare module BABYLON {
  55432. /**
  55433. * Defines the options associated with the creation of a SkeletonViewer.
  55434. */
  55435. export interface ISkeletonViewerOptions {
  55436. /** Should the system pause animations before building the Viewer? */
  55437. pauseAnimations: boolean;
  55438. /** Should the system return the skeleton to rest before building? */
  55439. returnToRest: boolean;
  55440. /** public Display Mode of the Viewer */
  55441. displayMode: number;
  55442. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55443. displayOptions: ISkeletonViewerDisplayOptions;
  55444. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55445. computeBonesUsingShaders: boolean;
  55446. /** Flag ignore non weighted bones */
  55447. useAllBones: boolean;
  55448. }
  55449. /**
  55450. * Defines how to display the various bone meshes for the viewer.
  55451. */
  55452. export interface ISkeletonViewerDisplayOptions {
  55453. /** How far down to start tapering the bone spurs */
  55454. midStep?: number;
  55455. /** How big is the midStep? */
  55456. midStepFactor?: number;
  55457. /** Base for the Sphere Size */
  55458. sphereBaseSize?: number;
  55459. /** The ratio of the sphere to the longest bone in units */
  55460. sphereScaleUnit?: number;
  55461. /** Ratio for the Sphere Size */
  55462. sphereFactor?: number;
  55463. /** Whether a spur should attach its far end to the child bone position */
  55464. spurFollowsChild?: boolean;
  55465. /** Whether to show local axes or not */
  55466. showLocalAxes?: boolean;
  55467. /** Length of each local axis */
  55468. localAxesSize?: number;
  55469. }
  55470. /**
  55471. * Defines the constructor options for the BoneWeight Shader.
  55472. */
  55473. export interface IBoneWeightShaderOptions {
  55474. /** Skeleton to Map */
  55475. skeleton: Skeleton;
  55476. /** Colors for Uninfluenced bones */
  55477. colorBase?: Color3;
  55478. /** Colors for 0.0-0.25 Weight bones */
  55479. colorZero?: Color3;
  55480. /** Color for 0.25-0.5 Weight Influence */
  55481. colorQuarter?: Color3;
  55482. /** Color for 0.5-0.75 Weight Influence */
  55483. colorHalf?: Color3;
  55484. /** Color for 0.75-1 Weight Influence */
  55485. colorFull?: Color3;
  55486. /** Color for Zero Weight Influence */
  55487. targetBoneIndex?: number;
  55488. }
  55489. /**
  55490. * Simple structure of the gradient steps for the Color Map.
  55491. */
  55492. export interface ISkeletonMapShaderColorMapKnot {
  55493. /** Color of the Knot */
  55494. color: Color3;
  55495. /** Location of the Knot */
  55496. location: number;
  55497. }
  55498. /**
  55499. * Defines the constructor options for the SkeletonMap Shader.
  55500. */
  55501. export interface ISkeletonMapShaderOptions {
  55502. /** Skeleton to Map */
  55503. skeleton: Skeleton;
  55504. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55505. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55506. }
  55507. }
  55508. declare module BABYLON {
  55509. /**
  55510. * Class containing static functions to help procedurally build meshes
  55511. */
  55512. export class RibbonBuilder {
  55513. /**
  55514. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55515. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55516. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55517. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55518. * * 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
  55519. * * 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
  55520. * * 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
  55521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55522. * * 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
  55523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55524. * * 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
  55525. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55526. * * 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
  55527. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55529. * @param name defines the name of the mesh
  55530. * @param options defines the options used to create the mesh
  55531. * @param scene defines the hosting scene
  55532. * @returns the ribbon mesh
  55533. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55534. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55535. */
  55536. static CreateRibbon(name: string, options: {
  55537. pathArray: Vector3[][];
  55538. closeArray?: boolean;
  55539. closePath?: boolean;
  55540. offset?: number;
  55541. updatable?: boolean;
  55542. sideOrientation?: number;
  55543. frontUVs?: Vector4;
  55544. backUVs?: Vector4;
  55545. instance?: Mesh;
  55546. invertUV?: boolean;
  55547. uvs?: Vector2[];
  55548. colors?: Color4[];
  55549. }, scene?: Nullable<Scene>): Mesh;
  55550. }
  55551. }
  55552. declare module BABYLON {
  55553. /**
  55554. * Class containing static functions to help procedurally build meshes
  55555. */
  55556. export class ShapeBuilder {
  55557. /**
  55558. * 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.
  55559. * * 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.
  55560. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55561. * * 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.
  55562. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55563. * * 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
  55564. * * 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
  55565. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55567. * * 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
  55568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55570. * @param name defines the name of the mesh
  55571. * @param options defines the options used to create the mesh
  55572. * @param scene defines the hosting scene
  55573. * @returns the extruded shape mesh
  55574. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55576. */
  55577. static ExtrudeShape(name: string, options: {
  55578. shape: Vector3[];
  55579. path: Vector3[];
  55580. scale?: number;
  55581. rotation?: number;
  55582. cap?: number;
  55583. updatable?: boolean;
  55584. sideOrientation?: number;
  55585. frontUVs?: Vector4;
  55586. backUVs?: Vector4;
  55587. instance?: Mesh;
  55588. invertUV?: boolean;
  55589. }, scene?: Nullable<Scene>): Mesh;
  55590. /**
  55591. * Creates an custom extruded shape mesh.
  55592. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55593. * * 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.
  55594. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55595. * * 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
  55596. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55597. * * 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
  55598. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55599. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55600. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55601. * * 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
  55602. * * 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
  55603. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55605. * * 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
  55606. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55608. * @param name defines the name of the mesh
  55609. * @param options defines the options used to create the mesh
  55610. * @param scene defines the hosting scene
  55611. * @returns the custom extruded shape mesh
  55612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55615. */
  55616. static ExtrudeShapeCustom(name: string, options: {
  55617. shape: Vector3[];
  55618. path: Vector3[];
  55619. scaleFunction?: any;
  55620. rotationFunction?: any;
  55621. ribbonCloseArray?: boolean;
  55622. ribbonClosePath?: boolean;
  55623. cap?: number;
  55624. updatable?: boolean;
  55625. sideOrientation?: number;
  55626. frontUVs?: Vector4;
  55627. backUVs?: Vector4;
  55628. instance?: Mesh;
  55629. invertUV?: boolean;
  55630. }, scene?: Nullable<Scene>): Mesh;
  55631. private static _ExtrudeShapeGeneric;
  55632. }
  55633. }
  55634. declare module BABYLON.Debug {
  55635. /**
  55636. * Class used to render a debug view of a given skeleton
  55637. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55638. */
  55639. export class SkeletonViewer {
  55640. /** defines the skeleton to render */
  55641. skeleton: Skeleton;
  55642. /** defines the mesh attached to the skeleton */
  55643. mesh: AbstractMesh;
  55644. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55645. autoUpdateBonesMatrices: boolean;
  55646. /** defines the rendering group id to use with the viewer */
  55647. renderingGroupId: number;
  55648. /** is the options for the viewer */
  55649. options: Partial<ISkeletonViewerOptions>;
  55650. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55651. static readonly DISPLAY_LINES: number;
  55652. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55653. static readonly DISPLAY_SPHERES: number;
  55654. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55655. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55656. /** public static method to create a BoneWeight Shader
  55657. * @param options The constructor options
  55658. * @param scene The scene that the shader is scoped to
  55659. * @returns The created ShaderMaterial
  55660. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55661. */
  55662. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55663. /** public static method to create a BoneWeight Shader
  55664. * @param options The constructor options
  55665. * @param scene The scene that the shader is scoped to
  55666. * @returns The created ShaderMaterial
  55667. */
  55668. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55669. /** private static method to create a BoneWeight Shader
  55670. * @param size The size of the buffer to create (usually the bone count)
  55671. * @param colorMap The gradient data to generate
  55672. * @param scene The scene that the shader is scoped to
  55673. * @returns an Array of floats from the color gradient values
  55674. */
  55675. private static _CreateBoneMapColorBuffer;
  55676. /** If SkeletonViewer scene scope. */
  55677. private _scene;
  55678. /** Gets or sets the color used to render the skeleton */
  55679. color: Color3;
  55680. /** Array of the points of the skeleton fo the line view. */
  55681. private _debugLines;
  55682. /** The SkeletonViewers Mesh. */
  55683. private _debugMesh;
  55684. /** The local axes Meshes. */
  55685. private _localAxes;
  55686. /** If SkeletonViewer is enabled. */
  55687. private _isEnabled;
  55688. /** If SkeletonViewer is ready. */
  55689. private _ready;
  55690. /** SkeletonViewer render observable. */
  55691. private _obs;
  55692. /** The Utility Layer to render the gizmos in. */
  55693. private _utilityLayer;
  55694. private _boneIndices;
  55695. /** Gets the Scene. */
  55696. get scene(): Scene;
  55697. /** Gets the utilityLayer. */
  55698. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55699. /** Checks Ready Status. */
  55700. get isReady(): Boolean;
  55701. /** Sets Ready Status. */
  55702. set ready(value: boolean);
  55703. /** Gets the debugMesh */
  55704. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55705. /** Sets the debugMesh */
  55706. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55707. /** Gets the displayMode */
  55708. get displayMode(): number;
  55709. /** Sets the displayMode */
  55710. set displayMode(value: number);
  55711. /**
  55712. * Creates a new SkeletonViewer
  55713. * @param skeleton defines the skeleton to render
  55714. * @param mesh defines the mesh attached to the skeleton
  55715. * @param scene defines the hosting scene
  55716. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55717. * @param renderingGroupId defines the rendering group id to use with the viewer
  55718. * @param options All of the extra constructor options for the SkeletonViewer
  55719. */
  55720. constructor(
  55721. /** defines the skeleton to render */
  55722. skeleton: Skeleton,
  55723. /** defines the mesh attached to the skeleton */
  55724. mesh: AbstractMesh,
  55725. /** The Scene scope*/
  55726. scene: Scene,
  55727. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55728. autoUpdateBonesMatrices?: boolean,
  55729. /** defines the rendering group id to use with the viewer */
  55730. renderingGroupId?: number,
  55731. /** is the options for the viewer */
  55732. options?: Partial<ISkeletonViewerOptions>);
  55733. /** The Dynamic bindings for the update functions */
  55734. private _bindObs;
  55735. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55736. update(): void;
  55737. /** Gets or sets a boolean indicating if the viewer is enabled */
  55738. set isEnabled(value: boolean);
  55739. get isEnabled(): boolean;
  55740. private _getBonePosition;
  55741. private _getLinesForBonesWithLength;
  55742. private _getLinesForBonesNoLength;
  55743. /** function to revert the mesh and scene back to the initial state. */
  55744. private _revert;
  55745. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55746. private _getAbsoluteBindPoseToRef;
  55747. /** function to build and bind sphere joint points and spur bone representations. */
  55748. private _buildSpheresAndSpurs;
  55749. private _buildLocalAxes;
  55750. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55751. private _displayLinesUpdate;
  55752. /** Changes the displayMode of the skeleton viewer
  55753. * @param mode The displayMode numerical value
  55754. */
  55755. changeDisplayMode(mode: number): void;
  55756. /** Sets a display option of the skeleton viewer
  55757. *
  55758. * | Option | Type | Default | Description |
  55759. * | ---------------- | ------- | ------- | ----------- |
  55760. * | 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`. |
  55761. * | 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`. |
  55762. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55763. * | 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`. |
  55764. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55765. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55766. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55767. *
  55768. * @param option String of the option name
  55769. * @param value The numerical option value
  55770. */
  55771. changeDisplayOptions(option: string, value: number): void;
  55772. /** Release associated resources */
  55773. dispose(): void;
  55774. }
  55775. }
  55776. declare module BABYLON {
  55777. /**
  55778. * Enum for Device Types
  55779. */
  55780. export enum DeviceType {
  55781. /** Generic */
  55782. Generic = 0,
  55783. /** Keyboard */
  55784. Keyboard = 1,
  55785. /** Mouse */
  55786. Mouse = 2,
  55787. /** Touch Pointers */
  55788. Touch = 3,
  55789. /** PS4 Dual Shock */
  55790. DualShock = 4,
  55791. /** Xbox */
  55792. Xbox = 5,
  55793. /** Switch Controller */
  55794. Switch = 6
  55795. }
  55796. /**
  55797. * Enum for All Pointers (Touch/Mouse)
  55798. */
  55799. export enum PointerInput {
  55800. /** Horizontal Axis */
  55801. Horizontal = 0,
  55802. /** Vertical Axis */
  55803. Vertical = 1,
  55804. /** Left Click or Touch */
  55805. LeftClick = 2,
  55806. /** Middle Click */
  55807. MiddleClick = 3,
  55808. /** Right Click */
  55809. RightClick = 4,
  55810. /** Browser Back */
  55811. BrowserBack = 5,
  55812. /** Browser Forward */
  55813. BrowserForward = 6
  55814. }
  55815. /**
  55816. * Enum for Dual Shock Gamepad
  55817. */
  55818. export enum DualShockInput {
  55819. /** Cross */
  55820. Cross = 0,
  55821. /** Circle */
  55822. Circle = 1,
  55823. /** Square */
  55824. Square = 2,
  55825. /** Triangle */
  55826. Triangle = 3,
  55827. /** L1 */
  55828. L1 = 4,
  55829. /** R1 */
  55830. R1 = 5,
  55831. /** L2 */
  55832. L2 = 6,
  55833. /** R2 */
  55834. R2 = 7,
  55835. /** Share */
  55836. Share = 8,
  55837. /** Options */
  55838. Options = 9,
  55839. /** L3 */
  55840. L3 = 10,
  55841. /** R3 */
  55842. R3 = 11,
  55843. /** DPadUp */
  55844. DPadUp = 12,
  55845. /** DPadDown */
  55846. DPadDown = 13,
  55847. /** DPadLeft */
  55848. DPadLeft = 14,
  55849. /** DRight */
  55850. DPadRight = 15,
  55851. /** Home */
  55852. Home = 16,
  55853. /** TouchPad */
  55854. TouchPad = 17,
  55855. /** LStickXAxis */
  55856. LStickXAxis = 18,
  55857. /** LStickYAxis */
  55858. LStickYAxis = 19,
  55859. /** RStickXAxis */
  55860. RStickXAxis = 20,
  55861. /** RStickYAxis */
  55862. RStickYAxis = 21
  55863. }
  55864. /**
  55865. * Enum for Xbox Gamepad
  55866. */
  55867. export enum XboxInput {
  55868. /** A */
  55869. A = 0,
  55870. /** B */
  55871. B = 1,
  55872. /** X */
  55873. X = 2,
  55874. /** Y */
  55875. Y = 3,
  55876. /** LB */
  55877. LB = 4,
  55878. /** RB */
  55879. RB = 5,
  55880. /** LT */
  55881. LT = 6,
  55882. /** RT */
  55883. RT = 7,
  55884. /** Back */
  55885. Back = 8,
  55886. /** Start */
  55887. Start = 9,
  55888. /** LS */
  55889. LS = 10,
  55890. /** RS */
  55891. RS = 11,
  55892. /** DPadUp */
  55893. DPadUp = 12,
  55894. /** DPadDown */
  55895. DPadDown = 13,
  55896. /** DPadLeft */
  55897. DPadLeft = 14,
  55898. /** DRight */
  55899. DPadRight = 15,
  55900. /** Home */
  55901. Home = 16,
  55902. /** LStickXAxis */
  55903. LStickXAxis = 17,
  55904. /** LStickYAxis */
  55905. LStickYAxis = 18,
  55906. /** RStickXAxis */
  55907. RStickXAxis = 19,
  55908. /** RStickYAxis */
  55909. RStickYAxis = 20
  55910. }
  55911. /**
  55912. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55913. */
  55914. export enum SwitchInput {
  55915. /** B */
  55916. B = 0,
  55917. /** A */
  55918. A = 1,
  55919. /** Y */
  55920. Y = 2,
  55921. /** X */
  55922. X = 3,
  55923. /** L */
  55924. L = 4,
  55925. /** R */
  55926. R = 5,
  55927. /** ZL */
  55928. ZL = 6,
  55929. /** ZR */
  55930. ZR = 7,
  55931. /** Minus */
  55932. Minus = 8,
  55933. /** Plus */
  55934. Plus = 9,
  55935. /** LS */
  55936. LS = 10,
  55937. /** RS */
  55938. RS = 11,
  55939. /** DPadUp */
  55940. DPadUp = 12,
  55941. /** DPadDown */
  55942. DPadDown = 13,
  55943. /** DPadLeft */
  55944. DPadLeft = 14,
  55945. /** DRight */
  55946. DPadRight = 15,
  55947. /** Home */
  55948. Home = 16,
  55949. /** Capture */
  55950. Capture = 17,
  55951. /** LStickXAxis */
  55952. LStickXAxis = 18,
  55953. /** LStickYAxis */
  55954. LStickYAxis = 19,
  55955. /** RStickXAxis */
  55956. RStickXAxis = 20,
  55957. /** RStickYAxis */
  55958. RStickYAxis = 21
  55959. }
  55960. }
  55961. declare module BABYLON {
  55962. /**
  55963. * This class will take all inputs from Keyboard, Pointer, and
  55964. * any Gamepads and provide a polling system that all devices
  55965. * will use. This class assumes that there will only be one
  55966. * pointer device and one keyboard.
  55967. */
  55968. export class DeviceInputSystem implements IDisposable {
  55969. /**
  55970. * Returns onDeviceConnected callback property
  55971. * @returns Callback with function to execute when a device is connected
  55972. */
  55973. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55974. /**
  55975. * Sets callback function when a device is connected and executes against all connected devices
  55976. * @param callback Function to execute when a device is connected
  55977. */
  55978. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55979. /**
  55980. * Callback to be triggered when a device is disconnected
  55981. */
  55982. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55983. /**
  55984. * Callback to be triggered when event driven input is updated
  55985. */
  55986. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55987. private _inputs;
  55988. private _gamepads;
  55989. private _keyboardActive;
  55990. private _pointerActive;
  55991. private _elementToAttachTo;
  55992. private _keyboardDownEvent;
  55993. private _keyboardUpEvent;
  55994. private _pointerMoveEvent;
  55995. private _pointerDownEvent;
  55996. private _pointerUpEvent;
  55997. private _gamepadConnectedEvent;
  55998. private _gamepadDisconnectedEvent;
  55999. private _onDeviceConnected;
  56000. private static _MAX_KEYCODES;
  56001. private static _MAX_POINTER_INPUTS;
  56002. private constructor();
  56003. /**
  56004. * Creates a new DeviceInputSystem instance
  56005. * @param engine Engine to pull input element from
  56006. * @returns The new instance
  56007. */
  56008. static Create(engine: Engine): DeviceInputSystem;
  56009. /**
  56010. * Checks for current device input value, given an id and input index
  56011. * @param deviceName Id of connected device
  56012. * @param inputIndex Index of device input
  56013. * @returns Current value of input
  56014. */
  56015. /**
  56016. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56017. * @param deviceType Enum specifiying device type
  56018. * @param deviceSlot "Slot" or index that device is referenced in
  56019. * @param inputIndex Id of input to be checked
  56020. * @returns Current value of input
  56021. */
  56022. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56023. /**
  56024. * Dispose of all the eventlisteners
  56025. */
  56026. dispose(): void;
  56027. /**
  56028. * Checks for existing connections to devices and register them, if necessary
  56029. * Currently handles gamepads and mouse
  56030. */
  56031. private _checkForConnectedDevices;
  56032. /**
  56033. * Add a gamepad to the DeviceInputSystem
  56034. * @param gamepad A single DOM Gamepad object
  56035. */
  56036. private _addGamePad;
  56037. /**
  56038. * Add pointer device to DeviceInputSystem
  56039. * @param deviceType Type of Pointer to add
  56040. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  56041. * @param currentX Current X at point of adding
  56042. * @param currentY Current Y at point of adding
  56043. */
  56044. private _addPointerDevice;
  56045. /**
  56046. * Add device and inputs to device array
  56047. * @param deviceType Enum specifiying device type
  56048. * @param deviceSlot "Slot" or index that device is referenced in
  56049. * @param numberOfInputs Number of input entries to create for given device
  56050. */
  56051. private _registerDevice;
  56052. /**
  56053. * Given a specific device name, remove that device from the device map
  56054. * @param deviceType Enum specifiying device type
  56055. * @param deviceSlot "Slot" or index that device is referenced in
  56056. */
  56057. private _unregisterDevice;
  56058. /**
  56059. * Handle all actions that come from keyboard interaction
  56060. */
  56061. private _handleKeyActions;
  56062. /**
  56063. * Handle all actions that come from pointer interaction
  56064. */
  56065. private _handlePointerActions;
  56066. /**
  56067. * Handle all actions that come from gamepad interaction
  56068. */
  56069. private _handleGamepadActions;
  56070. /**
  56071. * Update all non-event based devices with each frame
  56072. * @param deviceType Enum specifiying device type
  56073. * @param deviceSlot "Slot" or index that device is referenced in
  56074. * @param inputIndex Id of input to be checked
  56075. */
  56076. private _updateDevice;
  56077. /**
  56078. * Gets DeviceType from the device name
  56079. * @param deviceName Name of Device from DeviceInputSystem
  56080. * @returns DeviceType enum value
  56081. */
  56082. private _getGamepadDeviceType;
  56083. }
  56084. }
  56085. declare module BABYLON {
  56086. /**
  56087. * Type to handle enforcement of inputs
  56088. */
  56089. 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;
  56090. }
  56091. declare module BABYLON {
  56092. /**
  56093. * Class that handles all input for a specific device
  56094. */
  56095. export class DeviceSource<T extends DeviceType> {
  56096. /** Type of device */
  56097. readonly deviceType: DeviceType;
  56098. /** "Slot" or index that device is referenced in */
  56099. readonly deviceSlot: number;
  56100. /**
  56101. * Observable to handle device input changes per device
  56102. */
  56103. readonly onInputChangedObservable: Observable<{
  56104. inputIndex: DeviceInput<T>;
  56105. previousState: Nullable<number>;
  56106. currentState: Nullable<number>;
  56107. }>;
  56108. private readonly _deviceInputSystem;
  56109. /**
  56110. * Default Constructor
  56111. * @param deviceInputSystem Reference to DeviceInputSystem
  56112. * @param deviceType Type of device
  56113. * @param deviceSlot "Slot" or index that device is referenced in
  56114. */
  56115. constructor(deviceInputSystem: DeviceInputSystem,
  56116. /** Type of device */
  56117. deviceType: DeviceType,
  56118. /** "Slot" or index that device is referenced in */
  56119. deviceSlot?: number);
  56120. /**
  56121. * Get input for specific input
  56122. * @param inputIndex index of specific input on device
  56123. * @returns Input value from DeviceInputSystem
  56124. */
  56125. getInput(inputIndex: DeviceInput<T>): number;
  56126. }
  56127. /**
  56128. * Class to keep track of devices
  56129. */
  56130. export class DeviceSourceManager implements IDisposable {
  56131. /**
  56132. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56133. */
  56134. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56135. /**
  56136. * Observable to be triggered when after a device is disconnected
  56137. */
  56138. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56139. private readonly _devices;
  56140. private readonly _firstDevice;
  56141. private readonly _deviceInputSystem;
  56142. /**
  56143. * Default Constructor
  56144. * @param engine engine to pull input element from
  56145. */
  56146. constructor(engine: Engine);
  56147. /**
  56148. * Gets a DeviceSource, given a type and slot
  56149. * @param deviceType Enum specifying device type
  56150. * @param deviceSlot "Slot" or index that device is referenced in
  56151. * @returns DeviceSource object
  56152. */
  56153. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56154. /**
  56155. * Gets an array of DeviceSource objects for a given device type
  56156. * @param deviceType Enum specifying device type
  56157. * @returns Array of DeviceSource objects
  56158. */
  56159. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56160. /**
  56161. * Returns a read-only list of all available devices
  56162. * @returns Read-only array with active devices
  56163. */
  56164. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56165. /**
  56166. * Dispose of DeviceInputSystem and other parts
  56167. */
  56168. dispose(): void;
  56169. /**
  56170. * Function to add 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 _addDevice;
  56175. /**
  56176. * Function to remove device name to device list
  56177. * @param deviceType Enum specifying device type
  56178. * @param deviceSlot "Slot" or index that device is referenced in
  56179. */
  56180. private _removeDevice;
  56181. /**
  56182. * Updates array storing first connected device of each type
  56183. * @param type Type of Device
  56184. */
  56185. private _updateFirstDevices;
  56186. }
  56187. }
  56188. declare module BABYLON {
  56189. /**
  56190. * Options to create the null engine
  56191. */
  56192. export class NullEngineOptions {
  56193. /**
  56194. * Render width (Default: 512)
  56195. */
  56196. renderWidth: number;
  56197. /**
  56198. * Render height (Default: 256)
  56199. */
  56200. renderHeight: number;
  56201. /**
  56202. * Texture size (Default: 512)
  56203. */
  56204. textureSize: number;
  56205. /**
  56206. * If delta time between frames should be constant
  56207. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56208. */
  56209. deterministicLockstep: boolean;
  56210. /**
  56211. * Maximum about of steps between frames (Default: 4)
  56212. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56213. */
  56214. lockstepMaxSteps: number;
  56215. /**
  56216. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56217. */
  56218. useHighPrecisionMatrix?: boolean;
  56219. }
  56220. /**
  56221. * The null engine class provides support for headless version of babylon.js.
  56222. * This can be used in server side scenario or for testing purposes
  56223. */
  56224. export class NullEngine extends Engine {
  56225. private _options;
  56226. /**
  56227. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56228. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56229. * @returns true if engine is in deterministic lock step mode
  56230. */
  56231. isDeterministicLockStep(): boolean;
  56232. /**
  56233. * Gets the max steps when engine is running in deterministic lock step
  56234. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56235. * @returns the max steps
  56236. */
  56237. getLockstepMaxSteps(): number;
  56238. /**
  56239. * Gets the current hardware scaling level.
  56240. * By default the hardware scaling level is computed from the window device ratio.
  56241. * 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.
  56242. * @returns a number indicating the current hardware scaling level
  56243. */
  56244. getHardwareScalingLevel(): number;
  56245. constructor(options?: NullEngineOptions);
  56246. /**
  56247. * Creates a vertex buffer
  56248. * @param vertices the data for the vertex buffer
  56249. * @returns the new WebGL static buffer
  56250. */
  56251. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56252. /**
  56253. * Creates a new index buffer
  56254. * @param indices defines the content of the index buffer
  56255. * @param updatable defines if the index buffer must be updatable
  56256. * @returns a new webGL buffer
  56257. */
  56258. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56259. /**
  56260. * Clear the current render buffer or the current render target (if any is set up)
  56261. * @param color defines the color to use
  56262. * @param backBuffer defines if the back buffer must be cleared
  56263. * @param depth defines if the depth buffer must be cleared
  56264. * @param stencil defines if the stencil buffer must be cleared
  56265. */
  56266. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56267. /**
  56268. * Gets the current render width
  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 width
  56271. */
  56272. getRenderWidth(useScreen?: boolean): number;
  56273. /**
  56274. * Gets the current render height
  56275. * @param useScreen defines if screen size must be used (or the current render target if any)
  56276. * @returns a number defining the current render height
  56277. */
  56278. getRenderHeight(useScreen?: boolean): number;
  56279. /**
  56280. * Set the WebGL's viewport
  56281. * @param viewport defines the viewport element to be used
  56282. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56283. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56284. */
  56285. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56286. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56287. /**
  56288. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56289. * @param pipelineContext defines the pipeline context to use
  56290. * @param uniformsNames defines the list of uniform names
  56291. * @returns an array of webGL uniform locations
  56292. */
  56293. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56294. /**
  56295. * Gets the lsit of active attributes for a given webGL program
  56296. * @param pipelineContext defines the pipeline context to use
  56297. * @param attributesNames defines the list of attribute names to get
  56298. * @returns an array of indices indicating the offset of each attribute
  56299. */
  56300. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56301. /**
  56302. * Binds an effect to the webGL context
  56303. * @param effect defines the effect to bind
  56304. */
  56305. bindSamplers(effect: Effect): void;
  56306. /**
  56307. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56308. * @param effect defines the effect to activate
  56309. */
  56310. enableEffect(effect: Effect): void;
  56311. /**
  56312. * Set various states to the webGL context
  56313. * @param culling defines backface culling state
  56314. * @param zOffset defines the value to apply to zOffset (0 by default)
  56315. * @param force defines if states must be applied even if cache is up to date
  56316. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56317. */
  56318. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56319. /**
  56320. * Set the value of an uniform to an array of int32
  56321. * @param uniform defines the webGL uniform location where to store the value
  56322. * @param array defines the array of int32 to store
  56323. * @returns true if value was set
  56324. */
  56325. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56326. /**
  56327. * Set the value of an uniform to an array of int32 (stored as vec2)
  56328. * @param uniform defines the webGL uniform location where to store the value
  56329. * @param array defines the array of int32 to store
  56330. * @returns true if value was set
  56331. */
  56332. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56333. /**
  56334. * Set the value of an uniform to an array of int32 (stored as vec3)
  56335. * @param uniform defines the webGL uniform location where to store the value
  56336. * @param array defines the array of int32 to store
  56337. * @returns true if value was set
  56338. */
  56339. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56340. /**
  56341. * Set the value of an uniform to an array of int32 (stored as vec4)
  56342. * @param uniform defines the webGL uniform location where to store the value
  56343. * @param array defines the array of int32 to store
  56344. * @returns true if value was set
  56345. */
  56346. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56347. /**
  56348. * Set the value of an uniform to an array of float32
  56349. * @param uniform defines the webGL uniform location where to store the value
  56350. * @param array defines the array of float32 to store
  56351. * @returns true if value was set
  56352. */
  56353. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56354. /**
  56355. * Set the value of an uniform to an array of float32 (stored as vec2)
  56356. * @param uniform defines the webGL uniform location where to store the value
  56357. * @param array defines the array of float32 to store
  56358. * @returns true if value was set
  56359. */
  56360. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56361. /**
  56362. * Set the value of an uniform to an array of float32 (stored as vec3)
  56363. * @param uniform defines the webGL uniform location where to store the value
  56364. * @param array defines the array of float32 to store
  56365. * @returns true if value was set
  56366. */
  56367. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56368. /**
  56369. * Set the value of an uniform to an array of float32 (stored as vec4)
  56370. * @param uniform defines the webGL uniform location where to store the value
  56371. * @param array defines the array of float32 to store
  56372. * @returns true if value was set
  56373. */
  56374. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56375. /**
  56376. * Set the value of an uniform to an array of number
  56377. * @param uniform defines the webGL uniform location where to store the value
  56378. * @param array defines the array of number to store
  56379. * @returns true if value was set
  56380. */
  56381. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56382. /**
  56383. * Set the value of an uniform to an array of number (stored as vec2)
  56384. * @param uniform defines the webGL uniform location where to store the value
  56385. * @param array defines the array of number to store
  56386. * @returns true if value was set
  56387. */
  56388. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56389. /**
  56390. * Set the value of an uniform to an array of number (stored as vec3)
  56391. * @param uniform defines the webGL uniform location where to store the value
  56392. * @param array defines the array of number to store
  56393. * @returns true if value was set
  56394. */
  56395. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56396. /**
  56397. * Set the value of an uniform to an array of number (stored as vec4)
  56398. * @param uniform defines the webGL uniform location where to store the value
  56399. * @param array defines the array of number to store
  56400. * @returns true if value was set
  56401. */
  56402. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56403. /**
  56404. * Set the value of an uniform to an array of float32 (stored as matrices)
  56405. * @param uniform defines the webGL uniform location where to store the value
  56406. * @param matrices defines the array of float32 to store
  56407. * @returns true if value was set
  56408. */
  56409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56410. /**
  56411. * Set the value of an uniform to a matrix (3x3)
  56412. * @param uniform defines the webGL uniform location where to store the value
  56413. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56414. * @returns true if value was set
  56415. */
  56416. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56417. /**
  56418. * Set the value of an uniform to a matrix (2x2)
  56419. * @param uniform defines the webGL uniform location where to store the value
  56420. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56421. * @returns true if value was set
  56422. */
  56423. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56424. /**
  56425. * Set the value of an uniform to a number (float)
  56426. * @param uniform defines the webGL uniform location where to store the value
  56427. * @param value defines the float number to store
  56428. * @returns true if value was set
  56429. */
  56430. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56431. /**
  56432. * Set the value of an uniform to a vec2
  56433. * @param uniform defines the webGL uniform location where to store the value
  56434. * @param x defines the 1st component of the value
  56435. * @param y defines the 2nd component of the value
  56436. * @returns true if value was set
  56437. */
  56438. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56439. /**
  56440. * Set the value of an uniform to a vec3
  56441. * @param uniform defines the webGL uniform location where to store the value
  56442. * @param x defines the 1st component of the value
  56443. * @param y defines the 2nd component of the value
  56444. * @param z defines the 3rd component of the value
  56445. * @returns true if value was set
  56446. */
  56447. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56448. /**
  56449. * Set the value of an uniform to a boolean
  56450. * @param uniform defines the webGL uniform location where to store the value
  56451. * @param bool defines the boolean to store
  56452. * @returns true if value was set
  56453. */
  56454. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56455. /**
  56456. * Set the value of an uniform to a vec4
  56457. * @param uniform defines the webGL uniform location where to store the value
  56458. * @param x defines the 1st component of the value
  56459. * @param y defines the 2nd component of the value
  56460. * @param z defines the 3rd component of the value
  56461. * @param w defines the 4th component of the value
  56462. * @returns true if value was set
  56463. */
  56464. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56465. /**
  56466. * Sets the current alpha mode
  56467. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56468. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56469. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56470. */
  56471. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56472. /**
  56473. * Bind webGl buffers directly to the webGL context
  56474. * @param vertexBuffers defines the vertex buffer to bind
  56475. * @param indexBuffer defines the index buffer to bind
  56476. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56477. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56478. * @param effect defines the effect associated with the vertex buffer
  56479. */
  56480. bindBuffers(vertexBuffers: {
  56481. [key: string]: VertexBuffer;
  56482. }, indexBuffer: DataBuffer, effect: Effect): void;
  56483. /**
  56484. * Force the entire cache to be cleared
  56485. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56486. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56487. */
  56488. wipeCaches(bruteForce?: boolean): void;
  56489. /**
  56490. * Send a draw order
  56491. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56492. * @param indexStart defines the starting index
  56493. * @param indexCount defines the number of index to draw
  56494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56495. */
  56496. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56497. /**
  56498. * Draw a list of indexed primitives
  56499. * @param fillMode defines the primitive to use
  56500. * @param indexStart defines the starting index
  56501. * @param indexCount defines the number of index to draw
  56502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56503. */
  56504. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56505. /**
  56506. * Draw a list of unindexed primitives
  56507. * @param fillMode defines the primitive to use
  56508. * @param verticesStart defines the index of first vertex to draw
  56509. * @param verticesCount defines the count of vertices to draw
  56510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56511. */
  56512. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56513. /** @hidden */
  56514. _createTexture(): WebGLTexture;
  56515. /** @hidden */
  56516. _releaseTexture(texture: InternalTexture): void;
  56517. /**
  56518. * Usually called from Texture.ts.
  56519. * Passed information to create a WebGLTexture
  56520. * @param urlArg defines a value which contains one of the following:
  56521. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56522. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56523. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56524. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56525. * @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)
  56526. * @param scene needed for loading to the correct scene
  56527. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56528. * @param onLoad optional callback to be called upon successful completion
  56529. * @param onError optional callback to be called upon failure
  56530. * @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
  56531. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56532. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56533. * @param forcedExtension defines the extension to use to pick the right loader
  56534. * @param mimeType defines an optional mime type
  56535. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56536. */
  56537. 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;
  56538. /**
  56539. * Creates a new render target texture
  56540. * @param size defines the size of the texture
  56541. * @param options defines the options used to create the texture
  56542. * @returns a new render target texture stored in an InternalTexture
  56543. */
  56544. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56545. /**
  56546. * Update the sampling mode of a given texture
  56547. * @param samplingMode defines the required sampling mode
  56548. * @param texture defines the texture to update
  56549. */
  56550. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56551. /**
  56552. * Binds the frame buffer to the specified texture.
  56553. * @param texture The texture to render to or null for the default canvas
  56554. * @param faceIndex The face of the texture to render to in case of cube texture
  56555. * @param requiredWidth The width of the target to render to
  56556. * @param requiredHeight The height of the target to render to
  56557. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56558. * @param lodLevel defines le lod level to bind to the frame buffer
  56559. */
  56560. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56561. /**
  56562. * Unbind the current render target texture from the webGL context
  56563. * @param texture defines the render target texture to unbind
  56564. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56565. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56566. */
  56567. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56568. /**
  56569. * Creates a dynamic vertex buffer
  56570. * @param vertices the data for the dynamic vertex buffer
  56571. * @returns the new WebGL dynamic buffer
  56572. */
  56573. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56574. /**
  56575. * Update the content of a dynamic texture
  56576. * @param texture defines the texture to update
  56577. * @param canvas defines the canvas containing the source
  56578. * @param invertY defines if data must be stored with Y axis inverted
  56579. * @param premulAlpha defines if alpha is stored as premultiplied
  56580. * @param format defines the format of the data
  56581. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56582. */
  56583. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56584. /**
  56585. * Gets a boolean indicating if all created effects are ready
  56586. * @returns true if all effects are ready
  56587. */
  56588. areAllEffectsReady(): boolean;
  56589. /**
  56590. * @hidden
  56591. * Get the current error code of the webGL context
  56592. * @returns the error code
  56593. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56594. */
  56595. getError(): number;
  56596. /** @hidden */
  56597. _getUnpackAlignement(): number;
  56598. /** @hidden */
  56599. _unpackFlipY(value: boolean): void;
  56600. /**
  56601. * Update a dynamic index buffer
  56602. * @param indexBuffer defines the target index buffer
  56603. * @param indices defines the data to update
  56604. * @param offset defines the offset in the target index buffer where update should start
  56605. */
  56606. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56607. /**
  56608. * Updates a dynamic vertex buffer.
  56609. * @param vertexBuffer the vertex buffer to update
  56610. * @param vertices the data used to update the vertex buffer
  56611. * @param byteOffset the byte offset of the data (optional)
  56612. * @param byteLength the byte length of the data (optional)
  56613. */
  56614. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56615. /** @hidden */
  56616. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56617. /** @hidden */
  56618. _bindTexture(channel: number, texture: InternalTexture): void;
  56619. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56620. /**
  56621. * 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
  56622. */
  56623. releaseEffects(): void;
  56624. displayLoadingUI(): void;
  56625. hideLoadingUI(): void;
  56626. /** @hidden */
  56627. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56628. /** @hidden */
  56629. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56630. /** @hidden */
  56631. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56632. /** @hidden */
  56633. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56634. }
  56635. }
  56636. declare module BABYLON {
  56637. /**
  56638. * @hidden
  56639. **/
  56640. export class _TimeToken {
  56641. _startTimeQuery: Nullable<WebGLQuery>;
  56642. _endTimeQuery: Nullable<WebGLQuery>;
  56643. _timeElapsedQuery: Nullable<WebGLQuery>;
  56644. _timeElapsedQueryEnded: boolean;
  56645. }
  56646. }
  56647. declare module BABYLON {
  56648. /** @hidden */
  56649. export class _OcclusionDataStorage {
  56650. /** @hidden */
  56651. occlusionInternalRetryCounter: number;
  56652. /** @hidden */
  56653. isOcclusionQueryInProgress: boolean;
  56654. /** @hidden */
  56655. isOccluded: boolean;
  56656. /** @hidden */
  56657. occlusionRetryCount: number;
  56658. /** @hidden */
  56659. occlusionType: number;
  56660. /** @hidden */
  56661. occlusionQueryAlgorithmType: number;
  56662. }
  56663. interface Engine {
  56664. /**
  56665. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56666. * @return the new query
  56667. */
  56668. createQuery(): WebGLQuery;
  56669. /**
  56670. * Delete and release a webGL query
  56671. * @param query defines the query to delete
  56672. * @return the current engine
  56673. */
  56674. deleteQuery(query: WebGLQuery): Engine;
  56675. /**
  56676. * Check if a given query has resolved and got its value
  56677. * @param query defines the query to check
  56678. * @returns true if the query got its value
  56679. */
  56680. isQueryResultAvailable(query: WebGLQuery): boolean;
  56681. /**
  56682. * Gets the value of a given query
  56683. * @param query defines the query to check
  56684. * @returns the value of the query
  56685. */
  56686. getQueryResult(query: WebGLQuery): number;
  56687. /**
  56688. * Initiates an occlusion query
  56689. * @param algorithmType defines the algorithm to use
  56690. * @param query defines the query to use
  56691. * @returns the current engine
  56692. * @see https://doc.babylonjs.com/features/occlusionquery
  56693. */
  56694. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56695. /**
  56696. * Ends an occlusion query
  56697. * @see https://doc.babylonjs.com/features/occlusionquery
  56698. * @param algorithmType defines the algorithm to use
  56699. * @returns the current engine
  56700. */
  56701. endOcclusionQuery(algorithmType: number): Engine;
  56702. /**
  56703. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56704. * Please note that only one query can be issued at a time
  56705. * @returns a time token used to track the time span
  56706. */
  56707. startTimeQuery(): Nullable<_TimeToken>;
  56708. /**
  56709. * Ends a time query
  56710. * @param token defines the token used to measure the time span
  56711. * @returns the time spent (in ns)
  56712. */
  56713. endTimeQuery(token: _TimeToken): int;
  56714. /** @hidden */
  56715. _currentNonTimestampToken: Nullable<_TimeToken>;
  56716. /** @hidden */
  56717. _createTimeQuery(): WebGLQuery;
  56718. /** @hidden */
  56719. _deleteTimeQuery(query: WebGLQuery): void;
  56720. /** @hidden */
  56721. _getGlAlgorithmType(algorithmType: number): number;
  56722. /** @hidden */
  56723. _getTimeQueryResult(query: WebGLQuery): any;
  56724. /** @hidden */
  56725. _getTimeQueryAvailability(query: WebGLQuery): any;
  56726. }
  56727. interface AbstractMesh {
  56728. /**
  56729. * Backing filed
  56730. * @hidden
  56731. */
  56732. __occlusionDataStorage: _OcclusionDataStorage;
  56733. /**
  56734. * Access property
  56735. * @hidden
  56736. */
  56737. _occlusionDataStorage: _OcclusionDataStorage;
  56738. /**
  56739. * 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.
  56740. * The default value is -1 which means don't break the query and wait till the result
  56741. * @see https://doc.babylonjs.com/features/occlusionquery
  56742. */
  56743. occlusionRetryCount: number;
  56744. /**
  56745. * 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:
  56746. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56747. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56748. * * 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.
  56749. * @see https://doc.babylonjs.com/features/occlusionquery
  56750. */
  56751. occlusionType: number;
  56752. /**
  56753. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56754. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56755. * * 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.
  56756. * @see https://doc.babylonjs.com/features/occlusionquery
  56757. */
  56758. occlusionQueryAlgorithmType: number;
  56759. /**
  56760. * 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
  56761. * @see https://doc.babylonjs.com/features/occlusionquery
  56762. */
  56763. isOccluded: boolean;
  56764. /**
  56765. * Flag to check the progress status of the query
  56766. * @see https://doc.babylonjs.com/features/occlusionquery
  56767. */
  56768. isOcclusionQueryInProgress: boolean;
  56769. }
  56770. }
  56771. declare module BABYLON {
  56772. /** @hidden */
  56773. export var _forceTransformFeedbackToBundle: boolean;
  56774. interface Engine {
  56775. /**
  56776. * Creates a webGL transform feedback object
  56777. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56778. * @returns the webGL transform feedback object
  56779. */
  56780. createTransformFeedback(): WebGLTransformFeedback;
  56781. /**
  56782. * Delete a webGL transform feedback object
  56783. * @param value defines the webGL transform feedback object to delete
  56784. */
  56785. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56786. /**
  56787. * Bind a webGL transform feedback object to the webgl context
  56788. * @param value defines the webGL transform feedback object to bind
  56789. */
  56790. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56791. /**
  56792. * Begins a transform feedback operation
  56793. * @param usePoints defines if points or triangles must be used
  56794. */
  56795. beginTransformFeedback(usePoints: boolean): void;
  56796. /**
  56797. * Ends a transform feedback operation
  56798. */
  56799. endTransformFeedback(): void;
  56800. /**
  56801. * Specify the varyings to use with transform feedback
  56802. * @param program defines the associated webGL program
  56803. * @param value defines the list of strings representing the varying names
  56804. */
  56805. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56806. /**
  56807. * Bind a webGL buffer for a transform feedback operation
  56808. * @param value defines the webGL buffer to bind
  56809. */
  56810. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56811. }
  56812. }
  56813. declare module BABYLON {
  56814. /**
  56815. * Class used to define an additional view for the engine
  56816. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56817. */
  56818. export class EngineView {
  56819. /** Defines the canvas where to render the view */
  56820. target: HTMLCanvasElement;
  56821. /** Defines an optional camera used to render the view (will use active camera else) */
  56822. camera?: Camera;
  56823. }
  56824. interface Engine {
  56825. /**
  56826. * Gets or sets the HTML element to use for attaching events
  56827. */
  56828. inputElement: Nullable<HTMLElement>;
  56829. /**
  56830. * Gets the current engine view
  56831. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56832. */
  56833. activeView: Nullable<EngineView>;
  56834. /** Gets or sets the list of views */
  56835. views: EngineView[];
  56836. /**
  56837. * Register a new child canvas
  56838. * @param canvas defines the canvas to register
  56839. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56840. * @returns the associated view
  56841. */
  56842. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56843. /**
  56844. * Remove a registered child canvas
  56845. * @param canvas defines the canvas to remove
  56846. * @returns the current engine
  56847. */
  56848. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56849. }
  56850. }
  56851. declare module BABYLON {
  56852. interface Engine {
  56853. /** @hidden */
  56854. _excludedCompressedTextures: string[];
  56855. /** @hidden */
  56856. _textureFormatInUse: string;
  56857. /**
  56858. * Gets the list of texture formats supported
  56859. */
  56860. readonly texturesSupported: Array<string>;
  56861. /**
  56862. * Gets the texture format in use
  56863. */
  56864. readonly textureFormatInUse: Nullable<string>;
  56865. /**
  56866. * Set the compressed texture extensions or file names to skip.
  56867. *
  56868. * @param skippedFiles defines the list of those texture files you want to skip
  56869. * Example: [".dds", ".env", "myfile.png"]
  56870. */
  56871. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56872. /**
  56873. * Set the compressed texture format to use, based on the formats you have, and the formats
  56874. * supported by the hardware / browser.
  56875. *
  56876. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56877. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56878. * to API arguments needed to compressed textures. This puts the burden on the container
  56879. * generator to house the arcane code for determining these for current & future formats.
  56880. *
  56881. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56882. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56883. *
  56884. * Note: The result of this call is not taken into account when a texture is base64.
  56885. *
  56886. * @param formatsAvailable defines the list of those format families you have created
  56887. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56888. *
  56889. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56890. * @returns The extension selected.
  56891. */
  56892. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56893. }
  56894. }
  56895. declare module BABYLON {
  56896. /** @hidden */
  56897. export var rgbdEncodePixelShader: {
  56898. name: string;
  56899. shader: string;
  56900. };
  56901. }
  56902. declare module BABYLON {
  56903. /**
  56904. * Raw texture data and descriptor sufficient for WebGL texture upload
  56905. */
  56906. export interface EnvironmentTextureInfo {
  56907. /**
  56908. * Version of the environment map
  56909. */
  56910. version: number;
  56911. /**
  56912. * Width of image
  56913. */
  56914. width: number;
  56915. /**
  56916. * Irradiance information stored in the file.
  56917. */
  56918. irradiance: any;
  56919. /**
  56920. * Specular information stored in the file.
  56921. */
  56922. specular: any;
  56923. }
  56924. /**
  56925. * Defines One Image in the file. It requires only the position in the file
  56926. * as well as the length.
  56927. */
  56928. interface BufferImageData {
  56929. /**
  56930. * Length of the image data.
  56931. */
  56932. length: number;
  56933. /**
  56934. * Position of the data from the null terminator delimiting the end of the JSON.
  56935. */
  56936. position: number;
  56937. }
  56938. /**
  56939. * Defines the specular data enclosed in the file.
  56940. * This corresponds to the version 1 of the data.
  56941. */
  56942. export interface EnvironmentTextureSpecularInfoV1 {
  56943. /**
  56944. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56945. */
  56946. specularDataPosition?: number;
  56947. /**
  56948. * This contains all the images data needed to reconstruct the cubemap.
  56949. */
  56950. mipmaps: Array<BufferImageData>;
  56951. /**
  56952. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56953. */
  56954. lodGenerationScale: number;
  56955. }
  56956. /**
  56957. * Sets of helpers addressing the serialization and deserialization of environment texture
  56958. * stored in a BabylonJS env file.
  56959. * Those files are usually stored as .env files.
  56960. */
  56961. export class EnvironmentTextureTools {
  56962. /**
  56963. * Magic number identifying the env file.
  56964. */
  56965. private static _MagicBytes;
  56966. /**
  56967. * Gets the environment info from an env file.
  56968. * @param data The array buffer containing the .env bytes.
  56969. * @returns the environment file info (the json header) if successfully parsed.
  56970. */
  56971. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56972. /**
  56973. * Creates an environment texture from a loaded cube texture.
  56974. * @param texture defines the cube texture to convert in env file
  56975. * @return a promise containing the environment data if succesfull.
  56976. */
  56977. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56978. /**
  56979. * Creates a JSON representation of the spherical data.
  56980. * @param texture defines the texture containing the polynomials
  56981. * @return the JSON representation of the spherical info
  56982. */
  56983. private static _CreateEnvTextureIrradiance;
  56984. /**
  56985. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56986. * @param data the image data
  56987. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56988. * @return the views described by info providing access to the underlying buffer
  56989. */
  56990. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56991. /**
  56992. * Uploads the texture info contained in the env file to the GPU.
  56993. * @param texture defines the internal texture to upload to
  56994. * @param data defines the data to load
  56995. * @param info defines the texture info retrieved through the GetEnvInfo method
  56996. * @returns a promise
  56997. */
  56998. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56999. private static _OnImageReadyAsync;
  57000. /**
  57001. * Uploads the levels of image data to the GPU.
  57002. * @param texture defines the internal texture to upload to
  57003. * @param imageData defines the array buffer views of image data [mipmap][face]
  57004. * @returns a promise
  57005. */
  57006. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57007. /**
  57008. * Uploads spherical polynomials information to the texture.
  57009. * @param texture defines the texture we are trying to upload the information to
  57010. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57011. */
  57012. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57013. /** @hidden */
  57014. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57015. }
  57016. }
  57017. declare module BABYLON {
  57018. /**
  57019. * Class used to inline functions in shader code
  57020. */
  57021. export class ShaderCodeInliner {
  57022. private static readonly _RegexpFindFunctionNameAndType;
  57023. private _sourceCode;
  57024. private _functionDescr;
  57025. private _numMaxIterations;
  57026. /** Gets or sets the token used to mark the functions to inline */
  57027. inlineToken: string;
  57028. /** Gets or sets the debug mode */
  57029. debug: boolean;
  57030. /** Gets the code after the inlining process */
  57031. get code(): string;
  57032. /**
  57033. * Initializes the inliner
  57034. * @param sourceCode shader code source to inline
  57035. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57036. */
  57037. constructor(sourceCode: string, numMaxIterations?: number);
  57038. /**
  57039. * Start the processing of the shader code
  57040. */
  57041. processCode(): void;
  57042. private _collectFunctions;
  57043. private _processInlining;
  57044. private _extractBetweenMarkers;
  57045. private _skipWhitespaces;
  57046. private _removeComments;
  57047. private _replaceFunctionCallsByCode;
  57048. private _findBackward;
  57049. private _escapeRegExp;
  57050. private _replaceNames;
  57051. }
  57052. }
  57053. declare module BABYLON {
  57054. /**
  57055. * Container for accessors for natively-stored mesh data buffers.
  57056. */
  57057. class NativeDataBuffer extends DataBuffer {
  57058. /**
  57059. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57060. */
  57061. nativeIndexBuffer?: any;
  57062. /**
  57063. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57064. */
  57065. nativeVertexBuffer?: any;
  57066. }
  57067. /** @hidden */
  57068. class NativeTexture extends InternalTexture {
  57069. getInternalTexture(): InternalTexture;
  57070. getViewCount(): number;
  57071. }
  57072. /** @hidden */
  57073. export class NativeEngine extends Engine {
  57074. private readonly _native;
  57075. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57076. private readonly INVALID_HANDLE;
  57077. private _boundBuffersVertexArray;
  57078. private _currentDepthTest;
  57079. getHardwareScalingLevel(): number;
  57080. constructor();
  57081. dispose(): void;
  57082. /**
  57083. * Can be used to override the current requestAnimationFrame requester.
  57084. * @hidden
  57085. */
  57086. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57087. /**
  57088. * Override default engine behavior.
  57089. * @param color
  57090. * @param backBuffer
  57091. * @param depth
  57092. * @param stencil
  57093. */
  57094. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57095. /**
  57096. * Gets host document
  57097. * @returns the host document object
  57098. */
  57099. getHostDocument(): Nullable<Document>;
  57100. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57101. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57102. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57103. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57104. [key: string]: VertexBuffer;
  57105. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57106. bindBuffers(vertexBuffers: {
  57107. [key: string]: VertexBuffer;
  57108. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57109. recordVertexArrayObject(vertexBuffers: {
  57110. [key: string]: VertexBuffer;
  57111. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57112. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57113. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57114. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57115. /**
  57116. * Draw a list of indexed primitives
  57117. * @param fillMode defines the primitive to use
  57118. * @param indexStart defines the starting index
  57119. * @param indexCount defines the number of index to draw
  57120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57121. */
  57122. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57123. /**
  57124. * Draw a list of unindexed primitives
  57125. * @param fillMode defines the primitive to use
  57126. * @param verticesStart defines the index of first vertex to draw
  57127. * @param verticesCount defines the count of vertices to draw
  57128. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57129. */
  57130. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57131. createPipelineContext(): IPipelineContext;
  57132. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57133. /** @hidden */
  57134. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57135. /** @hidden */
  57136. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57137. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57138. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57139. protected _setProgram(program: WebGLProgram): void;
  57140. _releaseEffect(effect: Effect): void;
  57141. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57142. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57143. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57144. bindSamplers(effect: Effect): void;
  57145. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57146. getRenderWidth(useScreen?: boolean): number;
  57147. getRenderHeight(useScreen?: boolean): number;
  57148. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57149. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57150. /**
  57151. * Set the z offset to apply to current rendering
  57152. * @param value defines the offset to apply
  57153. */
  57154. setZOffset(value: number): void;
  57155. /**
  57156. * Gets the current value of the zOffset
  57157. * @returns the current zOffset state
  57158. */
  57159. getZOffset(): number;
  57160. /**
  57161. * Enable or disable depth buffering
  57162. * @param enable defines the state to set
  57163. */
  57164. setDepthBuffer(enable: boolean): void;
  57165. /**
  57166. * Gets a boolean indicating if depth writing is enabled
  57167. * @returns the current depth writing state
  57168. */
  57169. getDepthWrite(): boolean;
  57170. setDepthFunctionToGreater(): void;
  57171. setDepthFunctionToGreaterOrEqual(): void;
  57172. setDepthFunctionToLess(): void;
  57173. setDepthFunctionToLessOrEqual(): void;
  57174. /**
  57175. * Enable or disable depth writing
  57176. * @param enable defines the state to set
  57177. */
  57178. setDepthWrite(enable: boolean): void;
  57179. /**
  57180. * Enable or disable color writing
  57181. * @param enable defines the state to set
  57182. */
  57183. setColorWrite(enable: boolean): void;
  57184. /**
  57185. * Gets a boolean indicating if color writing is enabled
  57186. * @returns the current color writing state
  57187. */
  57188. getColorWrite(): boolean;
  57189. /**
  57190. * Sets alpha constants used by some alpha blending modes
  57191. * @param r defines the red component
  57192. * @param g defines the green component
  57193. * @param b defines the blue component
  57194. * @param a defines the alpha component
  57195. */
  57196. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57197. /**
  57198. * Sets the current alpha mode
  57199. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57200. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57201. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57202. */
  57203. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57204. /**
  57205. * Gets the current alpha mode
  57206. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57207. * @returns the current alpha mode
  57208. */
  57209. getAlphaMode(): number;
  57210. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57211. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57212. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57213. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57214. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57215. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57216. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57217. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57218. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57219. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57220. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57221. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57222. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57223. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57224. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57225. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57226. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57227. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57228. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57229. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57230. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57231. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57232. wipeCaches(bruteForce?: boolean): void;
  57233. _createTexture(): WebGLTexture;
  57234. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57235. /**
  57236. * Update the content of a dynamic texture
  57237. * @param texture defines the texture to update
  57238. * @param canvas defines the canvas containing the source
  57239. * @param invertY defines if data must be stored with Y axis inverted
  57240. * @param premulAlpha defines if alpha is stored as premultiplied
  57241. * @param format defines the format of the data
  57242. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57243. */
  57244. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57245. /**
  57246. * Usually called from Texture.ts.
  57247. * Passed information to create a WebGLTexture
  57248. * @param url defines a value which contains one of the following:
  57249. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57250. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57251. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57252. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57253. * @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)
  57254. * @param scene needed for loading to the correct scene
  57255. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57256. * @param onLoad optional callback to be called upon successful completion
  57257. * @param onError optional callback to be called upon failure
  57258. * @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
  57259. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57260. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57261. * @param forcedExtension defines the extension to use to pick the right loader
  57262. * @param mimeType defines an optional mime type
  57263. * @param loaderOptions options to be passed to the loader
  57264. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57265. */
  57266. 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;
  57267. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57268. _releaseFramebufferObjects(texture: InternalTexture): void;
  57269. /**
  57270. * Creates a cube texture
  57271. * @param rootUrl defines the url where the files to load is located
  57272. * @param scene defines the current scene
  57273. * @param files defines the list of files to load (1 per face)
  57274. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57275. * @param onLoad defines an optional callback raised when the texture is loaded
  57276. * @param onError defines an optional callback raised if there is an issue to load the texture
  57277. * @param format defines the format of the data
  57278. * @param forcedExtension defines the extension to use to pick the right loader
  57279. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57280. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57281. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57282. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57283. * @returns the cube texture as an InternalTexture
  57284. */
  57285. 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;
  57286. createRenderTargetTexture(size: number | {
  57287. width: number;
  57288. height: number;
  57289. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57290. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57291. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57292. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57293. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57294. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57295. /**
  57296. * Updates a dynamic vertex buffer.
  57297. * @param vertexBuffer the vertex buffer to update
  57298. * @param data the data used to update the vertex buffer
  57299. * @param byteOffset the byte offset of the data (optional)
  57300. * @param byteLength the byte length of the data (optional)
  57301. */
  57302. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57303. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57304. private _updateAnisotropicLevel;
  57305. private _getAddressMode;
  57306. /** @hidden */
  57307. _bindTexture(channel: number, texture: InternalTexture): void;
  57308. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57309. releaseEffects(): void;
  57310. /** @hidden */
  57311. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57312. /** @hidden */
  57313. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57314. /** @hidden */
  57315. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57316. /** @hidden */
  57317. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57318. private _getNativeSamplingMode;
  57319. private _getNativeTextureFormat;
  57320. private _getNativeAlphaMode;
  57321. private _getNativeAttribType;
  57322. }
  57323. }
  57324. declare module BABYLON {
  57325. /**
  57326. * Gather the list of clipboard event types as constants.
  57327. */
  57328. export class ClipboardEventTypes {
  57329. /**
  57330. * The clipboard event is fired when a copy command is active (pressed).
  57331. */
  57332. static readonly COPY: number;
  57333. /**
  57334. * The clipboard event is fired when a cut command is active (pressed).
  57335. */
  57336. static readonly CUT: number;
  57337. /**
  57338. * The clipboard event is fired when a paste command is active (pressed).
  57339. */
  57340. static readonly PASTE: number;
  57341. }
  57342. /**
  57343. * This class is used to store clipboard related info for the onClipboardObservable event.
  57344. */
  57345. export class ClipboardInfo {
  57346. /**
  57347. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57348. */
  57349. type: number;
  57350. /**
  57351. * Defines the related dom event
  57352. */
  57353. event: ClipboardEvent;
  57354. /**
  57355. *Creates an instance of ClipboardInfo.
  57356. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57357. * @param event Defines the related dom event
  57358. */
  57359. constructor(
  57360. /**
  57361. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57362. */
  57363. type: number,
  57364. /**
  57365. * Defines the related dom event
  57366. */
  57367. event: ClipboardEvent);
  57368. /**
  57369. * Get the clipboard event's type from the keycode.
  57370. * @param keyCode Defines the keyCode for the current keyboard event.
  57371. * @return {number}
  57372. */
  57373. static GetTypeFromCharacter(keyCode: number): number;
  57374. }
  57375. }
  57376. declare module BABYLON {
  57377. /**
  57378. * Google Daydream controller
  57379. */
  57380. export class DaydreamController extends WebVRController {
  57381. /**
  57382. * Base Url for the controller model.
  57383. */
  57384. static MODEL_BASE_URL: string;
  57385. /**
  57386. * File name for the controller model.
  57387. */
  57388. static MODEL_FILENAME: string;
  57389. /**
  57390. * Gamepad Id prefix used to identify Daydream Controller.
  57391. */
  57392. static readonly GAMEPAD_ID_PREFIX: string;
  57393. /**
  57394. * Creates a new DaydreamController from a gamepad
  57395. * @param vrGamepad the gamepad that the controller should be created from
  57396. */
  57397. constructor(vrGamepad: any);
  57398. /**
  57399. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57400. * @param scene scene in which to add meshes
  57401. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57402. */
  57403. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57404. /**
  57405. * Called once for each button that changed state since the last frame
  57406. * @param buttonIdx Which button index changed
  57407. * @param state New state of the button
  57408. * @param changes Which properties on the state changed since last frame
  57409. */
  57410. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57411. }
  57412. }
  57413. declare module BABYLON {
  57414. /**
  57415. * Gear VR Controller
  57416. */
  57417. export class GearVRController extends WebVRController {
  57418. /**
  57419. * Base Url for the controller model.
  57420. */
  57421. static MODEL_BASE_URL: string;
  57422. /**
  57423. * File name for the controller model.
  57424. */
  57425. static MODEL_FILENAME: string;
  57426. /**
  57427. * Gamepad Id prefix used to identify this controller.
  57428. */
  57429. static readonly GAMEPAD_ID_PREFIX: string;
  57430. private readonly _buttonIndexToObservableNameMap;
  57431. /**
  57432. * Creates a new GearVRController from a gamepad
  57433. * @param vrGamepad the gamepad that the controller should be created from
  57434. */
  57435. constructor(vrGamepad: any);
  57436. /**
  57437. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57438. * @param scene scene in which to add meshes
  57439. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57440. */
  57441. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57442. /**
  57443. * Called once for each button that changed state since the last frame
  57444. * @param buttonIdx Which button index changed
  57445. * @param state New state of the button
  57446. * @param changes Which properties on the state changed since last frame
  57447. */
  57448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57449. }
  57450. }
  57451. declare module BABYLON {
  57452. /**
  57453. * Generic Controller
  57454. */
  57455. export class GenericController extends WebVRController {
  57456. /**
  57457. * Base Url for the controller model.
  57458. */
  57459. static readonly MODEL_BASE_URL: string;
  57460. /**
  57461. * File name for the controller model.
  57462. */
  57463. static readonly MODEL_FILENAME: string;
  57464. /**
  57465. * Creates a new GenericController from a gamepad
  57466. * @param vrGamepad the gamepad that the controller should be created from
  57467. */
  57468. constructor(vrGamepad: any);
  57469. /**
  57470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57471. * @param scene scene in which to add meshes
  57472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57473. */
  57474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57475. /**
  57476. * Called once for each button that changed state since the last frame
  57477. * @param buttonIdx Which button index changed
  57478. * @param state New state of the button
  57479. * @param changes Which properties on the state changed since last frame
  57480. */
  57481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57482. }
  57483. }
  57484. declare module BABYLON {
  57485. /**
  57486. * Oculus Touch Controller
  57487. */
  57488. export class OculusTouchController extends WebVRController {
  57489. /**
  57490. * Base Url for the controller model.
  57491. */
  57492. static MODEL_BASE_URL: string;
  57493. /**
  57494. * File name for the left controller model.
  57495. */
  57496. static MODEL_LEFT_FILENAME: string;
  57497. /**
  57498. * File name for the right controller model.
  57499. */
  57500. static MODEL_RIGHT_FILENAME: string;
  57501. /**
  57502. * Base Url for the Quest controller model.
  57503. */
  57504. static QUEST_MODEL_BASE_URL: string;
  57505. /**
  57506. * @hidden
  57507. * If the controllers are running on a device that needs the updated Quest controller models
  57508. */
  57509. static _IsQuest: boolean;
  57510. /**
  57511. * Fired when the secondary trigger on this controller is modified
  57512. */
  57513. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57514. /**
  57515. * Fired when the thumb rest on this controller is modified
  57516. */
  57517. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57518. /**
  57519. * Creates a new OculusTouchController from a gamepad
  57520. * @param vrGamepad the gamepad that the controller should be created from
  57521. */
  57522. constructor(vrGamepad: any);
  57523. /**
  57524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57525. * @param scene scene in which to add meshes
  57526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57527. */
  57528. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57529. /**
  57530. * Fired when the A button on this controller is modified
  57531. */
  57532. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57533. /**
  57534. * Fired when the B button on this controller is modified
  57535. */
  57536. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57537. /**
  57538. * Fired when the X button on this controller is modified
  57539. */
  57540. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57541. /**
  57542. * Fired when the Y button on this controller is modified
  57543. */
  57544. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57545. /**
  57546. * Called once for each button that changed state since the last frame
  57547. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57548. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57549. * 2) secondary trigger (same)
  57550. * 3) A (right) X (left), touch, pressed = value
  57551. * 4) B / Y
  57552. * 5) thumb rest
  57553. * @param buttonIdx Which button index changed
  57554. * @param state New state of the button
  57555. * @param changes Which properties on the state changed since last frame
  57556. */
  57557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57558. }
  57559. }
  57560. declare module BABYLON {
  57561. /**
  57562. * Vive Controller
  57563. */
  57564. export class ViveController extends WebVRController {
  57565. /**
  57566. * Base Url for the controller model.
  57567. */
  57568. static MODEL_BASE_URL: string;
  57569. /**
  57570. * File name for the controller model.
  57571. */
  57572. static MODEL_FILENAME: string;
  57573. /**
  57574. * Creates a new ViveController from a gamepad
  57575. * @param vrGamepad the gamepad that the controller should be created from
  57576. */
  57577. constructor(vrGamepad: any);
  57578. /**
  57579. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57580. * @param scene scene in which to add meshes
  57581. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57582. */
  57583. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57584. /**
  57585. * Fired when the left button on this controller is modified
  57586. */
  57587. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57588. /**
  57589. * Fired when the right button on this controller is modified
  57590. */
  57591. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57592. /**
  57593. * Fired when the menu button on this controller is modified
  57594. */
  57595. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57596. /**
  57597. * Called once for each button that changed state since the last frame
  57598. * Vive mapping:
  57599. * 0: touchpad
  57600. * 1: trigger
  57601. * 2: left AND right buttons
  57602. * 3: menu button
  57603. * @param buttonIdx Which button index changed
  57604. * @param state New state of the button
  57605. * @param changes Which properties on the state changed since last frame
  57606. */
  57607. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57608. }
  57609. }
  57610. declare module BABYLON {
  57611. /**
  57612. * Defines the WindowsMotionController object that the state of the windows motion controller
  57613. */
  57614. export class WindowsMotionController extends WebVRController {
  57615. /**
  57616. * The base url used to load the left and right controller models
  57617. */
  57618. static MODEL_BASE_URL: string;
  57619. /**
  57620. * The name of the left controller model file
  57621. */
  57622. static MODEL_LEFT_FILENAME: string;
  57623. /**
  57624. * The name of the right controller model file
  57625. */
  57626. static MODEL_RIGHT_FILENAME: string;
  57627. /**
  57628. * The controller name prefix for this controller type
  57629. */
  57630. static readonly GAMEPAD_ID_PREFIX: string;
  57631. /**
  57632. * The controller id pattern for this controller type
  57633. */
  57634. private static readonly GAMEPAD_ID_PATTERN;
  57635. private _loadedMeshInfo;
  57636. protected readonly _mapping: {
  57637. buttons: string[];
  57638. buttonMeshNames: {
  57639. trigger: string;
  57640. menu: string;
  57641. grip: string;
  57642. thumbstick: string;
  57643. trackpad: string;
  57644. };
  57645. buttonObservableNames: {
  57646. trigger: string;
  57647. menu: string;
  57648. grip: string;
  57649. thumbstick: string;
  57650. trackpad: string;
  57651. };
  57652. axisMeshNames: string[];
  57653. pointingPoseMeshName: string;
  57654. };
  57655. /**
  57656. * Fired when the trackpad on this controller is clicked
  57657. */
  57658. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57659. /**
  57660. * Fired when the trackpad on this controller is modified
  57661. */
  57662. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57663. /**
  57664. * The current x and y values of this controller's trackpad
  57665. */
  57666. trackpad: StickValues;
  57667. /**
  57668. * Creates a new WindowsMotionController from a gamepad
  57669. * @param vrGamepad the gamepad that the controller should be created from
  57670. */
  57671. constructor(vrGamepad: any);
  57672. /**
  57673. * Fired when the trigger on this controller is modified
  57674. */
  57675. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57676. /**
  57677. * Fired when the menu button on this controller is modified
  57678. */
  57679. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57680. /**
  57681. * Fired when the grip button on this controller is modified
  57682. */
  57683. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57684. /**
  57685. * Fired when the thumbstick button on this controller is modified
  57686. */
  57687. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57688. /**
  57689. * Fired when the touchpad button on this controller is modified
  57690. */
  57691. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57692. /**
  57693. * Fired when the touchpad values on this controller are modified
  57694. */
  57695. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57696. protected _updateTrackpad(): void;
  57697. /**
  57698. * Called once per frame by the engine.
  57699. */
  57700. update(): void;
  57701. /**
  57702. * Called once for each button that changed state since the last frame
  57703. * @param buttonIdx Which button index changed
  57704. * @param state New state of the button
  57705. * @param changes Which properties on the state changed since last frame
  57706. */
  57707. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57708. /**
  57709. * Moves the buttons on the controller mesh based on their current state
  57710. * @param buttonName the name of the button to move
  57711. * @param buttonValue the value of the button which determines the buttons new position
  57712. */
  57713. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57714. /**
  57715. * Moves the axis on the controller mesh based on its current state
  57716. * @param axis the index of the axis
  57717. * @param axisValue the value of the axis which determines the meshes new position
  57718. * @hidden
  57719. */
  57720. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57721. /**
  57722. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57723. * @param scene scene in which to add meshes
  57724. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57725. */
  57726. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57727. /**
  57728. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57729. * can be transformed by button presses and axes values, based on this._mapping.
  57730. *
  57731. * @param scene scene in which the meshes exist
  57732. * @param meshes list of meshes that make up the controller model to process
  57733. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57734. */
  57735. private processModel;
  57736. private createMeshInfo;
  57737. /**
  57738. * Gets the ray of the controller in the direction the controller is pointing
  57739. * @param length the length the resulting ray should be
  57740. * @returns a ray in the direction the controller is pointing
  57741. */
  57742. getForwardRay(length?: number): Ray;
  57743. /**
  57744. * Disposes of the controller
  57745. */
  57746. dispose(): void;
  57747. }
  57748. /**
  57749. * This class represents a new windows motion controller in XR.
  57750. */
  57751. export class XRWindowsMotionController extends WindowsMotionController {
  57752. /**
  57753. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57754. */
  57755. protected readonly _mapping: {
  57756. buttons: string[];
  57757. buttonMeshNames: {
  57758. trigger: string;
  57759. menu: string;
  57760. grip: string;
  57761. thumbstick: string;
  57762. trackpad: string;
  57763. };
  57764. buttonObservableNames: {
  57765. trigger: string;
  57766. menu: string;
  57767. grip: string;
  57768. thumbstick: string;
  57769. trackpad: string;
  57770. };
  57771. axisMeshNames: string[];
  57772. pointingPoseMeshName: string;
  57773. };
  57774. /**
  57775. * Construct a new XR-Based windows motion controller
  57776. *
  57777. * @param gamepadInfo the gamepad object from the browser
  57778. */
  57779. constructor(gamepadInfo: any);
  57780. /**
  57781. * holds the thumbstick values (X,Y)
  57782. */
  57783. thumbstickValues: StickValues;
  57784. /**
  57785. * Fired when the thumbstick on this controller is clicked
  57786. */
  57787. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57788. /**
  57789. * Fired when the thumbstick on this controller is modified
  57790. */
  57791. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57792. /**
  57793. * Fired when the touchpad button on this controller is modified
  57794. */
  57795. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57796. /**
  57797. * Fired when the touchpad values on this controller are modified
  57798. */
  57799. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57800. /**
  57801. * Fired when the thumbstick button on this controller is modified
  57802. * here to prevent breaking changes
  57803. */
  57804. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57805. /**
  57806. * updating the thumbstick(!) and not the trackpad.
  57807. * This is named this way due to the difference between WebVR and XR and to avoid
  57808. * changing the parent class.
  57809. */
  57810. protected _updateTrackpad(): void;
  57811. /**
  57812. * Disposes the class with joy
  57813. */
  57814. dispose(): void;
  57815. }
  57816. }
  57817. declare module BABYLON {
  57818. /**
  57819. * A directional light is defined by a direction (what a surprise!).
  57820. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57821. * 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.
  57822. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57823. */
  57824. export class DirectionalLight extends ShadowLight {
  57825. private _shadowFrustumSize;
  57826. /**
  57827. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57828. */
  57829. get shadowFrustumSize(): number;
  57830. /**
  57831. * Specifies a fix frustum size for the shadow generation.
  57832. */
  57833. set shadowFrustumSize(value: number);
  57834. private _shadowOrthoScale;
  57835. /**
  57836. * Gets 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. get shadowOrthoScale(): number;
  57841. /**
  57842. * Sets the shadow projection scale against the optimal computed one.
  57843. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57844. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57845. */
  57846. set shadowOrthoScale(value: number);
  57847. /**
  57848. * Automatically compute the projection matrix to best fit (including all the casters)
  57849. * on each frame.
  57850. */
  57851. autoUpdateExtends: boolean;
  57852. /**
  57853. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57854. * on each frame. autoUpdateExtends must be set to true for this to work
  57855. */
  57856. autoCalcShadowZBounds: boolean;
  57857. private _orthoLeft;
  57858. private _orthoRight;
  57859. private _orthoTop;
  57860. private _orthoBottom;
  57861. /**
  57862. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57863. * The directional light is emitted from everywhere in the given direction.
  57864. * It can cast shadows.
  57865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57866. * @param name The friendly name of the light
  57867. * @param direction The direction of the light
  57868. * @param scene The scene the light belongs to
  57869. */
  57870. constructor(name: string, direction: Vector3, scene: Scene);
  57871. /**
  57872. * Returns the string "DirectionalLight".
  57873. * @return The class name
  57874. */
  57875. getClassName(): string;
  57876. /**
  57877. * Returns the integer 1.
  57878. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57879. */
  57880. getTypeID(): number;
  57881. /**
  57882. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57883. * Returns the DirectionalLight Shadow projection matrix.
  57884. */
  57885. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57886. /**
  57887. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57888. * Returns the DirectionalLight Shadow projection matrix.
  57889. */
  57890. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57891. /**
  57892. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57893. * Returns the DirectionalLight Shadow projection matrix.
  57894. */
  57895. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57896. protected _buildUniformLayout(): void;
  57897. /**
  57898. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57899. * @param effect The effect to update
  57900. * @param lightIndex The index of the light in the effect to update
  57901. * @returns The directional light
  57902. */
  57903. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57904. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57905. /**
  57906. * Gets the minZ used for shadow according to both the scene and the light.
  57907. *
  57908. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57909. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57910. * @param activeCamera The camera we are returning the min for
  57911. * @returns the depth min z
  57912. */
  57913. getDepthMinZ(activeCamera: Camera): number;
  57914. /**
  57915. * Gets the maxZ used for shadow according to both the scene and the light.
  57916. *
  57917. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57918. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57919. * @param activeCamera The camera we are returning the max for
  57920. * @returns the depth max z
  57921. */
  57922. getDepthMaxZ(activeCamera: Camera): number;
  57923. /**
  57924. * Prepares the list of defines specific to the light type.
  57925. * @param defines the list of defines
  57926. * @param lightIndex defines the index of the light for the effect
  57927. */
  57928. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57929. }
  57930. }
  57931. declare module BABYLON {
  57932. /**
  57933. * Class containing static functions to help procedurally build meshes
  57934. */
  57935. export class HemisphereBuilder {
  57936. /**
  57937. * Creates a hemisphere mesh
  57938. * @param name defines the name of the mesh
  57939. * @param options defines the options used to create the mesh
  57940. * @param scene defines the hosting scene
  57941. * @returns the hemisphere mesh
  57942. */
  57943. static CreateHemisphere(name: string, options: {
  57944. segments?: number;
  57945. diameter?: number;
  57946. sideOrientation?: number;
  57947. }, scene: any): Mesh;
  57948. }
  57949. }
  57950. declare module BABYLON {
  57951. /**
  57952. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57953. * These values define a cone of light starting from the position, emitting toward the direction.
  57954. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57955. * and the exponent defines the speed of the decay of the light with distance (reach).
  57956. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57957. */
  57958. export class SpotLight extends ShadowLight {
  57959. private _angle;
  57960. private _innerAngle;
  57961. private _cosHalfAngle;
  57962. private _lightAngleScale;
  57963. private _lightAngleOffset;
  57964. /**
  57965. * Gets the cone angle of the spot light in Radians.
  57966. */
  57967. get angle(): number;
  57968. /**
  57969. * Sets the cone angle of the spot light in Radians.
  57970. */
  57971. set angle(value: 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. get innerAngle(): number;
  57978. /**
  57979. * Only used in gltf falloff mode, this defines the angle where
  57980. * the directional falloff will start before cutting at angle which could be seen
  57981. * as outer angle.
  57982. */
  57983. set innerAngle(value: number);
  57984. private _shadowAngleScale;
  57985. /**
  57986. * Allows scaling the angle of the light for shadow generation only.
  57987. */
  57988. get shadowAngleScale(): number;
  57989. /**
  57990. * Allows scaling the angle of the light for shadow generation only.
  57991. */
  57992. set shadowAngleScale(value: number);
  57993. /**
  57994. * The light decay speed with the distance from the emission spot.
  57995. */
  57996. exponent: number;
  57997. private _projectionTextureMatrix;
  57998. /**
  57999. * Allows reading the projecton texture
  58000. */
  58001. get projectionTextureMatrix(): Matrix;
  58002. protected _projectionTextureLightNear: number;
  58003. /**
  58004. * Gets the near clip of the Spotlight for texture projection.
  58005. */
  58006. get projectionTextureLightNear(): number;
  58007. /**
  58008. * Sets the near clip of the Spotlight for texture projection.
  58009. */
  58010. set projectionTextureLightNear(value: number);
  58011. protected _projectionTextureLightFar: number;
  58012. /**
  58013. * Gets the far clip of the Spotlight for texture projection.
  58014. */
  58015. get projectionTextureLightFar(): number;
  58016. /**
  58017. * Sets the far clip of the Spotlight for texture projection.
  58018. */
  58019. set projectionTextureLightFar(value: number);
  58020. protected _projectionTextureUpDirection: Vector3;
  58021. /**
  58022. * Gets the Up vector of the Spotlight for texture projection.
  58023. */
  58024. get projectionTextureUpDirection(): Vector3;
  58025. /**
  58026. * Sets the Up vector of the Spotlight for texture projection.
  58027. */
  58028. set projectionTextureUpDirection(value: Vector3);
  58029. private _projectionTexture;
  58030. /**
  58031. * Gets the projection texture of the light.
  58032. */
  58033. get projectionTexture(): Nullable<BaseTexture>;
  58034. /**
  58035. * Sets the projection texture of the light.
  58036. */
  58037. set projectionTexture(value: Nullable<BaseTexture>);
  58038. private static _IsProceduralTexture;
  58039. private static _IsTexture;
  58040. private _projectionTextureViewLightDirty;
  58041. private _projectionTextureProjectionLightDirty;
  58042. private _projectionTextureDirty;
  58043. private _projectionTextureViewTargetVector;
  58044. private _projectionTextureViewLightMatrix;
  58045. private _projectionTextureProjectionLightMatrix;
  58046. private _projectionTextureScalingMatrix;
  58047. /**
  58048. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  58049. * It can cast shadows.
  58050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58051. * @param name The light friendly name
  58052. * @param position The position of the spot light in the scene
  58053. * @param direction The direction of the light in the scene
  58054. * @param angle The cone angle of the light in Radians
  58055. * @param exponent The light decay speed with the distance from the emission spot
  58056. * @param scene The scene the lights belongs to
  58057. */
  58058. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58059. /**
  58060. * Returns the string "SpotLight".
  58061. * @returns the class name
  58062. */
  58063. getClassName(): string;
  58064. /**
  58065. * Returns the integer 2.
  58066. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58067. */
  58068. getTypeID(): number;
  58069. /**
  58070. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58071. */
  58072. protected _setDirection(value: Vector3): void;
  58073. /**
  58074. * Overrides the position setter to recompute the projection texture view light Matrix.
  58075. */
  58076. protected _setPosition(value: Vector3): void;
  58077. /**
  58078. * 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.
  58079. * Returns the SpotLight.
  58080. */
  58081. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58082. protected _computeProjectionTextureViewLightMatrix(): void;
  58083. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58084. /**
  58085. * Main function for light texture projection matrix computing.
  58086. */
  58087. protected _computeProjectionTextureMatrix(): void;
  58088. protected _buildUniformLayout(): void;
  58089. private _computeAngleValues;
  58090. /**
  58091. * Sets the passed Effect "effect" with the Light textures.
  58092. * @param effect The effect to update
  58093. * @param lightIndex The index of the light in the effect to update
  58094. * @returns The light
  58095. */
  58096. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58097. /**
  58098. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58099. * @param effect The effect to update
  58100. * @param lightIndex The index of the light in the effect to update
  58101. * @returns The spot light
  58102. */
  58103. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58104. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58105. /**
  58106. * Disposes the light and the associated resources.
  58107. */
  58108. dispose(): void;
  58109. /**
  58110. * Prepares the list of defines specific to the light type.
  58111. * @param defines the list of defines
  58112. * @param lightIndex defines the index of the light for the effect
  58113. */
  58114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58115. }
  58116. }
  58117. declare module BABYLON {
  58118. /**
  58119. * Gizmo that enables viewing a light
  58120. */
  58121. export class LightGizmo extends Gizmo {
  58122. private _lightMesh;
  58123. private _material;
  58124. private _cachedPosition;
  58125. private _cachedForward;
  58126. private _attachedMeshParent;
  58127. private _pointerObserver;
  58128. /**
  58129. * Event that fires each time the gizmo is clicked
  58130. */
  58131. onClickedObservable: Observable<Light>;
  58132. /**
  58133. * Creates a LightGizmo
  58134. * @param gizmoLayer The utility layer the gizmo will be added to
  58135. */
  58136. constructor(gizmoLayer?: UtilityLayerRenderer);
  58137. private _light;
  58138. /**
  58139. * The light that the gizmo is attached to
  58140. */
  58141. set light(light: Nullable<Light>);
  58142. get light(): Nullable<Light>;
  58143. /**
  58144. * Gets the material used to render the light gizmo
  58145. */
  58146. get material(): StandardMaterial;
  58147. /**
  58148. * @hidden
  58149. * Updates the gizmo to match the attached mesh's position/rotation
  58150. */
  58151. protected _update(): void;
  58152. private static _Scale;
  58153. /**
  58154. * Creates the lines for a light mesh
  58155. */
  58156. private static _CreateLightLines;
  58157. /**
  58158. * Disposes of the light gizmo
  58159. */
  58160. dispose(): void;
  58161. private static _CreateHemisphericLightMesh;
  58162. private static _CreatePointLightMesh;
  58163. private static _CreateSpotLightMesh;
  58164. private static _CreateDirectionalLightMesh;
  58165. }
  58166. }
  58167. declare module BABYLON {
  58168. /**
  58169. * Gizmo that enables viewing a camera
  58170. */
  58171. export class CameraGizmo extends Gizmo {
  58172. private _cameraMesh;
  58173. private _cameraLinesMesh;
  58174. private _material;
  58175. private _pointerObserver;
  58176. /**
  58177. * Event that fires each time the gizmo is clicked
  58178. */
  58179. onClickedObservable: Observable<Camera>;
  58180. /**
  58181. * Creates a CameraGizmo
  58182. * @param gizmoLayer The utility layer the gizmo will be added to
  58183. */
  58184. constructor(gizmoLayer?: UtilityLayerRenderer);
  58185. private _camera;
  58186. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58187. get displayFrustum(): boolean;
  58188. set displayFrustum(value: boolean);
  58189. /**
  58190. * The camera that the gizmo is attached to
  58191. */
  58192. set camera(camera: Nullable<Camera>);
  58193. get camera(): Nullable<Camera>;
  58194. /**
  58195. * Gets the material used to render the camera gizmo
  58196. */
  58197. get material(): StandardMaterial;
  58198. /**
  58199. * @hidden
  58200. * Updates the gizmo to match the attached mesh's position/rotation
  58201. */
  58202. protected _update(): void;
  58203. private static _Scale;
  58204. private _invProjection;
  58205. /**
  58206. * Disposes of the camera gizmo
  58207. */
  58208. dispose(): void;
  58209. private static _CreateCameraMesh;
  58210. private static _CreateCameraFrustum;
  58211. }
  58212. }
  58213. declare module BABYLON {
  58214. /** @hidden */
  58215. export var backgroundFragmentDeclaration: {
  58216. name: string;
  58217. shader: string;
  58218. };
  58219. }
  58220. declare module BABYLON {
  58221. /** @hidden */
  58222. export var backgroundUboDeclaration: {
  58223. name: string;
  58224. shader: string;
  58225. };
  58226. }
  58227. declare module BABYLON {
  58228. /** @hidden */
  58229. export var backgroundPixelShader: {
  58230. name: string;
  58231. shader: string;
  58232. };
  58233. }
  58234. declare module BABYLON {
  58235. /** @hidden */
  58236. export var backgroundVertexDeclaration: {
  58237. name: string;
  58238. shader: string;
  58239. };
  58240. }
  58241. declare module BABYLON {
  58242. /** @hidden */
  58243. export var backgroundVertexShader: {
  58244. name: string;
  58245. shader: string;
  58246. };
  58247. }
  58248. declare module BABYLON {
  58249. /**
  58250. * Background material used to create an efficient environement around your scene.
  58251. */
  58252. export class BackgroundMaterial extends PushMaterial {
  58253. /**
  58254. * Standard reflectance value at parallel view angle.
  58255. */
  58256. static StandardReflectance0: number;
  58257. /**
  58258. * Standard reflectance value at grazing angle.
  58259. */
  58260. static StandardReflectance90: number;
  58261. protected _primaryColor: Color3;
  58262. /**
  58263. * Key light Color (multiply against the environement texture)
  58264. */
  58265. primaryColor: Color3;
  58266. protected __perceptualColor: Nullable<Color3>;
  58267. /**
  58268. * Experimental Internal Use Only.
  58269. *
  58270. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58271. * This acts as a helper to set the primary color to a more "human friendly" value.
  58272. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58273. * output color as close as possible from the chosen value.
  58274. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58275. * part of lighting setup.)
  58276. */
  58277. get _perceptualColor(): Nullable<Color3>;
  58278. set _perceptualColor(value: Nullable<Color3>);
  58279. protected _primaryColorShadowLevel: float;
  58280. /**
  58281. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58282. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58283. */
  58284. get primaryColorShadowLevel(): float;
  58285. set primaryColorShadowLevel(value: float);
  58286. protected _primaryColorHighlightLevel: float;
  58287. /**
  58288. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58289. * The primary color is used at the level chosen to define what the white area would look.
  58290. */
  58291. get primaryColorHighlightLevel(): float;
  58292. set primaryColorHighlightLevel(value: float);
  58293. protected _reflectionTexture: Nullable<BaseTexture>;
  58294. /**
  58295. * Reflection Texture used in the material.
  58296. * Should be author in a specific way for the best result (refer to the documentation).
  58297. */
  58298. reflectionTexture: Nullable<BaseTexture>;
  58299. protected _reflectionBlur: float;
  58300. /**
  58301. * Reflection Texture level of blur.
  58302. *
  58303. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58304. * texture twice.
  58305. */
  58306. reflectionBlur: float;
  58307. protected _diffuseTexture: Nullable<BaseTexture>;
  58308. /**
  58309. * Diffuse Texture used in the material.
  58310. * Should be author in a specific way for the best result (refer to the documentation).
  58311. */
  58312. diffuseTexture: Nullable<BaseTexture>;
  58313. protected _shadowLights: Nullable<IShadowLight[]>;
  58314. /**
  58315. * Specify the list of lights casting shadow on the material.
  58316. * All scene shadow lights will be included if null.
  58317. */
  58318. shadowLights: Nullable<IShadowLight[]>;
  58319. protected _shadowLevel: float;
  58320. /**
  58321. * Helps adjusting the shadow to a softer level if required.
  58322. * 0 means black shadows and 1 means no shadows.
  58323. */
  58324. shadowLevel: float;
  58325. protected _sceneCenter: Vector3;
  58326. /**
  58327. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58328. * It is usually zero but might be interesting to modify according to your setup.
  58329. */
  58330. sceneCenter: Vector3;
  58331. protected _opacityFresnel: boolean;
  58332. /**
  58333. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58334. * This helps ensuring a nice transition when the camera goes under the ground.
  58335. */
  58336. opacityFresnel: boolean;
  58337. protected _reflectionFresnel: boolean;
  58338. /**
  58339. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58340. * This helps adding a mirror texture on the ground.
  58341. */
  58342. reflectionFresnel: boolean;
  58343. protected _reflectionFalloffDistance: number;
  58344. /**
  58345. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58346. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58347. */
  58348. reflectionFalloffDistance: number;
  58349. protected _reflectionAmount: number;
  58350. /**
  58351. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58352. */
  58353. reflectionAmount: number;
  58354. protected _reflectionReflectance0: number;
  58355. /**
  58356. * This specifies the weight of the reflection at grazing angle.
  58357. */
  58358. reflectionReflectance0: number;
  58359. protected _reflectionReflectance90: number;
  58360. /**
  58361. * This specifies the weight of the reflection at a perpendicular point of view.
  58362. */
  58363. reflectionReflectance90: number;
  58364. /**
  58365. * Sets the reflection reflectance fresnel values according to the default standard
  58366. * empirically know to work well :-)
  58367. */
  58368. set reflectionStandardFresnelWeight(value: number);
  58369. protected _useRGBColor: boolean;
  58370. /**
  58371. * Helps to directly use the maps channels instead of their level.
  58372. */
  58373. useRGBColor: boolean;
  58374. protected _enableNoise: boolean;
  58375. /**
  58376. * This helps reducing the banding effect that could occur on the background.
  58377. */
  58378. enableNoise: boolean;
  58379. /**
  58380. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58381. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58382. * Recommended to be keep at 1.0 except for special cases.
  58383. */
  58384. get fovMultiplier(): number;
  58385. set fovMultiplier(value: number);
  58386. private _fovMultiplier;
  58387. /**
  58388. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58389. */
  58390. useEquirectangularFOV: boolean;
  58391. private _maxSimultaneousLights;
  58392. /**
  58393. * Number of Simultaneous lights allowed on the material.
  58394. */
  58395. maxSimultaneousLights: int;
  58396. private _shadowOnly;
  58397. /**
  58398. * Make the material only render shadows
  58399. */
  58400. shadowOnly: boolean;
  58401. /**
  58402. * Default configuration related to image processing available in the Background Material.
  58403. */
  58404. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58405. /**
  58406. * Keep track of the image processing observer to allow dispose and replace.
  58407. */
  58408. private _imageProcessingObserver;
  58409. /**
  58410. * Attaches a new image processing configuration to the PBR Material.
  58411. * @param configuration (if null the scene configuration will be use)
  58412. */
  58413. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58414. /**
  58415. * Gets the image processing configuration used either in this material.
  58416. */
  58417. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58418. /**
  58419. * Sets the Default image processing configuration used either in the this material.
  58420. *
  58421. * If sets to null, the scene one is in use.
  58422. */
  58423. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58424. /**
  58425. * Gets wether the color curves effect is enabled.
  58426. */
  58427. get cameraColorCurvesEnabled(): boolean;
  58428. /**
  58429. * Sets wether the color curves effect is enabled.
  58430. */
  58431. set cameraColorCurvesEnabled(value: boolean);
  58432. /**
  58433. * Gets wether the color grading effect is enabled.
  58434. */
  58435. get cameraColorGradingEnabled(): boolean;
  58436. /**
  58437. * Gets wether the color grading effect is enabled.
  58438. */
  58439. set cameraColorGradingEnabled(value: boolean);
  58440. /**
  58441. * Gets wether tonemapping is enabled or not.
  58442. */
  58443. get cameraToneMappingEnabled(): boolean;
  58444. /**
  58445. * Sets wether tonemapping is enabled or not
  58446. */
  58447. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): float;
  58454. /**
  58455. * The camera exposure used on this material.
  58456. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58457. * This corresponds to a photographic exposure.
  58458. */
  58459. set cameraExposure(value: float);
  58460. /**
  58461. * Gets The camera contrast used on this material.
  58462. */
  58463. get cameraContrast(): float;
  58464. /**
  58465. * Sets The camera contrast used on this material.
  58466. */
  58467. set cameraContrast(value: float);
  58468. /**
  58469. * Gets the Color Grading 2D Lookup Texture.
  58470. */
  58471. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58472. /**
  58473. * Sets the Color Grading 2D Lookup Texture.
  58474. */
  58475. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58476. /**
  58477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58479. * 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;
  58480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58481. */
  58482. get cameraColorCurves(): Nullable<ColorCurves>;
  58483. /**
  58484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58486. * 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;
  58487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58488. */
  58489. set cameraColorCurves(value: Nullable<ColorCurves>);
  58490. /**
  58491. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58492. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58493. */
  58494. switchToBGR: boolean;
  58495. private _renderTargets;
  58496. private _reflectionControls;
  58497. private _white;
  58498. private _primaryShadowColor;
  58499. private _primaryHighlightColor;
  58500. /**
  58501. * Instantiates a Background Material in the given scene
  58502. * @param name The friendly name of the material
  58503. * @param scene The scene to add the material to
  58504. */
  58505. constructor(name: string, scene: Scene);
  58506. /**
  58507. * Gets a boolean indicating that current material needs to register RTT
  58508. */
  58509. get hasRenderTargetTextures(): boolean;
  58510. /**
  58511. * The entire material has been created in order to prevent overdraw.
  58512. * @returns false
  58513. */
  58514. needAlphaTesting(): boolean;
  58515. /**
  58516. * The entire material has been created in order to prevent overdraw.
  58517. * @returns true if blending is enable
  58518. */
  58519. needAlphaBlending(): boolean;
  58520. /**
  58521. * Checks wether the material is ready to be rendered for a given mesh.
  58522. * @param mesh The mesh to render
  58523. * @param subMesh The submesh to check against
  58524. * @param useInstances Specify wether or not the material is used with instances
  58525. * @returns true if all the dependencies are ready (Textures, Effects...)
  58526. */
  58527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58528. /**
  58529. * Compute the primary color according to the chosen perceptual color.
  58530. */
  58531. private _computePrimaryColorFromPerceptualColor;
  58532. /**
  58533. * Compute the highlights and shadow colors according to their chosen levels.
  58534. */
  58535. private _computePrimaryColors;
  58536. /**
  58537. * Build the uniform buffer used in the material.
  58538. */
  58539. buildUniformLayout(): void;
  58540. /**
  58541. * Unbind the material.
  58542. */
  58543. unbind(): void;
  58544. /**
  58545. * Bind only the world matrix to the material.
  58546. * @param world The world matrix to bind.
  58547. */
  58548. bindOnlyWorldMatrix(world: Matrix): void;
  58549. /**
  58550. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58551. * @param world The world matrix to bind.
  58552. * @param subMesh The submesh to bind for.
  58553. */
  58554. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58555. /**
  58556. * Checks to see if a texture is used in the material.
  58557. * @param texture - Base texture to use.
  58558. * @returns - Boolean specifying if a texture is used in the material.
  58559. */
  58560. hasTexture(texture: BaseTexture): boolean;
  58561. /**
  58562. * Dispose the material.
  58563. * @param forceDisposeEffect Force disposal of the associated effect.
  58564. * @param forceDisposeTextures Force disposal of the associated textures.
  58565. */
  58566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58567. /**
  58568. * Clones the material.
  58569. * @param name The cloned name.
  58570. * @returns The cloned material.
  58571. */
  58572. clone(name: string): BackgroundMaterial;
  58573. /**
  58574. * Serializes the current material to its JSON representation.
  58575. * @returns The JSON representation.
  58576. */
  58577. serialize(): any;
  58578. /**
  58579. * Gets the class name of the material
  58580. * @returns "BackgroundMaterial"
  58581. */
  58582. getClassName(): string;
  58583. /**
  58584. * Parse a JSON input to create back a background material.
  58585. * @param source The JSON data to parse
  58586. * @param scene The scene to create the parsed material in
  58587. * @param rootUrl The root url of the assets the material depends upon
  58588. * @returns the instantiated BackgroundMaterial.
  58589. */
  58590. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58591. }
  58592. }
  58593. declare module BABYLON {
  58594. /**
  58595. * Represents the different options available during the creation of
  58596. * a Environment helper.
  58597. *
  58598. * This can control the default ground, skybox and image processing setup of your scene.
  58599. */
  58600. export interface IEnvironmentHelperOptions {
  58601. /**
  58602. * Specifies whether or not to create a ground.
  58603. * True by default.
  58604. */
  58605. createGround: boolean;
  58606. /**
  58607. * Specifies the ground size.
  58608. * 15 by default.
  58609. */
  58610. groundSize: number;
  58611. /**
  58612. * The texture used on the ground for the main color.
  58613. * Comes from the BabylonJS CDN by default.
  58614. *
  58615. * Remarks: Can be either a texture or a url.
  58616. */
  58617. groundTexture: string | BaseTexture;
  58618. /**
  58619. * The color mixed in the ground texture by default.
  58620. * BabylonJS clearColor by default.
  58621. */
  58622. groundColor: Color3;
  58623. /**
  58624. * Specifies the ground opacity.
  58625. * 1 by default.
  58626. */
  58627. groundOpacity: number;
  58628. /**
  58629. * Enables the ground to receive shadows.
  58630. * True by default.
  58631. */
  58632. enableGroundShadow: boolean;
  58633. /**
  58634. * Helps preventing the shadow to be fully black on the ground.
  58635. * 0.5 by default.
  58636. */
  58637. groundShadowLevel: number;
  58638. /**
  58639. * Creates a mirror texture attach to the ground.
  58640. * false by default.
  58641. */
  58642. enableGroundMirror: boolean;
  58643. /**
  58644. * Specifies the ground mirror size ratio.
  58645. * 0.3 by default as the default kernel is 64.
  58646. */
  58647. groundMirrorSizeRatio: number;
  58648. /**
  58649. * Specifies the ground mirror blur kernel size.
  58650. * 64 by default.
  58651. */
  58652. groundMirrorBlurKernel: number;
  58653. /**
  58654. * Specifies the ground mirror visibility amount.
  58655. * 1 by default
  58656. */
  58657. groundMirrorAmount: number;
  58658. /**
  58659. * Specifies the ground mirror reflectance weight.
  58660. * This uses the standard weight of the background material to setup the fresnel effect
  58661. * of the mirror.
  58662. * 1 by default.
  58663. */
  58664. groundMirrorFresnelWeight: number;
  58665. /**
  58666. * Specifies the ground mirror Falloff distance.
  58667. * This can helps reducing the size of the reflection.
  58668. * 0 by Default.
  58669. */
  58670. groundMirrorFallOffDistance: number;
  58671. /**
  58672. * Specifies the ground mirror texture type.
  58673. * Unsigned Int by Default.
  58674. */
  58675. groundMirrorTextureType: number;
  58676. /**
  58677. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58678. * the shown objects.
  58679. */
  58680. groundYBias: number;
  58681. /**
  58682. * Specifies whether or not to create a skybox.
  58683. * True by default.
  58684. */
  58685. createSkybox: boolean;
  58686. /**
  58687. * Specifies the skybox size.
  58688. * 20 by default.
  58689. */
  58690. skyboxSize: number;
  58691. /**
  58692. * The texture used on the skybox for the main color.
  58693. * Comes from the BabylonJS CDN by default.
  58694. *
  58695. * Remarks: Can be either a texture or a url.
  58696. */
  58697. skyboxTexture: string | BaseTexture;
  58698. /**
  58699. * The color mixed in the skybox texture by default.
  58700. * BabylonJS clearColor by default.
  58701. */
  58702. skyboxColor: Color3;
  58703. /**
  58704. * The background rotation around the Y axis of the scene.
  58705. * This helps aligning the key lights of your scene with the background.
  58706. * 0 by default.
  58707. */
  58708. backgroundYRotation: number;
  58709. /**
  58710. * Compute automatically the size of the elements to best fit with the scene.
  58711. */
  58712. sizeAuto: boolean;
  58713. /**
  58714. * Default position of the rootMesh if autoSize is not true.
  58715. */
  58716. rootPosition: Vector3;
  58717. /**
  58718. * Sets up the image processing in the scene.
  58719. * true by default.
  58720. */
  58721. setupImageProcessing: boolean;
  58722. /**
  58723. * The texture used as your environment texture in the scene.
  58724. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58725. *
  58726. * Remarks: Can be either a texture or a url.
  58727. */
  58728. environmentTexture: string | BaseTexture;
  58729. /**
  58730. * The value of the exposure to apply to the scene.
  58731. * 0.6 by default if setupImageProcessing is true.
  58732. */
  58733. cameraExposure: number;
  58734. /**
  58735. * The value of the contrast to apply to the scene.
  58736. * 1.6 by default if setupImageProcessing is true.
  58737. */
  58738. cameraContrast: number;
  58739. /**
  58740. * Specifies whether or not tonemapping should be enabled in the scene.
  58741. * true by default if setupImageProcessing is true.
  58742. */
  58743. toneMappingEnabled: boolean;
  58744. }
  58745. /**
  58746. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58747. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58748. * It also helps with the default setup of your imageProcessing configuration.
  58749. */
  58750. export class EnvironmentHelper {
  58751. /**
  58752. * Default ground texture URL.
  58753. */
  58754. private static _groundTextureCDNUrl;
  58755. /**
  58756. * Default skybox texture URL.
  58757. */
  58758. private static _skyboxTextureCDNUrl;
  58759. /**
  58760. * Default environment texture URL.
  58761. */
  58762. private static _environmentTextureCDNUrl;
  58763. /**
  58764. * Creates the default options for the helper.
  58765. */
  58766. private static _getDefaultOptions;
  58767. private _rootMesh;
  58768. /**
  58769. * Gets the root mesh created by the helper.
  58770. */
  58771. get rootMesh(): Mesh;
  58772. private _skybox;
  58773. /**
  58774. * Gets the skybox created by the helper.
  58775. */
  58776. get skybox(): Nullable<Mesh>;
  58777. private _skyboxTexture;
  58778. /**
  58779. * Gets the skybox texture created by the helper.
  58780. */
  58781. get skyboxTexture(): Nullable<BaseTexture>;
  58782. private _skyboxMaterial;
  58783. /**
  58784. * Gets the skybox material created by the helper.
  58785. */
  58786. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58787. private _ground;
  58788. /**
  58789. * Gets the ground mesh created by the helper.
  58790. */
  58791. get ground(): Nullable<Mesh>;
  58792. private _groundTexture;
  58793. /**
  58794. * Gets the ground texture created by the helper.
  58795. */
  58796. get groundTexture(): Nullable<BaseTexture>;
  58797. private _groundMirror;
  58798. /**
  58799. * Gets the ground mirror created by the helper.
  58800. */
  58801. get groundMirror(): Nullable<MirrorTexture>;
  58802. /**
  58803. * Gets the ground mirror render list to helps pushing the meshes
  58804. * you wish in the ground reflection.
  58805. */
  58806. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58807. private _groundMaterial;
  58808. /**
  58809. * Gets the ground material created by the helper.
  58810. */
  58811. get groundMaterial(): Nullable<BackgroundMaterial>;
  58812. /**
  58813. * Stores the creation options.
  58814. */
  58815. private readonly _scene;
  58816. private _options;
  58817. /**
  58818. * This observable will be notified with any error during the creation of the environment,
  58819. * mainly texture creation errors.
  58820. */
  58821. onErrorObservable: Observable<{
  58822. message?: string;
  58823. exception?: any;
  58824. }>;
  58825. /**
  58826. * constructor
  58827. * @param options Defines the options we want to customize the helper
  58828. * @param scene The scene to add the material to
  58829. */
  58830. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58831. /**
  58832. * Updates the background according to the new options
  58833. * @param options
  58834. */
  58835. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58836. /**
  58837. * Sets the primary color of all the available elements.
  58838. * @param color the main color to affect to the ground and the background
  58839. */
  58840. setMainColor(color: Color3): void;
  58841. /**
  58842. * Setup the image processing according to the specified options.
  58843. */
  58844. private _setupImageProcessing;
  58845. /**
  58846. * Setup the environment texture according to the specified options.
  58847. */
  58848. private _setupEnvironmentTexture;
  58849. /**
  58850. * Setup the background according to the specified options.
  58851. */
  58852. private _setupBackground;
  58853. /**
  58854. * Get the scene sizes according to the setup.
  58855. */
  58856. private _getSceneSize;
  58857. /**
  58858. * Setup the ground according to the specified options.
  58859. */
  58860. private _setupGround;
  58861. /**
  58862. * Setup the ground material according to the specified options.
  58863. */
  58864. private _setupGroundMaterial;
  58865. /**
  58866. * Setup the ground diffuse texture according to the specified options.
  58867. */
  58868. private _setupGroundDiffuseTexture;
  58869. /**
  58870. * Setup the ground mirror texture according to the specified options.
  58871. */
  58872. private _setupGroundMirrorTexture;
  58873. /**
  58874. * Setup the ground to receive the mirror texture.
  58875. */
  58876. private _setupMirrorInGroundMaterial;
  58877. /**
  58878. * Setup the skybox according to the specified options.
  58879. */
  58880. private _setupSkybox;
  58881. /**
  58882. * Setup the skybox material according to the specified options.
  58883. */
  58884. private _setupSkyboxMaterial;
  58885. /**
  58886. * Setup the skybox reflection texture according to the specified options.
  58887. */
  58888. private _setupSkyboxReflectionTexture;
  58889. private _errorHandler;
  58890. /**
  58891. * Dispose all the elements created by the Helper.
  58892. */
  58893. dispose(): void;
  58894. }
  58895. }
  58896. declare module BABYLON {
  58897. /**
  58898. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58899. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58900. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58901. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58902. */
  58903. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58904. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58905. /**
  58906. * Define the source as a Monoscopic panoramic 360/180.
  58907. */
  58908. static readonly MODE_MONOSCOPIC: number;
  58909. /**
  58910. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58911. */
  58912. static readonly MODE_TOPBOTTOM: number;
  58913. /**
  58914. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58915. */
  58916. static readonly MODE_SIDEBYSIDE: number;
  58917. private _halfDome;
  58918. private _crossEye;
  58919. protected _useDirectMapping: boolean;
  58920. /**
  58921. * The texture being displayed on the sphere
  58922. */
  58923. protected _texture: T;
  58924. /**
  58925. * Gets the texture being displayed on the sphere
  58926. */
  58927. get texture(): T;
  58928. /**
  58929. * Sets the texture being displayed on the sphere
  58930. */
  58931. set texture(newTexture: T);
  58932. /**
  58933. * The skybox material
  58934. */
  58935. protected _material: BackgroundMaterial;
  58936. /**
  58937. * The surface used for the dome
  58938. */
  58939. protected _mesh: Mesh;
  58940. /**
  58941. * Gets the mesh used for the dome.
  58942. */
  58943. get mesh(): Mesh;
  58944. /**
  58945. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58946. */
  58947. private _halfDomeMask;
  58948. /**
  58949. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58950. * Also see the options.resolution property.
  58951. */
  58952. get fovMultiplier(): number;
  58953. set fovMultiplier(value: number);
  58954. protected _textureMode: number;
  58955. /**
  58956. * Gets or set the current texture mode for the texture. It can be:
  58957. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58958. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58959. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58960. */
  58961. get textureMode(): number;
  58962. /**
  58963. * Sets the current texture mode for the texture. It can be:
  58964. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58965. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58966. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58967. */
  58968. set textureMode(value: number);
  58969. /**
  58970. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58971. */
  58972. get halfDome(): boolean;
  58973. /**
  58974. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58975. */
  58976. set halfDome(enabled: boolean);
  58977. /**
  58978. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58979. */
  58980. set crossEye(enabled: boolean);
  58981. /**
  58982. * Is it a cross-eye texture?
  58983. */
  58984. get crossEye(): boolean;
  58985. /**
  58986. * The background material of this dome.
  58987. */
  58988. get material(): BackgroundMaterial;
  58989. /**
  58990. * Oberserver used in Stereoscopic VR Mode.
  58991. */
  58992. private _onBeforeCameraRenderObserver;
  58993. /**
  58994. * Observable raised when an error occured while loading the 360 image
  58995. */
  58996. onLoadErrorObservable: Observable<string>;
  58997. /**
  58998. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58999. * @param name Element's name, child elements will append suffixes for their own names.
  59000. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  59001. * @param options An object containing optional or exposed sub element properties
  59002. */
  59003. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  59004. resolution?: number;
  59005. clickToPlay?: boolean;
  59006. autoPlay?: boolean;
  59007. loop?: boolean;
  59008. size?: number;
  59009. poster?: string;
  59010. faceForward?: boolean;
  59011. useDirectMapping?: boolean;
  59012. halfDomeMode?: boolean;
  59013. crossEyeMode?: boolean;
  59014. generateMipMaps?: boolean;
  59015. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  59016. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  59017. protected _changeTextureMode(value: number): void;
  59018. /**
  59019. * Releases resources associated with this node.
  59020. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59021. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59022. */
  59023. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59024. }
  59025. }
  59026. declare module BABYLON {
  59027. /**
  59028. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  59029. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  59030. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  59031. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59032. */
  59033. export class PhotoDome extends TextureDome<Texture> {
  59034. /**
  59035. * Define the image as a Monoscopic panoramic 360 image.
  59036. */
  59037. static readonly MODE_MONOSCOPIC: number;
  59038. /**
  59039. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  59040. */
  59041. static readonly MODE_TOPBOTTOM: number;
  59042. /**
  59043. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  59044. */
  59045. static readonly MODE_SIDEBYSIDE: number;
  59046. /**
  59047. * Gets or sets the texture being displayed on the sphere
  59048. */
  59049. get photoTexture(): Texture;
  59050. /**
  59051. * sets the texture being displayed on the sphere
  59052. */
  59053. set photoTexture(value: Texture);
  59054. /**
  59055. * Gets the current video mode for the video. It can be:
  59056. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59057. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59058. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59059. */
  59060. get imageMode(): number;
  59061. /**
  59062. * Sets the current video mode for the video. It can be:
  59063. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59064. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59065. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59066. */
  59067. set imageMode(value: number);
  59068. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59069. }
  59070. }
  59071. declare module BABYLON {
  59072. /**
  59073. * Direct draw surface info
  59074. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59075. */
  59076. export interface DDSInfo {
  59077. /**
  59078. * Width of the texture
  59079. */
  59080. width: number;
  59081. /**
  59082. * Width of the texture
  59083. */
  59084. height: number;
  59085. /**
  59086. * Number of Mipmaps for the texture
  59087. * @see https://en.wikipedia.org/wiki/Mipmap
  59088. */
  59089. mipmapCount: number;
  59090. /**
  59091. * If the textures format is a known fourCC format
  59092. * @see https://www.fourcc.org/
  59093. */
  59094. isFourCC: boolean;
  59095. /**
  59096. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59097. */
  59098. isRGB: boolean;
  59099. /**
  59100. * If the texture is a lumincance format
  59101. */
  59102. isLuminance: boolean;
  59103. /**
  59104. * If this is a cube texture
  59105. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59106. */
  59107. isCube: boolean;
  59108. /**
  59109. * If the texture is a compressed format eg. FOURCC_DXT1
  59110. */
  59111. isCompressed: boolean;
  59112. /**
  59113. * The dxgiFormat of the texture
  59114. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59115. */
  59116. dxgiFormat: number;
  59117. /**
  59118. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59119. */
  59120. textureType: number;
  59121. /**
  59122. * Sphericle polynomial created for the dds texture
  59123. */
  59124. sphericalPolynomial?: SphericalPolynomial;
  59125. }
  59126. /**
  59127. * Class used to provide DDS decompression tools
  59128. */
  59129. export class DDSTools {
  59130. /**
  59131. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59132. */
  59133. static StoreLODInAlphaChannel: boolean;
  59134. /**
  59135. * Gets DDS information from an array buffer
  59136. * @param data defines the array buffer view to read data from
  59137. * @returns the DDS information
  59138. */
  59139. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59140. private static _FloatView;
  59141. private static _Int32View;
  59142. private static _ToHalfFloat;
  59143. private static _FromHalfFloat;
  59144. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59145. private static _GetHalfFloatRGBAArrayBuffer;
  59146. private static _GetFloatRGBAArrayBuffer;
  59147. private static _GetFloatAsUIntRGBAArrayBuffer;
  59148. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59149. private static _GetRGBAArrayBuffer;
  59150. private static _ExtractLongWordOrder;
  59151. private static _GetRGBArrayBuffer;
  59152. private static _GetLuminanceArrayBuffer;
  59153. /**
  59154. * Uploads DDS Levels to a Babylon Texture
  59155. * @hidden
  59156. */
  59157. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59158. }
  59159. interface ThinEngine {
  59160. /**
  59161. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59162. * @param rootUrl defines the url where the file to load is located
  59163. * @param scene defines the current scene
  59164. * @param lodScale defines scale to apply to the mip map selection
  59165. * @param lodOffset defines offset to apply to the mip map selection
  59166. * @param onLoad defines an optional callback raised when the texture is loaded
  59167. * @param onError defines an optional callback raised if there is an issue to load the texture
  59168. * @param format defines the format of the data
  59169. * @param forcedExtension defines the extension to use to pick the right loader
  59170. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59171. * @returns the cube texture as an InternalTexture
  59172. */
  59173. 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;
  59174. }
  59175. }
  59176. declare module BABYLON {
  59177. /**
  59178. * Implementation of the DDS Texture Loader.
  59179. * @hidden
  59180. */
  59181. export class _DDSTextureLoader implements IInternalTextureLoader {
  59182. /**
  59183. * Defines wether the loader supports cascade loading the different faces.
  59184. */
  59185. readonly supportCascades: boolean;
  59186. /**
  59187. * This returns if the loader support the current file information.
  59188. * @param extension defines the file extension of the file being loaded
  59189. * @returns true if the loader can load the specified file
  59190. */
  59191. canLoad(extension: string): boolean;
  59192. /**
  59193. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59194. * @param data contains the texture data
  59195. * @param texture defines the BabylonJS internal texture
  59196. * @param createPolynomials will be true if polynomials have been requested
  59197. * @param onLoad defines the callback to trigger once the texture is ready
  59198. * @param onError defines the callback to trigger in case of error
  59199. */
  59200. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59201. /**
  59202. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59203. * @param data contains the texture data
  59204. * @param texture defines the BabylonJS internal texture
  59205. * @param callback defines the method to call once ready to upload
  59206. */
  59207. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59208. }
  59209. }
  59210. declare module BABYLON {
  59211. /**
  59212. * Implementation of the ENV Texture Loader.
  59213. * @hidden
  59214. */
  59215. export class _ENVTextureLoader implements IInternalTextureLoader {
  59216. /**
  59217. * Defines wether the loader supports cascade loading the different faces.
  59218. */
  59219. readonly supportCascades: boolean;
  59220. /**
  59221. * This returns if the loader support the current file information.
  59222. * @param extension defines the file extension of the file being loaded
  59223. * @returns true if the loader can load the specified file
  59224. */
  59225. canLoad(extension: string): boolean;
  59226. /**
  59227. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59228. * @param data contains the texture data
  59229. * @param texture defines the BabylonJS internal texture
  59230. * @param createPolynomials will be true if polynomials have been requested
  59231. * @param onLoad defines the callback to trigger once the texture is ready
  59232. * @param onError defines the callback to trigger in case of error
  59233. */
  59234. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59235. /**
  59236. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59237. * @param data contains the texture data
  59238. * @param texture defines the BabylonJS internal texture
  59239. * @param callback defines the method to call once ready to upload
  59240. */
  59241. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59242. }
  59243. }
  59244. declare module BABYLON {
  59245. /**
  59246. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59247. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59248. */
  59249. export class KhronosTextureContainer {
  59250. /** contents of the KTX container file */
  59251. data: ArrayBufferView;
  59252. private static HEADER_LEN;
  59253. private static COMPRESSED_2D;
  59254. private static COMPRESSED_3D;
  59255. private static TEX_2D;
  59256. private static TEX_3D;
  59257. /**
  59258. * Gets the openGL type
  59259. */
  59260. glType: number;
  59261. /**
  59262. * Gets the openGL type size
  59263. */
  59264. glTypeSize: number;
  59265. /**
  59266. * Gets the openGL format
  59267. */
  59268. glFormat: number;
  59269. /**
  59270. * Gets the openGL internal format
  59271. */
  59272. glInternalFormat: number;
  59273. /**
  59274. * Gets the base internal format
  59275. */
  59276. glBaseInternalFormat: number;
  59277. /**
  59278. * Gets image width in pixel
  59279. */
  59280. pixelWidth: number;
  59281. /**
  59282. * Gets image height in pixel
  59283. */
  59284. pixelHeight: number;
  59285. /**
  59286. * Gets image depth in pixels
  59287. */
  59288. pixelDepth: number;
  59289. /**
  59290. * Gets the number of array elements
  59291. */
  59292. numberOfArrayElements: number;
  59293. /**
  59294. * Gets the number of faces
  59295. */
  59296. numberOfFaces: number;
  59297. /**
  59298. * Gets the number of mipmap levels
  59299. */
  59300. numberOfMipmapLevels: number;
  59301. /**
  59302. * Gets the bytes of key value data
  59303. */
  59304. bytesOfKeyValueData: number;
  59305. /**
  59306. * Gets the load type
  59307. */
  59308. loadType: number;
  59309. /**
  59310. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59311. */
  59312. isInvalid: boolean;
  59313. /**
  59314. * Creates a new KhronosTextureContainer
  59315. * @param data contents of the KTX container file
  59316. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59317. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59318. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59319. */
  59320. constructor(
  59321. /** contents of the KTX container file */
  59322. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59323. /**
  59324. * Uploads KTX content to a Babylon Texture.
  59325. * It is assumed that the texture has already been created & is currently bound
  59326. * @hidden
  59327. */
  59328. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59329. private _upload2DCompressedLevels;
  59330. /**
  59331. * Checks if the given data starts with a KTX file identifier.
  59332. * @param data the data to check
  59333. * @returns true if the data is a KTX file or false otherwise
  59334. */
  59335. static IsValid(data: ArrayBufferView): boolean;
  59336. }
  59337. }
  59338. declare module BABYLON {
  59339. /**
  59340. * Helper class to push actions to a pool of workers.
  59341. */
  59342. export class WorkerPool implements IDisposable {
  59343. private _workerInfos;
  59344. private _pendingActions;
  59345. /**
  59346. * Constructor
  59347. * @param workers Array of workers to use for actions
  59348. */
  59349. constructor(workers: Array<Worker>);
  59350. /**
  59351. * Terminates all workers and clears any pending actions.
  59352. */
  59353. dispose(): void;
  59354. /**
  59355. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59356. * pended until a worker has completed its action.
  59357. * @param action The action to perform. Call onComplete when the action is complete.
  59358. */
  59359. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59360. private _execute;
  59361. }
  59362. }
  59363. declare module BABYLON {
  59364. /**
  59365. * Class for loading KTX2 files
  59366. */
  59367. export class KhronosTextureContainer2 {
  59368. private static _WorkerPoolPromise?;
  59369. private static _Initialized;
  59370. private static _Ktx2Decoder;
  59371. /**
  59372. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59373. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59374. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59375. * Urls you can change:
  59376. * URLConfig.jsDecoderModule
  59377. * URLConfig.wasmUASTCToASTC
  59378. * URLConfig.wasmUASTCToBC7
  59379. * URLConfig.wasmUASTCToRGBA_UNORM
  59380. * URLConfig.wasmUASTCToRGBA_SRGB
  59381. * URLConfig.jsMSCTranscoder
  59382. * URLConfig.wasmMSCTranscoder
  59383. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59384. */
  59385. static URLConfig: {
  59386. jsDecoderModule: string;
  59387. wasmUASTCToASTC: null;
  59388. wasmUASTCToBC7: null;
  59389. wasmUASTCToRGBA_UNORM: null;
  59390. wasmUASTCToRGBA_SRGB: null;
  59391. jsMSCTranscoder: null;
  59392. wasmMSCTranscoder: null;
  59393. };
  59394. /**
  59395. * Default number of workers used to handle data decoding
  59396. */
  59397. static DefaultNumWorkers: number;
  59398. private static GetDefaultNumWorkers;
  59399. private _engine;
  59400. private static _CreateWorkerPool;
  59401. /**
  59402. * Constructor
  59403. * @param engine The engine to use
  59404. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59405. */
  59406. constructor(engine: ThinEngine, numWorkers?: number);
  59407. /** @hidden */
  59408. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59409. /**
  59410. * Stop all async operations and release resources.
  59411. */
  59412. dispose(): void;
  59413. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59414. /**
  59415. * Checks if the given data starts with a KTX2 file identifier.
  59416. * @param data the data to check
  59417. * @returns true if the data is a KTX2 file or false otherwise
  59418. */
  59419. static IsValid(data: ArrayBufferView): boolean;
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /**
  59424. * Implementation of the KTX Texture Loader.
  59425. * @hidden
  59426. */
  59427. export class _KTXTextureLoader implements IInternalTextureLoader {
  59428. /**
  59429. * Defines wether the loader supports cascade loading the different faces.
  59430. */
  59431. readonly supportCascades: boolean;
  59432. /**
  59433. * This returns if the loader support the current file information.
  59434. * @param extension defines the file extension of the file being loaded
  59435. * @param mimeType defines the optional mime type of the file being loaded
  59436. * @returns true if the loader can load the specified file
  59437. */
  59438. canLoad(extension: string, mimeType?: string): boolean;
  59439. /**
  59440. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59441. * @param data contains the texture data
  59442. * @param texture defines the BabylonJS internal texture
  59443. * @param createPolynomials will be true if polynomials have been requested
  59444. * @param onLoad defines the callback to trigger once the texture is ready
  59445. * @param onError defines the callback to trigger in case of error
  59446. */
  59447. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59448. /**
  59449. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59450. * @param data contains the texture data
  59451. * @param texture defines the BabylonJS internal texture
  59452. * @param callback defines the method to call once ready to upload
  59453. */
  59454. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59455. }
  59456. }
  59457. declare module BABYLON {
  59458. /** @hidden */
  59459. export var _forceSceneHelpersToBundle: boolean;
  59460. interface Scene {
  59461. /**
  59462. * Creates a default light for the scene.
  59463. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59464. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59465. */
  59466. createDefaultLight(replace?: boolean): void;
  59467. /**
  59468. * Creates a default camera for the scene.
  59469. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59470. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59471. * @param replace has default false, when true replaces the active camera in the scene
  59472. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59473. */
  59474. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59475. /**
  59476. * Creates a default camera and a default light.
  59477. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59478. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59479. * @param replace has the default false, when true replaces the active camera/light in the scene
  59480. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59481. */
  59482. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59483. /**
  59484. * Creates a new sky box
  59485. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59486. * @param environmentTexture defines the texture to use as environment texture
  59487. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59488. * @param scale defines the overall scale of the skybox
  59489. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59490. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59491. * @returns a new mesh holding the sky box
  59492. */
  59493. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59494. /**
  59495. * Creates a new environment
  59496. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59497. * @param options defines the options you can use to configure the environment
  59498. * @returns the new EnvironmentHelper
  59499. */
  59500. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59501. /**
  59502. * Creates a new VREXperienceHelper
  59503. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59504. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59505. * @returns a new VREXperienceHelper
  59506. */
  59507. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59508. /**
  59509. * Creates a new WebXRDefaultExperience
  59510. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59511. * @param options experience options
  59512. * @returns a promise for a new WebXRDefaultExperience
  59513. */
  59514. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59515. }
  59516. }
  59517. declare module BABYLON {
  59518. /**
  59519. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59520. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59521. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59522. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59523. */
  59524. export class VideoDome extends TextureDome<VideoTexture> {
  59525. /**
  59526. * Define the video source as a Monoscopic panoramic 360 video.
  59527. */
  59528. static readonly MODE_MONOSCOPIC: number;
  59529. /**
  59530. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59531. */
  59532. static readonly MODE_TOPBOTTOM: number;
  59533. /**
  59534. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59535. */
  59536. static readonly MODE_SIDEBYSIDE: number;
  59537. /**
  59538. * Get the video texture associated with this video dome
  59539. */
  59540. get videoTexture(): VideoTexture;
  59541. /**
  59542. * Get the video mode of this dome
  59543. */
  59544. get videoMode(): number;
  59545. /**
  59546. * Set the video mode of this dome.
  59547. * @see textureMode
  59548. */
  59549. set videoMode(value: number);
  59550. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59551. }
  59552. }
  59553. declare module BABYLON {
  59554. /**
  59555. * This class can be used to get instrumentation data from a Babylon engine
  59556. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59557. */
  59558. export class EngineInstrumentation implements IDisposable {
  59559. /**
  59560. * Define the instrumented engine.
  59561. */
  59562. engine: Engine;
  59563. private _captureGPUFrameTime;
  59564. private _gpuFrameTimeToken;
  59565. private _gpuFrameTime;
  59566. private _captureShaderCompilationTime;
  59567. private _shaderCompilationTime;
  59568. private _onBeginFrameObserver;
  59569. private _onEndFrameObserver;
  59570. private _onBeforeShaderCompilationObserver;
  59571. private _onAfterShaderCompilationObserver;
  59572. /**
  59573. * Gets the perf counter used for GPU frame time
  59574. */
  59575. get gpuFrameTimeCounter(): PerfCounter;
  59576. /**
  59577. * Gets the GPU frame time capture status
  59578. */
  59579. get captureGPUFrameTime(): boolean;
  59580. /**
  59581. * Enable or disable the GPU frame time capture
  59582. */
  59583. set captureGPUFrameTime(value: boolean);
  59584. /**
  59585. * Gets the perf counter used for shader compilation time
  59586. */
  59587. get shaderCompilationTimeCounter(): PerfCounter;
  59588. /**
  59589. * Gets the shader compilation time capture status
  59590. */
  59591. get captureShaderCompilationTime(): boolean;
  59592. /**
  59593. * Enable or disable the shader compilation time capture
  59594. */
  59595. set captureShaderCompilationTime(value: boolean);
  59596. /**
  59597. * Instantiates a new engine instrumentation.
  59598. * This class can be used to get instrumentation data from a Babylon engine
  59599. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59600. * @param engine Defines the engine to instrument
  59601. */
  59602. constructor(
  59603. /**
  59604. * Define the instrumented engine.
  59605. */
  59606. engine: Engine);
  59607. /**
  59608. * Dispose and release associated resources.
  59609. */
  59610. dispose(): void;
  59611. }
  59612. }
  59613. declare module BABYLON {
  59614. /**
  59615. * This class can be used to get instrumentation data from a Babylon engine
  59616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59617. */
  59618. export class SceneInstrumentation implements IDisposable {
  59619. /**
  59620. * Defines the scene to instrument
  59621. */
  59622. scene: Scene;
  59623. private _captureActiveMeshesEvaluationTime;
  59624. private _activeMeshesEvaluationTime;
  59625. private _captureRenderTargetsRenderTime;
  59626. private _renderTargetsRenderTime;
  59627. private _captureFrameTime;
  59628. private _frameTime;
  59629. private _captureRenderTime;
  59630. private _renderTime;
  59631. private _captureInterFrameTime;
  59632. private _interFrameTime;
  59633. private _captureParticlesRenderTime;
  59634. private _particlesRenderTime;
  59635. private _captureSpritesRenderTime;
  59636. private _spritesRenderTime;
  59637. private _capturePhysicsTime;
  59638. private _physicsTime;
  59639. private _captureAnimationsTime;
  59640. private _animationsTime;
  59641. private _captureCameraRenderTime;
  59642. private _cameraRenderTime;
  59643. private _onBeforeActiveMeshesEvaluationObserver;
  59644. private _onAfterActiveMeshesEvaluationObserver;
  59645. private _onBeforeRenderTargetsRenderObserver;
  59646. private _onAfterRenderTargetsRenderObserver;
  59647. private _onAfterRenderObserver;
  59648. private _onBeforeDrawPhaseObserver;
  59649. private _onAfterDrawPhaseObserver;
  59650. private _onBeforeAnimationsObserver;
  59651. private _onBeforeParticlesRenderingObserver;
  59652. private _onAfterParticlesRenderingObserver;
  59653. private _onBeforeSpritesRenderingObserver;
  59654. private _onAfterSpritesRenderingObserver;
  59655. private _onBeforePhysicsObserver;
  59656. private _onAfterPhysicsObserver;
  59657. private _onAfterAnimationsObserver;
  59658. private _onBeforeCameraRenderObserver;
  59659. private _onAfterCameraRenderObserver;
  59660. /**
  59661. * Gets the perf counter used for active meshes evaluation time
  59662. */
  59663. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59664. /**
  59665. * Gets the active meshes evaluation time capture status
  59666. */
  59667. get captureActiveMeshesEvaluationTime(): boolean;
  59668. /**
  59669. * Enable or disable the active meshes evaluation time capture
  59670. */
  59671. set captureActiveMeshesEvaluationTime(value: boolean);
  59672. /**
  59673. * Gets the perf counter used for render targets render time
  59674. */
  59675. get renderTargetsRenderTimeCounter(): PerfCounter;
  59676. /**
  59677. * Gets the render targets render time capture status
  59678. */
  59679. get captureRenderTargetsRenderTime(): boolean;
  59680. /**
  59681. * Enable or disable the render targets render time capture
  59682. */
  59683. set captureRenderTargetsRenderTime(value: boolean);
  59684. /**
  59685. * Gets the perf counter used for particles render time
  59686. */
  59687. get particlesRenderTimeCounter(): PerfCounter;
  59688. /**
  59689. * Gets the particles render time capture status
  59690. */
  59691. get captureParticlesRenderTime(): boolean;
  59692. /**
  59693. * Enable or disable the particles render time capture
  59694. */
  59695. set captureParticlesRenderTime(value: boolean);
  59696. /**
  59697. * Gets the perf counter used for sprites render time
  59698. */
  59699. get spritesRenderTimeCounter(): PerfCounter;
  59700. /**
  59701. * Gets the sprites render time capture status
  59702. */
  59703. get captureSpritesRenderTime(): boolean;
  59704. /**
  59705. * Enable or disable the sprites render time capture
  59706. */
  59707. set captureSpritesRenderTime(value: boolean);
  59708. /**
  59709. * Gets the perf counter used for physics time
  59710. */
  59711. get physicsTimeCounter(): PerfCounter;
  59712. /**
  59713. * Gets the physics time capture status
  59714. */
  59715. get capturePhysicsTime(): boolean;
  59716. /**
  59717. * Enable or disable the physics time capture
  59718. */
  59719. set capturePhysicsTime(value: boolean);
  59720. /**
  59721. * Gets the perf counter used for animations time
  59722. */
  59723. get animationsTimeCounter(): PerfCounter;
  59724. /**
  59725. * Gets the animations time capture status
  59726. */
  59727. get captureAnimationsTime(): boolean;
  59728. /**
  59729. * Enable or disable the animations time capture
  59730. */
  59731. set captureAnimationsTime(value: boolean);
  59732. /**
  59733. * Gets the perf counter used for frame time capture
  59734. */
  59735. get frameTimeCounter(): PerfCounter;
  59736. /**
  59737. * Gets the frame time capture status
  59738. */
  59739. get captureFrameTime(): boolean;
  59740. /**
  59741. * Enable or disable the frame time capture
  59742. */
  59743. set captureFrameTime(value: boolean);
  59744. /**
  59745. * Gets the perf counter used for inter-frames time capture
  59746. */
  59747. get interFrameTimeCounter(): PerfCounter;
  59748. /**
  59749. * Gets the inter-frames time capture status
  59750. */
  59751. get captureInterFrameTime(): boolean;
  59752. /**
  59753. * Enable or disable the inter-frames time capture
  59754. */
  59755. set captureInterFrameTime(value: boolean);
  59756. /**
  59757. * Gets the perf counter used for render time capture
  59758. */
  59759. get renderTimeCounter(): PerfCounter;
  59760. /**
  59761. * Gets the render time capture status
  59762. */
  59763. get captureRenderTime(): boolean;
  59764. /**
  59765. * Enable or disable the render time capture
  59766. */
  59767. set captureRenderTime(value: boolean);
  59768. /**
  59769. * Gets the perf counter used for camera render time capture
  59770. */
  59771. get cameraRenderTimeCounter(): PerfCounter;
  59772. /**
  59773. * Gets the camera render time capture status
  59774. */
  59775. get captureCameraRenderTime(): boolean;
  59776. /**
  59777. * Enable or disable the camera render time capture
  59778. */
  59779. set captureCameraRenderTime(value: boolean);
  59780. /**
  59781. * Gets the perf counter used for draw calls
  59782. */
  59783. get drawCallsCounter(): PerfCounter;
  59784. /**
  59785. * Instantiates a new scene instrumentation.
  59786. * This class can be used to get instrumentation data from a Babylon engine
  59787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59788. * @param scene Defines the scene to instrument
  59789. */
  59790. constructor(
  59791. /**
  59792. * Defines the scene to instrument
  59793. */
  59794. scene: Scene);
  59795. /**
  59796. * Dispose and release associated resources.
  59797. */
  59798. dispose(): void;
  59799. }
  59800. }
  59801. declare module BABYLON {
  59802. /** @hidden */
  59803. export var glowMapGenerationPixelShader: {
  59804. name: string;
  59805. shader: string;
  59806. };
  59807. }
  59808. declare module BABYLON {
  59809. /** @hidden */
  59810. export var glowMapGenerationVertexShader: {
  59811. name: string;
  59812. shader: string;
  59813. };
  59814. }
  59815. declare module BABYLON {
  59816. /**
  59817. * Effect layer options. This helps customizing the behaviour
  59818. * of the effect layer.
  59819. */
  59820. export interface IEffectLayerOptions {
  59821. /**
  59822. * Multiplication factor apply to the canvas size to compute the render target size
  59823. * used to generated the objects (the smaller the faster).
  59824. */
  59825. mainTextureRatio: number;
  59826. /**
  59827. * Enforces a fixed size texture to ensure effect stability across devices.
  59828. */
  59829. mainTextureFixedSize?: number;
  59830. /**
  59831. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59832. */
  59833. alphaBlendingMode: number;
  59834. /**
  59835. * The camera attached to the layer.
  59836. */
  59837. camera: Nullable<Camera>;
  59838. /**
  59839. * The rendering group to draw the layer in.
  59840. */
  59841. renderingGroupId: number;
  59842. }
  59843. /**
  59844. * The effect layer Helps adding post process effect blended with the main pass.
  59845. *
  59846. * This can be for instance use to generate glow or higlight effects on the scene.
  59847. *
  59848. * The effect layer class can not be used directly and is intented to inherited from to be
  59849. * customized per effects.
  59850. */
  59851. export abstract class EffectLayer {
  59852. private _vertexBuffers;
  59853. private _indexBuffer;
  59854. private _cachedDefines;
  59855. private _effectLayerMapGenerationEffect;
  59856. private _effectLayerOptions;
  59857. private _mergeEffect;
  59858. protected _scene: Scene;
  59859. protected _engine: Engine;
  59860. protected _maxSize: number;
  59861. protected _mainTextureDesiredSize: ISize;
  59862. protected _mainTexture: RenderTargetTexture;
  59863. protected _shouldRender: boolean;
  59864. protected _postProcesses: PostProcess[];
  59865. protected _textures: BaseTexture[];
  59866. protected _emissiveTextureAndColor: {
  59867. texture: Nullable<BaseTexture>;
  59868. color: Color4;
  59869. };
  59870. /**
  59871. * The name of the layer
  59872. */
  59873. name: string;
  59874. /**
  59875. * The clear color of the texture used to generate the glow map.
  59876. */
  59877. neutralColor: Color4;
  59878. /**
  59879. * Specifies whether the highlight layer is enabled or not.
  59880. */
  59881. isEnabled: boolean;
  59882. /**
  59883. * Gets the camera attached to the layer.
  59884. */
  59885. get camera(): Nullable<Camera>;
  59886. /**
  59887. * Gets the rendering group id the layer should render in.
  59888. */
  59889. get renderingGroupId(): number;
  59890. set renderingGroupId(renderingGroupId: number);
  59891. /**
  59892. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59893. */
  59894. disableBoundingBoxesFromEffectLayer: boolean;
  59895. /**
  59896. * An event triggered when the effect layer has been disposed.
  59897. */
  59898. onDisposeObservable: Observable<EffectLayer>;
  59899. /**
  59900. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59901. */
  59902. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59903. /**
  59904. * An event triggered when the generated texture is being merged in the scene.
  59905. */
  59906. onBeforeComposeObservable: Observable<EffectLayer>;
  59907. /**
  59908. * An event triggered when the mesh is rendered into the effect render target.
  59909. */
  59910. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59911. /**
  59912. * An event triggered after the mesh has been rendered into the effect render target.
  59913. */
  59914. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59915. /**
  59916. * An event triggered when the generated texture has been merged in the scene.
  59917. */
  59918. onAfterComposeObservable: Observable<EffectLayer>;
  59919. /**
  59920. * An event triggered when the efffect layer changes its size.
  59921. */
  59922. onSizeChangedObservable: Observable<EffectLayer>;
  59923. /** @hidden */
  59924. static _SceneComponentInitialization: (scene: Scene) => void;
  59925. /**
  59926. * Instantiates a new effect Layer and references it in the scene.
  59927. * @param name The name of the layer
  59928. * @param scene The scene to use the layer in
  59929. */
  59930. constructor(
  59931. /** The Friendly of the effect in the scene */
  59932. name: string, scene: Scene);
  59933. /**
  59934. * Get the effect name of the layer.
  59935. * @return The effect name
  59936. */
  59937. abstract getEffectName(): string;
  59938. /**
  59939. * Checks for the readiness of the element composing the layer.
  59940. * @param subMesh the mesh to check for
  59941. * @param useInstances specify whether or not to use instances to render the mesh
  59942. * @return true if ready otherwise, false
  59943. */
  59944. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59945. /**
  59946. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59947. * @returns true if the effect requires stencil during the main canvas render pass.
  59948. */
  59949. abstract needStencil(): boolean;
  59950. /**
  59951. * Create the merge effect. This is the shader use to blit the information back
  59952. * to the main canvas at the end of the scene rendering.
  59953. * @returns The effect containing the shader used to merge the effect on the main canvas
  59954. */
  59955. protected abstract _createMergeEffect(): Effect;
  59956. /**
  59957. * Creates the render target textures and post processes used in the effect layer.
  59958. */
  59959. protected abstract _createTextureAndPostProcesses(): void;
  59960. /**
  59961. * Implementation specific of rendering the generating effect on the main canvas.
  59962. * @param effect The effect used to render through
  59963. */
  59964. protected abstract _internalRender(effect: Effect): void;
  59965. /**
  59966. * Sets the required values for both the emissive texture and and the main color.
  59967. */
  59968. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59969. /**
  59970. * Free any resources and references associated to a mesh.
  59971. * Internal use
  59972. * @param mesh The mesh to free.
  59973. */
  59974. abstract _disposeMesh(mesh: Mesh): void;
  59975. /**
  59976. * Serializes this layer (Glow or Highlight for example)
  59977. * @returns a serialized layer object
  59978. */
  59979. abstract serialize?(): any;
  59980. /**
  59981. * Initializes the effect layer with the required options.
  59982. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59983. */
  59984. protected _init(options: Partial<IEffectLayerOptions>): void;
  59985. /**
  59986. * Generates the index buffer of the full screen quad blending to the main canvas.
  59987. */
  59988. private _generateIndexBuffer;
  59989. /**
  59990. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59991. */
  59992. private _generateVertexBuffer;
  59993. /**
  59994. * Sets the main texture desired size which is the closest power of two
  59995. * of the engine canvas size.
  59996. */
  59997. private _setMainTextureSize;
  59998. /**
  59999. * Creates the main texture for the effect layer.
  60000. */
  60001. protected _createMainTexture(): void;
  60002. /**
  60003. * Adds specific effects defines.
  60004. * @param defines The defines to add specifics to.
  60005. */
  60006. protected _addCustomEffectDefines(defines: string[]): void;
  60007. /**
  60008. * Checks for the readiness of the element composing the layer.
  60009. * @param subMesh the mesh to check for
  60010. * @param useInstances specify whether or not to use instances to render the mesh
  60011. * @param emissiveTexture the associated emissive texture used to generate the glow
  60012. * @return true if ready otherwise, false
  60013. */
  60014. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60015. /**
  60016. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60017. */
  60018. render(): void;
  60019. /**
  60020. * Determine if a given mesh will be used in the current effect.
  60021. * @param mesh mesh to test
  60022. * @returns true if the mesh will be used
  60023. */
  60024. hasMesh(mesh: AbstractMesh): boolean;
  60025. /**
  60026. * Returns true if the layer contains information to display, otherwise false.
  60027. * @returns true if the glow layer should be rendered
  60028. */
  60029. shouldRender(): boolean;
  60030. /**
  60031. * Returns true if the mesh should render, otherwise false.
  60032. * @param mesh The mesh to render
  60033. * @returns true if it should render otherwise false
  60034. */
  60035. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60036. /**
  60037. * Returns true if the mesh can be rendered, otherwise false.
  60038. * @param mesh The mesh to render
  60039. * @param material The material used on the mesh
  60040. * @returns true if it can be rendered otherwise false
  60041. */
  60042. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60043. /**
  60044. * Returns true if the mesh should render, otherwise false.
  60045. * @param mesh The mesh to render
  60046. * @returns true if it should render otherwise false
  60047. */
  60048. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60049. /**
  60050. * Renders the submesh passed in parameter to the generation map.
  60051. */
  60052. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60053. /**
  60054. * Defines whether the current material of the mesh should be use to render the effect.
  60055. * @param mesh defines the current mesh to render
  60056. */
  60057. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60058. /**
  60059. * Rebuild the required buffers.
  60060. * @hidden Internal use only.
  60061. */
  60062. _rebuild(): void;
  60063. /**
  60064. * Dispose only the render target textures and post process.
  60065. */
  60066. private _disposeTextureAndPostProcesses;
  60067. /**
  60068. * Dispose the highlight layer and free resources.
  60069. */
  60070. dispose(): void;
  60071. /**
  60072. * Gets the class name of the effect layer
  60073. * @returns the string with the class name of the effect layer
  60074. */
  60075. getClassName(): string;
  60076. /**
  60077. * Creates an effect layer from parsed effect layer data
  60078. * @param parsedEffectLayer defines effect layer data
  60079. * @param scene defines the current scene
  60080. * @param rootUrl defines the root URL containing the effect layer information
  60081. * @returns a parsed effect Layer
  60082. */
  60083. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60084. }
  60085. }
  60086. declare module BABYLON {
  60087. interface AbstractScene {
  60088. /**
  60089. * The list of effect layers (highlights/glow) added to the scene
  60090. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60091. * @see https://doc.babylonjs.com/how_to/glow_layer
  60092. */
  60093. effectLayers: Array<EffectLayer>;
  60094. /**
  60095. * Removes the given effect layer from this scene.
  60096. * @param toRemove defines the effect layer to remove
  60097. * @returns the index of the removed effect layer
  60098. */
  60099. removeEffectLayer(toRemove: EffectLayer): number;
  60100. /**
  60101. * Adds the given effect layer to this scene
  60102. * @param newEffectLayer defines the effect layer to add
  60103. */
  60104. addEffectLayer(newEffectLayer: EffectLayer): void;
  60105. }
  60106. /**
  60107. * Defines the layer scene component responsible to manage any effect layers
  60108. * in a given scene.
  60109. */
  60110. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60111. /**
  60112. * The component name helpfull to identify the component in the list of scene components.
  60113. */
  60114. readonly name: string;
  60115. /**
  60116. * The scene the component belongs to.
  60117. */
  60118. scene: Scene;
  60119. private _engine;
  60120. private _renderEffects;
  60121. private _needStencil;
  60122. private _previousStencilState;
  60123. /**
  60124. * Creates a new instance of the component for the given scene
  60125. * @param scene Defines the scene to register the component in
  60126. */
  60127. constructor(scene: Scene);
  60128. /**
  60129. * Registers the component in a given scene
  60130. */
  60131. register(): void;
  60132. /**
  60133. * Rebuilds the elements related to this component in case of
  60134. * context lost for instance.
  60135. */
  60136. rebuild(): void;
  60137. /**
  60138. * Serializes the component data to the specified json object
  60139. * @param serializationObject The object to serialize to
  60140. */
  60141. serialize(serializationObject: any): void;
  60142. /**
  60143. * Adds all the elements from the container to the scene
  60144. * @param container the container holding the elements
  60145. */
  60146. addFromContainer(container: AbstractScene): void;
  60147. /**
  60148. * Removes all the elements in the container from the scene
  60149. * @param container contains the elements to remove
  60150. * @param dispose if the removed element should be disposed (default: false)
  60151. */
  60152. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60153. /**
  60154. * Disposes the component and the associated ressources.
  60155. */
  60156. dispose(): void;
  60157. private _isReadyForMesh;
  60158. private _renderMainTexture;
  60159. private _setStencil;
  60160. private _setStencilBack;
  60161. private _draw;
  60162. private _drawCamera;
  60163. private _drawRenderingGroup;
  60164. }
  60165. }
  60166. declare module BABYLON {
  60167. /** @hidden */
  60168. export var glowMapMergePixelShader: {
  60169. name: string;
  60170. shader: string;
  60171. };
  60172. }
  60173. declare module BABYLON {
  60174. /** @hidden */
  60175. export var glowMapMergeVertexShader: {
  60176. name: string;
  60177. shader: string;
  60178. };
  60179. }
  60180. declare module BABYLON {
  60181. interface AbstractScene {
  60182. /**
  60183. * Return a the first highlight layer of the scene with a given name.
  60184. * @param name The name of the highlight layer to look for.
  60185. * @return The highlight layer if found otherwise null.
  60186. */
  60187. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60188. }
  60189. /**
  60190. * Glow layer options. This helps customizing the behaviour
  60191. * of the glow layer.
  60192. */
  60193. export interface IGlowLayerOptions {
  60194. /**
  60195. * Multiplication factor apply to the canvas size to compute the render target size
  60196. * used to generated the glowing objects (the smaller the faster).
  60197. */
  60198. mainTextureRatio: number;
  60199. /**
  60200. * Enforces a fixed size texture to ensure resize independant blur.
  60201. */
  60202. mainTextureFixedSize?: number;
  60203. /**
  60204. * How big is the kernel of the blur texture.
  60205. */
  60206. blurKernelSize: number;
  60207. /**
  60208. * The camera attached to the layer.
  60209. */
  60210. camera: Nullable<Camera>;
  60211. /**
  60212. * Enable MSAA by chosing the number of samples.
  60213. */
  60214. mainTextureSamples?: number;
  60215. /**
  60216. * The rendering group to draw the layer in.
  60217. */
  60218. renderingGroupId: number;
  60219. }
  60220. /**
  60221. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60222. *
  60223. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60224. *
  60225. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60226. */
  60227. export class GlowLayer extends EffectLayer {
  60228. /**
  60229. * Effect Name of the layer.
  60230. */
  60231. static readonly EffectName: string;
  60232. /**
  60233. * The default blur kernel size used for the glow.
  60234. */
  60235. static DefaultBlurKernelSize: number;
  60236. /**
  60237. * The default texture size ratio used for the glow.
  60238. */
  60239. static DefaultTextureRatio: number;
  60240. /**
  60241. * Sets the kernel size of the blur.
  60242. */
  60243. set blurKernelSize(value: number);
  60244. /**
  60245. * Gets the kernel size of the blur.
  60246. */
  60247. get blurKernelSize(): number;
  60248. /**
  60249. * Sets the glow intensity.
  60250. */
  60251. set intensity(value: number);
  60252. /**
  60253. * Gets the glow intensity.
  60254. */
  60255. get intensity(): number;
  60256. private _options;
  60257. private _intensity;
  60258. private _horizontalBlurPostprocess1;
  60259. private _verticalBlurPostprocess1;
  60260. private _horizontalBlurPostprocess2;
  60261. private _verticalBlurPostprocess2;
  60262. private _blurTexture1;
  60263. private _blurTexture2;
  60264. private _postProcesses1;
  60265. private _postProcesses2;
  60266. private _includedOnlyMeshes;
  60267. private _excludedMeshes;
  60268. private _meshesUsingTheirOwnMaterials;
  60269. /**
  60270. * Callback used to let the user override the color selection on a per mesh basis
  60271. */
  60272. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60273. /**
  60274. * Callback used to let the user override the texture selection on a per mesh basis
  60275. */
  60276. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60277. /**
  60278. * Instantiates a new glow Layer and references it to the scene.
  60279. * @param name The name of the layer
  60280. * @param scene The scene to use the layer in
  60281. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60282. */
  60283. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60284. /**
  60285. * Get the effect name of the layer.
  60286. * @return The effect name
  60287. */
  60288. getEffectName(): string;
  60289. /**
  60290. * Create the merge effect. This is the shader use to blit the information back
  60291. * to the main canvas at the end of the scene rendering.
  60292. */
  60293. protected _createMergeEffect(): Effect;
  60294. /**
  60295. * Creates the render target textures and post processes used in the glow layer.
  60296. */
  60297. protected _createTextureAndPostProcesses(): void;
  60298. /**
  60299. * Checks for the readiness of the element composing the layer.
  60300. * @param subMesh the mesh to check for
  60301. * @param useInstances specify wether or not to use instances to render the mesh
  60302. * @param emissiveTexture the associated emissive texture used to generate the glow
  60303. * @return true if ready otherwise, false
  60304. */
  60305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60306. /**
  60307. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60308. */
  60309. needStencil(): boolean;
  60310. /**
  60311. * Returns true if the mesh can be rendered, otherwise false.
  60312. * @param mesh The mesh to render
  60313. * @param material The material used on the mesh
  60314. * @returns true if it can be rendered otherwise false
  60315. */
  60316. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60317. /**
  60318. * Implementation specific of rendering the generating effect on the main canvas.
  60319. * @param effect The effect used to render through
  60320. */
  60321. protected _internalRender(effect: Effect): void;
  60322. /**
  60323. * Sets the required values for both the emissive texture and and the main color.
  60324. */
  60325. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60326. /**
  60327. * Returns true if the mesh should render, otherwise false.
  60328. * @param mesh The mesh to render
  60329. * @returns true if it should render otherwise false
  60330. */
  60331. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60332. /**
  60333. * Adds specific effects defines.
  60334. * @param defines The defines to add specifics to.
  60335. */
  60336. protected _addCustomEffectDefines(defines: string[]): void;
  60337. /**
  60338. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60339. * @param mesh The mesh to exclude from the glow layer
  60340. */
  60341. addExcludedMesh(mesh: Mesh): void;
  60342. /**
  60343. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60344. * @param mesh The mesh to remove
  60345. */
  60346. removeExcludedMesh(mesh: Mesh): void;
  60347. /**
  60348. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60349. * @param mesh The mesh to include in the glow layer
  60350. */
  60351. addIncludedOnlyMesh(mesh: Mesh): void;
  60352. /**
  60353. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60354. * @param mesh The mesh to remove
  60355. */
  60356. removeIncludedOnlyMesh(mesh: Mesh): void;
  60357. /**
  60358. * Determine if a given mesh will be used in the glow layer
  60359. * @param mesh The mesh to test
  60360. * @returns true if the mesh will be highlighted by the current glow layer
  60361. */
  60362. hasMesh(mesh: AbstractMesh): boolean;
  60363. /**
  60364. * Defines whether the current material of the mesh should be use to render the effect.
  60365. * @param mesh defines the current mesh to render
  60366. */
  60367. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60368. /**
  60369. * Add a mesh to be rendered through its own material and not with emissive only.
  60370. * @param mesh The mesh for which we need to use its material
  60371. */
  60372. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60373. /**
  60374. * Remove a mesh from being rendered through its own material and not with emissive only.
  60375. * @param mesh The mesh for which we need to not use its material
  60376. */
  60377. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60378. /**
  60379. * Free any resources and references associated to a mesh.
  60380. * Internal use
  60381. * @param mesh The mesh to free.
  60382. * @hidden
  60383. */
  60384. _disposeMesh(mesh: Mesh): void;
  60385. /**
  60386. * Gets the class name of the effect layer
  60387. * @returns the string with the class name of the effect layer
  60388. */
  60389. getClassName(): string;
  60390. /**
  60391. * Serializes this glow layer
  60392. * @returns a serialized glow layer object
  60393. */
  60394. serialize(): any;
  60395. /**
  60396. * Creates a Glow Layer from parsed glow layer data
  60397. * @param parsedGlowLayer defines glow layer data
  60398. * @param scene defines the current scene
  60399. * @param rootUrl defines the root URL containing the glow layer information
  60400. * @returns a parsed Glow Layer
  60401. */
  60402. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60403. }
  60404. }
  60405. declare module BABYLON {
  60406. /** @hidden */
  60407. export var glowBlurPostProcessPixelShader: {
  60408. name: string;
  60409. shader: string;
  60410. };
  60411. }
  60412. declare module BABYLON {
  60413. interface AbstractScene {
  60414. /**
  60415. * Return a the first highlight layer of the scene with a given name.
  60416. * @param name The name of the highlight layer to look for.
  60417. * @return The highlight layer if found otherwise null.
  60418. */
  60419. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60420. }
  60421. /**
  60422. * Highlight layer options. This helps customizing the behaviour
  60423. * of the highlight layer.
  60424. */
  60425. export interface IHighlightLayerOptions {
  60426. /**
  60427. * Multiplication factor apply to the canvas size to compute the render target size
  60428. * used to generated the glowing objects (the smaller the faster).
  60429. */
  60430. mainTextureRatio: number;
  60431. /**
  60432. * Enforces a fixed size texture to ensure resize independant blur.
  60433. */
  60434. mainTextureFixedSize?: number;
  60435. /**
  60436. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60437. * of the picture to blur (the smaller the faster).
  60438. */
  60439. blurTextureSizeRatio: number;
  60440. /**
  60441. * How big in texel of the blur texture is the vertical blur.
  60442. */
  60443. blurVerticalSize: number;
  60444. /**
  60445. * How big in texel of the blur texture is the horizontal blur.
  60446. */
  60447. blurHorizontalSize: number;
  60448. /**
  60449. * Alpha blending mode used to apply the blur. Default is combine.
  60450. */
  60451. alphaBlendingMode: number;
  60452. /**
  60453. * The camera attached to the layer.
  60454. */
  60455. camera: Nullable<Camera>;
  60456. /**
  60457. * Should we display highlight as a solid stroke?
  60458. */
  60459. isStroke?: boolean;
  60460. /**
  60461. * The rendering group to draw the layer in.
  60462. */
  60463. renderingGroupId: number;
  60464. }
  60465. /**
  60466. * The highlight layer Helps adding a glow effect around a mesh.
  60467. *
  60468. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60469. * glowy meshes to your scene.
  60470. *
  60471. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60472. */
  60473. export class HighlightLayer extends EffectLayer {
  60474. name: string;
  60475. /**
  60476. * Effect Name of the highlight layer.
  60477. */
  60478. static readonly EffectName: string;
  60479. /**
  60480. * The neutral color used during the preparation of the glow effect.
  60481. * This is black by default as the blend operation is a blend operation.
  60482. */
  60483. static NeutralColor: Color4;
  60484. /**
  60485. * Stencil value used for glowing meshes.
  60486. */
  60487. static GlowingMeshStencilReference: number;
  60488. /**
  60489. * Stencil value used for the other meshes in the scene.
  60490. */
  60491. static NormalMeshStencilReference: number;
  60492. /**
  60493. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60494. */
  60495. innerGlow: boolean;
  60496. /**
  60497. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60498. */
  60499. outerGlow: boolean;
  60500. /**
  60501. * Specifies the horizontal size of the blur.
  60502. */
  60503. set blurHorizontalSize(value: number);
  60504. /**
  60505. * Specifies the vertical size of the blur.
  60506. */
  60507. set blurVerticalSize(value: number);
  60508. /**
  60509. * Gets the horizontal size of the blur.
  60510. */
  60511. get blurHorizontalSize(): number;
  60512. /**
  60513. * Gets the vertical size of the blur.
  60514. */
  60515. get blurVerticalSize(): number;
  60516. /**
  60517. * An event triggered when the highlight layer is being blurred.
  60518. */
  60519. onBeforeBlurObservable: Observable<HighlightLayer>;
  60520. /**
  60521. * An event triggered when the highlight layer has been blurred.
  60522. */
  60523. onAfterBlurObservable: Observable<HighlightLayer>;
  60524. private _instanceGlowingMeshStencilReference;
  60525. private _options;
  60526. private _downSamplePostprocess;
  60527. private _horizontalBlurPostprocess;
  60528. private _verticalBlurPostprocess;
  60529. private _blurTexture;
  60530. private _meshes;
  60531. private _excludedMeshes;
  60532. /**
  60533. * Instantiates a new highlight Layer and references it to the scene..
  60534. * @param name The name of the layer
  60535. * @param scene The scene to use the layer in
  60536. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60537. */
  60538. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60539. /**
  60540. * Get the effect name of the layer.
  60541. * @return The effect name
  60542. */
  60543. getEffectName(): string;
  60544. /**
  60545. * Create the merge effect. This is the shader use to blit the information back
  60546. * to the main canvas at the end of the scene rendering.
  60547. */
  60548. protected _createMergeEffect(): Effect;
  60549. /**
  60550. * Creates the render target textures and post processes used in the highlight layer.
  60551. */
  60552. protected _createTextureAndPostProcesses(): void;
  60553. /**
  60554. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60555. */
  60556. needStencil(): boolean;
  60557. /**
  60558. * Checks for the readiness of the element composing the layer.
  60559. * @param subMesh the mesh to check for
  60560. * @param useInstances specify wether or not to use instances to render the mesh
  60561. * @param emissiveTexture the associated emissive texture used to generate the glow
  60562. * @return true if ready otherwise, false
  60563. */
  60564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60565. /**
  60566. * Implementation specific of rendering the generating effect on the main canvas.
  60567. * @param effect The effect used to render through
  60568. */
  60569. protected _internalRender(effect: Effect): void;
  60570. /**
  60571. * Returns true if the layer contains information to display, otherwise false.
  60572. */
  60573. shouldRender(): boolean;
  60574. /**
  60575. * Returns true if the mesh should render, otherwise false.
  60576. * @param mesh The mesh to render
  60577. * @returns true if it should render otherwise false
  60578. */
  60579. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60580. /**
  60581. * Returns true if the mesh can be rendered, otherwise false.
  60582. * @param mesh The mesh to render
  60583. * @param material The material used on the mesh
  60584. * @returns true if it can be rendered otherwise false
  60585. */
  60586. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60587. /**
  60588. * Adds specific effects defines.
  60589. * @param defines The defines to add specifics to.
  60590. */
  60591. protected _addCustomEffectDefines(defines: string[]): void;
  60592. /**
  60593. * Sets the required values for both the emissive texture and and the main color.
  60594. */
  60595. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60596. /**
  60597. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60598. * @param mesh The mesh to exclude from the highlight layer
  60599. */
  60600. addExcludedMesh(mesh: Mesh): void;
  60601. /**
  60602. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60603. * @param mesh The mesh to highlight
  60604. */
  60605. removeExcludedMesh(mesh: Mesh): void;
  60606. /**
  60607. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60608. * @param mesh mesh to test
  60609. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60610. */
  60611. hasMesh(mesh: AbstractMesh): boolean;
  60612. /**
  60613. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60614. * @param mesh The mesh to highlight
  60615. * @param color The color of the highlight
  60616. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60617. */
  60618. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60619. /**
  60620. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60621. * @param mesh The mesh to highlight
  60622. */
  60623. removeMesh(mesh: Mesh): void;
  60624. /**
  60625. * Remove all the meshes currently referenced in the highlight layer
  60626. */
  60627. removeAllMeshes(): void;
  60628. /**
  60629. * Force the stencil to the normal expected value for none glowing parts
  60630. */
  60631. private _defaultStencilReference;
  60632. /**
  60633. * Free any resources and references associated to a mesh.
  60634. * Internal use
  60635. * @param mesh The mesh to free.
  60636. * @hidden
  60637. */
  60638. _disposeMesh(mesh: Mesh): void;
  60639. /**
  60640. * Dispose the highlight layer and free resources.
  60641. */
  60642. dispose(): void;
  60643. /**
  60644. * Gets the class name of the effect layer
  60645. * @returns the string with the class name of the effect layer
  60646. */
  60647. getClassName(): string;
  60648. /**
  60649. * Serializes this Highlight layer
  60650. * @returns a serialized Highlight layer object
  60651. */
  60652. serialize(): any;
  60653. /**
  60654. * Creates a Highlight layer from parsed Highlight layer data
  60655. * @param parsedHightlightLayer defines the Highlight layer data
  60656. * @param scene defines the current scene
  60657. * @param rootUrl defines the root URL containing the Highlight layer information
  60658. * @returns a parsed Highlight layer
  60659. */
  60660. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60661. }
  60662. }
  60663. declare module BABYLON {
  60664. interface AbstractScene {
  60665. /**
  60666. * The list of layers (background and foreground) of the scene
  60667. */
  60668. layers: Array<Layer>;
  60669. }
  60670. /**
  60671. * Defines the layer scene component responsible to manage any layers
  60672. * in a given scene.
  60673. */
  60674. export class LayerSceneComponent implements ISceneComponent {
  60675. /**
  60676. * The component name helpfull to identify the component in the list of scene components.
  60677. */
  60678. readonly name: string;
  60679. /**
  60680. * The scene the component belongs to.
  60681. */
  60682. scene: Scene;
  60683. private _engine;
  60684. /**
  60685. * Creates a new instance of the component for the given scene
  60686. * @param scene Defines the scene to register the component in
  60687. */
  60688. constructor(scene: Scene);
  60689. /**
  60690. * Registers the component in a given scene
  60691. */
  60692. register(): void;
  60693. /**
  60694. * Rebuilds the elements related to this component in case of
  60695. * context lost for instance.
  60696. */
  60697. rebuild(): void;
  60698. /**
  60699. * Disposes the component and the associated ressources.
  60700. */
  60701. dispose(): void;
  60702. private _draw;
  60703. private _drawCameraPredicate;
  60704. private _drawCameraBackground;
  60705. private _drawCameraForeground;
  60706. private _drawRenderTargetPredicate;
  60707. private _drawRenderTargetBackground;
  60708. private _drawRenderTargetForeground;
  60709. /**
  60710. * Adds all the elements from the container to the scene
  60711. * @param container the container holding the elements
  60712. */
  60713. addFromContainer(container: AbstractScene): void;
  60714. /**
  60715. * Removes all the elements in the container from the scene
  60716. * @param container contains the elements to remove
  60717. * @param dispose if the removed element should be disposed (default: false)
  60718. */
  60719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60720. }
  60721. }
  60722. declare module BABYLON {
  60723. /** @hidden */
  60724. export var layerPixelShader: {
  60725. name: string;
  60726. shader: string;
  60727. };
  60728. }
  60729. declare module BABYLON {
  60730. /** @hidden */
  60731. export var layerVertexShader: {
  60732. name: string;
  60733. shader: string;
  60734. };
  60735. }
  60736. declare module BABYLON {
  60737. /**
  60738. * This represents a full screen 2d layer.
  60739. * This can be useful to display a picture in the background of your scene for instance.
  60740. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60741. */
  60742. export class Layer {
  60743. /**
  60744. * Define the name of the layer.
  60745. */
  60746. name: string;
  60747. /**
  60748. * Define the texture the layer should display.
  60749. */
  60750. texture: Nullable<Texture>;
  60751. /**
  60752. * Is the layer in background or foreground.
  60753. */
  60754. isBackground: boolean;
  60755. /**
  60756. * Define the color of the layer (instead of texture).
  60757. */
  60758. color: Color4;
  60759. /**
  60760. * Define the scale of the layer in order to zoom in out of the texture.
  60761. */
  60762. scale: Vector2;
  60763. /**
  60764. * Define an offset for the layer in order to shift the texture.
  60765. */
  60766. offset: Vector2;
  60767. /**
  60768. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60769. */
  60770. alphaBlendingMode: number;
  60771. /**
  60772. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60773. * Alpha test will not mix with the background color in case of transparency.
  60774. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60775. */
  60776. alphaTest: boolean;
  60777. /**
  60778. * Define a mask to restrict the layer to only some of the scene cameras.
  60779. */
  60780. layerMask: number;
  60781. /**
  60782. * Define the list of render target the layer is visible into.
  60783. */
  60784. renderTargetTextures: RenderTargetTexture[];
  60785. /**
  60786. * Define if the layer is only used in renderTarget or if it also
  60787. * renders in the main frame buffer of the canvas.
  60788. */
  60789. renderOnlyInRenderTargetTextures: boolean;
  60790. private _scene;
  60791. private _vertexBuffers;
  60792. private _indexBuffer;
  60793. private _effect;
  60794. private _previousDefines;
  60795. /**
  60796. * An event triggered when the layer is disposed.
  60797. */
  60798. onDisposeObservable: Observable<Layer>;
  60799. private _onDisposeObserver;
  60800. /**
  60801. * Back compatibility with callback before the onDisposeObservable existed.
  60802. * The set callback will be triggered when the layer has been disposed.
  60803. */
  60804. set onDispose(callback: () => void);
  60805. /**
  60806. * An event triggered before rendering the scene
  60807. */
  60808. onBeforeRenderObservable: Observable<Layer>;
  60809. private _onBeforeRenderObserver;
  60810. /**
  60811. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60812. * The set callback will be triggered just before rendering the layer.
  60813. */
  60814. set onBeforeRender(callback: () => void);
  60815. /**
  60816. * An event triggered after rendering the scene
  60817. */
  60818. onAfterRenderObservable: Observable<Layer>;
  60819. private _onAfterRenderObserver;
  60820. /**
  60821. * Back compatibility with callback before the onAfterRenderObservable existed.
  60822. * The set callback will be triggered just after rendering the layer.
  60823. */
  60824. set onAfterRender(callback: () => void);
  60825. /**
  60826. * Instantiates a new layer.
  60827. * This represents a full screen 2d layer.
  60828. * This can be useful to display a picture in the background of your scene for instance.
  60829. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60830. * @param name Define the name of the layer in the scene
  60831. * @param imgUrl Define the url of the texture to display in the layer
  60832. * @param scene Define the scene the layer belongs to
  60833. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60834. * @param color Defines a color for the layer
  60835. */
  60836. constructor(
  60837. /**
  60838. * Define the name of the layer.
  60839. */
  60840. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60841. private _createIndexBuffer;
  60842. /** @hidden */
  60843. _rebuild(): void;
  60844. /**
  60845. * Renders the layer in the scene.
  60846. */
  60847. render(): void;
  60848. /**
  60849. * Disposes and releases the associated ressources.
  60850. */
  60851. dispose(): void;
  60852. }
  60853. }
  60854. declare module BABYLON {
  60855. /** @hidden */
  60856. export var lensFlarePixelShader: {
  60857. name: string;
  60858. shader: string;
  60859. };
  60860. }
  60861. declare module BABYLON {
  60862. /** @hidden */
  60863. export var lensFlareVertexShader: {
  60864. name: string;
  60865. shader: string;
  60866. };
  60867. }
  60868. declare module BABYLON {
  60869. /**
  60870. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60871. * It is usually composed of several `lensFlare`.
  60872. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60873. */
  60874. export class LensFlareSystem {
  60875. /**
  60876. * Define the name of the lens flare system
  60877. */
  60878. name: string;
  60879. /**
  60880. * List of lens flares used in this system.
  60881. */
  60882. lensFlares: LensFlare[];
  60883. /**
  60884. * Define a limit from the border the lens flare can be visible.
  60885. */
  60886. borderLimit: number;
  60887. /**
  60888. * Define a viewport border we do not want to see the lens flare in.
  60889. */
  60890. viewportBorder: number;
  60891. /**
  60892. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60893. */
  60894. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60895. /**
  60896. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60897. */
  60898. layerMask: number;
  60899. /**
  60900. * Define the id of the lens flare system in the scene.
  60901. * (equal to name by default)
  60902. */
  60903. id: string;
  60904. private _scene;
  60905. private _emitter;
  60906. private _vertexBuffers;
  60907. private _indexBuffer;
  60908. private _effect;
  60909. private _positionX;
  60910. private _positionY;
  60911. private _isEnabled;
  60912. /** @hidden */
  60913. static _SceneComponentInitialization: (scene: Scene) => void;
  60914. /**
  60915. * Instantiates a lens flare system.
  60916. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60917. * It is usually composed of several `lensFlare`.
  60918. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60919. * @param name Define the name of the lens flare system in the scene
  60920. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60921. * @param scene Define the scene the lens flare system belongs to
  60922. */
  60923. constructor(
  60924. /**
  60925. * Define the name of the lens flare system
  60926. */
  60927. name: string, emitter: any, scene: Scene);
  60928. /**
  60929. * Define if the lens flare system is enabled.
  60930. */
  60931. get isEnabled(): boolean;
  60932. set isEnabled(value: boolean);
  60933. /**
  60934. * Get the scene the effects belongs to.
  60935. * @returns the scene holding the lens flare system
  60936. */
  60937. getScene(): Scene;
  60938. /**
  60939. * Get 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. * @returns the emitter of the lens flare system
  60942. */
  60943. getEmitter(): any;
  60944. /**
  60945. * Set the emitter of the lens flare system.
  60946. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60947. * @param newEmitter Define the new emitter of the system
  60948. */
  60949. setEmitter(newEmitter: any): void;
  60950. /**
  60951. * Get the lens flare system emitter position.
  60952. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60953. * @returns the position
  60954. */
  60955. getEmitterPosition(): Vector3;
  60956. /**
  60957. * @hidden
  60958. */
  60959. computeEffectivePosition(globalViewport: Viewport): boolean;
  60960. /** @hidden */
  60961. _isVisible(): boolean;
  60962. /**
  60963. * @hidden
  60964. */
  60965. render(): boolean;
  60966. /**
  60967. * Dispose and release the lens flare with its associated resources.
  60968. */
  60969. dispose(): void;
  60970. /**
  60971. * Parse a lens flare system from a JSON repressentation
  60972. * @param parsedLensFlareSystem Define the JSON to parse
  60973. * @param scene Define the scene the parsed system should be instantiated in
  60974. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60975. * @returns the parsed system
  60976. */
  60977. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60978. /**
  60979. * Serialize the current Lens Flare System into a JSON representation.
  60980. * @returns the serialized JSON
  60981. */
  60982. serialize(): any;
  60983. }
  60984. }
  60985. declare module BABYLON {
  60986. /**
  60987. * This represents one of the lens effect in a `lensFlareSystem`.
  60988. * It controls one of the indiviual texture used in the effect.
  60989. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60990. */
  60991. export class LensFlare {
  60992. /**
  60993. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60994. */
  60995. size: number;
  60996. /**
  60997. * 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.
  60998. */
  60999. position: number;
  61000. /**
  61001. * Define the lens color.
  61002. */
  61003. color: Color3;
  61004. /**
  61005. * Define the lens texture.
  61006. */
  61007. texture: Nullable<Texture>;
  61008. /**
  61009. * Define the alpha mode to render this particular lens.
  61010. */
  61011. alphaMode: number;
  61012. private _system;
  61013. /**
  61014. * Creates a new Lens Flare.
  61015. * This represents one of the lens effect in a `lensFlareSystem`.
  61016. * It controls one of the indiviual texture used in the effect.
  61017. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61018. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61019. * @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.
  61020. * @param color Define the lens color
  61021. * @param imgUrl Define the lens texture url
  61022. * @param system Define the `lensFlareSystem` this flare is part of
  61023. * @returns The newly created Lens Flare
  61024. */
  61025. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61026. /**
  61027. * Instantiates a new Lens Flare.
  61028. * This represents one of the lens effect in a `lensFlareSystem`.
  61029. * It controls one of the indiviual texture used in the effect.
  61030. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61031. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61032. * @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.
  61033. * @param color Define the lens color
  61034. * @param imgUrl Define the lens texture url
  61035. * @param system Define the `lensFlareSystem` this flare is part of
  61036. */
  61037. constructor(
  61038. /**
  61039. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61040. */
  61041. size: number,
  61042. /**
  61043. * 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.
  61044. */
  61045. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61046. /**
  61047. * Dispose and release the lens flare with its associated resources.
  61048. */
  61049. dispose(): void;
  61050. }
  61051. }
  61052. declare module BABYLON {
  61053. interface AbstractScene {
  61054. /**
  61055. * The list of lens flare system added to the scene
  61056. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61057. */
  61058. lensFlareSystems: Array<LensFlareSystem>;
  61059. /**
  61060. * Removes the given lens flare system from this scene.
  61061. * @param toRemove The lens flare system to remove
  61062. * @returns The index of the removed lens flare system
  61063. */
  61064. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61065. /**
  61066. * Adds the given lens flare system to this scene
  61067. * @param newLensFlareSystem The lens flare system to add
  61068. */
  61069. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61070. /**
  61071. * Gets a lens flare system using its name
  61072. * @param name defines the name to look for
  61073. * @returns the lens flare system or null if not found
  61074. */
  61075. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61076. /**
  61077. * Gets a lens flare system using its id
  61078. * @param id defines the id to look for
  61079. * @returns the lens flare system or null if not found
  61080. */
  61081. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61082. }
  61083. /**
  61084. * Defines the lens flare scene component responsible to manage any lens flares
  61085. * in a given scene.
  61086. */
  61087. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61088. /**
  61089. * The component name helpfull to identify the component in the list of scene components.
  61090. */
  61091. readonly name: string;
  61092. /**
  61093. * The scene the component belongs to.
  61094. */
  61095. scene: Scene;
  61096. /**
  61097. * Creates a new instance of the component for the given scene
  61098. * @param scene Defines the scene to register the component in
  61099. */
  61100. constructor(scene: Scene);
  61101. /**
  61102. * Registers the component in a given scene
  61103. */
  61104. register(): void;
  61105. /**
  61106. * Rebuilds the elements related to this component in case of
  61107. * context lost for instance.
  61108. */
  61109. rebuild(): void;
  61110. /**
  61111. * Adds all the elements from the container to the scene
  61112. * @param container the container holding the elements
  61113. */
  61114. addFromContainer(container: AbstractScene): void;
  61115. /**
  61116. * Removes all the elements in the container from the scene
  61117. * @param container contains the elements to remove
  61118. * @param dispose if the removed element should be disposed (default: false)
  61119. */
  61120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61121. /**
  61122. * Serializes the component data to the specified json object
  61123. * @param serializationObject The object to serialize to
  61124. */
  61125. serialize(serializationObject: any): void;
  61126. /**
  61127. * Disposes the component and the associated ressources.
  61128. */
  61129. dispose(): void;
  61130. private _draw;
  61131. }
  61132. }
  61133. declare module BABYLON {
  61134. /** @hidden */
  61135. export var depthPixelShader: {
  61136. name: string;
  61137. shader: string;
  61138. };
  61139. }
  61140. declare module BABYLON {
  61141. /** @hidden */
  61142. export var depthVertexShader: {
  61143. name: string;
  61144. shader: string;
  61145. };
  61146. }
  61147. declare module BABYLON {
  61148. /**
  61149. * This represents a depth renderer in Babylon.
  61150. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61151. */
  61152. export class DepthRenderer {
  61153. private _scene;
  61154. private _depthMap;
  61155. private _effect;
  61156. private readonly _storeNonLinearDepth;
  61157. private readonly _clearColor;
  61158. /** Get if the depth renderer is using packed depth or not */
  61159. readonly isPacked: boolean;
  61160. private _cachedDefines;
  61161. private _camera;
  61162. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61163. enabled: boolean;
  61164. /**
  61165. * Specifiess that the depth renderer will only be used within
  61166. * the camera it is created for.
  61167. * This can help forcing its rendering during the camera processing.
  61168. */
  61169. useOnlyInActiveCamera: boolean;
  61170. /** @hidden */
  61171. static _SceneComponentInitialization: (scene: Scene) => void;
  61172. /**
  61173. * Instantiates a depth renderer
  61174. * @param scene The scene the renderer belongs to
  61175. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61176. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61177. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61178. */
  61179. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61180. /**
  61181. * Creates the depth rendering effect and checks if the effect is ready.
  61182. * @param subMesh The submesh to be used to render the depth map of
  61183. * @param useInstances If multiple world instances should be used
  61184. * @returns if the depth renderer is ready to render the depth map
  61185. */
  61186. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61187. /**
  61188. * Gets the texture which the depth map will be written to.
  61189. * @returns The depth map texture
  61190. */
  61191. getDepthMap(): RenderTargetTexture;
  61192. /**
  61193. * Disposes of the depth renderer.
  61194. */
  61195. dispose(): void;
  61196. }
  61197. }
  61198. declare module BABYLON {
  61199. /** @hidden */
  61200. export var minmaxReduxPixelShader: {
  61201. name: string;
  61202. shader: string;
  61203. };
  61204. }
  61205. declare module BABYLON {
  61206. /**
  61207. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61208. * and maximum values from all values of the texture.
  61209. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61210. * The source values are read from the red channel of the texture.
  61211. */
  61212. export class MinMaxReducer {
  61213. /**
  61214. * Observable triggered when the computation has been performed
  61215. */
  61216. onAfterReductionPerformed: Observable<{
  61217. min: number;
  61218. max: number;
  61219. }>;
  61220. protected _camera: Camera;
  61221. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61222. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61223. protected _postProcessManager: PostProcessManager;
  61224. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61225. protected _forceFullscreenViewport: boolean;
  61226. /**
  61227. * Creates a min/max reducer
  61228. * @param camera The camera to use for the post processes
  61229. */
  61230. constructor(camera: Camera);
  61231. /**
  61232. * Gets the texture used to read the values from.
  61233. */
  61234. get sourceTexture(): Nullable<RenderTargetTexture>;
  61235. /**
  61236. * Sets the source texture to read the values from.
  61237. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61238. * because in such textures '1' value must not be taken into account to compute the maximum
  61239. * as this value is used to clear the texture.
  61240. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61241. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61242. * @param depthRedux Indicates if the texture is a depth texture or not
  61243. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61244. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61245. */
  61246. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61247. /**
  61248. * Defines the refresh rate of the computation.
  61249. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61250. */
  61251. get refreshRate(): number;
  61252. set refreshRate(value: number);
  61253. protected _activated: boolean;
  61254. /**
  61255. * Gets the activation status of the reducer
  61256. */
  61257. get activated(): boolean;
  61258. /**
  61259. * Activates the reduction computation.
  61260. * When activated, the observers registered in onAfterReductionPerformed are
  61261. * called after the compuation is performed
  61262. */
  61263. activate(): void;
  61264. /**
  61265. * Deactivates the reduction computation.
  61266. */
  61267. deactivate(): void;
  61268. /**
  61269. * Disposes the min/max reducer
  61270. * @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.
  61271. */
  61272. dispose(disposeAll?: boolean): void;
  61273. }
  61274. }
  61275. declare module BABYLON {
  61276. /**
  61277. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61278. */
  61279. export class DepthReducer extends MinMaxReducer {
  61280. private _depthRenderer;
  61281. private _depthRendererId;
  61282. /**
  61283. * Gets the depth renderer used for the computation.
  61284. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61285. */
  61286. get depthRenderer(): Nullable<DepthRenderer>;
  61287. /**
  61288. * Creates a depth reducer
  61289. * @param camera The camera used to render the depth texture
  61290. */
  61291. constructor(camera: Camera);
  61292. /**
  61293. * Sets the depth renderer to use to generate the depth map
  61294. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61295. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61296. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61297. */
  61298. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61299. /** @hidden */
  61300. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61301. /**
  61302. * Activates the reduction computation.
  61303. * When activated, the observers registered in onAfterReductionPerformed are
  61304. * called after the compuation is performed
  61305. */
  61306. activate(): void;
  61307. /**
  61308. * Deactivates the reduction computation.
  61309. */
  61310. deactivate(): void;
  61311. /**
  61312. * Disposes the depth reducer
  61313. * @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.
  61314. */
  61315. dispose(disposeAll?: boolean): void;
  61316. }
  61317. }
  61318. declare module BABYLON {
  61319. /**
  61320. * A CSM implementation allowing casting shadows on large scenes.
  61321. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61322. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61323. */
  61324. export class CascadedShadowGenerator extends ShadowGenerator {
  61325. private static readonly frustumCornersNDCSpace;
  61326. /**
  61327. * Name of the CSM class
  61328. */
  61329. static CLASSNAME: string;
  61330. /**
  61331. * Defines the default number of cascades used by the CSM.
  61332. */
  61333. static readonly DEFAULT_CASCADES_COUNT: number;
  61334. /**
  61335. * Defines the minimum number of cascades used by the CSM.
  61336. */
  61337. static readonly MIN_CASCADES_COUNT: number;
  61338. /**
  61339. * Defines the maximum number of cascades used by the CSM.
  61340. */
  61341. static readonly MAX_CASCADES_COUNT: number;
  61342. protected _validateFilter(filter: number): number;
  61343. /**
  61344. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61345. */
  61346. penumbraDarkness: number;
  61347. private _numCascades;
  61348. /**
  61349. * Gets or set the number of cascades used by the CSM.
  61350. */
  61351. get numCascades(): number;
  61352. set numCascades(value: number);
  61353. /**
  61354. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61355. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61356. */
  61357. stabilizeCascades: boolean;
  61358. private _freezeShadowCastersBoundingInfo;
  61359. private _freezeShadowCastersBoundingInfoObservable;
  61360. /**
  61361. * Enables or disables the shadow casters bounding info computation.
  61362. * If your shadow casters don't move, you can disable this feature.
  61363. * If it is enabled, the bounding box computation is done every frame.
  61364. */
  61365. get freezeShadowCastersBoundingInfo(): boolean;
  61366. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61367. private _scbiMin;
  61368. private _scbiMax;
  61369. protected _computeShadowCastersBoundingInfo(): void;
  61370. protected _shadowCastersBoundingInfo: BoundingInfo;
  61371. /**
  61372. * Gets or sets the shadow casters bounding info.
  61373. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61374. * so that the system won't overwrite the bounds you provide
  61375. */
  61376. get shadowCastersBoundingInfo(): BoundingInfo;
  61377. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61378. protected _breaksAreDirty: boolean;
  61379. protected _minDistance: number;
  61380. protected _maxDistance: number;
  61381. /**
  61382. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61383. *
  61384. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61385. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61386. * @param min minimal distance for the breaks (default to 0.)
  61387. * @param max maximal distance for the breaks (default to 1.)
  61388. */
  61389. setMinMaxDistance(min: number, max: number): void;
  61390. /** Gets the minimal distance used in the cascade break computation */
  61391. get minDistance(): number;
  61392. /** Gets the maximal distance used in the cascade break computation */
  61393. get maxDistance(): number;
  61394. /**
  61395. * Gets the class name of that object
  61396. * @returns "CascadedShadowGenerator"
  61397. */
  61398. getClassName(): string;
  61399. private _cascadeMinExtents;
  61400. private _cascadeMaxExtents;
  61401. /**
  61402. * Gets a cascade minimum extents
  61403. * @param cascadeIndex index of the cascade
  61404. * @returns the minimum cascade extents
  61405. */
  61406. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61407. /**
  61408. * Gets a cascade maximum extents
  61409. * @param cascadeIndex index of the cascade
  61410. * @returns the maximum cascade extents
  61411. */
  61412. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61413. private _cascades;
  61414. private _currentLayer;
  61415. private _viewSpaceFrustumsZ;
  61416. private _viewMatrices;
  61417. private _projectionMatrices;
  61418. private _transformMatrices;
  61419. private _transformMatricesAsArray;
  61420. private _frustumLengths;
  61421. private _lightSizeUVCorrection;
  61422. private _depthCorrection;
  61423. private _frustumCornersWorldSpace;
  61424. private _frustumCenter;
  61425. private _shadowCameraPos;
  61426. private _shadowMaxZ;
  61427. /**
  61428. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61429. * It defaults to camera.maxZ
  61430. */
  61431. get shadowMaxZ(): number;
  61432. /**
  61433. * Sets the shadow max z distance.
  61434. */
  61435. set shadowMaxZ(value: number);
  61436. protected _debug: boolean;
  61437. /**
  61438. * Gets or sets the debug flag.
  61439. * When enabled, the cascades are materialized by different colors on the screen.
  61440. */
  61441. get debug(): boolean;
  61442. set debug(dbg: boolean);
  61443. private _depthClamp;
  61444. /**
  61445. * Gets or sets the depth clamping value.
  61446. *
  61447. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61448. * to account for the shadow casters far away.
  61449. *
  61450. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61451. */
  61452. get depthClamp(): boolean;
  61453. set depthClamp(value: boolean);
  61454. private _cascadeBlendPercentage;
  61455. /**
  61456. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61457. * It defaults to 0.1 (10% blending).
  61458. */
  61459. get cascadeBlendPercentage(): number;
  61460. set cascadeBlendPercentage(value: number);
  61461. private _lambda;
  61462. /**
  61463. * Gets or set the lambda parameter.
  61464. * This parameter is used to split the camera frustum and create the cascades.
  61465. * 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.
  61466. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61467. */
  61468. get lambda(): number;
  61469. set lambda(value: number);
  61470. /**
  61471. * Gets the view matrix corresponding to a given cascade
  61472. * @param cascadeNum cascade to retrieve the view matrix from
  61473. * @returns the cascade view matrix
  61474. */
  61475. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61476. /**
  61477. * Gets the projection matrix corresponding to a given cascade
  61478. * @param cascadeNum cascade to retrieve the projection matrix from
  61479. * @returns the cascade projection matrix
  61480. */
  61481. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61482. /**
  61483. * Gets the transformation matrix corresponding to a given cascade
  61484. * @param cascadeNum cascade to retrieve the transformation matrix from
  61485. * @returns the cascade transformation matrix
  61486. */
  61487. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61488. private _depthRenderer;
  61489. /**
  61490. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61491. *
  61492. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61493. *
  61494. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61495. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61496. * @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
  61497. */
  61498. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61499. private _depthReducer;
  61500. private _autoCalcDepthBounds;
  61501. /**
  61502. * Gets or sets the autoCalcDepthBounds property.
  61503. *
  61504. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61505. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61506. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61507. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61508. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61509. */
  61510. get autoCalcDepthBounds(): boolean;
  61511. set autoCalcDepthBounds(value: boolean);
  61512. /**
  61513. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61514. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61515. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61516. * for setting the refresh rate on the renderer yourself!
  61517. */
  61518. get autoCalcDepthBoundsRefreshRate(): number;
  61519. set autoCalcDepthBoundsRefreshRate(value: number);
  61520. /**
  61521. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61522. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61523. * you change the camera near/far planes!
  61524. */
  61525. splitFrustum(): void;
  61526. private _splitFrustum;
  61527. private _computeMatrices;
  61528. private _computeFrustumInWorldSpace;
  61529. private _computeCascadeFrustum;
  61530. /**
  61531. * Support test.
  61532. */
  61533. static get IsSupported(): boolean;
  61534. /** @hidden */
  61535. static _SceneComponentInitialization: (scene: Scene) => void;
  61536. /**
  61537. * Creates a Cascaded Shadow Generator object.
  61538. * A ShadowGenerator is the required tool to use the shadows.
  61539. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61540. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61541. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61542. * @param light The directional light object generating the shadows.
  61543. * @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.
  61544. */
  61545. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61546. protected _initializeGenerator(): void;
  61547. protected _createTargetRenderTexture(): void;
  61548. protected _initializeShadowMap(): void;
  61549. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61550. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61551. /**
  61552. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61553. * @param defines Defines of the material we want to update
  61554. * @param lightIndex Index of the light in the enabled light list of the material
  61555. */
  61556. prepareDefines(defines: any, lightIndex: number): void;
  61557. /**
  61558. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61559. * defined in the generator but impacting the effect).
  61560. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61561. * @param effect The effect we are binfing the information for
  61562. */
  61563. bindShadowLight(lightIndex: string, effect: Effect): void;
  61564. /**
  61565. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61566. * (eq to view projection * shadow projection matrices)
  61567. * @returns The transform matrix used to create the shadow map
  61568. */
  61569. getTransformMatrix(): Matrix;
  61570. /**
  61571. * Disposes the ShadowGenerator.
  61572. * Returns nothing.
  61573. */
  61574. dispose(): void;
  61575. /**
  61576. * Serializes the shadow generator setup to a json object.
  61577. * @returns The serialized JSON object
  61578. */
  61579. serialize(): any;
  61580. /**
  61581. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61582. * @param parsedShadowGenerator The JSON object to parse
  61583. * @param scene The scene to create the shadow map for
  61584. * @returns The parsed shadow generator
  61585. */
  61586. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61587. }
  61588. }
  61589. declare module BABYLON {
  61590. /**
  61591. * Defines the shadow generator component responsible to manage any shadow generators
  61592. * in a given scene.
  61593. */
  61594. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61595. /**
  61596. * The component name helpfull to identify the component in the list of scene components.
  61597. */
  61598. readonly name: string;
  61599. /**
  61600. * The scene the component belongs to.
  61601. */
  61602. scene: Scene;
  61603. /**
  61604. * Creates a new instance of the component for the given scene
  61605. * @param scene Defines the scene to register the component in
  61606. */
  61607. constructor(scene: Scene);
  61608. /**
  61609. * Registers the component in a given scene
  61610. */
  61611. register(): void;
  61612. /**
  61613. * Rebuilds the elements related to this component in case of
  61614. * context lost for instance.
  61615. */
  61616. rebuild(): void;
  61617. /**
  61618. * Serializes the component data to the specified json object
  61619. * @param serializationObject The object to serialize to
  61620. */
  61621. serialize(serializationObject: any): void;
  61622. /**
  61623. * Adds all the elements from the container to the scene
  61624. * @param container the container holding the elements
  61625. */
  61626. addFromContainer(container: AbstractScene): void;
  61627. /**
  61628. * Removes all the elements in the container from the scene
  61629. * @param container contains the elements to remove
  61630. * @param dispose if the removed element should be disposed (default: false)
  61631. */
  61632. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61633. /**
  61634. * Rebuilds the elements related to this component in case of
  61635. * context lost for instance.
  61636. */
  61637. dispose(): void;
  61638. private _gatherRenderTargets;
  61639. }
  61640. }
  61641. declare module BABYLON {
  61642. /**
  61643. * A point light is a light defined by an unique point in world space.
  61644. * The light is emitted in every direction from this point.
  61645. * A good example of a point light is a standard light bulb.
  61646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61647. */
  61648. export class PointLight extends ShadowLight {
  61649. private _shadowAngle;
  61650. /**
  61651. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61652. * This specifies what angle the shadow will use to be created.
  61653. *
  61654. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61655. */
  61656. get shadowAngle(): number;
  61657. /**
  61658. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61659. * This specifies what angle the shadow will use to be created.
  61660. *
  61661. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61662. */
  61663. set shadowAngle(value: number);
  61664. /**
  61665. * Gets the direction if it has been set.
  61666. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61667. */
  61668. get direction(): Vector3;
  61669. /**
  61670. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61671. */
  61672. set direction(value: Vector3);
  61673. /**
  61674. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61675. * A PointLight emits the light in every direction.
  61676. * It can cast shadows.
  61677. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61678. * ```javascript
  61679. * var pointLight = new PointLight("pl", camera.position, scene);
  61680. * ```
  61681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61682. * @param name The light friendly name
  61683. * @param position The position of the point light in the scene
  61684. * @param scene The scene the lights belongs to
  61685. */
  61686. constructor(name: string, position: Vector3, scene: Scene);
  61687. /**
  61688. * Returns the string "PointLight"
  61689. * @returns the class name
  61690. */
  61691. getClassName(): string;
  61692. /**
  61693. * Returns the integer 0.
  61694. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61695. */
  61696. getTypeID(): number;
  61697. /**
  61698. * Specifies wether or not the shadowmap should be a cube texture.
  61699. * @returns true if the shadowmap needs to be a cube texture.
  61700. */
  61701. needCube(): boolean;
  61702. /**
  61703. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61706. */
  61707. getShadowDirection(faceIndex?: number): Vector3;
  61708. /**
  61709. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61710. * - fov = PI / 2
  61711. * - aspect ratio : 1.0
  61712. * - z-near and far equal to the active camera minZ and maxZ.
  61713. * Returns the PointLight.
  61714. */
  61715. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61716. protected _buildUniformLayout(): void;
  61717. /**
  61718. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61719. * @param effect The effect to update
  61720. * @param lightIndex The index of the light in the effect to update
  61721. * @returns The point light
  61722. */
  61723. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61725. /**
  61726. * Prepares the list of defines specific to the light type.
  61727. * @param defines the list of defines
  61728. * @param lightIndex defines the index of the light for the effect
  61729. */
  61730. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61731. }
  61732. }
  61733. declare module BABYLON {
  61734. /**
  61735. * Header information of HDR texture files.
  61736. */
  61737. export interface HDRInfo {
  61738. /**
  61739. * The height of the texture in pixels.
  61740. */
  61741. height: number;
  61742. /**
  61743. * The width of the texture in pixels.
  61744. */
  61745. width: number;
  61746. /**
  61747. * The index of the beginning of the data in the binary file.
  61748. */
  61749. dataPosition: number;
  61750. }
  61751. /**
  61752. * This groups tools to convert HDR texture to native colors array.
  61753. */
  61754. export class HDRTools {
  61755. private static Ldexp;
  61756. private static Rgbe2float;
  61757. private static readStringLine;
  61758. /**
  61759. * Reads header information from an RGBE texture stored in a native array.
  61760. * More information on this format are available here:
  61761. * https://en.wikipedia.org/wiki/RGBE_image_format
  61762. *
  61763. * @param uint8array The binary file stored in native array.
  61764. * @return The header information.
  61765. */
  61766. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61767. /**
  61768. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61769. * This RGBE texture needs to store the information as a panorama.
  61770. *
  61771. * More information on this format are available here:
  61772. * https://en.wikipedia.org/wiki/RGBE_image_format
  61773. *
  61774. * @param buffer The binary file stored in an array buffer.
  61775. * @param size The expected size of the extracted cubemap.
  61776. * @return The Cube Map information.
  61777. */
  61778. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61779. /**
  61780. * Returns the pixels data extracted from an RGBE texture.
  61781. * This pixels will be stored left to right up to down in the R G B order in one array.
  61782. *
  61783. * More information on this format are available here:
  61784. * https://en.wikipedia.org/wiki/RGBE_image_format
  61785. *
  61786. * @param uint8array The binary file stored in an array buffer.
  61787. * @param hdrInfo The header information of the file.
  61788. * @return The pixels data in RGB right to left up to down order.
  61789. */
  61790. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61791. private static RGBE_ReadPixels_RLE;
  61792. private static RGBE_ReadPixels_NOT_RLE;
  61793. }
  61794. }
  61795. declare module BABYLON {
  61796. /**
  61797. * Effect Render Options
  61798. */
  61799. export interface IEffectRendererOptions {
  61800. /**
  61801. * Defines the vertices positions.
  61802. */
  61803. positions?: number[];
  61804. /**
  61805. * Defines the indices.
  61806. */
  61807. indices?: number[];
  61808. }
  61809. /**
  61810. * Helper class to render one or more effects.
  61811. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61812. */
  61813. export class EffectRenderer {
  61814. private engine;
  61815. private static _DefaultOptions;
  61816. private _vertexBuffers;
  61817. private _indexBuffer;
  61818. private _fullscreenViewport;
  61819. /**
  61820. * Creates an effect renderer
  61821. * @param engine the engine to use for rendering
  61822. * @param options defines the options of the effect renderer
  61823. */
  61824. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61825. /**
  61826. * Sets the current viewport in normalized coordinates 0-1
  61827. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61828. */
  61829. setViewport(viewport?: Viewport): void;
  61830. /**
  61831. * Binds the embedded attributes buffer to the effect.
  61832. * @param effect Defines the effect to bind the attributes for
  61833. */
  61834. bindBuffers(effect: Effect): void;
  61835. /**
  61836. * Sets the current effect wrapper to use during draw.
  61837. * The effect needs to be ready before calling this api.
  61838. * This also sets the default full screen position attribute.
  61839. * @param effectWrapper Defines the effect to draw with
  61840. */
  61841. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61842. /**
  61843. * Restores engine states
  61844. */
  61845. restoreStates(): void;
  61846. /**
  61847. * Draws a full screen quad.
  61848. */
  61849. draw(): void;
  61850. private isRenderTargetTexture;
  61851. /**
  61852. * renders one or more effects to a specified texture
  61853. * @param effectWrapper the effect to renderer
  61854. * @param outputTexture texture to draw to, if null it will render to the screen.
  61855. */
  61856. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61857. /**
  61858. * Disposes of the effect renderer
  61859. */
  61860. dispose(): void;
  61861. }
  61862. /**
  61863. * Options to create an EffectWrapper
  61864. */
  61865. interface EffectWrapperCreationOptions {
  61866. /**
  61867. * Engine to use to create the effect
  61868. */
  61869. engine: ThinEngine;
  61870. /**
  61871. * Fragment shader for the effect
  61872. */
  61873. fragmentShader: string;
  61874. /**
  61875. * Use the shader store instead of direct source code
  61876. */
  61877. useShaderStore?: boolean;
  61878. /**
  61879. * Vertex shader for the effect
  61880. */
  61881. vertexShader?: string;
  61882. /**
  61883. * Attributes to use in the shader
  61884. */
  61885. attributeNames?: Array<string>;
  61886. /**
  61887. * Uniforms to use in the shader
  61888. */
  61889. uniformNames?: Array<string>;
  61890. /**
  61891. * Texture sampler names to use in the shader
  61892. */
  61893. samplerNames?: Array<string>;
  61894. /**
  61895. * Defines to use in the shader
  61896. */
  61897. defines?: Array<string>;
  61898. /**
  61899. * Callback when effect is compiled
  61900. */
  61901. onCompiled?: Nullable<(effect: Effect) => void>;
  61902. /**
  61903. * The friendly name of the effect displayed in Spector.
  61904. */
  61905. name?: string;
  61906. }
  61907. /**
  61908. * Wraps an effect to be used for rendering
  61909. */
  61910. export class EffectWrapper {
  61911. /**
  61912. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61913. */
  61914. onApplyObservable: Observable<{}>;
  61915. /**
  61916. * The underlying effect
  61917. */
  61918. effect: Effect;
  61919. /**
  61920. * Creates an effect to be renderer
  61921. * @param creationOptions options to create the effect
  61922. */
  61923. constructor(creationOptions: EffectWrapperCreationOptions);
  61924. /**
  61925. * Disposes of the effect wrapper
  61926. */
  61927. dispose(): void;
  61928. }
  61929. }
  61930. declare module BABYLON {
  61931. /** @hidden */
  61932. export var hdrFilteringVertexShader: {
  61933. name: string;
  61934. shader: string;
  61935. };
  61936. }
  61937. declare module BABYLON {
  61938. /** @hidden */
  61939. export var hdrFilteringPixelShader: {
  61940. name: string;
  61941. shader: string;
  61942. };
  61943. }
  61944. declare module BABYLON {
  61945. /**
  61946. * Options for texture filtering
  61947. */
  61948. interface IHDRFilteringOptions {
  61949. /**
  61950. * Scales pixel intensity for the input HDR map.
  61951. */
  61952. hdrScale?: number;
  61953. /**
  61954. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61955. */
  61956. quality?: number;
  61957. }
  61958. /**
  61959. * Filters HDR maps to get correct renderings of PBR reflections
  61960. */
  61961. export class HDRFiltering {
  61962. private _engine;
  61963. private _effectRenderer;
  61964. private _effectWrapper;
  61965. private _lodGenerationOffset;
  61966. private _lodGenerationScale;
  61967. /**
  61968. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61969. * you care about baking speed.
  61970. */
  61971. quality: number;
  61972. /**
  61973. * Scales pixel intensity for the input HDR map.
  61974. */
  61975. hdrScale: number;
  61976. /**
  61977. * Instantiates HDR filter for reflection maps
  61978. *
  61979. * @param engine Thin engine
  61980. * @param options Options
  61981. */
  61982. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61983. private _createRenderTarget;
  61984. private _prefilterInternal;
  61985. private _createEffect;
  61986. /**
  61987. * Get a value indicating if the filter is ready to be used
  61988. * @param texture Texture to filter
  61989. * @returns true if the filter is ready
  61990. */
  61991. isReady(texture: BaseTexture): boolean;
  61992. /**
  61993. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61994. * Prefiltering will be invoked at the end of next rendering pass.
  61995. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61996. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61997. * @param texture Texture to filter
  61998. * @param onFinished Callback when filtering is done
  61999. * @return Promise called when prefiltering is done
  62000. */
  62001. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62002. }
  62003. }
  62004. declare module BABYLON {
  62005. /**
  62006. * This represents a texture coming from an HDR input.
  62007. *
  62008. * The only supported format is currently panorama picture stored in RGBE format.
  62009. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62010. */
  62011. export class HDRCubeTexture extends BaseTexture {
  62012. private static _facesMapping;
  62013. private _generateHarmonics;
  62014. private _noMipmap;
  62015. private _prefilterOnLoad;
  62016. private _textureMatrix;
  62017. private _size;
  62018. private _onLoad;
  62019. private _onError;
  62020. /**
  62021. * The texture URL.
  62022. */
  62023. url: string;
  62024. protected _isBlocking: boolean;
  62025. /**
  62026. * Sets wether or not the texture is blocking during loading.
  62027. */
  62028. set isBlocking(value: boolean);
  62029. /**
  62030. * Gets wether or not the texture is blocking during loading.
  62031. */
  62032. get isBlocking(): boolean;
  62033. protected _rotationY: number;
  62034. /**
  62035. * Sets texture matrix rotation angle around Y axis in radians.
  62036. */
  62037. set rotationY(value: number);
  62038. /**
  62039. * Gets texture matrix rotation angle around Y axis radians.
  62040. */
  62041. get rotationY(): number;
  62042. /**
  62043. * Gets or sets the center of the bounding box associated with the cube texture
  62044. * It must define where the camera used to render the texture was set
  62045. */
  62046. boundingBoxPosition: Vector3;
  62047. private _boundingBoxSize;
  62048. /**
  62049. * Gets or sets the size of the bounding box associated with the cube texture
  62050. * When defined, the cubemap will switch to local mode
  62051. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62052. * @example https://www.babylonjs-playground.com/#RNASML
  62053. */
  62054. set boundingBoxSize(value: Vector3);
  62055. get boundingBoxSize(): Vector3;
  62056. /**
  62057. * Instantiates an HDRTexture from the following parameters.
  62058. *
  62059. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62060. * @param sceneOrEngine The scene or engine the texture will be used in
  62061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62062. * @param noMipmap Forces to not generate the mipmap if true
  62063. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62064. * @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)
  62065. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62066. */
  62067. 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>);
  62068. /**
  62069. * Get the current class name of the texture useful for serialization or dynamic coding.
  62070. * @returns "HDRCubeTexture"
  62071. */
  62072. getClassName(): string;
  62073. /**
  62074. * Occurs when the file is raw .hdr file.
  62075. */
  62076. private loadTexture;
  62077. clone(): HDRCubeTexture;
  62078. delayLoad(): void;
  62079. /**
  62080. * Get the texture reflection matrix used to rotate/transform the reflection.
  62081. * @returns the reflection matrix
  62082. */
  62083. getReflectionTextureMatrix(): Matrix;
  62084. /**
  62085. * Set the texture reflection matrix used to rotate/transform the reflection.
  62086. * @param value Define the reflection matrix to set
  62087. */
  62088. setReflectionTextureMatrix(value: Matrix): void;
  62089. /**
  62090. * Parses a JSON representation of an HDR Texture in order to create the texture
  62091. * @param parsedTexture Define the JSON representation
  62092. * @param scene Define the scene the texture should be created in
  62093. * @param rootUrl Define the root url in case we need to load relative dependencies
  62094. * @returns the newly created texture after parsing
  62095. */
  62096. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62097. serialize(): any;
  62098. }
  62099. }
  62100. declare module BABYLON {
  62101. /**
  62102. * Class used to control physics engine
  62103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62104. */
  62105. export class PhysicsEngine implements IPhysicsEngine {
  62106. private _physicsPlugin;
  62107. /**
  62108. * Global value used to control the smallest number supported by the simulation
  62109. */
  62110. static Epsilon: number;
  62111. private _impostors;
  62112. private _joints;
  62113. private _subTimeStep;
  62114. /**
  62115. * Gets the gravity vector used by the simulation
  62116. */
  62117. gravity: Vector3;
  62118. /**
  62119. * Factory used to create the default physics plugin.
  62120. * @returns The default physics plugin
  62121. */
  62122. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62123. /**
  62124. * Creates a new Physics Engine
  62125. * @param gravity defines the gravity vector used by the simulation
  62126. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62127. */
  62128. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62129. /**
  62130. * Sets the gravity vector used by the simulation
  62131. * @param gravity defines the gravity vector to use
  62132. */
  62133. setGravity(gravity: Vector3): void;
  62134. /**
  62135. * Set the time step of the physics engine.
  62136. * Default is 1/60.
  62137. * To slow it down, enter 1/600 for example.
  62138. * To speed it up, 1/30
  62139. * @param newTimeStep defines the new timestep to apply to this world.
  62140. */
  62141. setTimeStep(newTimeStep?: number): void;
  62142. /**
  62143. * Get the time step of the physics engine.
  62144. * @returns the current time step
  62145. */
  62146. getTimeStep(): number;
  62147. /**
  62148. * Set the sub time step of the physics engine.
  62149. * Default is 0 meaning there is no sub steps
  62150. * To increase physics resolution precision, set a small value (like 1 ms)
  62151. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62152. */
  62153. setSubTimeStep(subTimeStep?: number): void;
  62154. /**
  62155. * Get the sub time step of the physics engine.
  62156. * @returns the current sub time step
  62157. */
  62158. getSubTimeStep(): number;
  62159. /**
  62160. * Release all resources
  62161. */
  62162. dispose(): void;
  62163. /**
  62164. * Gets the name of the current physics plugin
  62165. * @returns the name of the plugin
  62166. */
  62167. getPhysicsPluginName(): string;
  62168. /**
  62169. * Adding a new impostor for the impostor tracking.
  62170. * This will be done by the impostor itself.
  62171. * @param impostor the impostor to add
  62172. */
  62173. addImpostor(impostor: PhysicsImpostor): void;
  62174. /**
  62175. * Remove an impostor from the engine.
  62176. * This impostor and its mesh will not longer be updated by the physics engine.
  62177. * @param impostor the impostor to remove
  62178. */
  62179. removeImpostor(impostor: PhysicsImpostor): void;
  62180. /**
  62181. * Add a joint to the physics engine
  62182. * @param mainImpostor defines the main impostor to which the joint is added.
  62183. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62184. * @param joint defines the joint that will connect both impostors.
  62185. */
  62186. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62187. /**
  62188. * Removes a joint from the simulation
  62189. * @param mainImpostor defines the impostor used with the joint
  62190. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62191. * @param joint defines the joint to remove
  62192. */
  62193. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62194. /**
  62195. * Called by the scene. No need to call it.
  62196. * @param delta defines the timespam between frames
  62197. */
  62198. _step(delta: number): void;
  62199. /**
  62200. * Gets the current plugin used to run the simulation
  62201. * @returns current plugin
  62202. */
  62203. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62204. /**
  62205. * Gets the list of physic impostors
  62206. * @returns an array of PhysicsImpostor
  62207. */
  62208. getImpostors(): Array<PhysicsImpostor>;
  62209. /**
  62210. * Gets the impostor for a physics enabled object
  62211. * @param object defines the object impersonated by the impostor
  62212. * @returns the PhysicsImpostor or null if not found
  62213. */
  62214. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62215. /**
  62216. * Gets the impostor for a physics body object
  62217. * @param body defines physics body used by the impostor
  62218. * @returns the PhysicsImpostor or null if not found
  62219. */
  62220. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62221. /**
  62222. * Does a raycast in the physics world
  62223. * @param from when should the ray start?
  62224. * @param to when should the ray end?
  62225. * @returns PhysicsRaycastResult
  62226. */
  62227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /** @hidden */
  62232. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62233. private _useDeltaForWorldStep;
  62234. world: any;
  62235. name: string;
  62236. private _physicsMaterials;
  62237. private _fixedTimeStep;
  62238. private _cannonRaycastResult;
  62239. private _raycastResult;
  62240. private _physicsBodysToRemoveAfterStep;
  62241. private _firstFrame;
  62242. BJSCANNON: any;
  62243. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62244. setGravity(gravity: Vector3): void;
  62245. setTimeStep(timeStep: number): void;
  62246. getTimeStep(): number;
  62247. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62248. private _removeMarkedPhysicsBodiesFromWorld;
  62249. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62250. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62251. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62252. private _processChildMeshes;
  62253. removePhysicsBody(impostor: PhysicsImpostor): void;
  62254. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62255. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62256. private _addMaterial;
  62257. private _checkWithEpsilon;
  62258. private _createShape;
  62259. private _createHeightmap;
  62260. private _minus90X;
  62261. private _plus90X;
  62262. private _tmpPosition;
  62263. private _tmpDeltaPosition;
  62264. private _tmpUnityRotation;
  62265. private _updatePhysicsBodyTransformation;
  62266. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62267. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62268. isSupported(): boolean;
  62269. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62270. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62271. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62272. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62273. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62274. getBodyMass(impostor: PhysicsImpostor): number;
  62275. getBodyFriction(impostor: PhysicsImpostor): number;
  62276. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62277. getBodyRestitution(impostor: PhysicsImpostor): number;
  62278. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62279. sleepBody(impostor: PhysicsImpostor): void;
  62280. wakeUpBody(impostor: PhysicsImpostor): void;
  62281. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62282. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62283. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62284. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62285. getRadius(impostor: PhysicsImpostor): number;
  62286. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62287. dispose(): void;
  62288. private _extendNamespace;
  62289. /**
  62290. * Does a raycast in the physics world
  62291. * @param from when should the ray start?
  62292. * @param to when should the ray end?
  62293. * @returns PhysicsRaycastResult
  62294. */
  62295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62296. }
  62297. }
  62298. declare module BABYLON {
  62299. /** @hidden */
  62300. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62301. private _useDeltaForWorldStep;
  62302. world: any;
  62303. name: string;
  62304. BJSOIMO: any;
  62305. private _raycastResult;
  62306. private _fixedTimeStep;
  62307. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62308. setGravity(gravity: Vector3): void;
  62309. setTimeStep(timeStep: number): void;
  62310. getTimeStep(): number;
  62311. private _tmpImpostorsArray;
  62312. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62316. private _tmpPositionVector;
  62317. removePhysicsBody(impostor: PhysicsImpostor): void;
  62318. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62319. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62320. isSupported(): boolean;
  62321. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62322. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62323. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62324. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62325. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62326. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62327. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62328. getBodyMass(impostor: PhysicsImpostor): number;
  62329. getBodyFriction(impostor: PhysicsImpostor): number;
  62330. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62331. getBodyRestitution(impostor: PhysicsImpostor): number;
  62332. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62333. sleepBody(impostor: PhysicsImpostor): void;
  62334. wakeUpBody(impostor: PhysicsImpostor): void;
  62335. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62336. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62337. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62338. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62339. getRadius(impostor: PhysicsImpostor): number;
  62340. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62341. dispose(): void;
  62342. /**
  62343. * Does a raycast in the physics world
  62344. * @param from when should the ray start?
  62345. * @param to when should the ray end?
  62346. * @returns PhysicsRaycastResult
  62347. */
  62348. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62349. }
  62350. }
  62351. declare module BABYLON {
  62352. /**
  62353. * AmmoJS Physics plugin
  62354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62355. * @see https://github.com/kripken/ammo.js/
  62356. */
  62357. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62358. private _useDeltaForWorldStep;
  62359. /**
  62360. * Reference to the Ammo library
  62361. */
  62362. bjsAMMO: any;
  62363. /**
  62364. * Created ammoJS world which physics bodies are added to
  62365. */
  62366. world: any;
  62367. /**
  62368. * Name of the plugin
  62369. */
  62370. name: string;
  62371. private _timeStep;
  62372. private _fixedTimeStep;
  62373. private _maxSteps;
  62374. private _tmpQuaternion;
  62375. private _tmpAmmoTransform;
  62376. private _tmpAmmoQuaternion;
  62377. private _tmpAmmoConcreteContactResultCallback;
  62378. private _collisionConfiguration;
  62379. private _dispatcher;
  62380. private _overlappingPairCache;
  62381. private _solver;
  62382. private _softBodySolver;
  62383. private _tmpAmmoVectorA;
  62384. private _tmpAmmoVectorB;
  62385. private _tmpAmmoVectorC;
  62386. private _tmpAmmoVectorD;
  62387. private _tmpContactCallbackResult;
  62388. private _tmpAmmoVectorRCA;
  62389. private _tmpAmmoVectorRCB;
  62390. private _raycastResult;
  62391. private _tmpContactPoint;
  62392. private static readonly DISABLE_COLLISION_FLAG;
  62393. private static readonly KINEMATIC_FLAG;
  62394. private static readonly DISABLE_DEACTIVATION_FLAG;
  62395. /**
  62396. * Initializes the ammoJS plugin
  62397. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62398. * @param ammoInjection can be used to inject your own ammo reference
  62399. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62400. */
  62401. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62402. /**
  62403. * Sets the gravity of the physics world (m/(s^2))
  62404. * @param gravity Gravity to set
  62405. */
  62406. setGravity(gravity: Vector3): void;
  62407. /**
  62408. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62409. * @param timeStep timestep to use in seconds
  62410. */
  62411. setTimeStep(timeStep: number): void;
  62412. /**
  62413. * 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)
  62414. * @param fixedTimeStep fixedTimeStep to use in seconds
  62415. */
  62416. setFixedTimeStep(fixedTimeStep: number): void;
  62417. /**
  62418. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62419. * @param maxSteps the maximum number of steps by the physics engine per frame
  62420. */
  62421. setMaxSteps(maxSteps: number): void;
  62422. /**
  62423. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62424. * @returns the current timestep in seconds
  62425. */
  62426. getTimeStep(): number;
  62427. /**
  62428. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62429. */
  62430. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62431. private _isImpostorInContact;
  62432. private _isImpostorPairInContact;
  62433. private _stepSimulation;
  62434. /**
  62435. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62436. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62437. * After the step the babylon meshes are set to the position of the physics imposters
  62438. * @param delta amount of time to step forward
  62439. * @param impostors array of imposters to update before/after the step
  62440. */
  62441. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62442. /**
  62443. * Update babylon mesh to match physics world object
  62444. * @param impostor imposter to match
  62445. */
  62446. private _afterSoftStep;
  62447. /**
  62448. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62449. * @param impostor imposter to match
  62450. */
  62451. private _ropeStep;
  62452. /**
  62453. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62454. * @param impostor imposter to match
  62455. */
  62456. private _softbodyOrClothStep;
  62457. private _tmpMatrix;
  62458. /**
  62459. * Applies an impulse on the imposter
  62460. * @param impostor imposter to apply impulse to
  62461. * @param force amount of force to be applied to the imposter
  62462. * @param contactPoint the location to apply the impulse on the imposter
  62463. */
  62464. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62465. /**
  62466. * Applies a force on the imposter
  62467. * @param impostor imposter to apply force
  62468. * @param force amount of force to be applied to the imposter
  62469. * @param contactPoint the location to apply the force on the imposter
  62470. */
  62471. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62472. /**
  62473. * Creates a physics body using the plugin
  62474. * @param impostor the imposter to create the physics body on
  62475. */
  62476. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62477. /**
  62478. * Removes the physics body from the imposter and disposes of the body's memory
  62479. * @param impostor imposter to remove the physics body from
  62480. */
  62481. removePhysicsBody(impostor: PhysicsImpostor): void;
  62482. /**
  62483. * Generates a joint
  62484. * @param impostorJoint the imposter joint to create the joint with
  62485. */
  62486. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62487. /**
  62488. * Removes a joint
  62489. * @param impostorJoint the imposter joint to remove the joint from
  62490. */
  62491. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62492. private _addMeshVerts;
  62493. /**
  62494. * Initialise the soft body vertices to match its object's (mesh) vertices
  62495. * Softbody vertices (nodes) are in world space and to match this
  62496. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62497. * @param impostor to create the softbody for
  62498. */
  62499. private _softVertexData;
  62500. /**
  62501. * Create an impostor's soft body
  62502. * @param impostor to create the softbody for
  62503. */
  62504. private _createSoftbody;
  62505. /**
  62506. * Create cloth for an impostor
  62507. * @param impostor to create the softbody for
  62508. */
  62509. private _createCloth;
  62510. /**
  62511. * Create rope for an impostor
  62512. * @param impostor to create the softbody for
  62513. */
  62514. private _createRope;
  62515. /**
  62516. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62517. * @param impostor to create the custom physics shape for
  62518. */
  62519. private _createCustom;
  62520. private _addHullVerts;
  62521. private _createShape;
  62522. /**
  62523. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62524. * @param impostor imposter containing the physics body and babylon object
  62525. */
  62526. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62527. /**
  62528. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62529. * @param impostor imposter containing the physics body and babylon object
  62530. * @param newPosition new position
  62531. * @param newRotation new rotation
  62532. */
  62533. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62534. /**
  62535. * If this plugin is supported
  62536. * @returns true if its supported
  62537. */
  62538. isSupported(): boolean;
  62539. /**
  62540. * Sets the linear velocity of the physics body
  62541. * @param impostor imposter to set the velocity on
  62542. * @param velocity velocity to set
  62543. */
  62544. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62545. /**
  62546. * Sets the angular velocity of the physics body
  62547. * @param impostor imposter to set the velocity on
  62548. * @param velocity velocity to set
  62549. */
  62550. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62551. /**
  62552. * gets the linear velocity
  62553. * @param impostor imposter to get linear velocity from
  62554. * @returns linear velocity
  62555. */
  62556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62557. /**
  62558. * gets the angular velocity
  62559. * @param impostor imposter to get angular velocity from
  62560. * @returns angular velocity
  62561. */
  62562. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62563. /**
  62564. * Sets the mass of physics body
  62565. * @param impostor imposter to set the mass on
  62566. * @param mass mass to set
  62567. */
  62568. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62569. /**
  62570. * Gets the mass of the physics body
  62571. * @param impostor imposter to get the mass from
  62572. * @returns mass
  62573. */
  62574. getBodyMass(impostor: PhysicsImpostor): number;
  62575. /**
  62576. * Gets friction of the impostor
  62577. * @param impostor impostor to get friction from
  62578. * @returns friction value
  62579. */
  62580. getBodyFriction(impostor: PhysicsImpostor): number;
  62581. /**
  62582. * Sets friction of the impostor
  62583. * @param impostor impostor to set friction on
  62584. * @param friction friction value
  62585. */
  62586. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62587. /**
  62588. * Gets restitution of the impostor
  62589. * @param impostor impostor to get restitution from
  62590. * @returns restitution value
  62591. */
  62592. getBodyRestitution(impostor: PhysicsImpostor): number;
  62593. /**
  62594. * Sets resitution of the impostor
  62595. * @param impostor impostor to set resitution on
  62596. * @param restitution resitution value
  62597. */
  62598. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62599. /**
  62600. * Gets pressure inside the impostor
  62601. * @param impostor impostor to get pressure from
  62602. * @returns pressure value
  62603. */
  62604. getBodyPressure(impostor: PhysicsImpostor): number;
  62605. /**
  62606. * Sets pressure inside a soft body impostor
  62607. * Cloth and rope must remain 0 pressure
  62608. * @param impostor impostor to set pressure on
  62609. * @param pressure pressure value
  62610. */
  62611. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62612. /**
  62613. * Gets stiffness of the impostor
  62614. * @param impostor impostor to get stiffness from
  62615. * @returns pressure value
  62616. */
  62617. getBodyStiffness(impostor: PhysicsImpostor): number;
  62618. /**
  62619. * Sets stiffness of the impostor
  62620. * @param impostor impostor to set stiffness on
  62621. * @param stiffness stiffness value from 0 to 1
  62622. */
  62623. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62624. /**
  62625. * Gets velocityIterations of the impostor
  62626. * @param impostor impostor to get velocity iterations from
  62627. * @returns velocityIterations value
  62628. */
  62629. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62630. /**
  62631. * Sets velocityIterations of the impostor
  62632. * @param impostor impostor to set velocity iterations on
  62633. * @param velocityIterations velocityIterations value
  62634. */
  62635. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62636. /**
  62637. * Gets positionIterations of the impostor
  62638. * @param impostor impostor to get position iterations from
  62639. * @returns positionIterations value
  62640. */
  62641. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62642. /**
  62643. * Sets positionIterations of the impostor
  62644. * @param impostor impostor to set position on
  62645. * @param positionIterations positionIterations value
  62646. */
  62647. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62648. /**
  62649. * Append an anchor to a cloth object
  62650. * @param impostor is the cloth impostor to add anchor to
  62651. * @param otherImpostor is the rigid impostor to anchor to
  62652. * @param width ratio across width from 0 to 1
  62653. * @param height ratio up height from 0 to 1
  62654. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62655. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62656. */
  62657. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62658. /**
  62659. * Append an hook to a rope object
  62660. * @param impostor is the rope impostor to add hook to
  62661. * @param otherImpostor is the rigid impostor to hook to
  62662. * @param length ratio along the rope from 0 to 1
  62663. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62664. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62665. */
  62666. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62667. /**
  62668. * Sleeps the physics body and stops it from being active
  62669. * @param impostor impostor to sleep
  62670. */
  62671. sleepBody(impostor: PhysicsImpostor): void;
  62672. /**
  62673. * Activates the physics body
  62674. * @param impostor impostor to activate
  62675. */
  62676. wakeUpBody(impostor: PhysicsImpostor): void;
  62677. /**
  62678. * Updates the distance parameters of the joint
  62679. * @param joint joint to update
  62680. * @param maxDistance maximum distance of the joint
  62681. * @param minDistance minimum distance of the joint
  62682. */
  62683. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62684. /**
  62685. * Sets a motor on the joint
  62686. * @param joint joint to set motor on
  62687. * @param speed speed of the motor
  62688. * @param maxForce maximum force of the motor
  62689. * @param motorIndex index of the motor
  62690. */
  62691. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62692. /**
  62693. * Sets the motors limit
  62694. * @param joint joint to set limit on
  62695. * @param upperLimit upper limit
  62696. * @param lowerLimit lower limit
  62697. */
  62698. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62699. /**
  62700. * Syncs the position and rotation of a mesh with the impostor
  62701. * @param mesh mesh to sync
  62702. * @param impostor impostor to update the mesh with
  62703. */
  62704. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62705. /**
  62706. * Gets the radius of the impostor
  62707. * @param impostor impostor to get radius from
  62708. * @returns the radius
  62709. */
  62710. getRadius(impostor: PhysicsImpostor): number;
  62711. /**
  62712. * Gets the box size of the impostor
  62713. * @param impostor impostor to get box size from
  62714. * @param result the resulting box size
  62715. */
  62716. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62717. /**
  62718. * Disposes of the impostor
  62719. */
  62720. dispose(): void;
  62721. /**
  62722. * Does a raycast in the physics world
  62723. * @param from when should the ray start?
  62724. * @param to when should the ray end?
  62725. * @returns PhysicsRaycastResult
  62726. */
  62727. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. interface AbstractScene {
  62732. /**
  62733. * The list of reflection probes added to the scene
  62734. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62735. */
  62736. reflectionProbes: Array<ReflectionProbe>;
  62737. /**
  62738. * Removes the given reflection probe from this scene.
  62739. * @param toRemove The reflection probe to remove
  62740. * @returns The index of the removed reflection probe
  62741. */
  62742. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62743. /**
  62744. * Adds the given reflection probe to this scene.
  62745. * @param newReflectionProbe The reflection probe to add
  62746. */
  62747. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62748. }
  62749. /**
  62750. * Class used to generate realtime reflection / refraction cube textures
  62751. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62752. */
  62753. export class ReflectionProbe {
  62754. /** defines the name of the probe */
  62755. name: string;
  62756. private _scene;
  62757. private _renderTargetTexture;
  62758. private _projectionMatrix;
  62759. private _viewMatrix;
  62760. private _target;
  62761. private _add;
  62762. private _attachedMesh;
  62763. private _invertYAxis;
  62764. /** Gets or sets probe position (center of the cube map) */
  62765. position: Vector3;
  62766. /**
  62767. * Creates a new reflection probe
  62768. * @param name defines the name of the probe
  62769. * @param size defines the texture resolution (for each face)
  62770. * @param scene defines the hosting scene
  62771. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62772. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62773. */
  62774. constructor(
  62775. /** defines the name of the probe */
  62776. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62777. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62778. get samples(): number;
  62779. set samples(value: number);
  62780. /** Gets or sets the refresh rate to use (on every frame by default) */
  62781. get refreshRate(): number;
  62782. set refreshRate(value: number);
  62783. /**
  62784. * Gets the hosting scene
  62785. * @returns a Scene
  62786. */
  62787. getScene(): Scene;
  62788. /** Gets the internal CubeTexture used to render to */
  62789. get cubeTexture(): RenderTargetTexture;
  62790. /** Gets the list of meshes to render */
  62791. get renderList(): Nullable<AbstractMesh[]>;
  62792. /**
  62793. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62794. * @param mesh defines the mesh to attach to
  62795. */
  62796. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62797. /**
  62798. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62799. * @param renderingGroupId The rendering group id corresponding to its index
  62800. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62801. */
  62802. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62803. /**
  62804. * Clean all associated resources
  62805. */
  62806. dispose(): void;
  62807. /**
  62808. * Converts the reflection probe information to a readable string for debug purpose.
  62809. * @param fullDetails Supports for multiple levels of logging within scene loading
  62810. * @returns the human readable reflection probe info
  62811. */
  62812. toString(fullDetails?: boolean): string;
  62813. /**
  62814. * Get the class name of the relfection probe.
  62815. * @returns "ReflectionProbe"
  62816. */
  62817. getClassName(): string;
  62818. /**
  62819. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62820. * @returns The JSON representation of the texture
  62821. */
  62822. serialize(): any;
  62823. /**
  62824. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62825. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62826. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62827. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62828. * @returns The parsed reflection probe if successful
  62829. */
  62830. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62831. }
  62832. }
  62833. declare module BABYLON {
  62834. /** @hidden */
  62835. export var _BabylonLoaderRegistered: boolean;
  62836. /**
  62837. * Helps setting up some configuration for the babylon file loader.
  62838. */
  62839. export class BabylonFileLoaderConfiguration {
  62840. /**
  62841. * The loader does not allow injecting custom physix engine into the plugins.
  62842. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62843. * So you could set this variable to your engine import to make it work.
  62844. */
  62845. static LoaderInjectedPhysicsEngine: any;
  62846. }
  62847. }
  62848. declare module BABYLON {
  62849. /**
  62850. * A material to use for fast depth-only rendering.
  62851. */
  62852. export class OcclusionMaterial extends ShaderMaterial {
  62853. constructor(name: string, scene: Scene);
  62854. }
  62855. }
  62856. declare module BABYLON {
  62857. /**
  62858. * The Physically based simple base material of BJS.
  62859. *
  62860. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62861. * It is used as the base class for both the specGloss and metalRough conventions.
  62862. */
  62863. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62864. /**
  62865. * Number of Simultaneous lights allowed on the material.
  62866. */
  62867. maxSimultaneousLights: number;
  62868. /**
  62869. * If sets to true, disables all the lights affecting the material.
  62870. */
  62871. disableLighting: boolean;
  62872. /**
  62873. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62874. */
  62875. environmentTexture: BaseTexture;
  62876. /**
  62877. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62878. */
  62879. invertNormalMapX: boolean;
  62880. /**
  62881. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62882. */
  62883. invertNormalMapY: boolean;
  62884. /**
  62885. * Normal map used in the model.
  62886. */
  62887. normalTexture: BaseTexture;
  62888. /**
  62889. * Emissivie color used to self-illuminate the model.
  62890. */
  62891. emissiveColor: Color3;
  62892. /**
  62893. * Emissivie texture used to self-illuminate the model.
  62894. */
  62895. emissiveTexture: BaseTexture;
  62896. /**
  62897. * Occlusion Channel Strenght.
  62898. */
  62899. occlusionStrength: number;
  62900. /**
  62901. * Occlusion Texture of the material (adding extra occlusion effects).
  62902. */
  62903. occlusionTexture: BaseTexture;
  62904. /**
  62905. * Defines the alpha limits in alpha test mode.
  62906. */
  62907. alphaCutOff: number;
  62908. /**
  62909. * Gets the current double sided mode.
  62910. */
  62911. get doubleSided(): boolean;
  62912. /**
  62913. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62914. */
  62915. set doubleSided(value: boolean);
  62916. /**
  62917. * Stores the pre-calculated light information of a mesh in a texture.
  62918. */
  62919. lightmapTexture: BaseTexture;
  62920. /**
  62921. * If true, the light map contains occlusion information instead of lighting info.
  62922. */
  62923. useLightmapAsShadowmap: boolean;
  62924. /**
  62925. * Instantiates a new PBRMaterial instance.
  62926. *
  62927. * @param name The material name
  62928. * @param scene The scene the material will be use in.
  62929. */
  62930. constructor(name: string, scene: Scene);
  62931. getClassName(): string;
  62932. }
  62933. }
  62934. declare module BABYLON {
  62935. /**
  62936. * The PBR material of BJS following the metal roughness convention.
  62937. *
  62938. * This fits to the PBR convention in the GLTF definition:
  62939. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62940. */
  62941. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62942. /**
  62943. * The base color has two different interpretations depending on the value of metalness.
  62944. * When the material is a metal, the base color is the specific measured reflectance value
  62945. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62946. * of the material.
  62947. */
  62948. baseColor: Color3;
  62949. /**
  62950. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62951. * well as opacity information in the alpha channel.
  62952. */
  62953. baseTexture: BaseTexture;
  62954. /**
  62955. * Specifies the metallic scalar value of the material.
  62956. * Can also be used to scale the metalness values of the metallic texture.
  62957. */
  62958. metallic: number;
  62959. /**
  62960. * Specifies the roughness scalar value of the material.
  62961. * Can also be used to scale the roughness values of the metallic texture.
  62962. */
  62963. roughness: number;
  62964. /**
  62965. * Texture containing both the metallic value in the B channel and the
  62966. * roughness value in the G channel to keep better precision.
  62967. */
  62968. metallicRoughnessTexture: BaseTexture;
  62969. /**
  62970. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62971. *
  62972. * @param name The material name
  62973. * @param scene The scene the material will be use in.
  62974. */
  62975. constructor(name: string, scene: Scene);
  62976. /**
  62977. * Return the currrent class name of the material.
  62978. */
  62979. getClassName(): string;
  62980. /**
  62981. * Makes a duplicate of the current material.
  62982. * @param name - name to use for the new material.
  62983. */
  62984. clone(name: string): PBRMetallicRoughnessMaterial;
  62985. /**
  62986. * Serialize the material to a parsable JSON object.
  62987. */
  62988. serialize(): any;
  62989. /**
  62990. * Parses a JSON object correponding to the serialize function.
  62991. */
  62992. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /**
  62997. * The PBR material of BJS following the specular glossiness convention.
  62998. *
  62999. * This fits to the PBR convention in the GLTF definition:
  63000. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63001. */
  63002. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63003. /**
  63004. * Specifies the diffuse color of the material.
  63005. */
  63006. diffuseColor: Color3;
  63007. /**
  63008. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63009. * channel.
  63010. */
  63011. diffuseTexture: BaseTexture;
  63012. /**
  63013. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63014. */
  63015. specularColor: Color3;
  63016. /**
  63017. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63018. */
  63019. glossiness: number;
  63020. /**
  63021. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63022. */
  63023. specularGlossinessTexture: BaseTexture;
  63024. /**
  63025. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63026. *
  63027. * @param name The material name
  63028. * @param scene The scene the material will be use in.
  63029. */
  63030. constructor(name: string, scene: Scene);
  63031. /**
  63032. * Return the currrent class name of the material.
  63033. */
  63034. getClassName(): string;
  63035. /**
  63036. * Makes a duplicate of the current material.
  63037. * @param name - name to use for the new material.
  63038. */
  63039. clone(name: string): PBRSpecularGlossinessMaterial;
  63040. /**
  63041. * Serialize the material to a parsable JSON object.
  63042. */
  63043. serialize(): any;
  63044. /**
  63045. * Parses a JSON object correponding to the serialize function.
  63046. */
  63047. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63048. }
  63049. }
  63050. declare module BABYLON {
  63051. /**
  63052. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63053. * It can help converting any input color in a desired output one. This can then be used to create effects
  63054. * from sepia, black and white to sixties or futuristic rendering...
  63055. *
  63056. * The only supported format is currently 3dl.
  63057. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63058. */
  63059. export class ColorGradingTexture extends BaseTexture {
  63060. /**
  63061. * The texture URL.
  63062. */
  63063. url: string;
  63064. /**
  63065. * Empty line regex stored for GC.
  63066. */
  63067. private static _noneEmptyLineRegex;
  63068. private _textureMatrix;
  63069. private _onLoad;
  63070. /**
  63071. * Instantiates a ColorGradingTexture from the following parameters.
  63072. *
  63073. * @param url The location of the color gradind data (currently only supporting 3dl)
  63074. * @param sceneOrEngine The scene or engine the texture will be used in
  63075. * @param onLoad defines a callback triggered when the texture has been loaded
  63076. */
  63077. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63078. /**
  63079. * Fires the onload event from the constructor if requested.
  63080. */
  63081. private _triggerOnLoad;
  63082. /**
  63083. * Returns the texture matrix used in most of the material.
  63084. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63085. */
  63086. getTextureMatrix(): Matrix;
  63087. /**
  63088. * Occurs when the file being loaded is a .3dl LUT file.
  63089. */
  63090. private load3dlTexture;
  63091. /**
  63092. * Starts the loading process of the texture.
  63093. */
  63094. private loadTexture;
  63095. /**
  63096. * Clones the color gradind texture.
  63097. */
  63098. clone(): ColorGradingTexture;
  63099. /**
  63100. * Called during delayed load for textures.
  63101. */
  63102. delayLoad(): void;
  63103. /**
  63104. * Parses a color grading texture serialized by Babylon.
  63105. * @param parsedTexture The texture information being parsedTexture
  63106. * @param scene The scene to load the texture in
  63107. * @param rootUrl The root url of the data assets to load
  63108. * @return A color gradind texture
  63109. */
  63110. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63111. /**
  63112. * Serializes the LUT texture to json format.
  63113. */
  63114. serialize(): any;
  63115. }
  63116. }
  63117. declare module BABYLON {
  63118. /**
  63119. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63120. */
  63121. export class EquiRectangularCubeTexture extends BaseTexture {
  63122. /** The six faces of the cube. */
  63123. private static _FacesMapping;
  63124. private _noMipmap;
  63125. private _onLoad;
  63126. private _onError;
  63127. /** The size of the cubemap. */
  63128. private _size;
  63129. /** The buffer of the image. */
  63130. private _buffer;
  63131. /** The width of the input image. */
  63132. private _width;
  63133. /** The height of the input image. */
  63134. private _height;
  63135. /** The URL to the image. */
  63136. url: string;
  63137. /**
  63138. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63139. * @param url The location of the image
  63140. * @param scene The scene the texture will be used in
  63141. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63142. * @param noMipmap Forces to not generate the mipmap if true
  63143. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63144. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63145. * @param onLoad — defines a callback called when texture is loaded
  63146. * @param onError — defines a callback called if there is an error
  63147. */
  63148. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63149. /**
  63150. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63151. */
  63152. private loadImage;
  63153. /**
  63154. * Convert the image buffer into a cubemap and create a CubeTexture.
  63155. */
  63156. private loadTexture;
  63157. /**
  63158. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63159. * @param buffer The ArrayBuffer that should be converted.
  63160. * @returns The buffer as Float32Array.
  63161. */
  63162. private getFloat32ArrayFromArrayBuffer;
  63163. /**
  63164. * Get the current class name of the texture useful for serialization or dynamic coding.
  63165. * @returns "EquiRectangularCubeTexture"
  63166. */
  63167. getClassName(): string;
  63168. /**
  63169. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63170. * @returns A clone of the current EquiRectangularCubeTexture.
  63171. */
  63172. clone(): EquiRectangularCubeTexture;
  63173. }
  63174. }
  63175. declare module BABYLON {
  63176. /**
  63177. * Defines the options related to the creation of an HtmlElementTexture
  63178. */
  63179. export interface IHtmlElementTextureOptions {
  63180. /**
  63181. * Defines wether mip maps should be created or not.
  63182. */
  63183. generateMipMaps?: boolean;
  63184. /**
  63185. * Defines the sampling mode of the texture.
  63186. */
  63187. samplingMode?: number;
  63188. /**
  63189. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63190. */
  63191. engine: Nullable<ThinEngine>;
  63192. /**
  63193. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63194. */
  63195. scene: Nullable<Scene>;
  63196. }
  63197. /**
  63198. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63199. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63200. * is automatically managed.
  63201. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63202. * in your application.
  63203. *
  63204. * As the update is not automatic, you need to call them manually.
  63205. */
  63206. export class HtmlElementTexture extends BaseTexture {
  63207. /**
  63208. * The texture URL.
  63209. */
  63210. element: HTMLVideoElement | HTMLCanvasElement;
  63211. private static readonly DefaultOptions;
  63212. private _textureMatrix;
  63213. private _isVideo;
  63214. private _generateMipMaps;
  63215. private _samplingMode;
  63216. /**
  63217. * Instantiates a HtmlElementTexture from the following parameters.
  63218. *
  63219. * @param name Defines the name of the texture
  63220. * @param element Defines the video or canvas the texture is filled with
  63221. * @param options Defines the other none mandatory texture creation options
  63222. */
  63223. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63224. private _createInternalTexture;
  63225. /**
  63226. * Returns the texture matrix used in most of the material.
  63227. */
  63228. getTextureMatrix(): Matrix;
  63229. /**
  63230. * Updates the content of the texture.
  63231. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63232. */
  63233. update(invertY?: Nullable<boolean>): void;
  63234. }
  63235. }
  63236. declare module BABYLON {
  63237. /**
  63238. * Based on jsTGALoader - Javascript loader for TGA file
  63239. * By Vincent Thibault
  63240. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63241. */
  63242. export class TGATools {
  63243. private static _TYPE_INDEXED;
  63244. private static _TYPE_RGB;
  63245. private static _TYPE_GREY;
  63246. private static _TYPE_RLE_INDEXED;
  63247. private static _TYPE_RLE_RGB;
  63248. private static _TYPE_RLE_GREY;
  63249. private static _ORIGIN_MASK;
  63250. private static _ORIGIN_SHIFT;
  63251. private static _ORIGIN_BL;
  63252. private static _ORIGIN_BR;
  63253. private static _ORIGIN_UL;
  63254. private static _ORIGIN_UR;
  63255. /**
  63256. * Gets the header of a TGA file
  63257. * @param data defines the TGA data
  63258. * @returns the header
  63259. */
  63260. static GetTGAHeader(data: Uint8Array): any;
  63261. /**
  63262. * Uploads TGA content to a Babylon Texture
  63263. * @hidden
  63264. */
  63265. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63266. /** @hidden */
  63267. 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;
  63268. /** @hidden */
  63269. 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;
  63270. /** @hidden */
  63271. 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;
  63272. /** @hidden */
  63273. 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;
  63274. /** @hidden */
  63275. 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;
  63276. /** @hidden */
  63277. 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;
  63278. }
  63279. }
  63280. declare module BABYLON {
  63281. /**
  63282. * Implementation of the TGA Texture Loader.
  63283. * @hidden
  63284. */
  63285. export class _TGATextureLoader implements IInternalTextureLoader {
  63286. /**
  63287. * Defines wether the loader supports cascade loading the different faces.
  63288. */
  63289. readonly supportCascades: boolean;
  63290. /**
  63291. * This returns if the loader support the current file information.
  63292. * @param extension defines the file extension of the file being loaded
  63293. * @returns true if the loader can load the specified file
  63294. */
  63295. canLoad(extension: string): boolean;
  63296. /**
  63297. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63298. * @param data contains the texture data
  63299. * @param texture defines the BabylonJS internal texture
  63300. * @param createPolynomials will be true if polynomials have been requested
  63301. * @param onLoad defines the callback to trigger once the texture is ready
  63302. * @param onError defines the callback to trigger in case of error
  63303. */
  63304. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63305. /**
  63306. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63307. * @param data contains the texture data
  63308. * @param texture defines the BabylonJS internal texture
  63309. * @param callback defines the method to call once ready to upload
  63310. */
  63311. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63312. }
  63313. }
  63314. declare module BABYLON {
  63315. /**
  63316. * Info about the .basis files
  63317. */
  63318. class BasisFileInfo {
  63319. /**
  63320. * If the file has alpha
  63321. */
  63322. hasAlpha: boolean;
  63323. /**
  63324. * Info about each image of the basis file
  63325. */
  63326. images: Array<{
  63327. levels: Array<{
  63328. width: number;
  63329. height: number;
  63330. transcodedPixels: ArrayBufferView;
  63331. }>;
  63332. }>;
  63333. }
  63334. /**
  63335. * Result of transcoding a basis file
  63336. */
  63337. class TranscodeResult {
  63338. /**
  63339. * Info about the .basis file
  63340. */
  63341. fileInfo: BasisFileInfo;
  63342. /**
  63343. * Format to use when loading the file
  63344. */
  63345. format: number;
  63346. }
  63347. /**
  63348. * Configuration options for the Basis transcoder
  63349. */
  63350. export class BasisTranscodeConfiguration {
  63351. /**
  63352. * Supported compression formats used to determine the supported output format of the transcoder
  63353. */
  63354. supportedCompressionFormats?: {
  63355. /**
  63356. * etc1 compression format
  63357. */
  63358. etc1?: boolean;
  63359. /**
  63360. * s3tc compression format
  63361. */
  63362. s3tc?: boolean;
  63363. /**
  63364. * pvrtc compression format
  63365. */
  63366. pvrtc?: boolean;
  63367. /**
  63368. * etc2 compression format
  63369. */
  63370. etc2?: boolean;
  63371. };
  63372. /**
  63373. * If mipmap levels should be loaded for transcoded images (Default: true)
  63374. */
  63375. loadMipmapLevels?: boolean;
  63376. /**
  63377. * Index of a single image to load (Default: all images)
  63378. */
  63379. loadSingleImage?: number;
  63380. }
  63381. /**
  63382. * Used to load .Basis files
  63383. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63384. */
  63385. export class BasisTools {
  63386. private static _IgnoreSupportedFormats;
  63387. /**
  63388. * URL to use when loading the basis transcoder
  63389. */
  63390. static JSModuleURL: string;
  63391. /**
  63392. * URL to use when loading the wasm module for the transcoder
  63393. */
  63394. static WasmModuleURL: string;
  63395. /**
  63396. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63397. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63398. * @returns internal format corresponding to the Basis format
  63399. */
  63400. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63401. private static _WorkerPromise;
  63402. private static _Worker;
  63403. private static _actionId;
  63404. private static _CreateWorkerAsync;
  63405. /**
  63406. * Transcodes a loaded image file to compressed pixel data
  63407. * @param data image data to transcode
  63408. * @param config configuration options for the transcoding
  63409. * @returns a promise resulting in the transcoded image
  63410. */
  63411. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63412. /**
  63413. * Loads a texture from the transcode result
  63414. * @param texture texture load to
  63415. * @param transcodeResult the result of transcoding the basis file to load from
  63416. */
  63417. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * Loader for .basis file format
  63423. */
  63424. export class _BasisTextureLoader implements IInternalTextureLoader {
  63425. /**
  63426. * Defines whether the loader supports cascade loading the different faces.
  63427. */
  63428. readonly supportCascades: boolean;
  63429. /**
  63430. * This returns if the loader support the current file information.
  63431. * @param extension defines the file extension of the file being loaded
  63432. * @returns true if the loader can load the specified file
  63433. */
  63434. canLoad(extension: string): boolean;
  63435. /**
  63436. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63437. * @param data contains the texture data
  63438. * @param texture defines the BabylonJS internal texture
  63439. * @param createPolynomials will be true if polynomials have been requested
  63440. * @param onLoad defines the callback to trigger once the texture is ready
  63441. * @param onError defines the callback to trigger in case of error
  63442. */
  63443. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63444. /**
  63445. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63446. * @param data contains the texture data
  63447. * @param texture defines the BabylonJS internal texture
  63448. * @param callback defines the method to call once ready to upload
  63449. */
  63450. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63451. }
  63452. }
  63453. declare module BABYLON {
  63454. /**
  63455. * Defines the basic options interface of a TexturePacker Frame
  63456. */
  63457. export interface ITexturePackerFrame {
  63458. /**
  63459. * The frame ID
  63460. */
  63461. id: number;
  63462. /**
  63463. * The frames Scale
  63464. */
  63465. scale: Vector2;
  63466. /**
  63467. * The Frames offset
  63468. */
  63469. offset: Vector2;
  63470. }
  63471. /**
  63472. * This is a support class for frame Data on texture packer sets.
  63473. */
  63474. export class TexturePackerFrame implements ITexturePackerFrame {
  63475. /**
  63476. * The frame ID
  63477. */
  63478. id: number;
  63479. /**
  63480. * The frames Scale
  63481. */
  63482. scale: Vector2;
  63483. /**
  63484. * The Frames offset
  63485. */
  63486. offset: Vector2;
  63487. /**
  63488. * Initializes a texture package frame.
  63489. * @param id The numerical frame identifier
  63490. * @param scale Scalar Vector2 for UV frame
  63491. * @param offset Vector2 for the frame position in UV units.
  63492. * @returns TexturePackerFrame
  63493. */
  63494. constructor(id: number, scale: Vector2, offset: Vector2);
  63495. }
  63496. }
  63497. declare module BABYLON {
  63498. /**
  63499. * Defines the basic options interface of a TexturePacker
  63500. */
  63501. export interface ITexturePackerOptions {
  63502. /**
  63503. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63504. */
  63505. map?: string[];
  63506. /**
  63507. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63508. */
  63509. uvsIn?: string;
  63510. /**
  63511. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63512. */
  63513. uvsOut?: string;
  63514. /**
  63515. * number representing the layout style. Defaults to LAYOUT_STRIP
  63516. */
  63517. layout?: number;
  63518. /**
  63519. * number of columns if using custom column count layout(2). This defaults to 4.
  63520. */
  63521. colnum?: number;
  63522. /**
  63523. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63524. */
  63525. updateInputMeshes?: boolean;
  63526. /**
  63527. * boolean flag to dispose all the source textures. Defaults to true.
  63528. */
  63529. disposeSources?: boolean;
  63530. /**
  63531. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63532. */
  63533. fillBlanks?: boolean;
  63534. /**
  63535. * string value representing the context fill style color. Defaults to 'black'.
  63536. */
  63537. customFillColor?: string;
  63538. /**
  63539. * Width and Height Value of each Frame in the TexturePacker Sets
  63540. */
  63541. frameSize?: number;
  63542. /**
  63543. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63544. */
  63545. paddingRatio?: number;
  63546. /**
  63547. * Number that declares the fill method for the padding gutter.
  63548. */
  63549. paddingMode?: number;
  63550. /**
  63551. * If in SUBUV_COLOR padding mode what color to use.
  63552. */
  63553. paddingColor?: Color3 | Color4;
  63554. }
  63555. /**
  63556. * Defines the basic interface of a TexturePacker JSON File
  63557. */
  63558. export interface ITexturePackerJSON {
  63559. /**
  63560. * The frame ID
  63561. */
  63562. name: string;
  63563. /**
  63564. * The base64 channel data
  63565. */
  63566. sets: any;
  63567. /**
  63568. * The options of the Packer
  63569. */
  63570. options: ITexturePackerOptions;
  63571. /**
  63572. * The frame data of the Packer
  63573. */
  63574. frames: Array<number>;
  63575. }
  63576. /**
  63577. * This is a support class that generates a series of packed texture sets.
  63578. * @see https://doc.babylonjs.com/babylon101/materials
  63579. */
  63580. export class TexturePacker {
  63581. /** Packer Layout Constant 0 */
  63582. static readonly LAYOUT_STRIP: number;
  63583. /** Packer Layout Constant 1 */
  63584. static readonly LAYOUT_POWER2: number;
  63585. /** Packer Layout Constant 2 */
  63586. static readonly LAYOUT_COLNUM: number;
  63587. /** Packer Layout Constant 0 */
  63588. static readonly SUBUV_WRAP: number;
  63589. /** Packer Layout Constant 1 */
  63590. static readonly SUBUV_EXTEND: number;
  63591. /** Packer Layout Constant 2 */
  63592. static readonly SUBUV_COLOR: number;
  63593. /** The Name of the Texture Package */
  63594. name: string;
  63595. /** The scene scope of the TexturePacker */
  63596. scene: Scene;
  63597. /** The Meshes to target */
  63598. meshes: AbstractMesh[];
  63599. /** Arguments passed with the Constructor */
  63600. options: ITexturePackerOptions;
  63601. /** The promise that is started upon initialization */
  63602. promise: Nullable<Promise<TexturePacker | string>>;
  63603. /** The Container object for the channel sets that are generated */
  63604. sets: object;
  63605. /** The Container array for the frames that are generated */
  63606. frames: TexturePackerFrame[];
  63607. /** The expected number of textures the system is parsing. */
  63608. private _expecting;
  63609. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63610. private _paddingValue;
  63611. /**
  63612. * Initializes a texture package series from an array of meshes or a single mesh.
  63613. * @param name The name of the package
  63614. * @param meshes The target meshes to compose the package from
  63615. * @param options The arguments that texture packer should follow while building.
  63616. * @param scene The scene which the textures are scoped to.
  63617. * @returns TexturePacker
  63618. */
  63619. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63620. /**
  63621. * Starts the package process
  63622. * @param resolve The promises resolution function
  63623. * @returns TexturePacker
  63624. */
  63625. private _createFrames;
  63626. /**
  63627. * Calculates the Size of the Channel Sets
  63628. * @returns Vector2
  63629. */
  63630. private _calculateSize;
  63631. /**
  63632. * Calculates the UV data for the frames.
  63633. * @param baseSize the base frameSize
  63634. * @param padding the base frame padding
  63635. * @param dtSize size of the Dynamic Texture for that channel
  63636. * @param dtUnits is 1/dtSize
  63637. * @param update flag to update the input meshes
  63638. */
  63639. private _calculateMeshUVFrames;
  63640. /**
  63641. * Calculates the frames Offset.
  63642. * @param index of the frame
  63643. * @returns Vector2
  63644. */
  63645. private _getFrameOffset;
  63646. /**
  63647. * Updates a Mesh to the frame data
  63648. * @param mesh that is the target
  63649. * @param frameID or the frame index
  63650. */
  63651. private _updateMeshUV;
  63652. /**
  63653. * Updates a Meshes materials to use the texture packer channels
  63654. * @param m is the mesh to target
  63655. * @param force all channels on the packer to be set.
  63656. */
  63657. private _updateTextureReferences;
  63658. /**
  63659. * Public method to set a Mesh to a frame
  63660. * @param m that is the target
  63661. * @param frameID or the frame index
  63662. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63663. */
  63664. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63665. /**
  63666. * Starts the async promise to compile the texture packer.
  63667. * @returns Promise<void>
  63668. */
  63669. processAsync(): Promise<void>;
  63670. /**
  63671. * Disposes all textures associated with this packer
  63672. */
  63673. dispose(): void;
  63674. /**
  63675. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63676. * @param imageType is the image type to use.
  63677. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63678. */
  63679. download(imageType?: string, quality?: number): void;
  63680. /**
  63681. * Public method to load a texturePacker JSON file.
  63682. * @param data of the JSON file in string format.
  63683. */
  63684. updateFromJSON(data: string): void;
  63685. }
  63686. }
  63687. declare module BABYLON {
  63688. /**
  63689. * 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.
  63690. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63691. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63692. */
  63693. export class CustomProceduralTexture extends ProceduralTexture {
  63694. private _animate;
  63695. private _time;
  63696. private _config;
  63697. private _texturePath;
  63698. /**
  63699. * Instantiates a new Custom Procedural Texture.
  63700. * 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.
  63701. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63702. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63703. * @param name Define the name of the texture
  63704. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63705. * @param size Define the size of the texture to create
  63706. * @param scene Define the scene the texture belongs to
  63707. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63708. * @param generateMipMaps Define if the texture should creates mip maps or not
  63709. */
  63710. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63711. private _loadJson;
  63712. /**
  63713. * Is the texture ready to be used ? (rendered at least once)
  63714. * @returns true if ready, otherwise, false.
  63715. */
  63716. isReady(): boolean;
  63717. /**
  63718. * Render the texture to its associated render target.
  63719. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63720. */
  63721. render(useCameraPostProcess?: boolean): void;
  63722. /**
  63723. * Update the list of dependant textures samplers in the shader.
  63724. */
  63725. updateTextures(): void;
  63726. /**
  63727. * Update the uniform values of the procedural texture in the shader.
  63728. */
  63729. updateShaderUniforms(): void;
  63730. /**
  63731. * Define if the texture animates or not.
  63732. */
  63733. get animate(): boolean;
  63734. set animate(value: boolean);
  63735. }
  63736. }
  63737. declare module BABYLON {
  63738. /** @hidden */
  63739. export var noisePixelShader: {
  63740. name: string;
  63741. shader: string;
  63742. };
  63743. }
  63744. declare module BABYLON {
  63745. /**
  63746. * Class used to generate noise procedural textures
  63747. */
  63748. export class NoiseProceduralTexture extends ProceduralTexture {
  63749. /** Gets or sets the start time (default is 0) */
  63750. time: number;
  63751. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63752. brightness: number;
  63753. /** Defines the number of octaves to process */
  63754. octaves: number;
  63755. /** Defines the level of persistence (0.8 by default) */
  63756. persistence: number;
  63757. /** Gets or sets animation speed factor (default is 1) */
  63758. animationSpeedFactor: number;
  63759. /**
  63760. * Creates a new NoiseProceduralTexture
  63761. * @param name defines the name fo the texture
  63762. * @param size defines the size of the texture (default is 256)
  63763. * @param scene defines the hosting scene
  63764. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63765. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63766. */
  63767. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63768. private _updateShaderUniforms;
  63769. protected _getDefines(): string;
  63770. /** Generate the current state of the procedural texture */
  63771. render(useCameraPostProcess?: boolean): void;
  63772. /**
  63773. * Serializes this noise procedural texture
  63774. * @returns a serialized noise procedural texture object
  63775. */
  63776. serialize(): any;
  63777. /**
  63778. * Clone the texture.
  63779. * @returns the cloned texture
  63780. */
  63781. clone(): NoiseProceduralTexture;
  63782. /**
  63783. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63784. * @param parsedTexture defines parsed texture data
  63785. * @param scene defines the current scene
  63786. * @param rootUrl defines the root URL containing noise procedural texture information
  63787. * @returns a parsed NoiseProceduralTexture
  63788. */
  63789. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63790. }
  63791. }
  63792. declare module BABYLON {
  63793. /**
  63794. * Raw cube texture where the raw buffers are passed in
  63795. */
  63796. export class RawCubeTexture extends CubeTexture {
  63797. /**
  63798. * Creates a cube texture where the raw buffers are passed in.
  63799. * @param scene defines the scene the texture is attached to
  63800. * @param data defines the array of data to use to create each face
  63801. * @param size defines the size of the textures
  63802. * @param format defines the format of the data
  63803. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63804. * @param generateMipMaps defines if the engine should generate the mip levels
  63805. * @param invertY defines if data must be stored with Y axis inverted
  63806. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63807. * @param compression defines the compression used (null by default)
  63808. */
  63809. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63810. /**
  63811. * Updates the raw cube texture.
  63812. * @param data defines the data to store
  63813. * @param format defines the data format
  63814. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63815. * @param invertY defines if data must be stored with Y axis inverted
  63816. * @param compression defines the compression used (null by default)
  63817. * @param level defines which level of the texture to update
  63818. */
  63819. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63820. /**
  63821. * Updates a raw cube texture with RGBD encoded data.
  63822. * @param data defines the array of data [mipmap][face] to use to create each face
  63823. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63826. * @returns a promsie that resolves when the operation is complete
  63827. */
  63828. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63829. /**
  63830. * Clones the raw cube texture.
  63831. * @return a new cube texture
  63832. */
  63833. clone(): CubeTexture;
  63834. /** @hidden */
  63835. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63836. }
  63837. }
  63838. declare module BABYLON {
  63839. /**
  63840. * Class used to store 2D array textures containing user data
  63841. */
  63842. export class RawTexture2DArray extends Texture {
  63843. /** Gets or sets the texture format to use */
  63844. format: number;
  63845. /**
  63846. * Create a new RawTexture2DArray
  63847. * @param data defines the data of the texture
  63848. * @param width defines the width of the texture
  63849. * @param height defines the height of the texture
  63850. * @param depth defines the number of layers of the texture
  63851. * @param format defines the texture format to use
  63852. * @param scene defines the hosting scene
  63853. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63854. * @param invertY defines if texture must be stored with Y axis inverted
  63855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63856. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63857. */
  63858. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63859. /** Gets or sets the texture format to use */
  63860. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63861. /**
  63862. * Update the texture with new data
  63863. * @param data defines the data to store in the texture
  63864. */
  63865. update(data: ArrayBufferView): void;
  63866. }
  63867. }
  63868. declare module BABYLON {
  63869. /**
  63870. * Class used to store 3D textures containing user data
  63871. */
  63872. export class RawTexture3D extends Texture {
  63873. /** Gets or sets the texture format to use */
  63874. format: number;
  63875. /**
  63876. * Create a new RawTexture3D
  63877. * @param data defines the data of the texture
  63878. * @param width defines the width of the texture
  63879. * @param height defines the height of the texture
  63880. * @param depth defines the depth of the texture
  63881. * @param format defines the texture format to use
  63882. * @param scene defines the hosting scene
  63883. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63884. * @param invertY defines if texture must be stored with Y axis inverted
  63885. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63886. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63887. */
  63888. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63889. /** Gets or sets the texture format to use */
  63890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63891. /**
  63892. * Update the texture with new data
  63893. * @param data defines the data to store in the texture
  63894. */
  63895. update(data: ArrayBufferView): void;
  63896. }
  63897. }
  63898. declare module BABYLON {
  63899. /**
  63900. * Creates a refraction texture used by refraction channel of the standard material.
  63901. * It is like a mirror but to see through a material.
  63902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63903. */
  63904. export class RefractionTexture extends RenderTargetTexture {
  63905. /**
  63906. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63907. * 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.
  63908. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63909. */
  63910. refractionPlane: Plane;
  63911. /**
  63912. * Define how deep under the surface we should see.
  63913. */
  63914. depth: number;
  63915. /**
  63916. * Creates a refraction texture used by refraction channel of the standard material.
  63917. * It is like a mirror but to see through a material.
  63918. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63919. * @param name Define the texture name
  63920. * @param size Define the size of the underlying texture
  63921. * @param scene Define the scene the refraction belongs to
  63922. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63923. */
  63924. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63925. /**
  63926. * Clone the refraction texture.
  63927. * @returns the cloned texture
  63928. */
  63929. clone(): RefractionTexture;
  63930. /**
  63931. * Serialize the texture to a JSON representation you could use in Parse later on
  63932. * @returns the serialized JSON representation
  63933. */
  63934. serialize(): any;
  63935. }
  63936. }
  63937. declare module BABYLON {
  63938. /**
  63939. * Block used to add support for vertex skinning (bones)
  63940. */
  63941. export class BonesBlock extends NodeMaterialBlock {
  63942. /**
  63943. * Creates a new BonesBlock
  63944. * @param name defines the block name
  63945. */
  63946. constructor(name: string);
  63947. /**
  63948. * Initialize the block and prepare the context for build
  63949. * @param state defines the state that will be used for the build
  63950. */
  63951. initialize(state: NodeMaterialBuildState): void;
  63952. /**
  63953. * Gets the current class name
  63954. * @returns the class name
  63955. */
  63956. getClassName(): string;
  63957. /**
  63958. * Gets the matrix indices input component
  63959. */
  63960. get matricesIndices(): NodeMaterialConnectionPoint;
  63961. /**
  63962. * Gets the matrix weights input component
  63963. */
  63964. get matricesWeights(): NodeMaterialConnectionPoint;
  63965. /**
  63966. * Gets the extra matrix indices input component
  63967. */
  63968. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63969. /**
  63970. * Gets the extra matrix weights input component
  63971. */
  63972. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63973. /**
  63974. * Gets the world input component
  63975. */
  63976. get world(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the output component
  63979. */
  63980. get output(): NodeMaterialConnectionPoint;
  63981. autoConfigure(material: NodeMaterial): void;
  63982. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63983. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63985. protected _buildBlock(state: NodeMaterialBuildState): this;
  63986. }
  63987. }
  63988. declare module BABYLON {
  63989. /**
  63990. * Block used to add support for instances
  63991. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63992. */
  63993. export class InstancesBlock extends NodeMaterialBlock {
  63994. /**
  63995. * Creates a new InstancesBlock
  63996. * @param name defines the block name
  63997. */
  63998. constructor(name: string);
  63999. /**
  64000. * Gets the current class name
  64001. * @returns the class name
  64002. */
  64003. getClassName(): string;
  64004. /**
  64005. * Gets the first world row input component
  64006. */
  64007. get world0(): NodeMaterialConnectionPoint;
  64008. /**
  64009. * Gets the second world row input component
  64010. */
  64011. get world1(): NodeMaterialConnectionPoint;
  64012. /**
  64013. * Gets the third world row input component
  64014. */
  64015. get world2(): NodeMaterialConnectionPoint;
  64016. /**
  64017. * Gets the forth world row input component
  64018. */
  64019. get world3(): NodeMaterialConnectionPoint;
  64020. /**
  64021. * Gets the world input component
  64022. */
  64023. get world(): NodeMaterialConnectionPoint;
  64024. /**
  64025. * Gets the output component
  64026. */
  64027. get output(): NodeMaterialConnectionPoint;
  64028. /**
  64029. * Gets the isntanceID component
  64030. */
  64031. get instanceID(): NodeMaterialConnectionPoint;
  64032. autoConfigure(material: NodeMaterial): void;
  64033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64034. protected _buildBlock(state: NodeMaterialBuildState): this;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /**
  64039. * Block used to add morph targets support to vertex shader
  64040. */
  64041. export class MorphTargetsBlock extends NodeMaterialBlock {
  64042. private _repeatableContentAnchor;
  64043. /**
  64044. * Create a new MorphTargetsBlock
  64045. * @param name defines the block name
  64046. */
  64047. constructor(name: string);
  64048. /**
  64049. * Gets the current class name
  64050. * @returns the class name
  64051. */
  64052. getClassName(): string;
  64053. /**
  64054. * Gets the position input component
  64055. */
  64056. get position(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the normal input component
  64059. */
  64060. get normal(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the tangent input component
  64063. */
  64064. get tangent(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the tangent input component
  64067. */
  64068. get uv(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the position output component
  64071. */
  64072. get positionOutput(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the normal output component
  64075. */
  64076. get normalOutput(): NodeMaterialConnectionPoint;
  64077. /**
  64078. * Gets the tangent output component
  64079. */
  64080. get tangentOutput(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the tangent output component
  64083. */
  64084. get uvOutput(): NodeMaterialConnectionPoint;
  64085. initialize(state: NodeMaterialBuildState): void;
  64086. autoConfigure(material: NodeMaterial): void;
  64087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64089. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64090. protected _buildBlock(state: NodeMaterialBuildState): this;
  64091. }
  64092. }
  64093. declare module BABYLON {
  64094. /**
  64095. * Block used to get data information from a light
  64096. */
  64097. export class LightInformationBlock extends NodeMaterialBlock {
  64098. private _lightDataUniformName;
  64099. private _lightColorUniformName;
  64100. private _lightTypeDefineName;
  64101. /**
  64102. * Gets or sets the light associated with this block
  64103. */
  64104. light: Nullable<Light>;
  64105. /**
  64106. * Creates a new LightInformationBlock
  64107. * @param name defines the block name
  64108. */
  64109. constructor(name: string);
  64110. /**
  64111. * Gets the current class name
  64112. * @returns the class name
  64113. */
  64114. getClassName(): string;
  64115. /**
  64116. * Gets the world position input component
  64117. */
  64118. get worldPosition(): NodeMaterialConnectionPoint;
  64119. /**
  64120. * Gets the direction output component
  64121. */
  64122. get direction(): NodeMaterialConnectionPoint;
  64123. /**
  64124. * Gets the direction output component
  64125. */
  64126. get color(): NodeMaterialConnectionPoint;
  64127. /**
  64128. * Gets the direction output component
  64129. */
  64130. get intensity(): NodeMaterialConnectionPoint;
  64131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64132. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64133. protected _buildBlock(state: NodeMaterialBuildState): this;
  64134. serialize(): any;
  64135. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64136. }
  64137. }
  64138. declare module BABYLON {
  64139. /**
  64140. * Block used to add image processing support to fragment shader
  64141. */
  64142. export class ImageProcessingBlock extends NodeMaterialBlock {
  64143. /**
  64144. * Create a new ImageProcessingBlock
  64145. * @param name defines the block name
  64146. */
  64147. constructor(name: string);
  64148. /**
  64149. * Gets the current class name
  64150. * @returns the class name
  64151. */
  64152. getClassName(): string;
  64153. /**
  64154. * Gets the color input component
  64155. */
  64156. get color(): NodeMaterialConnectionPoint;
  64157. /**
  64158. * Gets the output component
  64159. */
  64160. get output(): NodeMaterialConnectionPoint;
  64161. /**
  64162. * Initialize the block and prepare the context for build
  64163. * @param state defines the state that will be used for the build
  64164. */
  64165. initialize(state: NodeMaterialBuildState): void;
  64166. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64169. protected _buildBlock(state: NodeMaterialBuildState): this;
  64170. }
  64171. }
  64172. declare module BABYLON {
  64173. /**
  64174. * Block used to pertub normals based on a normal map
  64175. */
  64176. export class PerturbNormalBlock extends NodeMaterialBlock {
  64177. private _tangentSpaceParameterName;
  64178. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64179. invertX: boolean;
  64180. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64181. invertY: boolean;
  64182. /**
  64183. * Create a new PerturbNormalBlock
  64184. * @param name defines the block name
  64185. */
  64186. constructor(name: string);
  64187. /**
  64188. * Gets the current class name
  64189. * @returns the class name
  64190. */
  64191. getClassName(): string;
  64192. /**
  64193. * Gets the world position input component
  64194. */
  64195. get worldPosition(): NodeMaterialConnectionPoint;
  64196. /**
  64197. * Gets the world normal input component
  64198. */
  64199. get worldNormal(): NodeMaterialConnectionPoint;
  64200. /**
  64201. * Gets the world tangent input component
  64202. */
  64203. get worldTangent(): NodeMaterialConnectionPoint;
  64204. /**
  64205. * Gets the uv input component
  64206. */
  64207. get uv(): NodeMaterialConnectionPoint;
  64208. /**
  64209. * Gets the normal map color input component
  64210. */
  64211. get normalMapColor(): NodeMaterialConnectionPoint;
  64212. /**
  64213. * Gets the strength input component
  64214. */
  64215. get strength(): NodeMaterialConnectionPoint;
  64216. /**
  64217. * Gets the output component
  64218. */
  64219. get output(): NodeMaterialConnectionPoint;
  64220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64222. autoConfigure(material: NodeMaterial): void;
  64223. protected _buildBlock(state: NodeMaterialBuildState): this;
  64224. protected _dumpPropertiesCode(): string;
  64225. serialize(): any;
  64226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64227. }
  64228. }
  64229. declare module BABYLON {
  64230. /**
  64231. * Block used to discard a pixel if a value is smaller than a cutoff
  64232. */
  64233. export class DiscardBlock extends NodeMaterialBlock {
  64234. /**
  64235. * Create a new DiscardBlock
  64236. * @param name defines the block name
  64237. */
  64238. constructor(name: string);
  64239. /**
  64240. * Gets the current class name
  64241. * @returns the class name
  64242. */
  64243. getClassName(): string;
  64244. /**
  64245. * Gets the color input component
  64246. */
  64247. get value(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the cutoff input component
  64250. */
  64251. get cutoff(): NodeMaterialConnectionPoint;
  64252. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64253. }
  64254. }
  64255. declare module BABYLON {
  64256. /**
  64257. * Block used to test if the fragment shader is front facing
  64258. */
  64259. export class FrontFacingBlock extends NodeMaterialBlock {
  64260. /**
  64261. * Creates a new FrontFacingBlock
  64262. * @param name defines the block name
  64263. */
  64264. constructor(name: string);
  64265. /**
  64266. * Gets the current class name
  64267. * @returns the class name
  64268. */
  64269. getClassName(): string;
  64270. /**
  64271. * Gets the output component
  64272. */
  64273. get output(): NodeMaterialConnectionPoint;
  64274. protected _buildBlock(state: NodeMaterialBuildState): this;
  64275. }
  64276. }
  64277. declare module BABYLON {
  64278. /**
  64279. * Block used to get the derivative value on x and y of a given input
  64280. */
  64281. export class DerivativeBlock extends NodeMaterialBlock {
  64282. /**
  64283. * Create a new DerivativeBlock
  64284. * @param name defines the block name
  64285. */
  64286. constructor(name: string);
  64287. /**
  64288. * Gets the current class name
  64289. * @returns the class name
  64290. */
  64291. getClassName(): string;
  64292. /**
  64293. * Gets the input component
  64294. */
  64295. get input(): NodeMaterialConnectionPoint;
  64296. /**
  64297. * Gets the derivative output on x
  64298. */
  64299. get dx(): NodeMaterialConnectionPoint;
  64300. /**
  64301. * Gets the derivative output on y
  64302. */
  64303. get dy(): NodeMaterialConnectionPoint;
  64304. protected _buildBlock(state: NodeMaterialBuildState): this;
  64305. }
  64306. }
  64307. declare module BABYLON {
  64308. /**
  64309. * Block used to make gl_FragCoord available
  64310. */
  64311. export class FragCoordBlock extends NodeMaterialBlock {
  64312. /**
  64313. * Creates a new FragCoordBlock
  64314. * @param name defines the block name
  64315. */
  64316. constructor(name: string);
  64317. /**
  64318. * Gets the current class name
  64319. * @returns the class name
  64320. */
  64321. getClassName(): string;
  64322. /**
  64323. * Gets the xy component
  64324. */
  64325. get xy(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the xyz component
  64328. */
  64329. get xyz(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the xyzw component
  64332. */
  64333. get xyzw(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the x component
  64336. */
  64337. get x(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the y component
  64340. */
  64341. get y(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the z component
  64344. */
  64345. get z(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the w component
  64348. */
  64349. get output(): NodeMaterialConnectionPoint;
  64350. protected writeOutputs(state: NodeMaterialBuildState): string;
  64351. protected _buildBlock(state: NodeMaterialBuildState): this;
  64352. }
  64353. }
  64354. declare module BABYLON {
  64355. /**
  64356. * Block used to get the screen sizes
  64357. */
  64358. export class ScreenSizeBlock extends NodeMaterialBlock {
  64359. private _varName;
  64360. private _scene;
  64361. /**
  64362. * Creates a new ScreenSizeBlock
  64363. * @param name defines the block name
  64364. */
  64365. constructor(name: string);
  64366. /**
  64367. * Gets the current class name
  64368. * @returns the class name
  64369. */
  64370. getClassName(): string;
  64371. /**
  64372. * Gets the xy component
  64373. */
  64374. get xy(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the x component
  64377. */
  64378. get x(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Gets the y component
  64381. */
  64382. get y(): NodeMaterialConnectionPoint;
  64383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64384. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64385. protected _buildBlock(state: NodeMaterialBuildState): this;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * Block used to add support for scene fog
  64391. */
  64392. export class FogBlock extends NodeMaterialBlock {
  64393. private _fogDistanceName;
  64394. private _fogParameters;
  64395. /**
  64396. * Create a new FogBlock
  64397. * @param name defines the block name
  64398. */
  64399. constructor(name: string);
  64400. /**
  64401. * Gets the current class name
  64402. * @returns the class name
  64403. */
  64404. getClassName(): string;
  64405. /**
  64406. * Gets the world position input component
  64407. */
  64408. get worldPosition(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the view input component
  64411. */
  64412. get view(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the color input component
  64415. */
  64416. get input(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the fog color input component
  64419. */
  64420. get fogColor(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the output component
  64423. */
  64424. get output(): NodeMaterialConnectionPoint;
  64425. autoConfigure(material: NodeMaterial): void;
  64426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64428. protected _buildBlock(state: NodeMaterialBuildState): this;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * Block used to add light in the fragment shader
  64434. */
  64435. export class LightBlock extends NodeMaterialBlock {
  64436. private _lightId;
  64437. /**
  64438. * Gets or sets the light associated with this block
  64439. */
  64440. light: Nullable<Light>;
  64441. /**
  64442. * Create a new LightBlock
  64443. * @param name defines the block name
  64444. */
  64445. constructor(name: string);
  64446. /**
  64447. * Gets the current class name
  64448. * @returns the class name
  64449. */
  64450. getClassName(): string;
  64451. /**
  64452. * Gets the world position input component
  64453. */
  64454. get worldPosition(): NodeMaterialConnectionPoint;
  64455. /**
  64456. * Gets the world normal input component
  64457. */
  64458. get worldNormal(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the camera (or eye) position component
  64461. */
  64462. get cameraPosition(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the glossiness component
  64465. */
  64466. get glossiness(): NodeMaterialConnectionPoint;
  64467. /**
  64468. * Gets the glossinness power component
  64469. */
  64470. get glossPower(): NodeMaterialConnectionPoint;
  64471. /**
  64472. * Gets the diffuse color component
  64473. */
  64474. get diffuseColor(): NodeMaterialConnectionPoint;
  64475. /**
  64476. * Gets the specular color component
  64477. */
  64478. get specularColor(): NodeMaterialConnectionPoint;
  64479. /**
  64480. * Gets the view matrix component
  64481. */
  64482. get view(): NodeMaterialConnectionPoint;
  64483. /**
  64484. * Gets the diffuse output component
  64485. */
  64486. get diffuseOutput(): NodeMaterialConnectionPoint;
  64487. /**
  64488. * Gets the specular output component
  64489. */
  64490. get specularOutput(): NodeMaterialConnectionPoint;
  64491. /**
  64492. * Gets the shadow output component
  64493. */
  64494. get shadow(): NodeMaterialConnectionPoint;
  64495. autoConfigure(material: NodeMaterial): void;
  64496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64497. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64499. private _injectVertexCode;
  64500. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64501. serialize(): any;
  64502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64503. }
  64504. }
  64505. declare module BABYLON {
  64506. /**
  64507. * Block used to read a reflection texture from a sampler
  64508. */
  64509. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64510. /**
  64511. * Create a new ReflectionTextureBlock
  64512. * @param name defines the block name
  64513. */
  64514. constructor(name: string);
  64515. /**
  64516. * Gets the current class name
  64517. * @returns the class name
  64518. */
  64519. getClassName(): string;
  64520. /**
  64521. * Gets the world position input component
  64522. */
  64523. get position(): NodeMaterialConnectionPoint;
  64524. /**
  64525. * Gets the world position input component
  64526. */
  64527. get worldPosition(): NodeMaterialConnectionPoint;
  64528. /**
  64529. * Gets the world normal input component
  64530. */
  64531. get worldNormal(): NodeMaterialConnectionPoint;
  64532. /**
  64533. * Gets the world input component
  64534. */
  64535. get world(): NodeMaterialConnectionPoint;
  64536. /**
  64537. * Gets the camera (or eye) position component
  64538. */
  64539. get cameraPosition(): NodeMaterialConnectionPoint;
  64540. /**
  64541. * Gets the view input component
  64542. */
  64543. get view(): NodeMaterialConnectionPoint;
  64544. /**
  64545. * Gets the rgb output component
  64546. */
  64547. get rgb(): NodeMaterialConnectionPoint;
  64548. /**
  64549. * Gets the rgba output component
  64550. */
  64551. get rgba(): NodeMaterialConnectionPoint;
  64552. /**
  64553. * Gets the r output component
  64554. */
  64555. get r(): NodeMaterialConnectionPoint;
  64556. /**
  64557. * Gets the g output component
  64558. */
  64559. get g(): NodeMaterialConnectionPoint;
  64560. /**
  64561. * Gets the b output component
  64562. */
  64563. get b(): NodeMaterialConnectionPoint;
  64564. /**
  64565. * Gets the a output component
  64566. */
  64567. get a(): NodeMaterialConnectionPoint;
  64568. autoConfigure(material: NodeMaterial): void;
  64569. protected _buildBlock(state: NodeMaterialBuildState): this;
  64570. }
  64571. }
  64572. declare module BABYLON {
  64573. /**
  64574. * Block used to add 2 vectors
  64575. */
  64576. export class AddBlock extends NodeMaterialBlock {
  64577. /**
  64578. * Creates a new AddBlock
  64579. * @param name defines the block name
  64580. */
  64581. constructor(name: string);
  64582. /**
  64583. * Gets the current class name
  64584. * @returns the class name
  64585. */
  64586. getClassName(): string;
  64587. /**
  64588. * Gets the left operand input component
  64589. */
  64590. get left(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the right operand input component
  64593. */
  64594. get right(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the output component
  64597. */
  64598. get output(): NodeMaterialConnectionPoint;
  64599. protected _buildBlock(state: NodeMaterialBuildState): this;
  64600. }
  64601. }
  64602. declare module BABYLON {
  64603. /**
  64604. * Block used to scale a vector by a float
  64605. */
  64606. export class ScaleBlock extends NodeMaterialBlock {
  64607. /**
  64608. * Creates a new ScaleBlock
  64609. * @param name defines the block name
  64610. */
  64611. constructor(name: string);
  64612. /**
  64613. * Gets the current class name
  64614. * @returns the class name
  64615. */
  64616. getClassName(): string;
  64617. /**
  64618. * Gets the input component
  64619. */
  64620. get input(): NodeMaterialConnectionPoint;
  64621. /**
  64622. * Gets the factor input component
  64623. */
  64624. get factor(): NodeMaterialConnectionPoint;
  64625. /**
  64626. * Gets the output component
  64627. */
  64628. get output(): NodeMaterialConnectionPoint;
  64629. protected _buildBlock(state: NodeMaterialBuildState): this;
  64630. }
  64631. }
  64632. declare module BABYLON {
  64633. /**
  64634. * Block used to clamp a float
  64635. */
  64636. export class ClampBlock extends NodeMaterialBlock {
  64637. /** Gets or sets the minimum range */
  64638. minimum: number;
  64639. /** Gets or sets the maximum range */
  64640. maximum: number;
  64641. /**
  64642. * Creates a new ClampBlock
  64643. * @param name defines the block name
  64644. */
  64645. constructor(name: string);
  64646. /**
  64647. * Gets the current class name
  64648. * @returns the class name
  64649. */
  64650. getClassName(): string;
  64651. /**
  64652. * Gets the value input component
  64653. */
  64654. get value(): NodeMaterialConnectionPoint;
  64655. /**
  64656. * Gets the output component
  64657. */
  64658. get output(): NodeMaterialConnectionPoint;
  64659. protected _buildBlock(state: NodeMaterialBuildState): this;
  64660. protected _dumpPropertiesCode(): string;
  64661. serialize(): any;
  64662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64663. }
  64664. }
  64665. declare module BABYLON {
  64666. /**
  64667. * Block used to apply a cross product between 2 vectors
  64668. */
  64669. export class CrossBlock extends NodeMaterialBlock {
  64670. /**
  64671. * Creates a new CrossBlock
  64672. * @param name defines the block name
  64673. */
  64674. constructor(name: string);
  64675. /**
  64676. * Gets the current class name
  64677. * @returns the class name
  64678. */
  64679. getClassName(): string;
  64680. /**
  64681. * Gets the left operand input component
  64682. */
  64683. get left(): NodeMaterialConnectionPoint;
  64684. /**
  64685. * Gets the right operand input component
  64686. */
  64687. get right(): NodeMaterialConnectionPoint;
  64688. /**
  64689. * Gets the output component
  64690. */
  64691. get output(): NodeMaterialConnectionPoint;
  64692. protected _buildBlock(state: NodeMaterialBuildState): this;
  64693. }
  64694. }
  64695. declare module BABYLON {
  64696. /**
  64697. * Block used to apply a dot product between 2 vectors
  64698. */
  64699. export class DotBlock extends NodeMaterialBlock {
  64700. /**
  64701. * Creates a new DotBlock
  64702. * @param name defines the block name
  64703. */
  64704. constructor(name: string);
  64705. /**
  64706. * Gets the current class name
  64707. * @returns the class name
  64708. */
  64709. getClassName(): string;
  64710. /**
  64711. * Gets the left operand input component
  64712. */
  64713. get left(): NodeMaterialConnectionPoint;
  64714. /**
  64715. * Gets the right operand input component
  64716. */
  64717. get right(): NodeMaterialConnectionPoint;
  64718. /**
  64719. * Gets the output component
  64720. */
  64721. get output(): NodeMaterialConnectionPoint;
  64722. protected _buildBlock(state: NodeMaterialBuildState): this;
  64723. }
  64724. }
  64725. declare module BABYLON {
  64726. /**
  64727. * Block used to normalize a vector
  64728. */
  64729. export class NormalizeBlock extends NodeMaterialBlock {
  64730. /**
  64731. * Creates a new NormalizeBlock
  64732. * @param name defines the block name
  64733. */
  64734. constructor(name: string);
  64735. /**
  64736. * Gets the current class name
  64737. * @returns the class name
  64738. */
  64739. getClassName(): string;
  64740. /**
  64741. * Gets the input component
  64742. */
  64743. get input(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the output component
  64746. */
  64747. get output(): NodeMaterialConnectionPoint;
  64748. protected _buildBlock(state: NodeMaterialBuildState): this;
  64749. }
  64750. }
  64751. declare module BABYLON {
  64752. /**
  64753. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64754. */
  64755. export class ColorMergerBlock extends NodeMaterialBlock {
  64756. /**
  64757. * Create a new ColorMergerBlock
  64758. * @param name defines the block name
  64759. */
  64760. constructor(name: string);
  64761. /**
  64762. * Gets the current class name
  64763. * @returns the class name
  64764. */
  64765. getClassName(): string;
  64766. /**
  64767. * Gets the rgb component (input)
  64768. */
  64769. get rgbIn(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the r component (input)
  64772. */
  64773. get r(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the g component (input)
  64776. */
  64777. get g(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the b component (input)
  64780. */
  64781. get b(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the a component (input)
  64784. */
  64785. get a(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the rgba component (output)
  64788. */
  64789. get rgba(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the rgb component (output)
  64792. */
  64793. get rgbOut(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the rgb component (output)
  64796. * @deprecated Please use rgbOut instead.
  64797. */
  64798. get rgb(): NodeMaterialConnectionPoint;
  64799. protected _buildBlock(state: NodeMaterialBuildState): this;
  64800. }
  64801. }
  64802. declare module BABYLON {
  64803. /**
  64804. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64805. */
  64806. export class VectorSplitterBlock extends NodeMaterialBlock {
  64807. /**
  64808. * Create a new VectorSplitterBlock
  64809. * @param name defines the block name
  64810. */
  64811. constructor(name: string);
  64812. /**
  64813. * Gets the current class name
  64814. * @returns the class name
  64815. */
  64816. getClassName(): string;
  64817. /**
  64818. * Gets the xyzw component (input)
  64819. */
  64820. get xyzw(): NodeMaterialConnectionPoint;
  64821. /**
  64822. * Gets the xyz component (input)
  64823. */
  64824. get xyzIn(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the xy component (input)
  64827. */
  64828. get xyIn(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the xyz component (output)
  64831. */
  64832. get xyzOut(): NodeMaterialConnectionPoint;
  64833. /**
  64834. * Gets the xy component (output)
  64835. */
  64836. get xyOut(): NodeMaterialConnectionPoint;
  64837. /**
  64838. * Gets the x component (output)
  64839. */
  64840. get x(): NodeMaterialConnectionPoint;
  64841. /**
  64842. * Gets the y component (output)
  64843. */
  64844. get y(): NodeMaterialConnectionPoint;
  64845. /**
  64846. * Gets the z component (output)
  64847. */
  64848. get z(): NodeMaterialConnectionPoint;
  64849. /**
  64850. * Gets the w component (output)
  64851. */
  64852. get w(): NodeMaterialConnectionPoint;
  64853. protected _inputRename(name: string): string;
  64854. protected _outputRename(name: string): string;
  64855. protected _buildBlock(state: NodeMaterialBuildState): this;
  64856. }
  64857. }
  64858. declare module BABYLON {
  64859. /**
  64860. * Block used to lerp between 2 values
  64861. */
  64862. export class LerpBlock extends NodeMaterialBlock {
  64863. /**
  64864. * Creates a new LerpBlock
  64865. * @param name defines the block name
  64866. */
  64867. constructor(name: string);
  64868. /**
  64869. * Gets the current class name
  64870. * @returns the class name
  64871. */
  64872. getClassName(): string;
  64873. /**
  64874. * Gets the left operand input component
  64875. */
  64876. get left(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the right operand input component
  64879. */
  64880. get right(): NodeMaterialConnectionPoint;
  64881. /**
  64882. * Gets the gradient operand input component
  64883. */
  64884. get gradient(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the output component
  64887. */
  64888. get output(): NodeMaterialConnectionPoint;
  64889. protected _buildBlock(state: NodeMaterialBuildState): this;
  64890. }
  64891. }
  64892. declare module BABYLON {
  64893. /**
  64894. * Block used to divide 2 vectors
  64895. */
  64896. export class DivideBlock extends NodeMaterialBlock {
  64897. /**
  64898. * Creates a new DivideBlock
  64899. * @param name defines the block name
  64900. */
  64901. constructor(name: string);
  64902. /**
  64903. * Gets the current class name
  64904. * @returns the class name
  64905. */
  64906. getClassName(): string;
  64907. /**
  64908. * Gets the left operand input component
  64909. */
  64910. get left(): NodeMaterialConnectionPoint;
  64911. /**
  64912. * Gets the right operand input component
  64913. */
  64914. get right(): NodeMaterialConnectionPoint;
  64915. /**
  64916. * Gets the output component
  64917. */
  64918. get output(): NodeMaterialConnectionPoint;
  64919. protected _buildBlock(state: NodeMaterialBuildState): this;
  64920. }
  64921. }
  64922. declare module BABYLON {
  64923. /**
  64924. * Block used to subtract 2 vectors
  64925. */
  64926. export class SubtractBlock extends NodeMaterialBlock {
  64927. /**
  64928. * Creates a new SubtractBlock
  64929. * @param name defines the block name
  64930. */
  64931. constructor(name: string);
  64932. /**
  64933. * Gets the current class name
  64934. * @returns the class name
  64935. */
  64936. getClassName(): string;
  64937. /**
  64938. * Gets the left operand input component
  64939. */
  64940. get left(): NodeMaterialConnectionPoint;
  64941. /**
  64942. * Gets the right operand input component
  64943. */
  64944. get right(): NodeMaterialConnectionPoint;
  64945. /**
  64946. * Gets the output component
  64947. */
  64948. get output(): NodeMaterialConnectionPoint;
  64949. protected _buildBlock(state: NodeMaterialBuildState): this;
  64950. }
  64951. }
  64952. declare module BABYLON {
  64953. /**
  64954. * Block used to step a value
  64955. */
  64956. export class StepBlock extends NodeMaterialBlock {
  64957. /**
  64958. * Creates a new StepBlock
  64959. * @param name defines the block name
  64960. */
  64961. constructor(name: string);
  64962. /**
  64963. * Gets the current class name
  64964. * @returns the class name
  64965. */
  64966. getClassName(): string;
  64967. /**
  64968. * Gets the value operand input component
  64969. */
  64970. get value(): NodeMaterialConnectionPoint;
  64971. /**
  64972. * Gets the edge operand input component
  64973. */
  64974. get edge(): NodeMaterialConnectionPoint;
  64975. /**
  64976. * Gets the output component
  64977. */
  64978. get output(): NodeMaterialConnectionPoint;
  64979. protected _buildBlock(state: NodeMaterialBuildState): this;
  64980. }
  64981. }
  64982. declare module BABYLON {
  64983. /**
  64984. * Block used to get the opposite (1 - x) of a value
  64985. */
  64986. export class OneMinusBlock extends NodeMaterialBlock {
  64987. /**
  64988. * Creates a new OneMinusBlock
  64989. * @param name defines the block name
  64990. */
  64991. constructor(name: string);
  64992. /**
  64993. * Gets the current class name
  64994. * @returns the class name
  64995. */
  64996. getClassName(): string;
  64997. /**
  64998. * Gets the input component
  64999. */
  65000. get input(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the output component
  65003. */
  65004. get output(): NodeMaterialConnectionPoint;
  65005. protected _buildBlock(state: NodeMaterialBuildState): this;
  65006. }
  65007. }
  65008. declare module BABYLON {
  65009. /**
  65010. * Block used to get the view direction
  65011. */
  65012. export class ViewDirectionBlock extends NodeMaterialBlock {
  65013. /**
  65014. * Creates a new ViewDirectionBlock
  65015. * @param name defines the block name
  65016. */
  65017. constructor(name: string);
  65018. /**
  65019. * Gets the current class name
  65020. * @returns the class name
  65021. */
  65022. getClassName(): string;
  65023. /**
  65024. * Gets the world position component
  65025. */
  65026. get worldPosition(): NodeMaterialConnectionPoint;
  65027. /**
  65028. * Gets the camera position component
  65029. */
  65030. get cameraPosition(): NodeMaterialConnectionPoint;
  65031. /**
  65032. * Gets the output component
  65033. */
  65034. get output(): NodeMaterialConnectionPoint;
  65035. autoConfigure(material: NodeMaterial): void;
  65036. protected _buildBlock(state: NodeMaterialBuildState): this;
  65037. }
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * Block used to compute fresnel value
  65042. */
  65043. export class FresnelBlock extends NodeMaterialBlock {
  65044. /**
  65045. * Create a new FresnelBlock
  65046. * @param name defines the block name
  65047. */
  65048. constructor(name: string);
  65049. /**
  65050. * Gets the current class name
  65051. * @returns the class name
  65052. */
  65053. getClassName(): string;
  65054. /**
  65055. * Gets the world normal input component
  65056. */
  65057. get worldNormal(): NodeMaterialConnectionPoint;
  65058. /**
  65059. * Gets the view direction input component
  65060. */
  65061. get viewDirection(): NodeMaterialConnectionPoint;
  65062. /**
  65063. * Gets the bias input component
  65064. */
  65065. get bias(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the camera (or eye) position component
  65068. */
  65069. get power(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the fresnel output component
  65072. */
  65073. get fresnel(): NodeMaterialConnectionPoint;
  65074. autoConfigure(material: NodeMaterial): void;
  65075. protected _buildBlock(state: NodeMaterialBuildState): this;
  65076. }
  65077. }
  65078. declare module BABYLON {
  65079. /**
  65080. * Block used to get the max of 2 values
  65081. */
  65082. export class MaxBlock extends NodeMaterialBlock {
  65083. /**
  65084. * Creates a new MaxBlock
  65085. * @param name defines the block name
  65086. */
  65087. constructor(name: string);
  65088. /**
  65089. * Gets the current class name
  65090. * @returns the class name
  65091. */
  65092. getClassName(): string;
  65093. /**
  65094. * Gets the left operand input component
  65095. */
  65096. get left(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the right operand input component
  65099. */
  65100. get right(): NodeMaterialConnectionPoint;
  65101. /**
  65102. * Gets the output component
  65103. */
  65104. get output(): NodeMaterialConnectionPoint;
  65105. protected _buildBlock(state: NodeMaterialBuildState): this;
  65106. }
  65107. }
  65108. declare module BABYLON {
  65109. /**
  65110. * Block used to get the min of 2 values
  65111. */
  65112. export class MinBlock extends NodeMaterialBlock {
  65113. /**
  65114. * Creates a new MinBlock
  65115. * @param name defines the block name
  65116. */
  65117. constructor(name: string);
  65118. /**
  65119. * Gets the current class name
  65120. * @returns the class name
  65121. */
  65122. getClassName(): string;
  65123. /**
  65124. * Gets the left operand input component
  65125. */
  65126. get left(): NodeMaterialConnectionPoint;
  65127. /**
  65128. * Gets the right operand input component
  65129. */
  65130. get right(): NodeMaterialConnectionPoint;
  65131. /**
  65132. * Gets the output component
  65133. */
  65134. get output(): NodeMaterialConnectionPoint;
  65135. protected _buildBlock(state: NodeMaterialBuildState): this;
  65136. }
  65137. }
  65138. declare module BABYLON {
  65139. /**
  65140. * Block used to get the distance between 2 values
  65141. */
  65142. export class DistanceBlock extends NodeMaterialBlock {
  65143. /**
  65144. * Creates a new DistanceBlock
  65145. * @param name defines the block name
  65146. */
  65147. constructor(name: string);
  65148. /**
  65149. * Gets the current class name
  65150. * @returns the class name
  65151. */
  65152. getClassName(): string;
  65153. /**
  65154. * Gets the left operand input component
  65155. */
  65156. get left(): NodeMaterialConnectionPoint;
  65157. /**
  65158. * Gets the right operand input component
  65159. */
  65160. get right(): NodeMaterialConnectionPoint;
  65161. /**
  65162. * Gets the output component
  65163. */
  65164. get output(): NodeMaterialConnectionPoint;
  65165. protected _buildBlock(state: NodeMaterialBuildState): this;
  65166. }
  65167. }
  65168. declare module BABYLON {
  65169. /**
  65170. * Block used to get the length of a vector
  65171. */
  65172. export class LengthBlock extends NodeMaterialBlock {
  65173. /**
  65174. * Creates a new LengthBlock
  65175. * @param name defines the block name
  65176. */
  65177. constructor(name: string);
  65178. /**
  65179. * Gets the current class name
  65180. * @returns the class name
  65181. */
  65182. getClassName(): string;
  65183. /**
  65184. * Gets the value input component
  65185. */
  65186. get value(): NodeMaterialConnectionPoint;
  65187. /**
  65188. * Gets the output component
  65189. */
  65190. get output(): NodeMaterialConnectionPoint;
  65191. protected _buildBlock(state: NodeMaterialBuildState): this;
  65192. }
  65193. }
  65194. declare module BABYLON {
  65195. /**
  65196. * Block used to get negative version of a value (i.e. x * -1)
  65197. */
  65198. export class NegateBlock extends NodeMaterialBlock {
  65199. /**
  65200. * Creates a new NegateBlock
  65201. * @param name defines the block name
  65202. */
  65203. constructor(name: string);
  65204. /**
  65205. * Gets the current class name
  65206. * @returns the class name
  65207. */
  65208. getClassName(): string;
  65209. /**
  65210. * Gets the value input component
  65211. */
  65212. get value(): NodeMaterialConnectionPoint;
  65213. /**
  65214. * Gets the output component
  65215. */
  65216. get output(): NodeMaterialConnectionPoint;
  65217. protected _buildBlock(state: NodeMaterialBuildState): this;
  65218. }
  65219. }
  65220. declare module BABYLON {
  65221. /**
  65222. * Block used to get the value of the first parameter raised to the power of the second
  65223. */
  65224. export class PowBlock extends NodeMaterialBlock {
  65225. /**
  65226. * Creates a new PowBlock
  65227. * @param name defines the block name
  65228. */
  65229. constructor(name: string);
  65230. /**
  65231. * Gets the current class name
  65232. * @returns the class name
  65233. */
  65234. getClassName(): string;
  65235. /**
  65236. * Gets the value operand input component
  65237. */
  65238. get value(): NodeMaterialConnectionPoint;
  65239. /**
  65240. * Gets the power operand input component
  65241. */
  65242. get power(): NodeMaterialConnectionPoint;
  65243. /**
  65244. * Gets the output component
  65245. */
  65246. get output(): NodeMaterialConnectionPoint;
  65247. protected _buildBlock(state: NodeMaterialBuildState): this;
  65248. }
  65249. }
  65250. declare module BABYLON {
  65251. /**
  65252. * Block used to get a random number
  65253. */
  65254. export class RandomNumberBlock extends NodeMaterialBlock {
  65255. /**
  65256. * Creates a new RandomNumberBlock
  65257. * @param name defines the block name
  65258. */
  65259. constructor(name: string);
  65260. /**
  65261. * Gets the current class name
  65262. * @returns the class name
  65263. */
  65264. getClassName(): string;
  65265. /**
  65266. * Gets the seed input component
  65267. */
  65268. get seed(): NodeMaterialConnectionPoint;
  65269. /**
  65270. * Gets the output component
  65271. */
  65272. get output(): NodeMaterialConnectionPoint;
  65273. protected _buildBlock(state: NodeMaterialBuildState): this;
  65274. }
  65275. }
  65276. declare module BABYLON {
  65277. /**
  65278. * Block used to compute arc tangent of 2 values
  65279. */
  65280. export class ArcTan2Block extends NodeMaterialBlock {
  65281. /**
  65282. * Creates a new ArcTan2Block
  65283. * @param name defines the block name
  65284. */
  65285. constructor(name: string);
  65286. /**
  65287. * Gets the current class name
  65288. * @returns the class name
  65289. */
  65290. getClassName(): string;
  65291. /**
  65292. * Gets the x operand input component
  65293. */
  65294. get x(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the y operand input component
  65297. */
  65298. get y(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the output component
  65301. */
  65302. get output(): NodeMaterialConnectionPoint;
  65303. protected _buildBlock(state: NodeMaterialBuildState): this;
  65304. }
  65305. }
  65306. declare module BABYLON {
  65307. /**
  65308. * Block used to smooth step a value
  65309. */
  65310. export class SmoothStepBlock extends NodeMaterialBlock {
  65311. /**
  65312. * Creates a new SmoothStepBlock
  65313. * @param name defines the block name
  65314. */
  65315. constructor(name: string);
  65316. /**
  65317. * Gets the current class name
  65318. * @returns the class name
  65319. */
  65320. getClassName(): string;
  65321. /**
  65322. * Gets the value operand input component
  65323. */
  65324. get value(): NodeMaterialConnectionPoint;
  65325. /**
  65326. * Gets the first edge operand input component
  65327. */
  65328. get edge0(): NodeMaterialConnectionPoint;
  65329. /**
  65330. * Gets the second edge operand input component
  65331. */
  65332. get edge1(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the output component
  65335. */
  65336. get output(): NodeMaterialConnectionPoint;
  65337. protected _buildBlock(state: NodeMaterialBuildState): this;
  65338. }
  65339. }
  65340. declare module BABYLON {
  65341. /**
  65342. * Block used to get the reciprocal (1 / x) of a value
  65343. */
  65344. export class ReciprocalBlock extends NodeMaterialBlock {
  65345. /**
  65346. * Creates a new ReciprocalBlock
  65347. * @param name defines the block name
  65348. */
  65349. constructor(name: string);
  65350. /**
  65351. * Gets the current class name
  65352. * @returns the class name
  65353. */
  65354. getClassName(): string;
  65355. /**
  65356. * Gets the input component
  65357. */
  65358. get input(): NodeMaterialConnectionPoint;
  65359. /**
  65360. * Gets the output component
  65361. */
  65362. get output(): NodeMaterialConnectionPoint;
  65363. protected _buildBlock(state: NodeMaterialBuildState): this;
  65364. }
  65365. }
  65366. declare module BABYLON {
  65367. /**
  65368. * Block used to replace a color by another one
  65369. */
  65370. export class ReplaceColorBlock extends NodeMaterialBlock {
  65371. /**
  65372. * Creates a new ReplaceColorBlock
  65373. * @param name defines the block name
  65374. */
  65375. constructor(name: string);
  65376. /**
  65377. * Gets the current class name
  65378. * @returns the class name
  65379. */
  65380. getClassName(): string;
  65381. /**
  65382. * Gets the value input component
  65383. */
  65384. get value(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the reference input component
  65387. */
  65388. get reference(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the distance input component
  65391. */
  65392. get distance(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the replacement input component
  65395. */
  65396. get replacement(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the output component
  65399. */
  65400. get output(): NodeMaterialConnectionPoint;
  65401. protected _buildBlock(state: NodeMaterialBuildState): this;
  65402. }
  65403. }
  65404. declare module BABYLON {
  65405. /**
  65406. * Block used to posterize a value
  65407. * @see https://en.wikipedia.org/wiki/Posterization
  65408. */
  65409. export class PosterizeBlock extends NodeMaterialBlock {
  65410. /**
  65411. * Creates a new PosterizeBlock
  65412. * @param name defines the block name
  65413. */
  65414. constructor(name: string);
  65415. /**
  65416. * Gets the current class name
  65417. * @returns the class name
  65418. */
  65419. getClassName(): string;
  65420. /**
  65421. * Gets the value input component
  65422. */
  65423. get value(): NodeMaterialConnectionPoint;
  65424. /**
  65425. * Gets the steps input component
  65426. */
  65427. get steps(): NodeMaterialConnectionPoint;
  65428. /**
  65429. * Gets the output component
  65430. */
  65431. get output(): NodeMaterialConnectionPoint;
  65432. protected _buildBlock(state: NodeMaterialBuildState): this;
  65433. }
  65434. }
  65435. declare module BABYLON {
  65436. /**
  65437. * Operations supported by the Wave block
  65438. */
  65439. export enum WaveBlockKind {
  65440. /** SawTooth */
  65441. SawTooth = 0,
  65442. /** Square */
  65443. Square = 1,
  65444. /** Triangle */
  65445. Triangle = 2
  65446. }
  65447. /**
  65448. * Block used to apply wave operation to floats
  65449. */
  65450. export class WaveBlock extends NodeMaterialBlock {
  65451. /**
  65452. * Gets or sets the kibnd of wave to be applied by the block
  65453. */
  65454. kind: WaveBlockKind;
  65455. /**
  65456. * Creates a new WaveBlock
  65457. * @param name defines the block name
  65458. */
  65459. constructor(name: string);
  65460. /**
  65461. * Gets the current class name
  65462. * @returns the class name
  65463. */
  65464. getClassName(): string;
  65465. /**
  65466. * Gets the input component
  65467. */
  65468. get input(): NodeMaterialConnectionPoint;
  65469. /**
  65470. * Gets the output component
  65471. */
  65472. get output(): NodeMaterialConnectionPoint;
  65473. protected _buildBlock(state: NodeMaterialBuildState): this;
  65474. serialize(): any;
  65475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65476. }
  65477. }
  65478. declare module BABYLON {
  65479. /**
  65480. * Class used to store a color step for the GradientBlock
  65481. */
  65482. export class GradientBlockColorStep {
  65483. private _step;
  65484. /**
  65485. * Gets value indicating which step this color is associated with (between 0 and 1)
  65486. */
  65487. get step(): number;
  65488. /**
  65489. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65490. */
  65491. set step(val: number);
  65492. private _color;
  65493. /**
  65494. * Gets the color associated with this step
  65495. */
  65496. get color(): Color3;
  65497. /**
  65498. * Sets the color associated with this step
  65499. */
  65500. set color(val: Color3);
  65501. /**
  65502. * Creates a new GradientBlockColorStep
  65503. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65504. * @param color defines the color associated with this step
  65505. */
  65506. constructor(step: number, color: Color3);
  65507. }
  65508. /**
  65509. * Block used to return a color from a gradient based on an input value between 0 and 1
  65510. */
  65511. export class GradientBlock extends NodeMaterialBlock {
  65512. /**
  65513. * Gets or sets the list of color steps
  65514. */
  65515. colorSteps: GradientBlockColorStep[];
  65516. /** Gets an observable raised when the value is changed */
  65517. onValueChangedObservable: Observable<GradientBlock>;
  65518. /** calls observable when the value is changed*/
  65519. colorStepsUpdated(): void;
  65520. /**
  65521. * Creates a new GradientBlock
  65522. * @param name defines the block name
  65523. */
  65524. constructor(name: string);
  65525. /**
  65526. * Gets the current class name
  65527. * @returns the class name
  65528. */
  65529. getClassName(): string;
  65530. /**
  65531. * Gets the gradient input component
  65532. */
  65533. get gradient(): NodeMaterialConnectionPoint;
  65534. /**
  65535. * Gets the output component
  65536. */
  65537. get output(): NodeMaterialConnectionPoint;
  65538. private _writeColorConstant;
  65539. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65540. serialize(): any;
  65541. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65542. protected _dumpPropertiesCode(): string;
  65543. }
  65544. }
  65545. declare module BABYLON {
  65546. /**
  65547. * Block used to normalize lerp between 2 values
  65548. */
  65549. export class NLerpBlock extends NodeMaterialBlock {
  65550. /**
  65551. * Creates a new NLerpBlock
  65552. * @param name defines the block name
  65553. */
  65554. constructor(name: string);
  65555. /**
  65556. * Gets the current class name
  65557. * @returns the class name
  65558. */
  65559. getClassName(): string;
  65560. /**
  65561. * Gets the left operand input component
  65562. */
  65563. get left(): NodeMaterialConnectionPoint;
  65564. /**
  65565. * Gets the right operand input component
  65566. */
  65567. get right(): NodeMaterialConnectionPoint;
  65568. /**
  65569. * Gets the gradient operand input component
  65570. */
  65571. get gradient(): NodeMaterialConnectionPoint;
  65572. /**
  65573. * Gets the output component
  65574. */
  65575. get output(): NodeMaterialConnectionPoint;
  65576. protected _buildBlock(state: NodeMaterialBuildState): this;
  65577. }
  65578. }
  65579. declare module BABYLON {
  65580. /**
  65581. * block used to Generate a Worley Noise 3D Noise Pattern
  65582. */
  65583. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65584. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65585. manhattanDistance: boolean;
  65586. /**
  65587. * Creates a new WorleyNoise3DBlock
  65588. * @param name defines the block name
  65589. */
  65590. constructor(name: string);
  65591. /**
  65592. * Gets the current class name
  65593. * @returns the class name
  65594. */
  65595. getClassName(): string;
  65596. /**
  65597. * Gets the seed input component
  65598. */
  65599. get seed(): NodeMaterialConnectionPoint;
  65600. /**
  65601. * Gets the jitter input component
  65602. */
  65603. get jitter(): NodeMaterialConnectionPoint;
  65604. /**
  65605. * Gets the output component
  65606. */
  65607. get output(): NodeMaterialConnectionPoint;
  65608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65609. /**
  65610. * Exposes the properties to the UI?
  65611. */
  65612. protected _dumpPropertiesCode(): string;
  65613. /**
  65614. * Exposes the properties to the Seralize?
  65615. */
  65616. serialize(): any;
  65617. /**
  65618. * Exposes the properties to the deseralize?
  65619. */
  65620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65621. }
  65622. }
  65623. declare module BABYLON {
  65624. /**
  65625. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65626. */
  65627. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65628. /**
  65629. * Creates a new SimplexPerlin3DBlock
  65630. * @param name defines the block name
  65631. */
  65632. constructor(name: string);
  65633. /**
  65634. * Gets the current class name
  65635. * @returns the class name
  65636. */
  65637. getClassName(): string;
  65638. /**
  65639. * Gets the seed operand input component
  65640. */
  65641. get seed(): NodeMaterialConnectionPoint;
  65642. /**
  65643. * Gets the output component
  65644. */
  65645. get output(): NodeMaterialConnectionPoint;
  65646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65647. }
  65648. }
  65649. declare module BABYLON {
  65650. /**
  65651. * Block used to blend normals
  65652. */
  65653. export class NormalBlendBlock extends NodeMaterialBlock {
  65654. /**
  65655. * Creates a new NormalBlendBlock
  65656. * @param name defines the block name
  65657. */
  65658. constructor(name: string);
  65659. /**
  65660. * Gets the current class name
  65661. * @returns the class name
  65662. */
  65663. getClassName(): string;
  65664. /**
  65665. * Gets the first input component
  65666. */
  65667. get normalMap0(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the second input component
  65670. */
  65671. get normalMap1(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the output component
  65674. */
  65675. get output(): NodeMaterialConnectionPoint;
  65676. protected _buildBlock(state: NodeMaterialBuildState): this;
  65677. }
  65678. }
  65679. declare module BABYLON {
  65680. /**
  65681. * Block used to rotate a 2d vector by a given angle
  65682. */
  65683. export class Rotate2dBlock extends NodeMaterialBlock {
  65684. /**
  65685. * Creates a new Rotate2dBlock
  65686. * @param name defines the block name
  65687. */
  65688. constructor(name: string);
  65689. /**
  65690. * Gets the current class name
  65691. * @returns the class name
  65692. */
  65693. getClassName(): string;
  65694. /**
  65695. * Gets the input vector
  65696. */
  65697. get input(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the input angle
  65700. */
  65701. get angle(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the output component
  65704. */
  65705. get output(): NodeMaterialConnectionPoint;
  65706. autoConfigure(material: NodeMaterial): void;
  65707. protected _buildBlock(state: NodeMaterialBuildState): this;
  65708. }
  65709. }
  65710. declare module BABYLON {
  65711. /**
  65712. * Block used to get the reflected vector from a direction and a normal
  65713. */
  65714. export class ReflectBlock extends NodeMaterialBlock {
  65715. /**
  65716. * Creates a new ReflectBlock
  65717. * @param name defines the block name
  65718. */
  65719. constructor(name: string);
  65720. /**
  65721. * Gets the current class name
  65722. * @returns the class name
  65723. */
  65724. getClassName(): string;
  65725. /**
  65726. * Gets the incident component
  65727. */
  65728. get incident(): NodeMaterialConnectionPoint;
  65729. /**
  65730. * Gets the normal component
  65731. */
  65732. get normal(): NodeMaterialConnectionPoint;
  65733. /**
  65734. * Gets the output component
  65735. */
  65736. get output(): NodeMaterialConnectionPoint;
  65737. protected _buildBlock(state: NodeMaterialBuildState): this;
  65738. }
  65739. }
  65740. declare module BABYLON {
  65741. /**
  65742. * Block used to get the refracted vector from a direction and a normal
  65743. */
  65744. export class RefractBlock extends NodeMaterialBlock {
  65745. /**
  65746. * Creates a new RefractBlock
  65747. * @param name defines the block name
  65748. */
  65749. constructor(name: string);
  65750. /**
  65751. * Gets the current class name
  65752. * @returns the class name
  65753. */
  65754. getClassName(): string;
  65755. /**
  65756. * Gets the incident component
  65757. */
  65758. get incident(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the normal component
  65761. */
  65762. get normal(): NodeMaterialConnectionPoint;
  65763. /**
  65764. * Gets the index of refraction component
  65765. */
  65766. get ior(): NodeMaterialConnectionPoint;
  65767. /**
  65768. * Gets the output component
  65769. */
  65770. get output(): NodeMaterialConnectionPoint;
  65771. protected _buildBlock(state: NodeMaterialBuildState): this;
  65772. }
  65773. }
  65774. declare module BABYLON {
  65775. /**
  65776. * Block used to desaturate a color
  65777. */
  65778. export class DesaturateBlock extends NodeMaterialBlock {
  65779. /**
  65780. * Creates a new DesaturateBlock
  65781. * @param name defines the block name
  65782. */
  65783. constructor(name: string);
  65784. /**
  65785. * Gets the current class name
  65786. * @returns the class name
  65787. */
  65788. getClassName(): string;
  65789. /**
  65790. * Gets the color operand input component
  65791. */
  65792. get color(): NodeMaterialConnectionPoint;
  65793. /**
  65794. * Gets the level operand input component
  65795. */
  65796. get level(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the output component
  65799. */
  65800. get output(): NodeMaterialConnectionPoint;
  65801. protected _buildBlock(state: NodeMaterialBuildState): this;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /**
  65806. * Block used to implement the reflection module of the PBR material
  65807. */
  65808. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65809. /** @hidden */
  65810. _defineLODReflectionAlpha: string;
  65811. /** @hidden */
  65812. _defineLinearSpecularReflection: string;
  65813. private _vEnvironmentIrradianceName;
  65814. /** @hidden */
  65815. _vReflectionMicrosurfaceInfosName: string;
  65816. /** @hidden */
  65817. _vReflectionInfosName: string;
  65818. /** @hidden */
  65819. _vReflectionFilteringInfoName: string;
  65820. private _scene;
  65821. /**
  65822. * The properties below are set by the main PBR block prior to calling methods of this class.
  65823. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65824. * It's less burden on the user side in the editor part.
  65825. */
  65826. /** @hidden */
  65827. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65828. /** @hidden */
  65829. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65830. /** @hidden */
  65831. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65832. /** @hidden */
  65833. viewConnectionPoint: NodeMaterialConnectionPoint;
  65834. /**
  65835. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65836. * diffuse part of the IBL.
  65837. */
  65838. useSphericalHarmonics: boolean;
  65839. /**
  65840. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65841. */
  65842. forceIrradianceInFragment: boolean;
  65843. /**
  65844. * Create a new ReflectionBlock
  65845. * @param name defines the block name
  65846. */
  65847. constructor(name: string);
  65848. /**
  65849. * Gets the current class name
  65850. * @returns the class name
  65851. */
  65852. getClassName(): string;
  65853. /**
  65854. * Gets the position input component
  65855. */
  65856. get position(): NodeMaterialConnectionPoint;
  65857. /**
  65858. * Gets the world position input component
  65859. */
  65860. get worldPosition(): NodeMaterialConnectionPoint;
  65861. /**
  65862. * Gets the world normal input component
  65863. */
  65864. get worldNormal(): NodeMaterialConnectionPoint;
  65865. /**
  65866. * Gets the world input component
  65867. */
  65868. get world(): NodeMaterialConnectionPoint;
  65869. /**
  65870. * Gets the camera (or eye) position component
  65871. */
  65872. get cameraPosition(): NodeMaterialConnectionPoint;
  65873. /**
  65874. * Gets the view input component
  65875. */
  65876. get view(): NodeMaterialConnectionPoint;
  65877. /**
  65878. * Gets the color input component
  65879. */
  65880. get color(): NodeMaterialConnectionPoint;
  65881. /**
  65882. * Gets the reflection object output component
  65883. */
  65884. get reflection(): NodeMaterialConnectionPoint;
  65885. /**
  65886. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65887. */
  65888. get hasTexture(): boolean;
  65889. /**
  65890. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65891. */
  65892. get reflectionColor(): string;
  65893. protected _getTexture(): Nullable<BaseTexture>;
  65894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65896. /**
  65897. * Gets the code to inject in the vertex shader
  65898. * @param state current state of the node material building
  65899. * @returns the shader code
  65900. */
  65901. handleVertexSide(state: NodeMaterialBuildState): string;
  65902. /**
  65903. * Gets the main code of the block (fragment side)
  65904. * @param state current state of the node material building
  65905. * @param normalVarName name of the existing variable corresponding to the normal
  65906. * @returns the shader code
  65907. */
  65908. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65909. protected _buildBlock(state: NodeMaterialBuildState): this;
  65910. protected _dumpPropertiesCode(): string;
  65911. serialize(): any;
  65912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65913. }
  65914. }
  65915. declare module BABYLON {
  65916. /**
  65917. * Block used to implement the sheen module of the PBR material
  65918. */
  65919. export class SheenBlock extends NodeMaterialBlock {
  65920. /**
  65921. * Create a new SheenBlock
  65922. * @param name defines the block name
  65923. */
  65924. constructor(name: string);
  65925. /**
  65926. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65927. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65928. * making it easier to setup and tweak the effect
  65929. */
  65930. albedoScaling: boolean;
  65931. /**
  65932. * Defines if the sheen is linked to the sheen color.
  65933. */
  65934. linkSheenWithAlbedo: boolean;
  65935. /**
  65936. * Initialize the block and prepare the context for build
  65937. * @param state defines the state that will be used for the build
  65938. */
  65939. initialize(state: NodeMaterialBuildState): void;
  65940. /**
  65941. * Gets the current class name
  65942. * @returns the class name
  65943. */
  65944. getClassName(): string;
  65945. /**
  65946. * Gets the intensity input component
  65947. */
  65948. get intensity(): NodeMaterialConnectionPoint;
  65949. /**
  65950. * Gets the color input component
  65951. */
  65952. get color(): NodeMaterialConnectionPoint;
  65953. /**
  65954. * Gets the roughness input component
  65955. */
  65956. get roughness(): NodeMaterialConnectionPoint;
  65957. /**
  65958. * Gets the sheen object output component
  65959. */
  65960. get sheen(): NodeMaterialConnectionPoint;
  65961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65962. /**
  65963. * Gets the main code of the block (fragment side)
  65964. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65965. * @returns the shader code
  65966. */
  65967. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65968. protected _buildBlock(state: NodeMaterialBuildState): this;
  65969. protected _dumpPropertiesCode(): string;
  65970. serialize(): any;
  65971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65972. }
  65973. }
  65974. declare module BABYLON {
  65975. /**
  65976. * Block used to implement the anisotropy module of the PBR material
  65977. */
  65978. export class AnisotropyBlock extends NodeMaterialBlock {
  65979. /**
  65980. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65981. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65982. * It's less burden on the user side in the editor part.
  65983. */
  65984. /** @hidden */
  65985. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65986. /** @hidden */
  65987. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65988. /**
  65989. * Create a new AnisotropyBlock
  65990. * @param name defines the block name
  65991. */
  65992. constructor(name: string);
  65993. /**
  65994. * Initialize the block and prepare the context for build
  65995. * @param state defines the state that will be used for the build
  65996. */
  65997. initialize(state: NodeMaterialBuildState): void;
  65998. /**
  65999. * Gets the current class name
  66000. * @returns the class name
  66001. */
  66002. getClassName(): string;
  66003. /**
  66004. * Gets the intensity input component
  66005. */
  66006. get intensity(): NodeMaterialConnectionPoint;
  66007. /**
  66008. * Gets the direction input component
  66009. */
  66010. get direction(): NodeMaterialConnectionPoint;
  66011. /**
  66012. * Gets the uv input component
  66013. */
  66014. get uv(): NodeMaterialConnectionPoint;
  66015. /**
  66016. * Gets the worldTangent input component
  66017. */
  66018. get worldTangent(): NodeMaterialConnectionPoint;
  66019. /**
  66020. * Gets the anisotropy object output component
  66021. */
  66022. get anisotropy(): NodeMaterialConnectionPoint;
  66023. private _generateTBNSpace;
  66024. /**
  66025. * Gets the main code of the block (fragment side)
  66026. * @param state current state of the node material building
  66027. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66028. * @returns the shader code
  66029. */
  66030. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66032. protected _buildBlock(state: NodeMaterialBuildState): this;
  66033. }
  66034. }
  66035. declare module BABYLON {
  66036. /**
  66037. * Block used to implement the clear coat module of the PBR material
  66038. */
  66039. export class ClearCoatBlock extends NodeMaterialBlock {
  66040. private _scene;
  66041. /**
  66042. * Create a new ClearCoatBlock
  66043. * @param name defines the block name
  66044. */
  66045. constructor(name: string);
  66046. /**
  66047. * Defines if the F0 value should be remapped to account for the interface change in the material.
  66048. */
  66049. remapF0OnInterfaceChange: boolean;
  66050. /**
  66051. * Initialize the block and prepare the context for build
  66052. * @param state defines the state that will be used for the build
  66053. */
  66054. initialize(state: NodeMaterialBuildState): void;
  66055. /**
  66056. * Gets the current class name
  66057. * @returns the class name
  66058. */
  66059. getClassName(): string;
  66060. /**
  66061. * Gets the intensity input component
  66062. */
  66063. get intensity(): NodeMaterialConnectionPoint;
  66064. /**
  66065. * Gets the roughness input component
  66066. */
  66067. get roughness(): NodeMaterialConnectionPoint;
  66068. /**
  66069. * Gets the ior input component
  66070. */
  66071. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66072. /**
  66073. * Gets the bump texture input component
  66074. */
  66075. get normalMapColor(): NodeMaterialConnectionPoint;
  66076. /**
  66077. * Gets the uv input component
  66078. */
  66079. get uv(): NodeMaterialConnectionPoint;
  66080. /**
  66081. * Gets the tint color input component
  66082. */
  66083. get tintColor(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the tint "at distance" input component
  66086. */
  66087. get tintAtDistance(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the tint thickness input component
  66090. */
  66091. get tintThickness(): NodeMaterialConnectionPoint;
  66092. /**
  66093. * Gets the world tangent input component
  66094. */
  66095. get worldTangent(): NodeMaterialConnectionPoint;
  66096. /**
  66097. * Gets the clear coat object output component
  66098. */
  66099. get clearcoat(): NodeMaterialConnectionPoint;
  66100. autoConfigure(material: NodeMaterial): void;
  66101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66102. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66103. private _generateTBNSpace;
  66104. /**
  66105. * Gets the main code of the block (fragment side)
  66106. * @param state current state of the node material building
  66107. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66108. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66109. * @param worldPosVarName name of the variable holding the world position
  66110. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66111. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66112. * @param worldNormalVarName name of the variable holding the world normal
  66113. * @returns the shader code
  66114. */
  66115. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66116. protected _buildBlock(state: NodeMaterialBuildState): this;
  66117. protected _dumpPropertiesCode(): string;
  66118. serialize(): any;
  66119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * Block used to implement the sub surface module of the PBR material
  66125. */
  66126. export class SubSurfaceBlock extends NodeMaterialBlock {
  66127. /**
  66128. * Create a new SubSurfaceBlock
  66129. * @param name defines the block name
  66130. */
  66131. constructor(name: string);
  66132. /**
  66133. * Initialize the block and prepare the context for build
  66134. * @param state defines the state that will be used for the build
  66135. */
  66136. initialize(state: NodeMaterialBuildState): void;
  66137. /**
  66138. * Gets the current class name
  66139. * @returns the class name
  66140. */
  66141. getClassName(): string;
  66142. /**
  66143. * Gets the thickness component
  66144. */
  66145. get thickness(): NodeMaterialConnectionPoint;
  66146. /**
  66147. * Gets the tint color input component
  66148. */
  66149. get tintColor(): NodeMaterialConnectionPoint;
  66150. /**
  66151. * Gets the translucency intensity input component
  66152. */
  66153. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66154. /**
  66155. * Gets the translucency diffusion distance input component
  66156. */
  66157. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66158. /**
  66159. * Gets the refraction object parameters
  66160. */
  66161. get refraction(): NodeMaterialConnectionPoint;
  66162. /**
  66163. * Gets the sub surface object output component
  66164. */
  66165. get subsurface(): NodeMaterialConnectionPoint;
  66166. autoConfigure(material: NodeMaterial): void;
  66167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66168. /**
  66169. * Gets the main code of the block (fragment side)
  66170. * @param state current state of the node material building
  66171. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66172. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66173. * @param worldPosVarName name of the variable holding the world position
  66174. * @returns the shader code
  66175. */
  66176. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66177. protected _buildBlock(state: NodeMaterialBuildState): this;
  66178. }
  66179. }
  66180. declare module BABYLON {
  66181. /**
  66182. * Block used to implement the PBR metallic/roughness model
  66183. */
  66184. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66185. /**
  66186. * Gets or sets the light associated with this block
  66187. */
  66188. light: Nullable<Light>;
  66189. private _lightId;
  66190. private _scene;
  66191. private _environmentBRDFTexture;
  66192. private _environmentBrdfSamplerName;
  66193. private _vNormalWName;
  66194. private _invertNormalName;
  66195. private _metallicReflectanceColor;
  66196. private _metallicF0Factor;
  66197. private _vMetallicReflectanceFactorsName;
  66198. /**
  66199. * Create a new ReflectionBlock
  66200. * @param name defines the block name
  66201. */
  66202. constructor(name: string);
  66203. /**
  66204. * Intensity of the direct lights e.g. the four lights available in your scene.
  66205. * This impacts both the direct diffuse and specular highlights.
  66206. */
  66207. directIntensity: number;
  66208. /**
  66209. * Intensity of the environment e.g. how much the environment will light the object
  66210. * either through harmonics for rough material or through the refelction for shiny ones.
  66211. */
  66212. environmentIntensity: number;
  66213. /**
  66214. * This is a special control allowing the reduction of the specular highlights coming from the
  66215. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66216. */
  66217. specularIntensity: number;
  66218. /**
  66219. * Defines the falloff type used in this material.
  66220. * It by default is Physical.
  66221. */
  66222. lightFalloff: number;
  66223. /**
  66224. * Specifies that alpha test should be used
  66225. */
  66226. useAlphaTest: boolean;
  66227. /**
  66228. * Defines the alpha limits in alpha test mode.
  66229. */
  66230. alphaTestCutoff: number;
  66231. /**
  66232. * Specifies that alpha blending should be used
  66233. */
  66234. useAlphaBlending: boolean;
  66235. /**
  66236. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66237. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66238. */
  66239. useRadianceOverAlpha: boolean;
  66240. /**
  66241. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66242. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66243. */
  66244. useSpecularOverAlpha: boolean;
  66245. /**
  66246. * Enables specular anti aliasing in the PBR shader.
  66247. * It will both interacts on the Geometry for analytical and IBL lighting.
  66248. * It also prefilter the roughness map based on the bump values.
  66249. */
  66250. enableSpecularAntiAliasing: boolean;
  66251. /**
  66252. * Enables realtime filtering on the texture.
  66253. */
  66254. realTimeFiltering: boolean;
  66255. /**
  66256. * Quality switch for realtime filtering
  66257. */
  66258. realTimeFilteringQuality: number;
  66259. /**
  66260. * Defines if the material uses energy conservation.
  66261. */
  66262. useEnergyConservation: boolean;
  66263. /**
  66264. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66265. * too much the area relying on ambient texture to define their ambient occlusion.
  66266. */
  66267. useRadianceOcclusion: boolean;
  66268. /**
  66269. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66270. * makes the reflect vector face the model (under horizon).
  66271. */
  66272. useHorizonOcclusion: boolean;
  66273. /**
  66274. * If set to true, no lighting calculations will be applied.
  66275. */
  66276. unlit: boolean;
  66277. /**
  66278. * Force normal to face away from face.
  66279. */
  66280. forceNormalForward: boolean;
  66281. /**
  66282. * Defines the material debug mode.
  66283. * It helps seeing only some components of the material while troubleshooting.
  66284. */
  66285. debugMode: number;
  66286. /**
  66287. * Specify from where on screen the debug mode should start.
  66288. * The value goes from -1 (full screen) to 1 (not visible)
  66289. * It helps with side by side comparison against the final render
  66290. * This defaults to 0
  66291. */
  66292. debugLimit: number;
  66293. /**
  66294. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66295. * You can use the factor to better multiply the final value.
  66296. */
  66297. debugFactor: number;
  66298. /**
  66299. * Initialize the block and prepare the context for build
  66300. * @param state defines the state that will be used for the build
  66301. */
  66302. initialize(state: NodeMaterialBuildState): void;
  66303. /**
  66304. * Gets the current class name
  66305. * @returns the class name
  66306. */
  66307. getClassName(): string;
  66308. /**
  66309. * Gets the world position input component
  66310. */
  66311. get worldPosition(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the world normal input component
  66314. */
  66315. get worldNormal(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the view matrix parameter
  66318. */
  66319. get view(): NodeMaterialConnectionPoint;
  66320. /**
  66321. * Gets the camera position input component
  66322. */
  66323. get cameraPosition(): NodeMaterialConnectionPoint;
  66324. /**
  66325. * Gets the perturbed normal input component
  66326. */
  66327. get perturbedNormal(): NodeMaterialConnectionPoint;
  66328. /**
  66329. * Gets the base color input component
  66330. */
  66331. get baseColor(): NodeMaterialConnectionPoint;
  66332. /**
  66333. * Gets the metallic input component
  66334. */
  66335. get metallic(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the roughness input component
  66338. */
  66339. get roughness(): NodeMaterialConnectionPoint;
  66340. /**
  66341. * Gets the ambient occlusion input component
  66342. */
  66343. get ambientOcc(): NodeMaterialConnectionPoint;
  66344. /**
  66345. * Gets the opacity input component
  66346. */
  66347. get opacity(): NodeMaterialConnectionPoint;
  66348. /**
  66349. * Gets the index of refraction input component
  66350. */
  66351. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66352. /**
  66353. * Gets the ambient color input component
  66354. */
  66355. get ambientColor(): NodeMaterialConnectionPoint;
  66356. /**
  66357. * Gets the reflection object parameters
  66358. */
  66359. get reflection(): NodeMaterialConnectionPoint;
  66360. /**
  66361. * Gets the clear coat object parameters
  66362. */
  66363. get clearcoat(): NodeMaterialConnectionPoint;
  66364. /**
  66365. * Gets the sheen object parameters
  66366. */
  66367. get sheen(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the sub surface object parameters
  66370. */
  66371. get subsurface(): NodeMaterialConnectionPoint;
  66372. /**
  66373. * Gets the anisotropy object parameters
  66374. */
  66375. get anisotropy(): NodeMaterialConnectionPoint;
  66376. /**
  66377. * Gets the ambient output component
  66378. */
  66379. get ambientClr(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the diffuse output component
  66382. */
  66383. get diffuseDir(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the specular output component
  66386. */
  66387. get specularDir(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the clear coat output component
  66390. */
  66391. get clearcoatDir(): NodeMaterialConnectionPoint;
  66392. /**
  66393. * Gets the sheen output component
  66394. */
  66395. get sheenDir(): NodeMaterialConnectionPoint;
  66396. /**
  66397. * Gets the indirect diffuse output component
  66398. */
  66399. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66400. /**
  66401. * Gets the indirect specular output component
  66402. */
  66403. get specularIndirect(): NodeMaterialConnectionPoint;
  66404. /**
  66405. * Gets the indirect clear coat output component
  66406. */
  66407. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66408. /**
  66409. * Gets the indirect sheen output component
  66410. */
  66411. get sheenIndirect(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the refraction output component
  66414. */
  66415. get refraction(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the global lighting output component
  66418. */
  66419. get lighting(): NodeMaterialConnectionPoint;
  66420. /**
  66421. * Gets the shadow output component
  66422. */
  66423. get shadow(): NodeMaterialConnectionPoint;
  66424. /**
  66425. * Gets the alpha output component
  66426. */
  66427. get alpha(): NodeMaterialConnectionPoint;
  66428. autoConfigure(material: NodeMaterial): void;
  66429. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66430. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66431. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66432. private _injectVertexCode;
  66433. private _getAlbedoOpacityCode;
  66434. private _getAmbientOcclusionCode;
  66435. private _getReflectivityCode;
  66436. protected _buildBlock(state: NodeMaterialBuildState): this;
  66437. protected _dumpPropertiesCode(): string;
  66438. serialize(): any;
  66439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66440. }
  66441. }
  66442. declare module BABYLON {
  66443. /**
  66444. * Block used to compute value of one parameter modulo another
  66445. */
  66446. export class ModBlock extends NodeMaterialBlock {
  66447. /**
  66448. * Creates a new ModBlock
  66449. * @param name defines the block name
  66450. */
  66451. constructor(name: string);
  66452. /**
  66453. * Gets the current class name
  66454. * @returns the class name
  66455. */
  66456. getClassName(): string;
  66457. /**
  66458. * Gets the left operand input component
  66459. */
  66460. get left(): NodeMaterialConnectionPoint;
  66461. /**
  66462. * Gets the right operand input component
  66463. */
  66464. get right(): NodeMaterialConnectionPoint;
  66465. /**
  66466. * Gets the output component
  66467. */
  66468. get output(): NodeMaterialConnectionPoint;
  66469. protected _buildBlock(state: NodeMaterialBuildState): this;
  66470. }
  66471. }
  66472. declare module BABYLON {
  66473. /**
  66474. * Configuration for Draco compression
  66475. */
  66476. export interface IDracoCompressionConfiguration {
  66477. /**
  66478. * Configuration for the decoder.
  66479. */
  66480. decoder: {
  66481. /**
  66482. * The url to the WebAssembly module.
  66483. */
  66484. wasmUrl?: string;
  66485. /**
  66486. * The url to the WebAssembly binary.
  66487. */
  66488. wasmBinaryUrl?: string;
  66489. /**
  66490. * The url to the fallback JavaScript module.
  66491. */
  66492. fallbackUrl?: string;
  66493. };
  66494. }
  66495. /**
  66496. * Draco compression (https://google.github.io/draco/)
  66497. *
  66498. * This class wraps the Draco module.
  66499. *
  66500. * **Encoder**
  66501. *
  66502. * The encoder is not currently implemented.
  66503. *
  66504. * **Decoder**
  66505. *
  66506. * 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.
  66507. *
  66508. * To update the configuration, use the following code:
  66509. * ```javascript
  66510. * DracoCompression.Configuration = {
  66511. * decoder: {
  66512. * wasmUrl: "<url to the WebAssembly library>",
  66513. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66514. * fallbackUrl: "<url to the fallback JavaScript library>",
  66515. * }
  66516. * };
  66517. * ```
  66518. *
  66519. * 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.
  66520. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66521. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66522. *
  66523. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66524. * ```javascript
  66525. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66526. * ```
  66527. *
  66528. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66529. */
  66530. export class DracoCompression implements IDisposable {
  66531. private _workerPoolPromise?;
  66532. private _decoderModulePromise?;
  66533. /**
  66534. * The configuration. Defaults to the following urls:
  66535. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66536. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66537. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66538. */
  66539. static Configuration: IDracoCompressionConfiguration;
  66540. /**
  66541. * Returns true if the decoder configuration is available.
  66542. */
  66543. static get DecoderAvailable(): boolean;
  66544. /**
  66545. * Default number of workers to create when creating the draco compression object.
  66546. */
  66547. static DefaultNumWorkers: number;
  66548. private static GetDefaultNumWorkers;
  66549. private static _Default;
  66550. /**
  66551. * Default instance for the draco compression object.
  66552. */
  66553. static get Default(): DracoCompression;
  66554. /**
  66555. * Constructor
  66556. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66557. */
  66558. constructor(numWorkers?: number);
  66559. /**
  66560. * Stop all async operations and release resources.
  66561. */
  66562. dispose(): void;
  66563. /**
  66564. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66565. * @returns a promise that resolves when ready
  66566. */
  66567. whenReadyAsync(): Promise<void>;
  66568. /**
  66569. * Decode Draco compressed mesh data to vertex data.
  66570. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66571. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66572. * @returns A promise that resolves with the decoded vertex data
  66573. */
  66574. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66575. [kind: string]: number;
  66576. }): Promise<VertexData>;
  66577. }
  66578. }
  66579. declare module BABYLON {
  66580. /**
  66581. * Class for building Constructive Solid Geometry
  66582. */
  66583. export class CSG {
  66584. private polygons;
  66585. /**
  66586. * The world matrix
  66587. */
  66588. matrix: Matrix;
  66589. /**
  66590. * Stores the position
  66591. */
  66592. position: Vector3;
  66593. /**
  66594. * Stores the rotation
  66595. */
  66596. rotation: Vector3;
  66597. /**
  66598. * Stores the rotation quaternion
  66599. */
  66600. rotationQuaternion: Nullable<Quaternion>;
  66601. /**
  66602. * Stores the scaling vector
  66603. */
  66604. scaling: Vector3;
  66605. /**
  66606. * Convert the Mesh to CSG
  66607. * @param mesh The Mesh to convert to CSG
  66608. * @returns A new CSG from the Mesh
  66609. */
  66610. static FromMesh(mesh: Mesh): CSG;
  66611. /**
  66612. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66613. * @param polygons Polygons used to construct a CSG solid
  66614. */
  66615. private static FromPolygons;
  66616. /**
  66617. * Clones, or makes a deep copy, of the CSG
  66618. * @returns A new CSG
  66619. */
  66620. clone(): CSG;
  66621. /**
  66622. * Unions this CSG with another CSG
  66623. * @param csg The CSG to union against this CSG
  66624. * @returns The unioned CSG
  66625. */
  66626. union(csg: CSG): CSG;
  66627. /**
  66628. * Unions this CSG with another CSG in place
  66629. * @param csg The CSG to union against this CSG
  66630. */
  66631. unionInPlace(csg: CSG): void;
  66632. /**
  66633. * Subtracts this CSG with another CSG
  66634. * @param csg The CSG to subtract against this CSG
  66635. * @returns A new CSG
  66636. */
  66637. subtract(csg: CSG): CSG;
  66638. /**
  66639. * Subtracts this CSG with another CSG in place
  66640. * @param csg The CSG to subtact against this CSG
  66641. */
  66642. subtractInPlace(csg: CSG): void;
  66643. /**
  66644. * Intersect this CSG with another CSG
  66645. * @param csg The CSG to intersect against this CSG
  66646. * @returns A new CSG
  66647. */
  66648. intersect(csg: CSG): CSG;
  66649. /**
  66650. * Intersects this CSG with another CSG in place
  66651. * @param csg The CSG to intersect against this CSG
  66652. */
  66653. intersectInPlace(csg: CSG): void;
  66654. /**
  66655. * Return a new CSG solid with solid and empty space switched. This solid is
  66656. * not modified.
  66657. * @returns A new CSG solid with solid and empty space switched
  66658. */
  66659. inverse(): CSG;
  66660. /**
  66661. * Inverses the CSG in place
  66662. */
  66663. inverseInPlace(): void;
  66664. /**
  66665. * This is used to keep meshes transformations so they can be restored
  66666. * when we build back a Babylon Mesh
  66667. * NB : All CSG operations are performed in world coordinates
  66668. * @param csg The CSG to copy the transform attributes from
  66669. * @returns This CSG
  66670. */
  66671. copyTransformAttributes(csg: CSG): CSG;
  66672. /**
  66673. * Build Raw mesh from CSG
  66674. * Coordinates here are in world space
  66675. * @param name The name of the mesh geometry
  66676. * @param scene The Scene
  66677. * @param keepSubMeshes Specifies if the submeshes should be kept
  66678. * @returns A new Mesh
  66679. */
  66680. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66681. /**
  66682. * Build Mesh from CSG taking material and transforms into account
  66683. * @param name The name of the Mesh
  66684. * @param material The material of the Mesh
  66685. * @param scene The Scene
  66686. * @param keepSubMeshes Specifies if submeshes should be kept
  66687. * @returns The new Mesh
  66688. */
  66689. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66690. }
  66691. }
  66692. declare module BABYLON {
  66693. /**
  66694. * Class used to create a trail following a mesh
  66695. */
  66696. export class TrailMesh extends Mesh {
  66697. private _generator;
  66698. private _autoStart;
  66699. private _running;
  66700. private _diameter;
  66701. private _length;
  66702. private _sectionPolygonPointsCount;
  66703. private _sectionVectors;
  66704. private _sectionNormalVectors;
  66705. private _beforeRenderObserver;
  66706. /**
  66707. * @constructor
  66708. * @param name The value used by scene.getMeshByName() to do a lookup.
  66709. * @param generator The mesh or transform node to generate a trail.
  66710. * @param scene The scene to add this mesh to.
  66711. * @param diameter Diameter of trailing mesh. Default is 1.
  66712. * @param length Length of trailing mesh. Default is 60.
  66713. * @param autoStart Automatically start trailing mesh. Default true.
  66714. */
  66715. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66716. /**
  66717. * "TrailMesh"
  66718. * @returns "TrailMesh"
  66719. */
  66720. getClassName(): string;
  66721. private _createMesh;
  66722. /**
  66723. * Start trailing mesh.
  66724. */
  66725. start(): void;
  66726. /**
  66727. * Stop trailing mesh.
  66728. */
  66729. stop(): void;
  66730. /**
  66731. * Update trailing mesh geometry.
  66732. */
  66733. update(): void;
  66734. /**
  66735. * Returns a new TrailMesh object.
  66736. * @param name is a string, the name given to the new mesh
  66737. * @param newGenerator use new generator object for cloned trail mesh
  66738. * @returns a new mesh
  66739. */
  66740. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66741. /**
  66742. * Serializes this trail mesh
  66743. * @param serializationObject object to write serialization to
  66744. */
  66745. serialize(serializationObject: any): void;
  66746. /**
  66747. * Parses a serialized trail mesh
  66748. * @param parsedMesh the serialized mesh
  66749. * @param scene the scene to create the trail mesh in
  66750. * @returns the created trail mesh
  66751. */
  66752. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66753. }
  66754. }
  66755. declare module BABYLON {
  66756. /**
  66757. * Class containing static functions to help procedurally build meshes
  66758. */
  66759. export class TiledBoxBuilder {
  66760. /**
  66761. * Creates a box mesh
  66762. * 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)
  66763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66765. * * 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
  66766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66767. * @param name defines the name of the mesh
  66768. * @param options defines the options used to create the mesh
  66769. * @param scene defines the hosting scene
  66770. * @returns the box mesh
  66771. */
  66772. static CreateTiledBox(name: string, options: {
  66773. pattern?: number;
  66774. width?: number;
  66775. height?: number;
  66776. depth?: number;
  66777. tileSize?: number;
  66778. tileWidth?: number;
  66779. tileHeight?: number;
  66780. alignHorizontal?: number;
  66781. alignVertical?: number;
  66782. faceUV?: Vector4[];
  66783. faceColors?: Color4[];
  66784. sideOrientation?: number;
  66785. updatable?: boolean;
  66786. }, scene?: Nullable<Scene>): Mesh;
  66787. }
  66788. }
  66789. declare module BABYLON {
  66790. /**
  66791. * Class containing static functions to help procedurally build meshes
  66792. */
  66793. export class TorusKnotBuilder {
  66794. /**
  66795. * Creates a torus knot mesh
  66796. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66797. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66798. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66799. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66801. * * 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
  66802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66803. * @param name defines the name of the mesh
  66804. * @param options defines the options used to create the mesh
  66805. * @param scene defines the hosting scene
  66806. * @returns the torus knot mesh
  66807. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66808. */
  66809. static CreateTorusKnot(name: string, options: {
  66810. radius?: number;
  66811. tube?: number;
  66812. radialSegments?: number;
  66813. tubularSegments?: number;
  66814. p?: number;
  66815. q?: number;
  66816. updatable?: boolean;
  66817. sideOrientation?: number;
  66818. frontUVs?: Vector4;
  66819. backUVs?: Vector4;
  66820. }, scene: any): Mesh;
  66821. }
  66822. }
  66823. declare module BABYLON {
  66824. /**
  66825. * Polygon
  66826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66827. */
  66828. export class Polygon {
  66829. /**
  66830. * Creates a rectangle
  66831. * @param xmin bottom X coord
  66832. * @param ymin bottom Y coord
  66833. * @param xmax top X coord
  66834. * @param ymax top Y coord
  66835. * @returns points that make the resulting rectation
  66836. */
  66837. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66838. /**
  66839. * Creates a circle
  66840. * @param radius radius of circle
  66841. * @param cx scale in x
  66842. * @param cy scale in y
  66843. * @param numberOfSides number of sides that make up the circle
  66844. * @returns points that make the resulting circle
  66845. */
  66846. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66847. /**
  66848. * Creates a polygon from input string
  66849. * @param input Input polygon data
  66850. * @returns the parsed points
  66851. */
  66852. static Parse(input: string): Vector2[];
  66853. /**
  66854. * Starts building a polygon from x and y coordinates
  66855. * @param x x coordinate
  66856. * @param y y coordinate
  66857. * @returns the started path2
  66858. */
  66859. static StartingAt(x: number, y: number): Path2;
  66860. }
  66861. /**
  66862. * Builds a polygon
  66863. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66864. */
  66865. export class PolygonMeshBuilder {
  66866. private _points;
  66867. private _outlinepoints;
  66868. private _holes;
  66869. private _name;
  66870. private _scene;
  66871. private _epoints;
  66872. private _eholes;
  66873. private _addToepoint;
  66874. /**
  66875. * Babylon reference to the earcut plugin.
  66876. */
  66877. bjsEarcut: any;
  66878. /**
  66879. * Creates a PolygonMeshBuilder
  66880. * @param name name of the builder
  66881. * @param contours Path of the polygon
  66882. * @param scene scene to add to when creating the mesh
  66883. * @param earcutInjection can be used to inject your own earcut reference
  66884. */
  66885. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66886. /**
  66887. * Adds a whole within the polygon
  66888. * @param hole Array of points defining the hole
  66889. * @returns this
  66890. */
  66891. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66892. /**
  66893. * Creates the polygon
  66894. * @param updatable If the mesh should be updatable
  66895. * @param depth The depth of the mesh created
  66896. * @returns the created mesh
  66897. */
  66898. build(updatable?: boolean, depth?: number): Mesh;
  66899. /**
  66900. * Creates the polygon
  66901. * @param depth The depth of the mesh created
  66902. * @returns the created VertexData
  66903. */
  66904. buildVertexData(depth?: number): VertexData;
  66905. /**
  66906. * Adds a side to the polygon
  66907. * @param positions points that make the polygon
  66908. * @param normals normals of the polygon
  66909. * @param uvs uvs of the polygon
  66910. * @param indices indices of the polygon
  66911. * @param bounds bounds of the polygon
  66912. * @param points points of the polygon
  66913. * @param depth depth of the polygon
  66914. * @param flip flip of the polygon
  66915. */
  66916. private addSide;
  66917. }
  66918. }
  66919. declare module BABYLON {
  66920. /**
  66921. * Class containing static functions to help procedurally build meshes
  66922. */
  66923. export class PolygonBuilder {
  66924. /**
  66925. * Creates a polygon mesh
  66926. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66927. * * 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
  66928. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66930. * * 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)
  66931. * * Remember you can only change the shape positions, not their number when updating a polygon
  66932. * @param name defines the name of the mesh
  66933. * @param options defines the options used to create the mesh
  66934. * @param scene defines the hosting scene
  66935. * @param earcutInjection can be used to inject your own earcut reference
  66936. * @returns the polygon mesh
  66937. */
  66938. static CreatePolygon(name: string, options: {
  66939. shape: Vector3[];
  66940. holes?: Vector3[][];
  66941. depth?: number;
  66942. faceUV?: Vector4[];
  66943. faceColors?: Color4[];
  66944. updatable?: boolean;
  66945. sideOrientation?: number;
  66946. frontUVs?: Vector4;
  66947. backUVs?: Vector4;
  66948. wrap?: boolean;
  66949. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66950. /**
  66951. * Creates an extruded polygon mesh, with depth in the Y direction.
  66952. * * 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)
  66953. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66954. * @param name defines the name of the mesh
  66955. * @param options defines the options used to create the mesh
  66956. * @param scene defines the hosting scene
  66957. * @param earcutInjection can be used to inject your own earcut reference
  66958. * @returns the polygon mesh
  66959. */
  66960. static ExtrudePolygon(name: string, options: {
  66961. shape: Vector3[];
  66962. holes?: Vector3[][];
  66963. depth?: number;
  66964. faceUV?: Vector4[];
  66965. faceColors?: Color4[];
  66966. updatable?: boolean;
  66967. sideOrientation?: number;
  66968. frontUVs?: Vector4;
  66969. backUVs?: Vector4;
  66970. wrap?: boolean;
  66971. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66972. }
  66973. }
  66974. declare module BABYLON {
  66975. /**
  66976. * Class containing static functions to help procedurally build meshes
  66977. */
  66978. export class LatheBuilder {
  66979. /**
  66980. * Creates lathe mesh.
  66981. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66982. * * 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
  66983. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66984. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66985. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66986. * * 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
  66987. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66988. * * 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
  66989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66990. * * 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
  66991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66993. * @param name defines the name of the mesh
  66994. * @param options defines the options used to create the mesh
  66995. * @param scene defines the hosting scene
  66996. * @returns the lathe mesh
  66997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66998. */
  66999. static CreateLathe(name: string, options: {
  67000. shape: Vector3[];
  67001. radius?: number;
  67002. tessellation?: number;
  67003. clip?: number;
  67004. arc?: number;
  67005. closed?: boolean;
  67006. updatable?: boolean;
  67007. sideOrientation?: number;
  67008. frontUVs?: Vector4;
  67009. backUVs?: Vector4;
  67010. cap?: number;
  67011. invertUV?: boolean;
  67012. }, scene?: Nullable<Scene>): Mesh;
  67013. }
  67014. }
  67015. declare module BABYLON {
  67016. /**
  67017. * Class containing static functions to help procedurally build meshes
  67018. */
  67019. export class TiledPlaneBuilder {
  67020. /**
  67021. * Creates a tiled plane mesh
  67022. * * The parameter `pattern` will, depending on value, do nothing or
  67023. * * * flip (reflect about central vertical) alternate tiles across and up
  67024. * * * flip every tile on alternate rows
  67025. * * * rotate (180 degs) alternate tiles across and up
  67026. * * * rotate every tile on alternate rows
  67027. * * * flip and rotate alternate tiles across and up
  67028. * * * flip and rotate every tile on alternate rows
  67029. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67030. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67031. * * 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
  67032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67033. * * 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)
  67034. * * 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)
  67035. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67036. * @param name defines the name of the mesh
  67037. * @param options defines the options used to create the mesh
  67038. * @param scene defines the hosting scene
  67039. * @returns the box mesh
  67040. */
  67041. static CreateTiledPlane(name: string, options: {
  67042. pattern?: number;
  67043. tileSize?: number;
  67044. tileWidth?: number;
  67045. tileHeight?: number;
  67046. size?: number;
  67047. width?: number;
  67048. height?: number;
  67049. alignHorizontal?: number;
  67050. alignVertical?: number;
  67051. sideOrientation?: number;
  67052. frontUVs?: Vector4;
  67053. backUVs?: Vector4;
  67054. updatable?: boolean;
  67055. }, scene?: Nullable<Scene>): Mesh;
  67056. }
  67057. }
  67058. declare module BABYLON {
  67059. /**
  67060. * Class containing static functions to help procedurally build meshes
  67061. */
  67062. export class TubeBuilder {
  67063. /**
  67064. * Creates a tube mesh.
  67065. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67066. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67067. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67068. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67069. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67070. * * 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)
  67071. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67072. * * 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
  67073. * * 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
  67074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67075. * * 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
  67076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67078. * @param name defines the name of the mesh
  67079. * @param options defines the options used to create the mesh
  67080. * @param scene defines the hosting scene
  67081. * @returns the tube mesh
  67082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67083. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67084. */
  67085. static CreateTube(name: string, options: {
  67086. path: Vector3[];
  67087. radius?: number;
  67088. tessellation?: number;
  67089. radiusFunction?: {
  67090. (i: number, distance: number): number;
  67091. };
  67092. cap?: number;
  67093. arc?: number;
  67094. updatable?: boolean;
  67095. sideOrientation?: number;
  67096. frontUVs?: Vector4;
  67097. backUVs?: Vector4;
  67098. instance?: Mesh;
  67099. invertUV?: boolean;
  67100. }, scene?: Nullable<Scene>): Mesh;
  67101. }
  67102. }
  67103. declare module BABYLON {
  67104. /**
  67105. * Class containing static functions to help procedurally build meshes
  67106. */
  67107. export class IcoSphereBuilder {
  67108. /**
  67109. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67110. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67111. * * 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`)
  67112. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67113. * * 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
  67114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67115. * * 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
  67116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67117. * @param name defines the name of the mesh
  67118. * @param options defines the options used to create the mesh
  67119. * @param scene defines the hosting scene
  67120. * @returns the icosahedron mesh
  67121. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67122. */
  67123. static CreateIcoSphere(name: string, options: {
  67124. radius?: number;
  67125. radiusX?: number;
  67126. radiusY?: number;
  67127. radiusZ?: number;
  67128. flat?: boolean;
  67129. subdivisions?: number;
  67130. sideOrientation?: number;
  67131. frontUVs?: Vector4;
  67132. backUVs?: Vector4;
  67133. updatable?: boolean;
  67134. }, scene?: Nullable<Scene>): Mesh;
  67135. }
  67136. }
  67137. declare module BABYLON {
  67138. /**
  67139. * Class containing static functions to help procedurally build meshes
  67140. */
  67141. export class DecalBuilder {
  67142. /**
  67143. * Creates a decal mesh.
  67144. * 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
  67145. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67146. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67147. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67148. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67149. * @param name defines the name of the mesh
  67150. * @param sourceMesh defines the mesh where the decal must be applied
  67151. * @param options defines the options used to create the mesh
  67152. * @param scene defines the hosting scene
  67153. * @returns the decal mesh
  67154. * @see https://doc.babylonjs.com/how_to/decals
  67155. */
  67156. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67157. position?: Vector3;
  67158. normal?: Vector3;
  67159. size?: Vector3;
  67160. angle?: number;
  67161. }): Mesh;
  67162. }
  67163. }
  67164. declare module BABYLON {
  67165. /**
  67166. * Class containing static functions to help procedurally build meshes
  67167. */
  67168. export class MeshBuilder {
  67169. /**
  67170. * Creates a box mesh
  67171. * * The parameter `size` sets the size (float) of each box side (default 1)
  67172. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67173. * * 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)
  67174. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67176. * * 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
  67177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67178. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67179. * @param name defines the name of the mesh
  67180. * @param options defines the options used to create the mesh
  67181. * @param scene defines the hosting scene
  67182. * @returns the box mesh
  67183. */
  67184. static CreateBox(name: string, options: {
  67185. size?: number;
  67186. width?: number;
  67187. height?: number;
  67188. depth?: number;
  67189. faceUV?: Vector4[];
  67190. faceColors?: Color4[];
  67191. sideOrientation?: number;
  67192. frontUVs?: Vector4;
  67193. backUVs?: Vector4;
  67194. wrap?: boolean;
  67195. topBaseAt?: number;
  67196. bottomBaseAt?: number;
  67197. updatable?: boolean;
  67198. }, scene?: Nullable<Scene>): Mesh;
  67199. /**
  67200. * Creates a tiled box mesh
  67201. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67203. * @param name defines the name of the mesh
  67204. * @param options defines the options used to create the mesh
  67205. * @param scene defines the hosting scene
  67206. * @returns the tiled box mesh
  67207. */
  67208. static CreateTiledBox(name: string, options: {
  67209. pattern?: number;
  67210. size?: number;
  67211. width?: number;
  67212. height?: number;
  67213. depth: number;
  67214. tileSize?: number;
  67215. tileWidth?: number;
  67216. tileHeight?: number;
  67217. faceUV?: Vector4[];
  67218. faceColors?: Color4[];
  67219. alignHorizontal?: number;
  67220. alignVertical?: number;
  67221. sideOrientation?: number;
  67222. updatable?: boolean;
  67223. }, scene?: Nullable<Scene>): Mesh;
  67224. /**
  67225. * Creates a sphere mesh
  67226. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67227. * * 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`)
  67228. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67229. * * 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
  67230. * * 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)
  67231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67232. * * 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
  67233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67234. * @param name defines the name of the mesh
  67235. * @param options defines the options used to create the mesh
  67236. * @param scene defines the hosting scene
  67237. * @returns the sphere mesh
  67238. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67239. */
  67240. static CreateSphere(name: string, options: {
  67241. segments?: number;
  67242. diameter?: number;
  67243. diameterX?: number;
  67244. diameterY?: number;
  67245. diameterZ?: number;
  67246. arc?: number;
  67247. slice?: number;
  67248. sideOrientation?: number;
  67249. frontUVs?: Vector4;
  67250. backUVs?: Vector4;
  67251. updatable?: boolean;
  67252. }, scene?: Nullable<Scene>): Mesh;
  67253. /**
  67254. * Creates a plane polygonal mesh. By default, this is a disc
  67255. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67256. * * 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
  67257. * * 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
  67258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67259. * * 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
  67260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67261. * @param name defines the name of the mesh
  67262. * @param options defines the options used to create the mesh
  67263. * @param scene defines the hosting scene
  67264. * @returns the plane polygonal mesh
  67265. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67266. */
  67267. static CreateDisc(name: string, options: {
  67268. radius?: number;
  67269. tessellation?: number;
  67270. arc?: number;
  67271. updatable?: boolean;
  67272. sideOrientation?: number;
  67273. frontUVs?: Vector4;
  67274. backUVs?: Vector4;
  67275. }, scene?: Nullable<Scene>): Mesh;
  67276. /**
  67277. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67278. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67279. * * 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`)
  67280. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67281. * * 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
  67282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67283. * * 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
  67284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67285. * @param name defines the name of the mesh
  67286. * @param options defines the options used to create the mesh
  67287. * @param scene defines the hosting scene
  67288. * @returns the icosahedron mesh
  67289. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67290. */
  67291. static CreateIcoSphere(name: string, options: {
  67292. radius?: number;
  67293. radiusX?: number;
  67294. radiusY?: number;
  67295. radiusZ?: number;
  67296. flat?: boolean;
  67297. subdivisions?: number;
  67298. sideOrientation?: number;
  67299. frontUVs?: Vector4;
  67300. backUVs?: Vector4;
  67301. updatable?: boolean;
  67302. }, scene?: Nullable<Scene>): Mesh;
  67303. /**
  67304. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67305. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67306. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67307. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67308. * * 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
  67309. * * 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
  67310. * * 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
  67311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67312. * * 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
  67313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67314. * * 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
  67315. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67316. * * 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
  67317. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67319. * @param name defines the name of the mesh
  67320. * @param options defines the options used to create the mesh
  67321. * @param scene defines the hosting scene
  67322. * @returns the ribbon mesh
  67323. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67324. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67325. */
  67326. static CreateRibbon(name: string, options: {
  67327. pathArray: Vector3[][];
  67328. closeArray?: boolean;
  67329. closePath?: boolean;
  67330. offset?: number;
  67331. updatable?: boolean;
  67332. sideOrientation?: number;
  67333. frontUVs?: Vector4;
  67334. backUVs?: Vector4;
  67335. instance?: Mesh;
  67336. invertUV?: boolean;
  67337. uvs?: Vector2[];
  67338. colors?: Color4[];
  67339. }, scene?: Nullable<Scene>): Mesh;
  67340. /**
  67341. * Creates a cylinder or a cone mesh
  67342. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67343. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67344. * * 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.
  67345. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67346. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67347. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67348. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67349. * * 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).
  67350. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67351. * * 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).
  67352. * * 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
  67353. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67354. * * 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
  67355. * * 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.
  67356. * * If `enclose` is false, a ring surface is one element.
  67357. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67358. * * 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
  67359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67360. * * 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
  67361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67362. * @param name defines the name of the mesh
  67363. * @param options defines the options used to create the mesh
  67364. * @param scene defines the hosting scene
  67365. * @returns the cylinder mesh
  67366. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67367. */
  67368. static CreateCylinder(name: string, options: {
  67369. height?: number;
  67370. diameterTop?: number;
  67371. diameterBottom?: number;
  67372. diameter?: number;
  67373. tessellation?: number;
  67374. subdivisions?: number;
  67375. arc?: number;
  67376. faceColors?: Color4[];
  67377. faceUV?: Vector4[];
  67378. updatable?: boolean;
  67379. hasRings?: boolean;
  67380. enclose?: boolean;
  67381. cap?: number;
  67382. sideOrientation?: number;
  67383. frontUVs?: Vector4;
  67384. backUVs?: Vector4;
  67385. }, scene?: Nullable<Scene>): Mesh;
  67386. /**
  67387. * Creates a torus mesh
  67388. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67389. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67390. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67392. * * 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
  67393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67394. * @param name defines the name of the mesh
  67395. * @param options defines the options used to create the mesh
  67396. * @param scene defines the hosting scene
  67397. * @returns the torus mesh
  67398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67399. */
  67400. static CreateTorus(name: string, options: {
  67401. diameter?: number;
  67402. thickness?: number;
  67403. tessellation?: number;
  67404. updatable?: boolean;
  67405. sideOrientation?: number;
  67406. frontUVs?: Vector4;
  67407. backUVs?: Vector4;
  67408. }, scene?: Nullable<Scene>): Mesh;
  67409. /**
  67410. * Creates a torus knot mesh
  67411. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67412. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67413. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67414. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67416. * * 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
  67417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67418. * @param name defines the name of the mesh
  67419. * @param options defines the options used to create the mesh
  67420. * @param scene defines the hosting scene
  67421. * @returns the torus knot mesh
  67422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67423. */
  67424. static CreateTorusKnot(name: string, options: {
  67425. radius?: number;
  67426. tube?: number;
  67427. radialSegments?: number;
  67428. tubularSegments?: number;
  67429. p?: number;
  67430. q?: number;
  67431. updatable?: boolean;
  67432. sideOrientation?: number;
  67433. frontUVs?: Vector4;
  67434. backUVs?: Vector4;
  67435. }, scene?: Nullable<Scene>): Mesh;
  67436. /**
  67437. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67438. * * 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
  67439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67440. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67441. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67442. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67444. * * 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
  67445. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67448. * @param name defines the name of the new line system
  67449. * @param options defines the options used to create the line system
  67450. * @param scene defines the hosting scene
  67451. * @returns a new line system mesh
  67452. */
  67453. static CreateLineSystem(name: string, options: {
  67454. lines: Vector3[][];
  67455. updatable?: boolean;
  67456. instance?: Nullable<LinesMesh>;
  67457. colors?: Nullable<Color4[][]>;
  67458. useVertexAlpha?: boolean;
  67459. }, scene: Nullable<Scene>): LinesMesh;
  67460. /**
  67461. * Creates a line mesh
  67462. * 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
  67463. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67464. * * The parameter `points` is an array successive Vector3
  67465. * * 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
  67466. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67467. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67468. * * When updating an instance, remember that only point positions can change, not the number of points
  67469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67471. * @param name defines the name of the new line system
  67472. * @param options defines the options used to create the line system
  67473. * @param scene defines the hosting scene
  67474. * @returns a new line mesh
  67475. */
  67476. static CreateLines(name: string, options: {
  67477. points: Vector3[];
  67478. updatable?: boolean;
  67479. instance?: Nullable<LinesMesh>;
  67480. colors?: Color4[];
  67481. useVertexAlpha?: boolean;
  67482. }, scene?: Nullable<Scene>): LinesMesh;
  67483. /**
  67484. * Creates a dashed line mesh
  67485. * * 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
  67486. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67487. * * The parameter `points` is an array successive Vector3
  67488. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67489. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67490. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67491. * * 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
  67492. * * When updating an instance, remember that only point positions can change, not the number of points
  67493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67494. * @param name defines the name of the mesh
  67495. * @param options defines the options used to create the mesh
  67496. * @param scene defines the hosting scene
  67497. * @returns the dashed line mesh
  67498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67499. */
  67500. static CreateDashedLines(name: string, options: {
  67501. points: Vector3[];
  67502. dashSize?: number;
  67503. gapSize?: number;
  67504. dashNb?: number;
  67505. updatable?: boolean;
  67506. instance?: LinesMesh;
  67507. }, scene?: Nullable<Scene>): LinesMesh;
  67508. /**
  67509. * 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.
  67510. * * 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.
  67511. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67512. * * 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.
  67513. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67514. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  67515. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  67516. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67521. * @param name defines the name of the mesh
  67522. * @param options defines the options used to create the mesh
  67523. * @param scene defines the hosting scene
  67524. * @returns the extruded shape mesh
  67525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67527. */
  67528. static ExtrudeShape(name: string, options: {
  67529. shape: Vector3[];
  67530. path: Vector3[];
  67531. scale?: number;
  67532. rotation?: number;
  67533. cap?: number;
  67534. updatable?: boolean;
  67535. sideOrientation?: number;
  67536. frontUVs?: Vector4;
  67537. backUVs?: Vector4;
  67538. instance?: Mesh;
  67539. invertUV?: boolean;
  67540. }, scene?: Nullable<Scene>): Mesh;
  67541. /**
  67542. * Creates an custom extruded shape mesh.
  67543. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67544. * * 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.
  67545. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67546. * * 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
  67547. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67548. * * 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
  67549. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67550. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67551. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67552. * * 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
  67553. * * 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
  67554. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67556. * * 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
  67557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67559. * @param name defines the name of the mesh
  67560. * @param options defines the options used to create the mesh
  67561. * @param scene defines the hosting scene
  67562. * @returns the custom extruded shape mesh
  67563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67566. */
  67567. static ExtrudeShapeCustom(name: string, options: {
  67568. shape: Vector3[];
  67569. path: Vector3[];
  67570. scaleFunction?: any;
  67571. rotationFunction?: any;
  67572. ribbonCloseArray?: boolean;
  67573. ribbonClosePath?: boolean;
  67574. cap?: number;
  67575. updatable?: boolean;
  67576. sideOrientation?: number;
  67577. frontUVs?: Vector4;
  67578. backUVs?: Vector4;
  67579. instance?: Mesh;
  67580. invertUV?: boolean;
  67581. }, scene?: Nullable<Scene>): Mesh;
  67582. /**
  67583. * Creates lathe mesh.
  67584. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67585. * * 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
  67586. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67587. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67588. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67589. * * 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
  67590. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67591. * * 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
  67592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67593. * * 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
  67594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67596. * @param name defines the name of the mesh
  67597. * @param options defines the options used to create the mesh
  67598. * @param scene defines the hosting scene
  67599. * @returns the lathe mesh
  67600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67601. */
  67602. static CreateLathe(name: string, options: {
  67603. shape: Vector3[];
  67604. radius?: number;
  67605. tessellation?: number;
  67606. clip?: number;
  67607. arc?: number;
  67608. closed?: boolean;
  67609. updatable?: boolean;
  67610. sideOrientation?: number;
  67611. frontUVs?: Vector4;
  67612. backUVs?: Vector4;
  67613. cap?: number;
  67614. invertUV?: boolean;
  67615. }, scene?: Nullable<Scene>): Mesh;
  67616. /**
  67617. * Creates a tiled plane mesh
  67618. * * You can set a limited pattern arrangement with the tiles
  67619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67620. * * 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
  67621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67622. * @param name defines the name of the mesh
  67623. * @param options defines the options used to create the mesh
  67624. * @param scene defines the hosting scene
  67625. * @returns the plane mesh
  67626. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67627. */
  67628. static CreateTiledPlane(name: string, options: {
  67629. pattern?: number;
  67630. tileSize?: number;
  67631. tileWidth?: number;
  67632. tileHeight?: number;
  67633. size?: number;
  67634. width?: number;
  67635. height?: number;
  67636. alignHorizontal?: number;
  67637. alignVertical?: number;
  67638. sideOrientation?: number;
  67639. frontUVs?: Vector4;
  67640. backUVs?: Vector4;
  67641. updatable?: boolean;
  67642. }, scene?: Nullable<Scene>): Mesh;
  67643. /**
  67644. * Creates a plane mesh
  67645. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67646. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67647. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67649. * * 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
  67650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67651. * @param name defines the name of the mesh
  67652. * @param options defines the options used to create the mesh
  67653. * @param scene defines the hosting scene
  67654. * @returns the plane mesh
  67655. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67656. */
  67657. static CreatePlane(name: string, options: {
  67658. size?: number;
  67659. width?: number;
  67660. height?: number;
  67661. sideOrientation?: number;
  67662. frontUVs?: Vector4;
  67663. backUVs?: Vector4;
  67664. updatable?: boolean;
  67665. sourcePlane?: Plane;
  67666. }, scene?: Nullable<Scene>): Mesh;
  67667. /**
  67668. * Creates a ground mesh
  67669. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67670. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67672. * @param name defines the name of the mesh
  67673. * @param options defines the options used to create the mesh
  67674. * @param scene defines the hosting scene
  67675. * @returns the ground mesh
  67676. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67677. */
  67678. static CreateGround(name: string, options: {
  67679. width?: number;
  67680. height?: number;
  67681. subdivisions?: number;
  67682. subdivisionsX?: number;
  67683. subdivisionsY?: number;
  67684. updatable?: boolean;
  67685. }, scene?: Nullable<Scene>): Mesh;
  67686. /**
  67687. * Creates a tiled ground mesh
  67688. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67689. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67690. * * 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
  67691. * * 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
  67692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67693. * @param name defines the name of the mesh
  67694. * @param options defines the options used to create the mesh
  67695. * @param scene defines the hosting scene
  67696. * @returns the tiled ground mesh
  67697. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67698. */
  67699. static CreateTiledGround(name: string, options: {
  67700. xmin: number;
  67701. zmin: number;
  67702. xmax: number;
  67703. zmax: number;
  67704. subdivisions?: {
  67705. w: number;
  67706. h: number;
  67707. };
  67708. precision?: {
  67709. w: number;
  67710. h: number;
  67711. };
  67712. updatable?: boolean;
  67713. }, scene?: Nullable<Scene>): Mesh;
  67714. /**
  67715. * Creates a ground mesh from a height map
  67716. * * The parameter `url` sets the URL of the height map image resource.
  67717. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67718. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67719. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67720. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67721. * * 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.
  67722. * * 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).
  67723. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67725. * @param name defines the name of the mesh
  67726. * @param url defines the url to the height map
  67727. * @param options defines the options used to create the mesh
  67728. * @param scene defines the hosting scene
  67729. * @returns the ground mesh
  67730. * @see https://doc.babylonjs.com/babylon101/height_map
  67731. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67732. */
  67733. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67734. width?: number;
  67735. height?: number;
  67736. subdivisions?: number;
  67737. minHeight?: number;
  67738. maxHeight?: number;
  67739. colorFilter?: Color3;
  67740. alphaFilter?: number;
  67741. updatable?: boolean;
  67742. onReady?: (mesh: GroundMesh) => void;
  67743. }, scene?: Nullable<Scene>): GroundMesh;
  67744. /**
  67745. * Creates a polygon mesh
  67746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67747. * * 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
  67748. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67750. * * 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)
  67751. * * Remember you can only change the shape positions, not their number when updating a polygon
  67752. * @param name defines the name of the mesh
  67753. * @param options defines the options used to create the mesh
  67754. * @param scene defines the hosting scene
  67755. * @param earcutInjection can be used to inject your own earcut reference
  67756. * @returns the polygon mesh
  67757. */
  67758. static CreatePolygon(name: string, options: {
  67759. shape: Vector3[];
  67760. holes?: Vector3[][];
  67761. depth?: number;
  67762. faceUV?: Vector4[];
  67763. faceColors?: Color4[];
  67764. updatable?: boolean;
  67765. sideOrientation?: number;
  67766. frontUVs?: Vector4;
  67767. backUVs?: Vector4;
  67768. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67769. /**
  67770. * Creates an extruded polygon mesh, with depth in the Y direction.
  67771. * * 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)
  67772. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67773. * @param name defines the name of the mesh
  67774. * @param options defines the options used to create the mesh
  67775. * @param scene defines the hosting scene
  67776. * @param earcutInjection can be used to inject your own earcut reference
  67777. * @returns the polygon mesh
  67778. */
  67779. static ExtrudePolygon(name: string, options: {
  67780. shape: Vector3[];
  67781. holes?: Vector3[][];
  67782. depth?: number;
  67783. faceUV?: Vector4[];
  67784. faceColors?: Color4[];
  67785. updatable?: boolean;
  67786. sideOrientation?: number;
  67787. frontUVs?: Vector4;
  67788. backUVs?: Vector4;
  67789. wrap?: boolean;
  67790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67791. /**
  67792. * Creates a tube mesh.
  67793. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67794. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67795. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67796. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67797. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67798. * * 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)
  67799. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67800. * * 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
  67801. * * 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
  67802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67803. * * 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
  67804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67806. * @param name defines the name of the mesh
  67807. * @param options defines the options used to create the mesh
  67808. * @param scene defines the hosting scene
  67809. * @returns the tube mesh
  67810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67811. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67812. */
  67813. static CreateTube(name: string, options: {
  67814. path: Vector3[];
  67815. radius?: number;
  67816. tessellation?: number;
  67817. radiusFunction?: {
  67818. (i: number, distance: number): number;
  67819. };
  67820. cap?: number;
  67821. arc?: number;
  67822. updatable?: boolean;
  67823. sideOrientation?: number;
  67824. frontUVs?: Vector4;
  67825. backUVs?: Vector4;
  67826. instance?: Mesh;
  67827. invertUV?: boolean;
  67828. }, scene?: Nullable<Scene>): Mesh;
  67829. /**
  67830. * Creates a polyhedron mesh
  67831. * * 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
  67832. * * The parameter `size` (positive float, default 1) sets the polygon size
  67833. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67834. * * 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`
  67835. * * 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
  67836. * * 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)`)
  67837. * * 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
  67838. * * 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
  67839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67840. * * 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
  67841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67842. * @param name defines the name of the mesh
  67843. * @param options defines the options used to create the mesh
  67844. * @param scene defines the hosting scene
  67845. * @returns the polyhedron mesh
  67846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67847. */
  67848. static CreatePolyhedron(name: string, options: {
  67849. type?: number;
  67850. size?: number;
  67851. sizeX?: number;
  67852. sizeY?: number;
  67853. sizeZ?: number;
  67854. custom?: any;
  67855. faceUV?: Vector4[];
  67856. faceColors?: Color4[];
  67857. flat?: boolean;
  67858. updatable?: boolean;
  67859. sideOrientation?: number;
  67860. frontUVs?: Vector4;
  67861. backUVs?: Vector4;
  67862. }, scene?: Nullable<Scene>): Mesh;
  67863. /**
  67864. * Creates a decal mesh.
  67865. * 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
  67866. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67867. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67868. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67869. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67870. * @param name defines the name of the mesh
  67871. * @param sourceMesh defines the mesh where the decal must be applied
  67872. * @param options defines the options used to create the mesh
  67873. * @param scene defines the hosting scene
  67874. * @returns the decal mesh
  67875. * @see https://doc.babylonjs.com/how_to/decals
  67876. */
  67877. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67878. position?: Vector3;
  67879. normal?: Vector3;
  67880. size?: Vector3;
  67881. angle?: number;
  67882. }): Mesh;
  67883. /**
  67884. * Creates a Capsule Mesh
  67885. * @param name defines the name of the mesh.
  67886. * @param options the constructors options used to shape the mesh.
  67887. * @param scene defines the scene the mesh is scoped to.
  67888. * @returns the capsule mesh
  67889. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67890. */
  67891. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67892. }
  67893. }
  67894. declare module BABYLON {
  67895. /**
  67896. * A simplifier interface for future simplification implementations
  67897. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67898. */
  67899. export interface ISimplifier {
  67900. /**
  67901. * Simplification of a given mesh according to the given settings.
  67902. * Since this requires computation, it is assumed that the function runs async.
  67903. * @param settings The settings of the simplification, including quality and distance
  67904. * @param successCallback A callback that will be called after the mesh was simplified.
  67905. * @param errorCallback in case of an error, this callback will be called. optional.
  67906. */
  67907. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67908. }
  67909. /**
  67910. * Expected simplification settings.
  67911. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67912. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67913. */
  67914. export interface ISimplificationSettings {
  67915. /**
  67916. * Gets or sets the expected quality
  67917. */
  67918. quality: number;
  67919. /**
  67920. * Gets or sets the distance when this optimized version should be used
  67921. */
  67922. distance: number;
  67923. /**
  67924. * Gets an already optimized mesh
  67925. */
  67926. optimizeMesh?: boolean;
  67927. }
  67928. /**
  67929. * Class used to specify simplification options
  67930. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67931. */
  67932. export class SimplificationSettings implements ISimplificationSettings {
  67933. /** expected quality */
  67934. quality: number;
  67935. /** distance when this optimized version should be used */
  67936. distance: number;
  67937. /** already optimized mesh */
  67938. optimizeMesh?: boolean | undefined;
  67939. /**
  67940. * Creates a SimplificationSettings
  67941. * @param quality expected quality
  67942. * @param distance distance when this optimized version should be used
  67943. * @param optimizeMesh already optimized mesh
  67944. */
  67945. constructor(
  67946. /** expected quality */
  67947. quality: number,
  67948. /** distance when this optimized version should be used */
  67949. distance: number,
  67950. /** already optimized mesh */
  67951. optimizeMesh?: boolean | undefined);
  67952. }
  67953. /**
  67954. * Interface used to define a simplification task
  67955. */
  67956. export interface ISimplificationTask {
  67957. /**
  67958. * Array of settings
  67959. */
  67960. settings: Array<ISimplificationSettings>;
  67961. /**
  67962. * Simplification type
  67963. */
  67964. simplificationType: SimplificationType;
  67965. /**
  67966. * Mesh to simplify
  67967. */
  67968. mesh: Mesh;
  67969. /**
  67970. * Callback called on success
  67971. */
  67972. successCallback?: () => void;
  67973. /**
  67974. * Defines if parallel processing can be used
  67975. */
  67976. parallelProcessing: boolean;
  67977. }
  67978. /**
  67979. * Queue used to order the simplification tasks
  67980. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67981. */
  67982. export class SimplificationQueue {
  67983. private _simplificationArray;
  67984. /**
  67985. * Gets a boolean indicating that the process is still running
  67986. */
  67987. running: boolean;
  67988. /**
  67989. * Creates a new queue
  67990. */
  67991. constructor();
  67992. /**
  67993. * Adds a new simplification task
  67994. * @param task defines a task to add
  67995. */
  67996. addTask(task: ISimplificationTask): void;
  67997. /**
  67998. * Execute next task
  67999. */
  68000. executeNext(): void;
  68001. /**
  68002. * Execute a simplification task
  68003. * @param task defines the task to run
  68004. */
  68005. runSimplification(task: ISimplificationTask): void;
  68006. private getSimplifier;
  68007. }
  68008. /**
  68009. * The implemented types of simplification
  68010. * At the moment only Quadratic Error Decimation is implemented
  68011. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68012. */
  68013. export enum SimplificationType {
  68014. /** Quadratic error decimation */
  68015. QUADRATIC = 0
  68016. }
  68017. /**
  68018. * An implementation of the Quadratic Error simplification algorithm.
  68019. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68020. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68021. * @author RaananW
  68022. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68023. */
  68024. export class QuadraticErrorSimplification implements ISimplifier {
  68025. private _mesh;
  68026. private triangles;
  68027. private vertices;
  68028. private references;
  68029. private _reconstructedMesh;
  68030. /** Gets or sets the number pf sync interations */
  68031. syncIterations: number;
  68032. /** Gets or sets the aggressiveness of the simplifier */
  68033. aggressiveness: number;
  68034. /** Gets or sets the number of allowed iterations for decimation */
  68035. decimationIterations: number;
  68036. /** Gets or sets the espilon to use for bounding box computation */
  68037. boundingBoxEpsilon: number;
  68038. /**
  68039. * Creates a new QuadraticErrorSimplification
  68040. * @param _mesh defines the target mesh
  68041. */
  68042. constructor(_mesh: Mesh);
  68043. /**
  68044. * Simplification of a given mesh according to the given settings.
  68045. * Since this requires computation, it is assumed that the function runs async.
  68046. * @param settings The settings of the simplification, including quality and distance
  68047. * @param successCallback A callback that will be called after the mesh was simplified.
  68048. */
  68049. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68050. private runDecimation;
  68051. private initWithMesh;
  68052. private init;
  68053. private reconstructMesh;
  68054. private initDecimatedMesh;
  68055. private isFlipped;
  68056. private updateTriangles;
  68057. private identifyBorder;
  68058. private updateMesh;
  68059. private vertexError;
  68060. private calculateError;
  68061. }
  68062. }
  68063. declare module BABYLON {
  68064. interface Scene {
  68065. /** @hidden (Backing field) */
  68066. _simplificationQueue: SimplificationQueue;
  68067. /**
  68068. * Gets or sets the simplification queue attached to the scene
  68069. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68070. */
  68071. simplificationQueue: SimplificationQueue;
  68072. }
  68073. interface Mesh {
  68074. /**
  68075. * Simplify the mesh according to the given array of settings.
  68076. * Function will return immediately and will simplify async
  68077. * @param settings a collection of simplification settings
  68078. * @param parallelProcessing should all levels calculate parallel or one after the other
  68079. * @param simplificationType the type of simplification to run
  68080. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68081. * @returns the current mesh
  68082. */
  68083. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68084. }
  68085. /**
  68086. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68087. * created in a scene
  68088. */
  68089. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68090. /**
  68091. * The component name helpfull to identify the component in the list of scene components.
  68092. */
  68093. readonly name: string;
  68094. /**
  68095. * The scene the component belongs to.
  68096. */
  68097. scene: Scene;
  68098. /**
  68099. * Creates a new instance of the component for the given scene
  68100. * @param scene Defines the scene to register the component in
  68101. */
  68102. constructor(scene: Scene);
  68103. /**
  68104. * Registers the component in a given scene
  68105. */
  68106. register(): void;
  68107. /**
  68108. * Rebuilds the elements related to this component in case of
  68109. * context lost for instance.
  68110. */
  68111. rebuild(): void;
  68112. /**
  68113. * Disposes the component and the associated ressources
  68114. */
  68115. dispose(): void;
  68116. private _beforeCameraUpdate;
  68117. }
  68118. }
  68119. declare module BABYLON {
  68120. interface Mesh {
  68121. /**
  68122. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68123. */
  68124. thinInstanceEnablePicking: boolean;
  68125. /**
  68126. * Creates a new thin instance
  68127. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  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. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68130. */
  68131. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68132. /**
  68133. * Adds the transformation (matrix) of the current mesh as a thin instance
  68134. * @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
  68135. * @returns the thin instance index number
  68136. */
  68137. thinInstanceAddSelf(refresh: boolean): number;
  68138. /**
  68139. * Registers a custom attribute to be used with thin instances
  68140. * @param kind name of the attribute
  68141. * @param stride size in floats of the attribute
  68142. */
  68143. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68144. /**
  68145. * Sets the matrix of a thin instance
  68146. * @param index index of the thin instance
  68147. * @param matrix matrix to set
  68148. * @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
  68149. */
  68150. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68151. /**
  68152. * Sets the value of a custom attribute for a thin instance
  68153. * @param kind name of the attribute
  68154. * @param index index of the thin instance
  68155. * @param value value to set
  68156. * @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
  68157. */
  68158. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68159. /**
  68160. * 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.
  68161. */
  68162. thinInstanceCount: number;
  68163. /**
  68164. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68165. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68166. * @param buffer buffer to set
  68167. * @param stride size in floats of each value of the buffer
  68168. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68169. */
  68170. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68171. /**
  68172. * Gets the list of world matrices
  68173. * @return an array containing all the world matrices from the thin instances
  68174. */
  68175. thinInstanceGetWorldMatrices(): Matrix[];
  68176. /**
  68177. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68178. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68179. */
  68180. thinInstanceBufferUpdated(kind: string): void;
  68181. /**
  68182. * Applies a partial update to a buffer directly on the GPU
  68183. * 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
  68184. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68185. * @param data the data to set in the GPU buffer
  68186. * @param offset the offset in the GPU buffer where to update the data
  68187. */
  68188. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68189. /**
  68190. * Refreshes the bounding info, taking into account all the thin instances defined
  68191. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68192. */
  68193. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68194. /** @hidden */
  68195. _thinInstanceInitializeUserStorage(): void;
  68196. /** @hidden */
  68197. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68198. /** @hidden */
  68199. _userThinInstanceBuffersStorage: {
  68200. data: {
  68201. [key: string]: Float32Array;
  68202. };
  68203. sizes: {
  68204. [key: string]: number;
  68205. };
  68206. vertexBuffers: {
  68207. [key: string]: Nullable<VertexBuffer>;
  68208. };
  68209. strides: {
  68210. [key: string]: number;
  68211. };
  68212. };
  68213. }
  68214. }
  68215. declare module BABYLON {
  68216. /**
  68217. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68218. */
  68219. export interface INavigationEnginePlugin {
  68220. /**
  68221. * plugin name
  68222. */
  68223. name: string;
  68224. /**
  68225. * Creates a navigation mesh
  68226. * @param meshes array of all the geometry used to compute the navigatio mesh
  68227. * @param parameters bunch of parameters used to filter geometry
  68228. */
  68229. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68230. /**
  68231. * Create a navigation mesh debug mesh
  68232. * @param scene is where the mesh will be added
  68233. * @returns debug display mesh
  68234. */
  68235. createDebugNavMesh(scene: Scene): Mesh;
  68236. /**
  68237. * Get a navigation mesh constrained position, closest to the parameter position
  68238. * @param position world position
  68239. * @returns the closest point to position constrained by the navigation mesh
  68240. */
  68241. getClosestPoint(position: Vector3): Vector3;
  68242. /**
  68243. * Get a navigation mesh constrained position, closest to the parameter position
  68244. * @param position world position
  68245. * @param result output the closest point to position constrained by the navigation mesh
  68246. */
  68247. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68248. /**
  68249. * Get a navigation mesh constrained position, within a particular radius
  68250. * @param position world position
  68251. * @param maxRadius the maximum distance to the constrained world position
  68252. * @returns the closest point to position constrained by the navigation mesh
  68253. */
  68254. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68255. /**
  68256. * Get a navigation mesh constrained position, within a particular radius
  68257. * @param position world position
  68258. * @param maxRadius the maximum distance to the constrained world position
  68259. * @param result output the closest point to position constrained by the navigation mesh
  68260. */
  68261. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68262. /**
  68263. * Compute the final position from a segment made of destination-position
  68264. * @param position world position
  68265. * @param destination world position
  68266. * @returns the resulting point along the navmesh
  68267. */
  68268. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68269. /**
  68270. * Compute the final position from a segment made of destination-position
  68271. * @param position world position
  68272. * @param destination world position
  68273. * @param result output the resulting point along the navmesh
  68274. */
  68275. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68276. /**
  68277. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68278. * @param start world position
  68279. * @param end world position
  68280. * @returns array containing world position composing the path
  68281. */
  68282. computePath(start: Vector3, end: Vector3): Vector3[];
  68283. /**
  68284. * If this plugin is supported
  68285. * @returns true if plugin is supported
  68286. */
  68287. isSupported(): boolean;
  68288. /**
  68289. * Create a new Crowd so you can add agents
  68290. * @param maxAgents the maximum agent count in the crowd
  68291. * @param maxAgentRadius the maximum radius an agent can have
  68292. * @param scene to attach the crowd to
  68293. * @returns the crowd you can add agents to
  68294. */
  68295. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68296. /**
  68297. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68298. * The queries will try to find a solution within those bounds
  68299. * default is (1,1,1)
  68300. * @param extent x,y,z value that define the extent around the queries point of reference
  68301. */
  68302. setDefaultQueryExtent(extent: Vector3): void;
  68303. /**
  68304. * Get the Bounding box extent specified by setDefaultQueryExtent
  68305. * @returns the box extent values
  68306. */
  68307. getDefaultQueryExtent(): Vector3;
  68308. /**
  68309. * build the navmesh from a previously saved state using getNavmeshData
  68310. * @param data the Uint8Array returned by getNavmeshData
  68311. */
  68312. buildFromNavmeshData(data: Uint8Array): void;
  68313. /**
  68314. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68315. * @returns data the Uint8Array that can be saved and reused
  68316. */
  68317. getNavmeshData(): Uint8Array;
  68318. /**
  68319. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68320. * @param result output the box extent values
  68321. */
  68322. getDefaultQueryExtentToRef(result: Vector3): void;
  68323. /**
  68324. * Set the time step of the navigation tick update.
  68325. * Default is 1/60.
  68326. * A value of 0 will disable fixed time update
  68327. * @param newTimeStep the new timestep to apply to this world.
  68328. */
  68329. setTimeStep(newTimeStep: number): void;
  68330. /**
  68331. * Get the time step of the navigation tick update.
  68332. * @returns the current time step
  68333. */
  68334. getTimeStep(): number;
  68335. /**
  68336. * If delta time in navigation tick update is greater than the time step
  68337. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68338. * they will be discarded.
  68339. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68340. * @param newStepCount the maximum number of iterations
  68341. */
  68342. setMaximumSubStepCount(newStepCount: number): void;
  68343. /**
  68344. * Get the maximum number of iterations per navigation tick update
  68345. * @returns the maximum number of iterations
  68346. */
  68347. getMaximumSubStepCount(): number;
  68348. /**
  68349. * Release all resources
  68350. */
  68351. dispose(): void;
  68352. }
  68353. /**
  68354. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68355. */
  68356. export interface ICrowd {
  68357. /**
  68358. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68359. * You can attach anything to that node. The node position is updated in the scene update tick.
  68360. * @param pos world position that will be constrained by the navigation mesh
  68361. * @param parameters agent parameters
  68362. * @param transform hooked to the agent that will be update by the scene
  68363. * @returns agent index
  68364. */
  68365. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68366. /**
  68367. * Returns the agent position in world space
  68368. * @param index agent index returned by addAgent
  68369. * @returns world space position
  68370. */
  68371. getAgentPosition(index: number): Vector3;
  68372. /**
  68373. * Gets the agent position result in world space
  68374. * @param index agent index returned by addAgent
  68375. * @param result output world space position
  68376. */
  68377. getAgentPositionToRef(index: number, result: Vector3): void;
  68378. /**
  68379. * Gets the agent velocity in world space
  68380. * @param index agent index returned by addAgent
  68381. * @returns world space velocity
  68382. */
  68383. getAgentVelocity(index: number): Vector3;
  68384. /**
  68385. * Gets the agent velocity result in world space
  68386. * @param index agent index returned by addAgent
  68387. * @param result output world space velocity
  68388. */
  68389. getAgentVelocityToRef(index: number, result: Vector3): void;
  68390. /**
  68391. * Gets the agent next target point on the path
  68392. * @param index agent index returned by addAgent
  68393. * @returns world space position
  68394. */
  68395. getAgentNextTargetPath(index: number): Vector3;
  68396. /**
  68397. * Gets the agent state
  68398. * @param index agent index returned by addAgent
  68399. * @returns agent state
  68400. */
  68401. getAgentState(index: number): number;
  68402. /**
  68403. * returns true if the agent in over an off mesh link connection
  68404. * @param index agent index returned by addAgent
  68405. * @returns true if over an off mesh link connection
  68406. */
  68407. overOffmeshConnection(index: number): boolean;
  68408. /**
  68409. * Gets the agent next target point on the path
  68410. * @param index agent index returned by addAgent
  68411. * @param result output world space position
  68412. */
  68413. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68414. /**
  68415. * remove a particular agent previously created
  68416. * @param index agent index returned by addAgent
  68417. */
  68418. removeAgent(index: number): void;
  68419. /**
  68420. * get the list of all agents attached to this crowd
  68421. * @returns list of agent indices
  68422. */
  68423. getAgents(): number[];
  68424. /**
  68425. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68426. * @param deltaTime in seconds
  68427. */
  68428. update(deltaTime: number): void;
  68429. /**
  68430. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68431. * @param index agent index returned by addAgent
  68432. * @param destination targeted world position
  68433. */
  68434. agentGoto(index: number, destination: Vector3): void;
  68435. /**
  68436. * Teleport the agent to a new position
  68437. * @param index agent index returned by addAgent
  68438. * @param destination targeted world position
  68439. */
  68440. agentTeleport(index: number, destination: Vector3): void;
  68441. /**
  68442. * Update agent parameters
  68443. * @param index agent index returned by addAgent
  68444. * @param parameters agent parameters
  68445. */
  68446. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68447. /**
  68448. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68449. * The queries will try to find a solution within those bounds
  68450. * default is (1,1,1)
  68451. * @param extent x,y,z value that define the extent around the queries point of reference
  68452. */
  68453. setDefaultQueryExtent(extent: Vector3): void;
  68454. /**
  68455. * Get the Bounding box extent specified by setDefaultQueryExtent
  68456. * @returns the box extent values
  68457. */
  68458. getDefaultQueryExtent(): Vector3;
  68459. /**
  68460. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68461. * @param result output the box extent values
  68462. */
  68463. getDefaultQueryExtentToRef(result: Vector3): void;
  68464. /**
  68465. * Release all resources
  68466. */
  68467. dispose(): void;
  68468. }
  68469. /**
  68470. * Configures an agent
  68471. */
  68472. export interface IAgentParameters {
  68473. /**
  68474. * Agent radius. [Limit: >= 0]
  68475. */
  68476. radius: number;
  68477. /**
  68478. * Agent height. [Limit: > 0]
  68479. */
  68480. height: number;
  68481. /**
  68482. * Maximum allowed acceleration. [Limit: >= 0]
  68483. */
  68484. maxAcceleration: number;
  68485. /**
  68486. * Maximum allowed speed. [Limit: >= 0]
  68487. */
  68488. maxSpeed: number;
  68489. /**
  68490. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68491. */
  68492. collisionQueryRange: number;
  68493. /**
  68494. * The path visibility optimization range. [Limit: > 0]
  68495. */
  68496. pathOptimizationRange: number;
  68497. /**
  68498. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68499. */
  68500. separationWeight: number;
  68501. }
  68502. /**
  68503. * Configures the navigation mesh creation
  68504. */
  68505. export interface INavMeshParameters {
  68506. /**
  68507. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68508. */
  68509. cs: number;
  68510. /**
  68511. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68512. */
  68513. ch: number;
  68514. /**
  68515. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68516. */
  68517. walkableSlopeAngle: number;
  68518. /**
  68519. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68520. * be considered walkable. [Limit: >= 3] [Units: vx]
  68521. */
  68522. walkableHeight: number;
  68523. /**
  68524. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68525. */
  68526. walkableClimb: number;
  68527. /**
  68528. * The distance to erode/shrink the walkable area of the heightfield away from
  68529. * obstructions. [Limit: >=0] [Units: vx]
  68530. */
  68531. walkableRadius: number;
  68532. /**
  68533. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68534. */
  68535. maxEdgeLen: number;
  68536. /**
  68537. * The maximum distance a simplfied contour's border edges should deviate
  68538. * the original raw contour. [Limit: >=0] [Units: vx]
  68539. */
  68540. maxSimplificationError: number;
  68541. /**
  68542. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68543. */
  68544. minRegionArea: number;
  68545. /**
  68546. * Any regions with a span count smaller than this value will, if possible,
  68547. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68548. */
  68549. mergeRegionArea: number;
  68550. /**
  68551. * The maximum number of vertices allowed for polygons generated during the
  68552. * contour to polygon conversion process. [Limit: >= 3]
  68553. */
  68554. maxVertsPerPoly: number;
  68555. /**
  68556. * Sets the sampling distance to use when generating the detail mesh.
  68557. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68558. */
  68559. detailSampleDist: number;
  68560. /**
  68561. * The maximum distance the detail mesh surface should deviate from heightfield
  68562. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68563. */
  68564. detailSampleMaxError: number;
  68565. }
  68566. }
  68567. declare module BABYLON {
  68568. /**
  68569. * RecastJS navigation plugin
  68570. */
  68571. export class RecastJSPlugin implements INavigationEnginePlugin {
  68572. /**
  68573. * Reference to the Recast library
  68574. */
  68575. bjsRECAST: any;
  68576. /**
  68577. * plugin name
  68578. */
  68579. name: string;
  68580. /**
  68581. * the first navmesh created. We might extend this to support multiple navmeshes
  68582. */
  68583. navMesh: any;
  68584. private _maximumSubStepCount;
  68585. private _timeStep;
  68586. /**
  68587. * Initializes the recastJS plugin
  68588. * @param recastInjection can be used to inject your own recast reference
  68589. */
  68590. constructor(recastInjection?: any);
  68591. /**
  68592. * Set the time step of the navigation tick update.
  68593. * Default is 1/60.
  68594. * A value of 0 will disable fixed time update
  68595. * @param newTimeStep the new timestep to apply to this world.
  68596. */
  68597. setTimeStep(newTimeStep?: number): void;
  68598. /**
  68599. * Get the time step of the navigation tick update.
  68600. * @returns the current time step
  68601. */
  68602. getTimeStep(): number;
  68603. /**
  68604. * If delta time in navigation tick update is greater than the time step
  68605. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68606. * they will be discarded.
  68607. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68608. * @param newStepCount the maximum number of iterations
  68609. */
  68610. setMaximumSubStepCount(newStepCount?: number): void;
  68611. /**
  68612. * Get the maximum number of iterations per navigation tick update
  68613. * @returns the maximum number of iterations
  68614. */
  68615. getMaximumSubStepCount(): number;
  68616. /**
  68617. * Creates a navigation mesh
  68618. * @param meshes array of all the geometry used to compute the navigatio mesh
  68619. * @param parameters bunch of parameters used to filter geometry
  68620. */
  68621. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68622. /**
  68623. * Create a navigation mesh debug mesh
  68624. * @param scene is where the mesh will be added
  68625. * @returns debug display mesh
  68626. */
  68627. createDebugNavMesh(scene: Scene): Mesh;
  68628. /**
  68629. * Get a navigation mesh constrained position, closest to the parameter position
  68630. * @param position world position
  68631. * @returns the closest point to position constrained by the navigation mesh
  68632. */
  68633. getClosestPoint(position: Vector3): Vector3;
  68634. /**
  68635. * Get a navigation mesh constrained position, closest to the parameter position
  68636. * @param position world position
  68637. * @param result output the closest point to position constrained by the navigation mesh
  68638. */
  68639. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68640. /**
  68641. * Get a navigation mesh constrained position, within a particular radius
  68642. * @param position world position
  68643. * @param maxRadius the maximum distance to the constrained world position
  68644. * @returns the closest point to position constrained by the navigation mesh
  68645. */
  68646. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68647. /**
  68648. * Get a navigation mesh constrained position, within a particular radius
  68649. * @param position world position
  68650. * @param maxRadius the maximum distance to the constrained world position
  68651. * @param result output the closest point to position constrained by the navigation mesh
  68652. */
  68653. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68654. /**
  68655. * Compute the final position from a segment made of destination-position
  68656. * @param position world position
  68657. * @param destination world position
  68658. * @returns the resulting point along the navmesh
  68659. */
  68660. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68661. /**
  68662. * Compute the final position from a segment made of destination-position
  68663. * @param position world position
  68664. * @param destination world position
  68665. * @param result output the resulting point along the navmesh
  68666. */
  68667. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68668. /**
  68669. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68670. * @param start world position
  68671. * @param end world position
  68672. * @returns array containing world position composing the path
  68673. */
  68674. computePath(start: Vector3, end: Vector3): Vector3[];
  68675. /**
  68676. * Create a new Crowd so you can add agents
  68677. * @param maxAgents the maximum agent count in the crowd
  68678. * @param maxAgentRadius the maximum radius an agent can have
  68679. * @param scene to attach the crowd to
  68680. * @returns the crowd you can add agents to
  68681. */
  68682. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68683. /**
  68684. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68685. * The queries will try to find a solution within those bounds
  68686. * default is (1,1,1)
  68687. * @param extent x,y,z value that define the extent around the queries point of reference
  68688. */
  68689. setDefaultQueryExtent(extent: Vector3): void;
  68690. /**
  68691. * Get the Bounding box extent specified by setDefaultQueryExtent
  68692. * @returns the box extent values
  68693. */
  68694. getDefaultQueryExtent(): Vector3;
  68695. /**
  68696. * build the navmesh from a previously saved state using getNavmeshData
  68697. * @param data the Uint8Array returned by getNavmeshData
  68698. */
  68699. buildFromNavmeshData(data: Uint8Array): void;
  68700. /**
  68701. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68702. * @returns data the Uint8Array that can be saved and reused
  68703. */
  68704. getNavmeshData(): Uint8Array;
  68705. /**
  68706. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68707. * @param result output the box extent values
  68708. */
  68709. getDefaultQueryExtentToRef(result: Vector3): void;
  68710. /**
  68711. * Disposes
  68712. */
  68713. dispose(): void;
  68714. /**
  68715. * If this plugin is supported
  68716. * @returns true if plugin is supported
  68717. */
  68718. isSupported(): boolean;
  68719. }
  68720. /**
  68721. * Recast detour crowd implementation
  68722. */
  68723. export class RecastJSCrowd implements ICrowd {
  68724. /**
  68725. * Recast/detour plugin
  68726. */
  68727. bjsRECASTPlugin: RecastJSPlugin;
  68728. /**
  68729. * Link to the detour crowd
  68730. */
  68731. recastCrowd: any;
  68732. /**
  68733. * One transform per agent
  68734. */
  68735. transforms: TransformNode[];
  68736. /**
  68737. * All agents created
  68738. */
  68739. agents: number[];
  68740. /**
  68741. * Link to the scene is kept to unregister the crowd from the scene
  68742. */
  68743. private _scene;
  68744. /**
  68745. * Observer for crowd updates
  68746. */
  68747. private _onBeforeAnimationsObserver;
  68748. /**
  68749. * Constructor
  68750. * @param plugin recastJS plugin
  68751. * @param maxAgents the maximum agent count in the crowd
  68752. * @param maxAgentRadius the maximum radius an agent can have
  68753. * @param scene to attach the crowd to
  68754. * @returns the crowd you can add agents to
  68755. */
  68756. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68757. /**
  68758. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68759. * You can attach anything to that node. The node position is updated in the scene update tick.
  68760. * @param pos world position that will be constrained by the navigation mesh
  68761. * @param parameters agent parameters
  68762. * @param transform hooked to the agent that will be update by the scene
  68763. * @returns agent index
  68764. */
  68765. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68766. /**
  68767. * Returns the agent position in world space
  68768. * @param index agent index returned by addAgent
  68769. * @returns world space position
  68770. */
  68771. getAgentPosition(index: number): Vector3;
  68772. /**
  68773. * Returns the agent position result in world space
  68774. * @param index agent index returned by addAgent
  68775. * @param result output world space position
  68776. */
  68777. getAgentPositionToRef(index: number, result: Vector3): void;
  68778. /**
  68779. * Returns the agent velocity in world space
  68780. * @param index agent index returned by addAgent
  68781. * @returns world space velocity
  68782. */
  68783. getAgentVelocity(index: number): Vector3;
  68784. /**
  68785. * Returns the agent velocity result in world space
  68786. * @param index agent index returned by addAgent
  68787. * @param result output world space velocity
  68788. */
  68789. getAgentVelocityToRef(index: number, result: Vector3): void;
  68790. /**
  68791. * Returns the agent next target point on the path
  68792. * @param index agent index returned by addAgent
  68793. * @returns world space position
  68794. */
  68795. getAgentNextTargetPath(index: number): Vector3;
  68796. /**
  68797. * Returns the agent next target point on the path
  68798. * @param index agent index returned by addAgent
  68799. * @param result output world space position
  68800. */
  68801. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68802. /**
  68803. * Gets the agent state
  68804. * @param index agent index returned by addAgent
  68805. * @returns agent state
  68806. */
  68807. getAgentState(index: number): number;
  68808. /**
  68809. * returns true if the agent in over an off mesh link connection
  68810. * @param index agent index returned by addAgent
  68811. * @returns true if over an off mesh link connection
  68812. */
  68813. overOffmeshConnection(index: number): boolean;
  68814. /**
  68815. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68816. * @param index agent index returned by addAgent
  68817. * @param destination targeted world position
  68818. */
  68819. agentGoto(index: number, destination: Vector3): void;
  68820. /**
  68821. * Teleport the agent to a new position
  68822. * @param index agent index returned by addAgent
  68823. * @param destination targeted world position
  68824. */
  68825. agentTeleport(index: number, destination: Vector3): void;
  68826. /**
  68827. * Update agent parameters
  68828. * @param index agent index returned by addAgent
  68829. * @param parameters agent parameters
  68830. */
  68831. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68832. /**
  68833. * remove a particular agent previously created
  68834. * @param index agent index returned by addAgent
  68835. */
  68836. removeAgent(index: number): void;
  68837. /**
  68838. * get the list of all agents attached to this crowd
  68839. * @returns list of agent indices
  68840. */
  68841. getAgents(): number[];
  68842. /**
  68843. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68844. * @param deltaTime in seconds
  68845. */
  68846. update(deltaTime: number): void;
  68847. /**
  68848. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68849. * The queries will try to find a solution within those bounds
  68850. * default is (1,1,1)
  68851. * @param extent x,y,z value that define the extent around the queries point of reference
  68852. */
  68853. setDefaultQueryExtent(extent: Vector3): void;
  68854. /**
  68855. * Get the Bounding box extent specified by setDefaultQueryExtent
  68856. * @returns the box extent values
  68857. */
  68858. getDefaultQueryExtent(): Vector3;
  68859. /**
  68860. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68861. * @param result output the box extent values
  68862. */
  68863. getDefaultQueryExtentToRef(result: Vector3): void;
  68864. /**
  68865. * Release all resources
  68866. */
  68867. dispose(): void;
  68868. }
  68869. }
  68870. declare module BABYLON {
  68871. /**
  68872. * Class used to enable access to IndexedDB
  68873. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68874. */
  68875. export class Database implements IOfflineProvider {
  68876. private _callbackManifestChecked;
  68877. private _currentSceneUrl;
  68878. private _db;
  68879. private _enableSceneOffline;
  68880. private _enableTexturesOffline;
  68881. private _manifestVersionFound;
  68882. private _mustUpdateRessources;
  68883. private _hasReachedQuota;
  68884. private _isSupported;
  68885. private _idbFactory;
  68886. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68887. private static IsUASupportingBlobStorage;
  68888. /**
  68889. * Gets a boolean indicating if Database storate is enabled (off by default)
  68890. */
  68891. static IDBStorageEnabled: boolean;
  68892. /**
  68893. * Gets a boolean indicating if scene must be saved in the database
  68894. */
  68895. get enableSceneOffline(): boolean;
  68896. /**
  68897. * Gets a boolean indicating if textures must be saved in the database
  68898. */
  68899. get enableTexturesOffline(): boolean;
  68900. /**
  68901. * Creates a new Database
  68902. * @param urlToScene defines the url to load the scene
  68903. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68904. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68905. */
  68906. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68907. private static _ParseURL;
  68908. private static _ReturnFullUrlLocation;
  68909. private _checkManifestFile;
  68910. /**
  68911. * Open the database and make it available
  68912. * @param successCallback defines the callback to call on success
  68913. * @param errorCallback defines the callback to call on error
  68914. */
  68915. open(successCallback: () => void, errorCallback: () => void): void;
  68916. /**
  68917. * Loads an image from the database
  68918. * @param url defines the url to load from
  68919. * @param image defines the target DOM image
  68920. */
  68921. loadImage(url: string, image: HTMLImageElement): void;
  68922. private _loadImageFromDBAsync;
  68923. private _saveImageIntoDBAsync;
  68924. private _checkVersionFromDB;
  68925. private _loadVersionFromDBAsync;
  68926. private _saveVersionIntoDBAsync;
  68927. /**
  68928. * Loads a file from database
  68929. * @param url defines the URL to load from
  68930. * @param sceneLoaded defines a callback to call on success
  68931. * @param progressCallBack defines a callback to call when progress changed
  68932. * @param errorCallback defines a callback to call on error
  68933. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68934. */
  68935. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68936. private _loadFileAsync;
  68937. private _saveFileAsync;
  68938. /**
  68939. * Validates if xhr data is correct
  68940. * @param xhr defines the request to validate
  68941. * @param dataType defines the expected data type
  68942. * @returns true if data is correct
  68943. */
  68944. private static _ValidateXHRData;
  68945. }
  68946. }
  68947. declare module BABYLON {
  68948. /** @hidden */
  68949. export var gpuUpdateParticlesPixelShader: {
  68950. name: string;
  68951. shader: string;
  68952. };
  68953. }
  68954. declare module BABYLON {
  68955. /** @hidden */
  68956. export var gpuUpdateParticlesVertexShader: {
  68957. name: string;
  68958. shader: string;
  68959. };
  68960. }
  68961. declare module BABYLON {
  68962. /** @hidden */
  68963. export var clipPlaneFragmentDeclaration2: {
  68964. name: string;
  68965. shader: string;
  68966. };
  68967. }
  68968. declare module BABYLON {
  68969. /** @hidden */
  68970. export var gpuRenderParticlesPixelShader: {
  68971. name: string;
  68972. shader: string;
  68973. };
  68974. }
  68975. declare module BABYLON {
  68976. /** @hidden */
  68977. export var clipPlaneVertexDeclaration2: {
  68978. name: string;
  68979. shader: string;
  68980. };
  68981. }
  68982. declare module BABYLON {
  68983. /** @hidden */
  68984. export var gpuRenderParticlesVertexShader: {
  68985. name: string;
  68986. shader: string;
  68987. };
  68988. }
  68989. declare module BABYLON {
  68990. /**
  68991. * This represents a GPU particle system in Babylon
  68992. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68993. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68994. */
  68995. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68996. /**
  68997. * The layer mask we are rendering the particles through.
  68998. */
  68999. layerMask: number;
  69000. private _capacity;
  69001. private _activeCount;
  69002. private _currentActiveCount;
  69003. private _accumulatedCount;
  69004. private _renderEffect;
  69005. private _updateEffect;
  69006. private _buffer0;
  69007. private _buffer1;
  69008. private _spriteBuffer;
  69009. private _updateVAO;
  69010. private _renderVAO;
  69011. private _targetIndex;
  69012. private _sourceBuffer;
  69013. private _targetBuffer;
  69014. private _currentRenderId;
  69015. private _started;
  69016. private _stopped;
  69017. private _timeDelta;
  69018. private _randomTexture;
  69019. private _randomTexture2;
  69020. private _attributesStrideSize;
  69021. private _updateEffectOptions;
  69022. private _randomTextureSize;
  69023. private _actualFrame;
  69024. private _customEffect;
  69025. private readonly _rawTextureWidth;
  69026. /**
  69027. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69028. */
  69029. static get IsSupported(): boolean;
  69030. /**
  69031. * An event triggered when the system is disposed.
  69032. */
  69033. onDisposeObservable: Observable<IParticleSystem>;
  69034. /**
  69035. * An event triggered when the system is stopped
  69036. */
  69037. onStoppedObservable: Observable<IParticleSystem>;
  69038. /**
  69039. * Gets the maximum number of particles active at the same time.
  69040. * @returns The max number of active particles.
  69041. */
  69042. getCapacity(): number;
  69043. /**
  69044. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69045. * to override the particles.
  69046. */
  69047. forceDepthWrite: boolean;
  69048. /**
  69049. * Gets or set the number of active particles
  69050. */
  69051. get activeParticleCount(): number;
  69052. set activeParticleCount(value: number);
  69053. private _preWarmDone;
  69054. /**
  69055. * Specifies if the particles are updated in emitter local space or world space.
  69056. */
  69057. isLocal: boolean;
  69058. /** Gets or sets a matrix to use to compute projection */
  69059. defaultProjectionMatrix: Matrix;
  69060. /**
  69061. * Is this system ready to be used/rendered
  69062. * @return true if the system is ready
  69063. */
  69064. isReady(): boolean;
  69065. /**
  69066. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69067. * @returns True if it has been started, otherwise false.
  69068. */
  69069. isStarted(): boolean;
  69070. /**
  69071. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69072. * @returns True if it has been stopped, otherwise false.
  69073. */
  69074. isStopped(): boolean;
  69075. /**
  69076. * Gets a boolean indicating that the system is stopping
  69077. * @returns true if the system is currently stopping
  69078. */
  69079. isStopping(): boolean;
  69080. /**
  69081. * Gets the number of particles active at the same time.
  69082. * @returns The number of active particles.
  69083. */
  69084. getActiveCount(): number;
  69085. /**
  69086. * Starts the particle system and begins to emit
  69087. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69088. */
  69089. start(delay?: number): void;
  69090. /**
  69091. * Stops the particle system.
  69092. */
  69093. stop(): void;
  69094. /**
  69095. * Remove all active particles
  69096. */
  69097. reset(): void;
  69098. /**
  69099. * Returns the string "GPUParticleSystem"
  69100. * @returns a string containing the class name
  69101. */
  69102. getClassName(): string;
  69103. /**
  69104. * Gets the custom effect used to render the particles
  69105. * @param blendMode Blend mode for which the effect should be retrieved
  69106. * @returns The effect
  69107. */
  69108. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69109. /**
  69110. * Sets the custom effect used to render the particles
  69111. * @param effect The effect to set
  69112. * @param blendMode Blend mode for which the effect should be set
  69113. */
  69114. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69115. /** @hidden */
  69116. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69117. /**
  69118. * Observable that will be called just before the particles are drawn
  69119. */
  69120. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69121. /**
  69122. * Gets the name of the particle vertex shader
  69123. */
  69124. get vertexShaderName(): string;
  69125. private _colorGradientsTexture;
  69126. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69127. /**
  69128. * Adds a new color gradient
  69129. * @param gradient defines the gradient to use (between 0 and 1)
  69130. * @param color1 defines the color to affect to the specified gradient
  69131. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69132. * @returns the current particle system
  69133. */
  69134. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69135. private _refreshColorGradient;
  69136. /** Force the system to rebuild all gradients that need to be resync */
  69137. forceRefreshGradients(): void;
  69138. /**
  69139. * Remove a specific color gradient
  69140. * @param gradient defines the gradient to remove
  69141. * @returns the current particle system
  69142. */
  69143. removeColorGradient(gradient: number): GPUParticleSystem;
  69144. private _angularSpeedGradientsTexture;
  69145. private _sizeGradientsTexture;
  69146. private _velocityGradientsTexture;
  69147. private _limitVelocityGradientsTexture;
  69148. private _dragGradientsTexture;
  69149. private _addFactorGradient;
  69150. /**
  69151. * Adds a new size gradient
  69152. * @param gradient defines the gradient to use (between 0 and 1)
  69153. * @param factor defines the size factor to affect to the specified gradient
  69154. * @returns the current particle system
  69155. */
  69156. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69157. /**
  69158. * Remove a specific size gradient
  69159. * @param gradient defines the gradient to remove
  69160. * @returns the current particle system
  69161. */
  69162. removeSizeGradient(gradient: number): GPUParticleSystem;
  69163. private _refreshFactorGradient;
  69164. /**
  69165. * Adds a new angular speed gradient
  69166. * @param gradient defines the gradient to use (between 0 and 1)
  69167. * @param factor defines the angular speed to affect to the specified gradient
  69168. * @returns the current particle system
  69169. */
  69170. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69171. /**
  69172. * Remove a specific angular speed gradient
  69173. * @param gradient defines the gradient to remove
  69174. * @returns the current particle system
  69175. */
  69176. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69177. /**
  69178. * Adds a new velocity gradient
  69179. * @param gradient defines the gradient to use (between 0 and 1)
  69180. * @param factor defines the velocity to affect to the specified gradient
  69181. * @returns the current particle system
  69182. */
  69183. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69184. /**
  69185. * Remove a specific velocity gradient
  69186. * @param gradient defines the gradient to remove
  69187. * @returns the current particle system
  69188. */
  69189. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69190. /**
  69191. * Adds a new limit velocity gradient
  69192. * @param gradient defines the gradient to use (between 0 and 1)
  69193. * @param factor defines the limit velocity value to affect to the specified gradient
  69194. * @returns the current particle system
  69195. */
  69196. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69197. /**
  69198. * Remove a specific limit velocity gradient
  69199. * @param gradient defines the gradient to remove
  69200. * @returns the current particle system
  69201. */
  69202. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69203. /**
  69204. * Adds a new drag gradient
  69205. * @param gradient defines the gradient to use (between 0 and 1)
  69206. * @param factor defines the drag value to affect to the specified gradient
  69207. * @returns the current particle system
  69208. */
  69209. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69210. /**
  69211. * Remove a specific drag gradient
  69212. * @param gradient defines the gradient to remove
  69213. * @returns the current particle system
  69214. */
  69215. removeDragGradient(gradient: number): GPUParticleSystem;
  69216. /**
  69217. * Not supported by GPUParticleSystem
  69218. * @param gradient defines the gradient to use (between 0 and 1)
  69219. * @param factor defines the emit rate value to affect to the specified gradient
  69220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69221. * @returns the current particle system
  69222. */
  69223. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69224. /**
  69225. * Not supported by GPUParticleSystem
  69226. * @param gradient defines the gradient to remove
  69227. * @returns the current particle system
  69228. */
  69229. removeEmitRateGradient(gradient: number): IParticleSystem;
  69230. /**
  69231. * Not supported by GPUParticleSystem
  69232. * @param gradient defines the gradient to use (between 0 and 1)
  69233. * @param factor defines the start size value to affect to the specified gradient
  69234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69235. * @returns the current particle system
  69236. */
  69237. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69238. /**
  69239. * Not supported by GPUParticleSystem
  69240. * @param gradient defines the gradient to remove
  69241. * @returns the current particle system
  69242. */
  69243. removeStartSizeGradient(gradient: number): IParticleSystem;
  69244. /**
  69245. * Not supported by GPUParticleSystem
  69246. * @param gradient defines the gradient to use (between 0 and 1)
  69247. * @param min defines the color remap minimal range
  69248. * @param max defines the color remap maximal range
  69249. * @returns the current particle system
  69250. */
  69251. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69252. /**
  69253. * Not supported by GPUParticleSystem
  69254. * @param gradient defines the gradient to remove
  69255. * @returns the current particle system
  69256. */
  69257. removeColorRemapGradient(): IParticleSystem;
  69258. /**
  69259. * Not supported by GPUParticleSystem
  69260. * @param gradient defines the gradient to use (between 0 and 1)
  69261. * @param min defines the alpha remap minimal range
  69262. * @param max defines the alpha remap maximal range
  69263. * @returns the current particle system
  69264. */
  69265. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69266. /**
  69267. * Not supported by GPUParticleSystem
  69268. * @param gradient defines the gradient to remove
  69269. * @returns the current particle system
  69270. */
  69271. removeAlphaRemapGradient(): IParticleSystem;
  69272. /**
  69273. * Not supported by GPUParticleSystem
  69274. * @param gradient defines the gradient to use (between 0 and 1)
  69275. * @param color defines the color to affect to the specified gradient
  69276. * @returns the current particle system
  69277. */
  69278. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69279. /**
  69280. * Not supported by GPUParticleSystem
  69281. * @param gradient defines the gradient to remove
  69282. * @returns the current particle system
  69283. */
  69284. removeRampGradient(): IParticleSystem;
  69285. /**
  69286. * Not supported by GPUParticleSystem
  69287. * @returns the list of ramp gradients
  69288. */
  69289. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69290. /**
  69291. * Not supported by GPUParticleSystem
  69292. * Gets or sets a boolean indicating that ramp gradients must be used
  69293. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69294. */
  69295. get useRampGradients(): boolean;
  69296. set useRampGradients(value: boolean);
  69297. /**
  69298. * Not supported by GPUParticleSystem
  69299. * @param gradient defines the gradient to use (between 0 and 1)
  69300. * @param factor defines the life time factor to affect to the specified gradient
  69301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69302. * @returns the current particle system
  69303. */
  69304. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69305. /**
  69306. * Not supported by GPUParticleSystem
  69307. * @param gradient defines the gradient to remove
  69308. * @returns the current particle system
  69309. */
  69310. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69311. /**
  69312. * Instantiates a GPU particle system.
  69313. * 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.
  69314. * @param name The name of the particle system
  69315. * @param options The options used to create the system
  69316. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69317. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69318. * @param customEffect a custom effect used to change the way particles are rendered by default
  69319. */
  69320. constructor(name: string, options: Partial<{
  69321. capacity: number;
  69322. randomTextureSize: number;
  69323. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69324. protected _reset(): void;
  69325. private _createUpdateVAO;
  69326. private _createRenderVAO;
  69327. private _initialize;
  69328. /** @hidden */
  69329. _recreateUpdateEffect(): void;
  69330. private _getEffect;
  69331. /**
  69332. * Fill the defines array according to the current settings of the particle system
  69333. * @param defines Array to be updated
  69334. * @param blendMode blend mode to take into account when updating the array
  69335. */
  69336. fillDefines(defines: Array<string>, blendMode?: number): void;
  69337. /**
  69338. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69339. * @param uniforms Uniforms array to fill
  69340. * @param attributes Attributes array to fill
  69341. * @param samplers Samplers array to fill
  69342. */
  69343. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69344. /** @hidden */
  69345. _recreateRenderEffect(): Effect;
  69346. /**
  69347. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69348. * @param preWarm defines if we are in the pre-warmimg phase
  69349. */
  69350. animate(preWarm?: boolean): void;
  69351. private _createFactorGradientTexture;
  69352. private _createSizeGradientTexture;
  69353. private _createAngularSpeedGradientTexture;
  69354. private _createVelocityGradientTexture;
  69355. private _createLimitVelocityGradientTexture;
  69356. private _createDragGradientTexture;
  69357. private _createColorGradientTexture;
  69358. /**
  69359. * Renders the particle system in its current state
  69360. * @param preWarm defines if the system should only update the particles but not render them
  69361. * @returns the current number of particles
  69362. */
  69363. render(preWarm?: boolean): number;
  69364. /**
  69365. * Rebuilds the particle system
  69366. */
  69367. rebuild(): void;
  69368. private _releaseBuffers;
  69369. private _releaseVAOs;
  69370. /**
  69371. * Disposes the particle system and free the associated resources
  69372. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69373. */
  69374. dispose(disposeTexture?: boolean): void;
  69375. /**
  69376. * Clones the particle system.
  69377. * @param name The name of the cloned object
  69378. * @param newEmitter The new emitter to use
  69379. * @returns the cloned particle system
  69380. */
  69381. clone(name: string, newEmitter: any): GPUParticleSystem;
  69382. /**
  69383. * Serializes the particle system to a JSON object
  69384. * @param serializeTexture defines if the texture must be serialized as well
  69385. * @returns the JSON object
  69386. */
  69387. serialize(serializeTexture?: boolean): any;
  69388. /**
  69389. * Parses a JSON object to create a GPU particle system.
  69390. * @param parsedParticleSystem The JSON object to parse
  69391. * @param sceneOrEngine The scene or the engine to create the particle system in
  69392. * @param rootUrl The root url to use to load external dependencies like texture
  69393. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69394. * @returns the parsed GPU particle system
  69395. */
  69396. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69397. }
  69398. }
  69399. declare module BABYLON {
  69400. /**
  69401. * Represents a set of particle systems working together to create a specific effect
  69402. */
  69403. export class ParticleSystemSet implements IDisposable {
  69404. /**
  69405. * Gets or sets base Assets URL
  69406. */
  69407. static BaseAssetsUrl: string;
  69408. private _emitterCreationOptions;
  69409. private _emitterNode;
  69410. /**
  69411. * Gets the particle system list
  69412. */
  69413. systems: IParticleSystem[];
  69414. /**
  69415. * Gets the emitter node used with this set
  69416. */
  69417. get emitterNode(): Nullable<TransformNode>;
  69418. /**
  69419. * Creates a new emitter mesh as a sphere
  69420. * @param options defines the options used to create the sphere
  69421. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69422. * @param scene defines the hosting scene
  69423. */
  69424. setEmitterAsSphere(options: {
  69425. diameter: number;
  69426. segments: number;
  69427. color: Color3;
  69428. }, renderingGroupId: number, scene: Scene): void;
  69429. /**
  69430. * Starts all particle systems of the set
  69431. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69432. */
  69433. start(emitter?: AbstractMesh): void;
  69434. /**
  69435. * Release all associated resources
  69436. */
  69437. dispose(): void;
  69438. /**
  69439. * Serialize the set into a JSON compatible object
  69440. * @param serializeTexture defines if the texture must be serialized as well
  69441. * @returns a JSON compatible representation of the set
  69442. */
  69443. serialize(serializeTexture?: boolean): any;
  69444. /**
  69445. * Parse a new ParticleSystemSet from a serialized source
  69446. * @param data defines a JSON compatible representation of the set
  69447. * @param scene defines the hosting scene
  69448. * @param gpu defines if we want GPU particles or CPU particles
  69449. * @returns a new ParticleSystemSet
  69450. */
  69451. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69452. }
  69453. }
  69454. declare module BABYLON {
  69455. /**
  69456. * This class is made for on one-liner static method to help creating particle system set.
  69457. */
  69458. export class ParticleHelper {
  69459. /**
  69460. * Gets or sets base Assets URL
  69461. */
  69462. static BaseAssetsUrl: string;
  69463. /** Define the Url to load snippets */
  69464. static SnippetUrl: string;
  69465. /**
  69466. * Create a default particle system that you can tweak
  69467. * @param emitter defines the emitter to use
  69468. * @param capacity defines the system capacity (default is 500 particles)
  69469. * @param scene defines the hosting scene
  69470. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69471. * @returns the new Particle system
  69472. */
  69473. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69474. /**
  69475. * This is the main static method (one-liner) of this helper to create different particle systems
  69476. * @param type This string represents the type to the particle system to create
  69477. * @param scene The scene where the particle system should live
  69478. * @param gpu If the system will use gpu
  69479. * @returns the ParticleSystemSet created
  69480. */
  69481. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69482. /**
  69483. * Static function used to export a particle system to a ParticleSystemSet variable.
  69484. * Please note that the emitter shape is not exported
  69485. * @param systems defines the particle systems to export
  69486. * @returns the created particle system set
  69487. */
  69488. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69489. /**
  69490. * Creates a particle system from a snippet saved in a remote file
  69491. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69492. * @param url defines the url to load from
  69493. * @param scene defines the hosting scene
  69494. * @param gpu If the system will use gpu
  69495. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69496. * @returns a promise that will resolve to the new particle system
  69497. */
  69498. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69499. /**
  69500. * Creates a particle system from a snippet saved by the particle system editor
  69501. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69502. * @param scene defines the hosting scene
  69503. * @param gpu If the system will use gpu
  69504. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69505. * @returns a promise that will resolve to the new particle system
  69506. */
  69507. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69508. }
  69509. }
  69510. declare module BABYLON {
  69511. interface Engine {
  69512. /**
  69513. * Create an effect to use with particle systems.
  69514. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69515. * the particle system for which you want to create a custom effect in the last parameter
  69516. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69517. * @param uniformsNames defines a list of attribute names
  69518. * @param samplers defines an array of string used to represent textures
  69519. * @param defines defines the string containing the defines to use to compile the shaders
  69520. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69521. * @param onCompiled defines a function to call when the effect creation is successful
  69522. * @param onError defines a function to call when the effect creation has failed
  69523. * @param particleSystem the particle system you want to create the effect for
  69524. * @returns the new Effect
  69525. */
  69526. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69527. }
  69528. interface Mesh {
  69529. /**
  69530. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69531. * @returns an array of IParticleSystem
  69532. */
  69533. getEmittedParticleSystems(): IParticleSystem[];
  69534. /**
  69535. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69536. * @returns an array of IParticleSystem
  69537. */
  69538. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69539. }
  69540. }
  69541. declare module BABYLON {
  69542. /** Defines the 4 color options */
  69543. export enum PointColor {
  69544. /** color value */
  69545. Color = 2,
  69546. /** uv value */
  69547. UV = 1,
  69548. /** random value */
  69549. Random = 0,
  69550. /** stated value */
  69551. Stated = 3
  69552. }
  69553. /**
  69554. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69555. * 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.
  69556. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69557. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69558. *
  69559. * Full documentation here : TO BE ENTERED
  69560. */
  69561. export class PointsCloudSystem implements IDisposable {
  69562. /**
  69563. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69564. * Example : var p = SPS.particles[i];
  69565. */
  69566. particles: CloudPoint[];
  69567. /**
  69568. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69569. */
  69570. nbParticles: number;
  69571. /**
  69572. * This a counter for your own usage. It's not set by any SPS functions.
  69573. */
  69574. counter: number;
  69575. /**
  69576. * The PCS name. This name is also given to the underlying mesh.
  69577. */
  69578. name: string;
  69579. /**
  69580. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69581. */
  69582. mesh: Mesh;
  69583. /**
  69584. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69585. * Please read :
  69586. */
  69587. vars: any;
  69588. /**
  69589. * @hidden
  69590. */
  69591. _size: number;
  69592. private _scene;
  69593. private _promises;
  69594. private _positions;
  69595. private _indices;
  69596. private _normals;
  69597. private _colors;
  69598. private _uvs;
  69599. private _indices32;
  69600. private _positions32;
  69601. private _colors32;
  69602. private _uvs32;
  69603. private _updatable;
  69604. private _isVisibilityBoxLocked;
  69605. private _alwaysVisible;
  69606. private _groups;
  69607. private _groupCounter;
  69608. private _computeParticleColor;
  69609. private _computeParticleTexture;
  69610. private _computeParticleRotation;
  69611. private _computeBoundingBox;
  69612. private _isReady;
  69613. /**
  69614. * Creates a PCS (Points Cloud System) object
  69615. * @param name (String) is the PCS name, this will be the underlying mesh name
  69616. * @param pointSize (number) is the size for each point
  69617. * @param scene (Scene) is the scene in which the PCS is added
  69618. * @param options defines the options of the PCS e.g.
  69619. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69620. */
  69621. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69622. updatable?: boolean;
  69623. });
  69624. /**
  69625. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69626. * If no points were added to the PCS, the returned mesh is just a single point.
  69627. * @returns a promise for the created mesh
  69628. */
  69629. buildMeshAsync(): Promise<Mesh>;
  69630. /**
  69631. * @hidden
  69632. */
  69633. private _buildMesh;
  69634. private _addParticle;
  69635. private _randomUnitVector;
  69636. private _getColorIndicesForCoord;
  69637. private _setPointsColorOrUV;
  69638. private _colorFromTexture;
  69639. private _calculateDensity;
  69640. /**
  69641. * Adds points to the PCS in random positions within a unit sphere
  69642. * @param nb (positive integer) the number of particles to be created from this model
  69643. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69644. * @returns the number of groups in the system
  69645. */
  69646. addPoints(nb: number, pointFunction?: any): number;
  69647. /**
  69648. * Adds points to the PCS from the surface of the model shape
  69649. * @param mesh is any Mesh object that will be used as a surface model for the points
  69650. * @param nb (positive integer) the number of particles to be created from this model
  69651. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69652. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69653. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69654. * @returns the number of groups in the system
  69655. */
  69656. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69657. /**
  69658. * Adds points to the PCS inside the model shape
  69659. * @param mesh is any Mesh object that will be used as a surface model for the points
  69660. * @param nb (positive integer) the number of particles to be created from this model
  69661. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69662. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69663. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69664. * @returns the number of groups in the system
  69665. */
  69666. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69667. /**
  69668. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69669. * This method calls `updateParticle()` for each particle of the SPS.
  69670. * For an animated SPS, it is usually called within the render loop.
  69671. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69672. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69673. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69674. * @returns the PCS.
  69675. */
  69676. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69677. /**
  69678. * Disposes the PCS.
  69679. */
  69680. dispose(): void;
  69681. /**
  69682. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69683. * doc :
  69684. * @returns the PCS.
  69685. */
  69686. refreshVisibleSize(): PointsCloudSystem;
  69687. /**
  69688. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69689. * @param size the size (float) of the visibility box
  69690. * note : this doesn't lock the PCS mesh bounding box.
  69691. * doc :
  69692. */
  69693. setVisibilityBox(size: number): void;
  69694. /**
  69695. * Gets whether the PCS is always visible or not
  69696. * doc :
  69697. */
  69698. get isAlwaysVisible(): boolean;
  69699. /**
  69700. * Sets the PCS as always visible or not
  69701. * doc :
  69702. */
  69703. set isAlwaysVisible(val: boolean);
  69704. /**
  69705. * Tells to `setParticles()` to compute the particle rotations or not
  69706. * Default value : false. The PCS is faster when it's set to false
  69707. * Note : particle rotations are only applied to parent particles
  69708. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69709. */
  69710. set computeParticleRotation(val: boolean);
  69711. /**
  69712. * Tells to `setParticles()` to compute the particle colors or not.
  69713. * Default value : true. The PCS is faster when it's set to false.
  69714. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69715. */
  69716. set computeParticleColor(val: boolean);
  69717. set computeParticleTexture(val: boolean);
  69718. /**
  69719. * Gets if `setParticles()` computes the particle colors or not.
  69720. * Default value : false. The PCS is faster when it's set to false.
  69721. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69722. */
  69723. get computeParticleColor(): boolean;
  69724. /**
  69725. * Gets if `setParticles()` computes the particle textures or not.
  69726. * Default value : false. The PCS is faster when it's set to false.
  69727. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69728. */
  69729. get computeParticleTexture(): boolean;
  69730. /**
  69731. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69732. */
  69733. set computeBoundingBox(val: boolean);
  69734. /**
  69735. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69736. */
  69737. get computeBoundingBox(): boolean;
  69738. /**
  69739. * This function does nothing. It may be overwritten to set all the particle first values.
  69740. * The PCS doesn't call this function, you may have to call it by your own.
  69741. * doc :
  69742. */
  69743. initParticles(): void;
  69744. /**
  69745. * This function does nothing. It may be overwritten to recycle a particle
  69746. * The PCS doesn't call this function, you can to call it
  69747. * doc :
  69748. * @param particle The particle to recycle
  69749. * @returns the recycled particle
  69750. */
  69751. recycleParticle(particle: CloudPoint): CloudPoint;
  69752. /**
  69753. * Updates a particle : this function should be overwritten by the user.
  69754. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69755. * doc :
  69756. * @example : just set a particle position or velocity and recycle conditions
  69757. * @param particle The particle to update
  69758. * @returns the updated particle
  69759. */
  69760. updateParticle(particle: CloudPoint): CloudPoint;
  69761. /**
  69762. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69763. * This does nothing and may be overwritten by the user.
  69764. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69765. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69766. * @param update the boolean update value actually passed to setParticles()
  69767. */
  69768. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69769. /**
  69770. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69771. * This will be passed three parameters.
  69772. * This does nothing and may be overwritten by the user.
  69773. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69774. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69775. * @param update the boolean update value actually passed to setParticles()
  69776. */
  69777. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69778. }
  69779. }
  69780. declare module BABYLON {
  69781. /**
  69782. * Represents one particle of a points cloud system.
  69783. */
  69784. export class CloudPoint {
  69785. /**
  69786. * particle global index
  69787. */
  69788. idx: number;
  69789. /**
  69790. * The color of the particle
  69791. */
  69792. color: Nullable<Color4>;
  69793. /**
  69794. * The world space position of the particle.
  69795. */
  69796. position: Vector3;
  69797. /**
  69798. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69799. */
  69800. rotation: Vector3;
  69801. /**
  69802. * The world space rotation quaternion of the particle.
  69803. */
  69804. rotationQuaternion: Nullable<Quaternion>;
  69805. /**
  69806. * The uv of the particle.
  69807. */
  69808. uv: Nullable<Vector2>;
  69809. /**
  69810. * The current speed of the particle.
  69811. */
  69812. velocity: Vector3;
  69813. /**
  69814. * The pivot point in the particle local space.
  69815. */
  69816. pivot: Vector3;
  69817. /**
  69818. * Must the particle be translated from its pivot point in its local space ?
  69819. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69820. * Default : false
  69821. */
  69822. translateFromPivot: boolean;
  69823. /**
  69824. * Index of this particle in the global "positions" array (Internal use)
  69825. * @hidden
  69826. */
  69827. _pos: number;
  69828. /**
  69829. * @hidden Index of this particle in the global "indices" array (Internal use)
  69830. */
  69831. _ind: number;
  69832. /**
  69833. * Group this particle belongs to
  69834. */
  69835. _group: PointsGroup;
  69836. /**
  69837. * Group id of this particle
  69838. */
  69839. groupId: number;
  69840. /**
  69841. * Index of the particle in its group id (Internal use)
  69842. */
  69843. idxInGroup: number;
  69844. /**
  69845. * @hidden Particle BoundingInfo object (Internal use)
  69846. */
  69847. _boundingInfo: BoundingInfo;
  69848. /**
  69849. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69850. */
  69851. _pcs: PointsCloudSystem;
  69852. /**
  69853. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69854. */
  69855. _stillInvisible: boolean;
  69856. /**
  69857. * @hidden Last computed particle rotation matrix
  69858. */
  69859. _rotationMatrix: number[];
  69860. /**
  69861. * Parent particle Id, if any.
  69862. * Default null.
  69863. */
  69864. parentId: Nullable<number>;
  69865. /**
  69866. * @hidden Internal global position in the PCS.
  69867. */
  69868. _globalPosition: Vector3;
  69869. /**
  69870. * Creates a Point Cloud object.
  69871. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69872. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69873. * @param group (PointsGroup) is the group the particle belongs to
  69874. * @param groupId (integer) is the group identifier in the PCS.
  69875. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69876. * @param pcs defines the PCS it is associated to
  69877. */
  69878. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69879. /**
  69880. * get point size
  69881. */
  69882. get size(): Vector3;
  69883. /**
  69884. * Set point size
  69885. */
  69886. set size(scale: Vector3);
  69887. /**
  69888. * Legacy support, changed quaternion to rotationQuaternion
  69889. */
  69890. get quaternion(): Nullable<Quaternion>;
  69891. /**
  69892. * Legacy support, changed quaternion to rotationQuaternion
  69893. */
  69894. set quaternion(q: Nullable<Quaternion>);
  69895. /**
  69896. * Returns a boolean. True if the particle intersects a mesh, else false
  69897. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69898. * @param target is the object (point or mesh) what the intersection is computed against
  69899. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69900. * @returns true if it intersects
  69901. */
  69902. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69903. /**
  69904. * get the rotation matrix of the particle
  69905. * @hidden
  69906. */
  69907. getRotationMatrix(m: Matrix): void;
  69908. }
  69909. /**
  69910. * Represents a group of points in a points cloud system
  69911. * * PCS internal tool, don't use it manually.
  69912. */
  69913. export class PointsGroup {
  69914. /**
  69915. * The group id
  69916. * @hidden
  69917. */
  69918. groupID: number;
  69919. /**
  69920. * image data for group (internal use)
  69921. * @hidden
  69922. */
  69923. _groupImageData: Nullable<ArrayBufferView>;
  69924. /**
  69925. * Image Width (internal use)
  69926. * @hidden
  69927. */
  69928. _groupImgWidth: number;
  69929. /**
  69930. * Image Height (internal use)
  69931. * @hidden
  69932. */
  69933. _groupImgHeight: number;
  69934. /**
  69935. * Custom position function (internal use)
  69936. * @hidden
  69937. */
  69938. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69939. /**
  69940. * density per facet for surface points
  69941. * @hidden
  69942. */
  69943. _groupDensity: number[];
  69944. /**
  69945. * Only when points are colored by texture carries pointer to texture list array
  69946. * @hidden
  69947. */
  69948. _textureNb: number;
  69949. /**
  69950. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69951. * PCS internal tool, don't use it manually.
  69952. * @hidden
  69953. */
  69954. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69955. }
  69956. }
  69957. declare module BABYLON {
  69958. interface Scene {
  69959. /** @hidden (Backing field) */
  69960. _physicsEngine: Nullable<IPhysicsEngine>;
  69961. /** @hidden */
  69962. _physicsTimeAccumulator: number;
  69963. /**
  69964. * Gets the current physics engine
  69965. * @returns a IPhysicsEngine or null if none attached
  69966. */
  69967. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69968. /**
  69969. * Enables physics to the current scene
  69970. * @param gravity defines the scene's gravity for the physics engine
  69971. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69972. * @return a boolean indicating if the physics engine was initialized
  69973. */
  69974. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69975. /**
  69976. * Disables and disposes the physics engine associated with the scene
  69977. */
  69978. disablePhysicsEngine(): void;
  69979. /**
  69980. * Gets a boolean indicating if there is an active physics engine
  69981. * @returns a boolean indicating if there is an active physics engine
  69982. */
  69983. isPhysicsEnabled(): boolean;
  69984. /**
  69985. * Deletes a physics compound impostor
  69986. * @param compound defines the compound to delete
  69987. */
  69988. deleteCompoundImpostor(compound: any): void;
  69989. /**
  69990. * An event triggered when physic simulation is about to be run
  69991. */
  69992. onBeforePhysicsObservable: Observable<Scene>;
  69993. /**
  69994. * An event triggered when physic simulation has been done
  69995. */
  69996. onAfterPhysicsObservable: Observable<Scene>;
  69997. }
  69998. interface AbstractMesh {
  69999. /** @hidden */
  70000. _physicsImpostor: Nullable<PhysicsImpostor>;
  70001. /**
  70002. * Gets or sets impostor used for physic simulation
  70003. * @see https://doc.babylonjs.com/features/physics_engine
  70004. */
  70005. physicsImpostor: Nullable<PhysicsImpostor>;
  70006. /**
  70007. * Gets the current physics impostor
  70008. * @see https://doc.babylonjs.com/features/physics_engine
  70009. * @returns a physics impostor or null
  70010. */
  70011. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70012. /** Apply a physic impulse to the mesh
  70013. * @param force defines the force to apply
  70014. * @param contactPoint defines where to apply the force
  70015. * @returns the current mesh
  70016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70017. */
  70018. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70019. /**
  70020. * Creates a physic joint between two meshes
  70021. * @param otherMesh defines the other mesh to use
  70022. * @param pivot1 defines the pivot to use on this mesh
  70023. * @param pivot2 defines the pivot to use on the other mesh
  70024. * @param options defines additional options (can be plugin dependent)
  70025. * @returns the current mesh
  70026. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70027. */
  70028. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70029. /** @hidden */
  70030. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70031. }
  70032. /**
  70033. * Defines the physics engine scene component responsible to manage a physics engine
  70034. */
  70035. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70036. /**
  70037. * The component name helpful to identify the component in the list of scene components.
  70038. */
  70039. readonly name: string;
  70040. /**
  70041. * The scene the component belongs to.
  70042. */
  70043. scene: Scene;
  70044. /**
  70045. * Creates a new instance of the component for the given scene
  70046. * @param scene Defines the scene to register the component in
  70047. */
  70048. constructor(scene: Scene);
  70049. /**
  70050. * Registers the component in a given scene
  70051. */
  70052. register(): void;
  70053. /**
  70054. * Rebuilds the elements related to this component in case of
  70055. * context lost for instance.
  70056. */
  70057. rebuild(): void;
  70058. /**
  70059. * Disposes the component and the associated ressources
  70060. */
  70061. dispose(): void;
  70062. }
  70063. }
  70064. declare module BABYLON {
  70065. /**
  70066. * A helper for physics simulations
  70067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70068. */
  70069. export class PhysicsHelper {
  70070. private _scene;
  70071. private _physicsEngine;
  70072. /**
  70073. * Initializes the Physics helper
  70074. * @param scene Babylon.js scene
  70075. */
  70076. constructor(scene: Scene);
  70077. /**
  70078. * Applies a radial explosion impulse
  70079. * @param origin the origin of the explosion
  70080. * @param radiusOrEventOptions the radius or the options of radial explosion
  70081. * @param strength the explosion strength
  70082. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70083. * @returns A physics radial explosion event, or null
  70084. */
  70085. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70086. /**
  70087. * Applies a radial explosion force
  70088. * @param origin the origin of the explosion
  70089. * @param radiusOrEventOptions the radius or the options of radial explosion
  70090. * @param strength the explosion strength
  70091. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70092. * @returns A physics radial explosion event, or null
  70093. */
  70094. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70095. /**
  70096. * Creates a gravitational field
  70097. * @param origin the origin of the explosion
  70098. * @param radiusOrEventOptions the radius or the options of radial explosion
  70099. * @param strength the explosion strength
  70100. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70101. * @returns A physics gravitational field event, or null
  70102. */
  70103. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70104. /**
  70105. * Creates a physics updraft event
  70106. * @param origin the origin of the updraft
  70107. * @param radiusOrEventOptions the radius or the options of the updraft
  70108. * @param strength the strength of the updraft
  70109. * @param height the height of the updraft
  70110. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70111. * @returns A physics updraft event, or null
  70112. */
  70113. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70114. /**
  70115. * Creates a physics vortex event
  70116. * @param origin the of the vortex
  70117. * @param radiusOrEventOptions the radius or the options of the vortex
  70118. * @param strength the strength of the vortex
  70119. * @param height the height of the vortex
  70120. * @returns a Physics vortex event, or null
  70121. * A physics vortex event or null
  70122. */
  70123. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70124. }
  70125. /**
  70126. * Represents a physics radial explosion event
  70127. */
  70128. class PhysicsRadialExplosionEvent {
  70129. private _scene;
  70130. private _options;
  70131. private _sphere;
  70132. private _dataFetched;
  70133. /**
  70134. * Initializes a radial explosioin event
  70135. * @param _scene BabylonJS scene
  70136. * @param _options The options for the vortex event
  70137. */
  70138. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70139. /**
  70140. * Returns the data related to the radial explosion event (sphere).
  70141. * @returns The radial explosion event data
  70142. */
  70143. getData(): PhysicsRadialExplosionEventData;
  70144. /**
  70145. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70146. * @param impostor A physics imposter
  70147. * @param origin the origin of the explosion
  70148. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70149. */
  70150. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70151. /**
  70152. * Triggers affecterd impostors callbacks
  70153. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70154. */
  70155. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70156. /**
  70157. * Disposes the sphere.
  70158. * @param force Specifies if the sphere should be disposed by force
  70159. */
  70160. dispose(force?: boolean): void;
  70161. /*** Helpers ***/
  70162. private _prepareSphere;
  70163. private _intersectsWithSphere;
  70164. }
  70165. /**
  70166. * Represents a gravitational field event
  70167. */
  70168. class PhysicsGravitationalFieldEvent {
  70169. private _physicsHelper;
  70170. private _scene;
  70171. private _origin;
  70172. private _options;
  70173. private _tickCallback;
  70174. private _sphere;
  70175. private _dataFetched;
  70176. /**
  70177. * Initializes the physics gravitational field event
  70178. * @param _physicsHelper A physics helper
  70179. * @param _scene BabylonJS scene
  70180. * @param _origin The origin position of the gravitational field event
  70181. * @param _options The options for the vortex event
  70182. */
  70183. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70184. /**
  70185. * Returns the data related to the gravitational field event (sphere).
  70186. * @returns A gravitational field event
  70187. */
  70188. getData(): PhysicsGravitationalFieldEventData;
  70189. /**
  70190. * Enables the gravitational field.
  70191. */
  70192. enable(): void;
  70193. /**
  70194. * Disables the gravitational field.
  70195. */
  70196. disable(): void;
  70197. /**
  70198. * Disposes the sphere.
  70199. * @param force The force to dispose from the gravitational field event
  70200. */
  70201. dispose(force?: boolean): void;
  70202. private _tick;
  70203. }
  70204. /**
  70205. * Represents a physics updraft event
  70206. */
  70207. class PhysicsUpdraftEvent {
  70208. private _scene;
  70209. private _origin;
  70210. private _options;
  70211. private _physicsEngine;
  70212. private _originTop;
  70213. private _originDirection;
  70214. private _tickCallback;
  70215. private _cylinder;
  70216. private _cylinderPosition;
  70217. private _dataFetched;
  70218. /**
  70219. * Initializes the physics updraft event
  70220. * @param _scene BabylonJS scene
  70221. * @param _origin The origin position of the updraft
  70222. * @param _options The options for the updraft event
  70223. */
  70224. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70225. /**
  70226. * Returns the data related to the updraft event (cylinder).
  70227. * @returns A physics updraft event
  70228. */
  70229. getData(): PhysicsUpdraftEventData;
  70230. /**
  70231. * Enables the updraft.
  70232. */
  70233. enable(): void;
  70234. /**
  70235. * Disables the updraft.
  70236. */
  70237. disable(): void;
  70238. /**
  70239. * Disposes the cylinder.
  70240. * @param force Specifies if the updraft should be disposed by force
  70241. */
  70242. dispose(force?: boolean): void;
  70243. private getImpostorHitData;
  70244. private _tick;
  70245. /*** Helpers ***/
  70246. private _prepareCylinder;
  70247. private _intersectsWithCylinder;
  70248. }
  70249. /**
  70250. * Represents a physics vortex event
  70251. */
  70252. class PhysicsVortexEvent {
  70253. private _scene;
  70254. private _origin;
  70255. private _options;
  70256. private _physicsEngine;
  70257. private _originTop;
  70258. private _tickCallback;
  70259. private _cylinder;
  70260. private _cylinderPosition;
  70261. private _dataFetched;
  70262. /**
  70263. * Initializes the physics vortex event
  70264. * @param _scene The BabylonJS scene
  70265. * @param _origin The origin position of the vortex
  70266. * @param _options The options for the vortex event
  70267. */
  70268. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70269. /**
  70270. * Returns the data related to the vortex event (cylinder).
  70271. * @returns The physics vortex event data
  70272. */
  70273. getData(): PhysicsVortexEventData;
  70274. /**
  70275. * Enables the vortex.
  70276. */
  70277. enable(): void;
  70278. /**
  70279. * Disables the cortex.
  70280. */
  70281. disable(): void;
  70282. /**
  70283. * Disposes the sphere.
  70284. * @param force
  70285. */
  70286. dispose(force?: boolean): void;
  70287. private getImpostorHitData;
  70288. private _tick;
  70289. /*** Helpers ***/
  70290. private _prepareCylinder;
  70291. private _intersectsWithCylinder;
  70292. }
  70293. /**
  70294. * Options fot the radial explosion event
  70295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70296. */
  70297. export class PhysicsRadialExplosionEventOptions {
  70298. /**
  70299. * The radius of the sphere for the radial explosion.
  70300. */
  70301. radius: number;
  70302. /**
  70303. * The strenth of the explosion.
  70304. */
  70305. strength: number;
  70306. /**
  70307. * The strenght of the force in correspondence to the distance of the affected object
  70308. */
  70309. falloff: PhysicsRadialImpulseFalloff;
  70310. /**
  70311. * Sphere options for the radial explosion.
  70312. */
  70313. sphere: {
  70314. segments: number;
  70315. diameter: number;
  70316. };
  70317. /**
  70318. * Sphere options for the radial explosion.
  70319. */
  70320. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70321. }
  70322. /**
  70323. * Options fot the updraft event
  70324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70325. */
  70326. export class PhysicsUpdraftEventOptions {
  70327. /**
  70328. * The radius of the cylinder for the vortex
  70329. */
  70330. radius: number;
  70331. /**
  70332. * The strenth of the updraft.
  70333. */
  70334. strength: number;
  70335. /**
  70336. * The height of the cylinder for the updraft.
  70337. */
  70338. height: number;
  70339. /**
  70340. * The mode for the the updraft.
  70341. */
  70342. updraftMode: PhysicsUpdraftMode;
  70343. }
  70344. /**
  70345. * Options fot the vortex event
  70346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70347. */
  70348. export class PhysicsVortexEventOptions {
  70349. /**
  70350. * The radius of the cylinder for the vortex
  70351. */
  70352. radius: number;
  70353. /**
  70354. * The strenth of the vortex.
  70355. */
  70356. strength: number;
  70357. /**
  70358. * The height of the cylinder for the vortex.
  70359. */
  70360. height: number;
  70361. /**
  70362. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70363. */
  70364. centripetalForceThreshold: number;
  70365. /**
  70366. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70367. */
  70368. centripetalForceMultiplier: number;
  70369. /**
  70370. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70371. */
  70372. centrifugalForceMultiplier: number;
  70373. /**
  70374. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70375. */
  70376. updraftForceMultiplier: number;
  70377. }
  70378. /**
  70379. * The strenght of the force in correspondence to the distance of the affected object
  70380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70381. */
  70382. export enum PhysicsRadialImpulseFalloff {
  70383. /** Defines that impulse is constant in strength across it's whole radius */
  70384. Constant = 0,
  70385. /** Defines that impulse gets weaker if it's further from the origin */
  70386. Linear = 1
  70387. }
  70388. /**
  70389. * The strength of the force in correspondence to the distance of the affected object
  70390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70391. */
  70392. export enum PhysicsUpdraftMode {
  70393. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70394. Center = 0,
  70395. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70396. Perpendicular = 1
  70397. }
  70398. /**
  70399. * Interface for a physics hit data
  70400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70401. */
  70402. export interface PhysicsHitData {
  70403. /**
  70404. * The force applied at the contact point
  70405. */
  70406. force: Vector3;
  70407. /**
  70408. * The contact point
  70409. */
  70410. contactPoint: Vector3;
  70411. /**
  70412. * The distance from the origin to the contact point
  70413. */
  70414. distanceFromOrigin: number;
  70415. }
  70416. /**
  70417. * Interface for radial explosion event data
  70418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70419. */
  70420. export interface PhysicsRadialExplosionEventData {
  70421. /**
  70422. * A sphere used for the radial explosion event
  70423. */
  70424. sphere: Mesh;
  70425. }
  70426. /**
  70427. * Interface for gravitational field event data
  70428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70429. */
  70430. export interface PhysicsGravitationalFieldEventData {
  70431. /**
  70432. * A sphere mesh used for the gravitational field event
  70433. */
  70434. sphere: Mesh;
  70435. }
  70436. /**
  70437. * Interface for updraft event data
  70438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70439. */
  70440. export interface PhysicsUpdraftEventData {
  70441. /**
  70442. * A cylinder used for the updraft event
  70443. */
  70444. cylinder: Mesh;
  70445. }
  70446. /**
  70447. * Interface for vortex event data
  70448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70449. */
  70450. export interface PhysicsVortexEventData {
  70451. /**
  70452. * A cylinder used for the vortex event
  70453. */
  70454. cylinder: Mesh;
  70455. }
  70456. /**
  70457. * Interface for an affected physics impostor
  70458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70459. */
  70460. export interface PhysicsAffectedImpostorWithData {
  70461. /**
  70462. * The impostor affected by the effect
  70463. */
  70464. impostor: PhysicsImpostor;
  70465. /**
  70466. * The data about the hit/horce from the explosion
  70467. */
  70468. hitData: PhysicsHitData;
  70469. }
  70470. }
  70471. declare module BABYLON {
  70472. /** @hidden */
  70473. export var blackAndWhitePixelShader: {
  70474. name: string;
  70475. shader: string;
  70476. };
  70477. }
  70478. declare module BABYLON {
  70479. /**
  70480. * Post process used to render in black and white
  70481. */
  70482. export class BlackAndWhitePostProcess extends PostProcess {
  70483. /**
  70484. * Linear about to convert he result to black and white (default: 1)
  70485. */
  70486. degree: number;
  70487. /**
  70488. * Gets a string identifying the name of the class
  70489. * @returns "BlackAndWhitePostProcess" string
  70490. */
  70491. getClassName(): string;
  70492. /**
  70493. * Creates a black and white post process
  70494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70495. * @param name The name of the effect.
  70496. * @param options The required width/height ratio to downsize to before computing the render pass.
  70497. * @param camera The camera to apply the render pass to.
  70498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70499. * @param engine The engine which the post process will be applied. (default: current engine)
  70500. * @param reusable If the post process can be reused on the same frame. (default: false)
  70501. */
  70502. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70503. /** @hidden */
  70504. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70505. }
  70506. }
  70507. declare module BABYLON {
  70508. /**
  70509. * This represents a set of one or more post processes in Babylon.
  70510. * A post process can be used to apply a shader to a texture after it is rendered.
  70511. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70512. */
  70513. export class PostProcessRenderEffect {
  70514. private _postProcesses;
  70515. private _getPostProcesses;
  70516. private _singleInstance;
  70517. private _cameras;
  70518. private _indicesForCamera;
  70519. /**
  70520. * Name of the effect
  70521. * @hidden
  70522. */
  70523. _name: string;
  70524. /**
  70525. * Instantiates a post process render effect.
  70526. * A post process can be used to apply a shader to a texture after it is rendered.
  70527. * @param engine The engine the effect is tied to
  70528. * @param name The name of the effect
  70529. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70530. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70531. */
  70532. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70533. /**
  70534. * Checks if all the post processes in the effect are supported.
  70535. */
  70536. get isSupported(): boolean;
  70537. /**
  70538. * Updates the current state of the effect
  70539. * @hidden
  70540. */
  70541. _update(): 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. * Attaches the effect on cameras
  70550. * @param cameras The camera to attach to.
  70551. * @hidden
  70552. */
  70553. _attachCameras(cameras: Camera[]): void;
  70554. /**
  70555. * Detaches the effect on cameras
  70556. * @param cameras The camera to detatch from.
  70557. * @hidden
  70558. */
  70559. _detachCameras(cameras: Camera): void;
  70560. /**
  70561. * Detatches the effect on cameras
  70562. * @param cameras The camera to detatch from.
  70563. * @hidden
  70564. */
  70565. _detachCameras(cameras: Camera[]): void;
  70566. /**
  70567. * Enables the effect on given cameras
  70568. * @param cameras The camera to enable.
  70569. * @hidden
  70570. */
  70571. _enable(cameras: Camera): void;
  70572. /**
  70573. * Enables the effect on given cameras
  70574. * @param cameras The camera to enable.
  70575. * @hidden
  70576. */
  70577. _enable(cameras: Nullable<Camera[]>): void;
  70578. /**
  70579. * Disables the effect on the given cameras
  70580. * @param cameras The camera to disable.
  70581. * @hidden
  70582. */
  70583. _disable(cameras: Camera): void;
  70584. /**
  70585. * Disables the effect on the given cameras
  70586. * @param cameras The camera to disable.
  70587. * @hidden
  70588. */
  70589. _disable(cameras: Nullable<Camera[]>): void;
  70590. /**
  70591. * Gets a list of the post processes contained in the effect.
  70592. * @param camera The camera to get the post processes on.
  70593. * @returns The list of the post processes in the effect.
  70594. */
  70595. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70596. }
  70597. }
  70598. declare module BABYLON {
  70599. /** @hidden */
  70600. export var extractHighlightsPixelShader: {
  70601. name: string;
  70602. shader: string;
  70603. };
  70604. }
  70605. declare module BABYLON {
  70606. /**
  70607. * 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.
  70608. */
  70609. export class ExtractHighlightsPostProcess extends PostProcess {
  70610. /**
  70611. * The luminance threshold, pixels below this value will be set to black.
  70612. */
  70613. threshold: number;
  70614. /** @hidden */
  70615. _exposure: number;
  70616. /**
  70617. * Post process which has the input texture to be used when performing highlight extraction
  70618. * @hidden
  70619. */
  70620. _inputPostProcess: Nullable<PostProcess>;
  70621. /**
  70622. * Gets a string identifying the name of the class
  70623. * @returns "ExtractHighlightsPostProcess" string
  70624. */
  70625. getClassName(): string;
  70626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70627. }
  70628. }
  70629. declare module BABYLON {
  70630. /** @hidden */
  70631. export var bloomMergePixelShader: {
  70632. name: string;
  70633. shader: string;
  70634. };
  70635. }
  70636. declare module BABYLON {
  70637. /**
  70638. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70639. */
  70640. export class BloomMergePostProcess extends PostProcess {
  70641. /** Weight of the bloom to be added to the original input. */
  70642. weight: number;
  70643. /**
  70644. * Gets a string identifying the name of the class
  70645. * @returns "BloomMergePostProcess" string
  70646. */
  70647. getClassName(): string;
  70648. /**
  70649. * Creates a new instance of @see BloomMergePostProcess
  70650. * @param name The name of the effect.
  70651. * @param originalFromInput Post process which's input will be used for the merge.
  70652. * @param blurred Blurred highlights post process which's output will be used.
  70653. * @param weight Weight of the bloom to be added to the original input.
  70654. * @param options The required width/height ratio to downsize to before computing the render pass.
  70655. * @param camera The camera to apply the render pass to.
  70656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70657. * @param engine The engine which the post process will be applied. (default: current engine)
  70658. * @param reusable If the post process can be reused on the same frame. (default: false)
  70659. * @param textureType Type of textures used when performing the post process. (default: 0)
  70660. * @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)
  70661. */
  70662. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70663. /** Weight of the bloom to be added to the original input. */
  70664. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70665. }
  70666. }
  70667. declare module BABYLON {
  70668. /**
  70669. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70670. */
  70671. export class BloomEffect extends PostProcessRenderEffect {
  70672. private bloomScale;
  70673. /**
  70674. * @hidden Internal
  70675. */
  70676. _effects: Array<PostProcess>;
  70677. /**
  70678. * @hidden Internal
  70679. */
  70680. _downscale: ExtractHighlightsPostProcess;
  70681. private _blurX;
  70682. private _blurY;
  70683. private _merge;
  70684. /**
  70685. * The luminance threshold to find bright areas of the image to bloom.
  70686. */
  70687. get threshold(): number;
  70688. set threshold(value: number);
  70689. /**
  70690. * The strength of the bloom.
  70691. */
  70692. get weight(): number;
  70693. set weight(value: number);
  70694. /**
  70695. * Specifies the size of the bloom blur kernel, relative to the final output size
  70696. */
  70697. get kernel(): number;
  70698. set kernel(value: number);
  70699. /**
  70700. * Creates a new instance of @see BloomEffect
  70701. * @param scene The scene the effect belongs to.
  70702. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70703. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70704. * @param bloomWeight The the strength of bloom.
  70705. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70706. * @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)
  70707. */
  70708. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70709. /**
  70710. * Disposes each of the internal effects for a given camera.
  70711. * @param camera The camera to dispose the effect on.
  70712. */
  70713. disposeEffects(camera: Camera): void;
  70714. /**
  70715. * @hidden Internal
  70716. */
  70717. _updateEffects(): void;
  70718. /**
  70719. * Internal
  70720. * @returns if all the contained post processes are ready.
  70721. * @hidden
  70722. */
  70723. _isReady(): boolean;
  70724. }
  70725. }
  70726. declare module BABYLON {
  70727. /** @hidden */
  70728. export var chromaticAberrationPixelShader: {
  70729. name: string;
  70730. shader: string;
  70731. };
  70732. }
  70733. declare module BABYLON {
  70734. /**
  70735. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70736. */
  70737. export class ChromaticAberrationPostProcess extends PostProcess {
  70738. /**
  70739. * The amount of seperation of rgb channels (default: 30)
  70740. */
  70741. aberrationAmount: number;
  70742. /**
  70743. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70744. */
  70745. radialIntensity: number;
  70746. /**
  70747. * 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))
  70748. */
  70749. direction: Vector2;
  70750. /**
  70751. * 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))
  70752. */
  70753. centerPosition: Vector2;
  70754. /** The width of the screen to apply the effect on */
  70755. screenWidth: number;
  70756. /** The height of the screen to apply the effect on */
  70757. screenHeight: number;
  70758. /**
  70759. * Gets a string identifying the name of the class
  70760. * @returns "ChromaticAberrationPostProcess" string
  70761. */
  70762. getClassName(): string;
  70763. /**
  70764. * Creates a new instance ChromaticAberrationPostProcess
  70765. * @param name The name of the effect.
  70766. * @param screenWidth The width of the screen to apply the effect on.
  70767. * @param screenHeight The height of the screen to apply the effect on.
  70768. * @param options The required width/height ratio to downsize to before computing the render pass.
  70769. * @param camera The camera to apply the render pass to.
  70770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70771. * @param engine The engine which the post process will be applied. (default: current engine)
  70772. * @param reusable If the post process can be reused on the same frame. (default: false)
  70773. * @param textureType Type of textures used when performing the post process. (default: 0)
  70774. * @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)
  70775. */
  70776. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70777. /** @hidden */
  70778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70779. }
  70780. }
  70781. declare module BABYLON {
  70782. /** @hidden */
  70783. export var circleOfConfusionPixelShader: {
  70784. name: string;
  70785. shader: string;
  70786. };
  70787. }
  70788. declare module BABYLON {
  70789. /**
  70790. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70791. */
  70792. export class CircleOfConfusionPostProcess extends PostProcess {
  70793. /**
  70794. * 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.
  70795. */
  70796. lensSize: number;
  70797. /**
  70798. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70799. */
  70800. fStop: number;
  70801. /**
  70802. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70803. */
  70804. focusDistance: number;
  70805. /**
  70806. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70807. */
  70808. focalLength: number;
  70809. /**
  70810. * Gets a string identifying the name of the class
  70811. * @returns "CircleOfConfusionPostProcess" string
  70812. */
  70813. getClassName(): string;
  70814. private _depthTexture;
  70815. /**
  70816. * Creates a new instance CircleOfConfusionPostProcess
  70817. * @param name The name of the effect.
  70818. * @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.
  70819. * @param options The required width/height ratio to downsize to before computing the render pass.
  70820. * @param camera The camera to apply the render pass to.
  70821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70822. * @param engine The engine which the post process will be applied. (default: current engine)
  70823. * @param reusable If the post process can be reused on the same frame. (default: false)
  70824. * @param textureType Type of textures used when performing the post process. (default: 0)
  70825. * @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)
  70826. */
  70827. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70828. /**
  70829. * 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.
  70830. */
  70831. set depthTexture(value: RenderTargetTexture);
  70832. }
  70833. }
  70834. declare module BABYLON {
  70835. /** @hidden */
  70836. export var colorCorrectionPixelShader: {
  70837. name: string;
  70838. shader: string;
  70839. };
  70840. }
  70841. declare module BABYLON {
  70842. /**
  70843. *
  70844. * This post-process allows the modification of rendered colors by using
  70845. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70846. *
  70847. * The object needs to be provided an url to a texture containing the color
  70848. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70849. * Use an image editing software to tweak the LUT to match your needs.
  70850. *
  70851. * For an example of a color LUT, see here:
  70852. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70853. * For explanations on color grading, see here:
  70854. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70855. *
  70856. */
  70857. export class ColorCorrectionPostProcess extends PostProcess {
  70858. private _colorTableTexture;
  70859. /**
  70860. * Gets the color table url used to create the LUT texture
  70861. */
  70862. colorTableUrl: string;
  70863. /**
  70864. * Gets a string identifying the name of the class
  70865. * @returns "ColorCorrectionPostProcess" string
  70866. */
  70867. getClassName(): string;
  70868. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70869. /** @hidden */
  70870. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70871. }
  70872. }
  70873. declare module BABYLON {
  70874. /** @hidden */
  70875. export var convolutionPixelShader: {
  70876. name: string;
  70877. shader: string;
  70878. };
  70879. }
  70880. declare module BABYLON {
  70881. /**
  70882. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70883. * input texture to perform effects such as edge detection or sharpening
  70884. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70885. */
  70886. export class ConvolutionPostProcess extends PostProcess {
  70887. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70888. kernel: number[];
  70889. /**
  70890. * Gets a string identifying the name of the class
  70891. * @returns "ConvolutionPostProcess" string
  70892. */
  70893. getClassName(): string;
  70894. /**
  70895. * Creates a new instance ConvolutionPostProcess
  70896. * @param name The name of the effect.
  70897. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70898. * @param options The required width/height ratio to downsize to before computing the render pass.
  70899. * @param camera The camera to apply the render pass to.
  70900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70901. * @param engine The engine which the post process will be applied. (default: current engine)
  70902. * @param reusable If the post process can be reused on the same frame. (default: false)
  70903. * @param textureType Type of textures used when performing the post process. (default: 0)
  70904. */
  70905. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70906. /** @hidden */
  70907. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70908. /**
  70909. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70910. */
  70911. static EdgeDetect0Kernel: number[];
  70912. /**
  70913. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70914. */
  70915. static EdgeDetect1Kernel: number[];
  70916. /**
  70917. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70918. */
  70919. static EdgeDetect2Kernel: number[];
  70920. /**
  70921. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70922. */
  70923. static SharpenKernel: number[];
  70924. /**
  70925. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70926. */
  70927. static EmbossKernel: number[];
  70928. /**
  70929. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70930. */
  70931. static GaussianKernel: number[];
  70932. }
  70933. }
  70934. declare module BABYLON {
  70935. /**
  70936. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70937. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70938. * based on samples that have a large difference in distance than the center pixel.
  70939. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70940. */
  70941. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70942. /**
  70943. * The direction the blur should be applied
  70944. */
  70945. direction: Vector2;
  70946. /**
  70947. * Gets a string identifying the name of the class
  70948. * @returns "DepthOfFieldBlurPostProcess" string
  70949. */
  70950. getClassName(): string;
  70951. /**
  70952. * Creates a new instance CircleOfConfusionPostProcess
  70953. * @param name The name of the effect.
  70954. * @param scene The scene the effect belongs to.
  70955. * @param direction The direction the blur should be applied.
  70956. * @param kernel The size of the kernel used to blur.
  70957. * @param options The required width/height ratio to downsize to before computing the render pass.
  70958. * @param camera The camera to apply the render pass to.
  70959. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70960. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70962. * @param engine The engine which the post process will be applied. (default: current engine)
  70963. * @param reusable If the post process can be reused on the same frame. (default: false)
  70964. * @param textureType Type of textures used when performing the post process. (default: 0)
  70965. * @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)
  70966. */
  70967. 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);
  70968. }
  70969. }
  70970. declare module BABYLON {
  70971. /** @hidden */
  70972. export var depthOfFieldMergePixelShader: {
  70973. name: string;
  70974. shader: string;
  70975. };
  70976. }
  70977. declare module BABYLON {
  70978. /**
  70979. * Options to be set when merging outputs from the default pipeline.
  70980. */
  70981. export class DepthOfFieldMergePostProcessOptions {
  70982. /**
  70983. * The original image to merge on top of
  70984. */
  70985. originalFromInput: PostProcess;
  70986. /**
  70987. * Parameters to perform the merge of the depth of field effect
  70988. */
  70989. depthOfField?: {
  70990. circleOfConfusion: PostProcess;
  70991. blurSteps: Array<PostProcess>;
  70992. };
  70993. /**
  70994. * Parameters to perform the merge of bloom effect
  70995. */
  70996. bloom?: {
  70997. blurred: PostProcess;
  70998. weight: number;
  70999. };
  71000. }
  71001. /**
  71002. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71003. */
  71004. export class DepthOfFieldMergePostProcess extends PostProcess {
  71005. private blurSteps;
  71006. /**
  71007. * Gets a string identifying the name of the class
  71008. * @returns "DepthOfFieldMergePostProcess" string
  71009. */
  71010. getClassName(): string;
  71011. /**
  71012. * Creates a new instance of DepthOfFieldMergePostProcess
  71013. * @param name The name of the effect.
  71014. * @param originalFromInput Post process which's input will be used for the merge.
  71015. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71016. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71017. * @param options The required width/height ratio to downsize to before computing the render pass.
  71018. * @param camera The camera to apply the render pass to.
  71019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71020. * @param engine The engine which the post process will be applied. (default: current engine)
  71021. * @param reusable If the post process can be reused on the same frame. (default: false)
  71022. * @param textureType Type of textures used when performing the post process. (default: 0)
  71023. * @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)
  71024. */
  71025. 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);
  71026. /**
  71027. * Updates the effect with the current post process compile time values and recompiles the shader.
  71028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71031. * @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
  71032. * @param onCompiled Called when the shader has been compiled.
  71033. * @param onError Called if there is an error when compiling a shader.
  71034. */
  71035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71036. }
  71037. }
  71038. declare module BABYLON {
  71039. /**
  71040. * Specifies the level of max blur that should be applied when using the depth of field effect
  71041. */
  71042. export enum DepthOfFieldEffectBlurLevel {
  71043. /**
  71044. * Subtle blur
  71045. */
  71046. Low = 0,
  71047. /**
  71048. * Medium blur
  71049. */
  71050. Medium = 1,
  71051. /**
  71052. * Large blur
  71053. */
  71054. High = 2
  71055. }
  71056. /**
  71057. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71058. */
  71059. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71060. private _circleOfConfusion;
  71061. /**
  71062. * @hidden Internal, blurs from high to low
  71063. */
  71064. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71065. private _depthOfFieldBlurY;
  71066. private _dofMerge;
  71067. /**
  71068. * @hidden Internal post processes in depth of field effect
  71069. */
  71070. _effects: Array<PostProcess>;
  71071. /**
  71072. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71073. */
  71074. set focalLength(value: number);
  71075. get focalLength(): number;
  71076. /**
  71077. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71078. */
  71079. set fStop(value: number);
  71080. get fStop(): number;
  71081. /**
  71082. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71083. */
  71084. set focusDistance(value: number);
  71085. get focusDistance(): number;
  71086. /**
  71087. * 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.
  71088. */
  71089. set lensSize(value: number);
  71090. get lensSize(): number;
  71091. /**
  71092. * Creates a new instance DepthOfFieldEffect
  71093. * @param scene The scene the effect belongs to.
  71094. * @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.
  71095. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71096. * @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)
  71097. */
  71098. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71099. /**
  71100. * Get the current class name of the current effet
  71101. * @returns "DepthOfFieldEffect"
  71102. */
  71103. getClassName(): string;
  71104. /**
  71105. * 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.
  71106. */
  71107. set depthTexture(value: RenderTargetTexture);
  71108. /**
  71109. * Disposes each of the internal effects for a given camera.
  71110. * @param camera The camera to dispose the effect on.
  71111. */
  71112. disposeEffects(camera: Camera): void;
  71113. /**
  71114. * @hidden Internal
  71115. */
  71116. _updateEffects(): void;
  71117. /**
  71118. * Internal
  71119. * @returns if all the contained post processes are ready.
  71120. * @hidden
  71121. */
  71122. _isReady(): boolean;
  71123. }
  71124. }
  71125. declare module BABYLON {
  71126. /** @hidden */
  71127. export var displayPassPixelShader: {
  71128. name: string;
  71129. shader: string;
  71130. };
  71131. }
  71132. declare module BABYLON {
  71133. /**
  71134. * DisplayPassPostProcess which produces an output the same as it's input
  71135. */
  71136. export class DisplayPassPostProcess extends PostProcess {
  71137. /**
  71138. * Gets a string identifying the name of the class
  71139. * @returns "DisplayPassPostProcess" string
  71140. */
  71141. getClassName(): string;
  71142. /**
  71143. * Creates the DisplayPassPostProcess
  71144. * @param name The name of the effect.
  71145. * @param options The required width/height ratio to downsize to before computing the render pass.
  71146. * @param camera The camera to apply the render pass to.
  71147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71148. * @param engine The engine which the post process will be applied. (default: current engine)
  71149. * @param reusable If the post process can be reused on the same frame. (default: false)
  71150. */
  71151. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71152. /** @hidden */
  71153. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71154. }
  71155. }
  71156. declare module BABYLON {
  71157. /** @hidden */
  71158. export var filterPixelShader: {
  71159. name: string;
  71160. shader: string;
  71161. };
  71162. }
  71163. declare module BABYLON {
  71164. /**
  71165. * Applies a kernel filter to the image
  71166. */
  71167. export class FilterPostProcess extends PostProcess {
  71168. /** The matrix to be applied to the image */
  71169. kernelMatrix: Matrix;
  71170. /**
  71171. * Gets a string identifying the name of the class
  71172. * @returns "FilterPostProcess" string
  71173. */
  71174. getClassName(): string;
  71175. /**
  71176. *
  71177. * @param name The name of the effect.
  71178. * @param kernelMatrix The matrix to be applied to the image
  71179. * @param options The required width/height ratio to downsize to before computing the render pass.
  71180. * @param camera The camera to apply the render pass to.
  71181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71182. * @param engine The engine which the post process will be applied. (default: current engine)
  71183. * @param reusable If the post process can be reused on the same frame. (default: false)
  71184. */
  71185. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71186. /** @hidden */
  71187. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71188. }
  71189. }
  71190. declare module BABYLON {
  71191. /** @hidden */
  71192. export var fxaaPixelShader: {
  71193. name: string;
  71194. shader: string;
  71195. };
  71196. }
  71197. declare module BABYLON {
  71198. /** @hidden */
  71199. export var fxaaVertexShader: {
  71200. name: string;
  71201. shader: string;
  71202. };
  71203. }
  71204. declare module BABYLON {
  71205. /**
  71206. * Fxaa post process
  71207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71208. */
  71209. export class FxaaPostProcess extends PostProcess {
  71210. /**
  71211. * Gets a string identifying the name of the class
  71212. * @returns "FxaaPostProcess" string
  71213. */
  71214. getClassName(): string;
  71215. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71216. private _getDefines;
  71217. /** @hidden */
  71218. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71219. }
  71220. }
  71221. declare module BABYLON {
  71222. /** @hidden */
  71223. export var grainPixelShader: {
  71224. name: string;
  71225. shader: string;
  71226. };
  71227. }
  71228. declare module BABYLON {
  71229. /**
  71230. * The GrainPostProcess adds noise to the image at mid luminance levels
  71231. */
  71232. export class GrainPostProcess extends PostProcess {
  71233. /**
  71234. * The intensity of the grain added (default: 30)
  71235. */
  71236. intensity: number;
  71237. /**
  71238. * If the grain should be randomized on every frame
  71239. */
  71240. animated: boolean;
  71241. /**
  71242. * Gets a string identifying the name of the class
  71243. * @returns "GrainPostProcess" string
  71244. */
  71245. getClassName(): string;
  71246. /**
  71247. * Creates a new instance of @see GrainPostProcess
  71248. * @param name The name of the effect.
  71249. * @param options The required width/height ratio to downsize to before computing the render pass.
  71250. * @param camera The camera to apply the render pass to.
  71251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71252. * @param engine The engine which the post process will be applied. (default: current engine)
  71253. * @param reusable If the post process can be reused on the same frame. (default: false)
  71254. * @param textureType Type of textures used when performing the post process. (default: 0)
  71255. * @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)
  71256. */
  71257. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71258. /** @hidden */
  71259. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71260. }
  71261. }
  71262. declare module BABYLON {
  71263. /** @hidden */
  71264. export var highlightsPixelShader: {
  71265. name: string;
  71266. shader: string;
  71267. };
  71268. }
  71269. declare module BABYLON {
  71270. /**
  71271. * Extracts highlights from the image
  71272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71273. */
  71274. export class HighlightsPostProcess extends PostProcess {
  71275. /**
  71276. * Gets a string identifying the name of the class
  71277. * @returns "HighlightsPostProcess" string
  71278. */
  71279. getClassName(): string;
  71280. /**
  71281. * Extracts highlights from the image
  71282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71283. * @param name The name of the effect.
  71284. * @param options The required width/height ratio to downsize to before computing the render pass.
  71285. * @param camera The camera to apply the render pass to.
  71286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71287. * @param engine The engine which the post process will be applied. (default: current engine)
  71288. * @param reusable If the post process can be reused on the same frame. (default: false)
  71289. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71290. */
  71291. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71292. }
  71293. }
  71294. declare module BABYLON {
  71295. /**
  71296. * Contains all parameters needed for the prepass to perform
  71297. * motion blur
  71298. */
  71299. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71300. /**
  71301. * Is motion blur enabled
  71302. */
  71303. enabled: boolean;
  71304. /**
  71305. * Name of the configuration
  71306. */
  71307. name: string;
  71308. /**
  71309. * Textures that should be present in the MRT for this effect to work
  71310. */
  71311. readonly texturesRequired: number[];
  71312. }
  71313. }
  71314. declare module BABYLON {
  71315. interface Scene {
  71316. /** @hidden (Backing field) */
  71317. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71318. /**
  71319. * Gets or Sets the current geometry buffer associated to the scene.
  71320. */
  71321. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71322. /**
  71323. * Enables a GeometryBufferRender and associates it with the scene
  71324. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71325. * @returns the GeometryBufferRenderer
  71326. */
  71327. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71328. /**
  71329. * Disables the GeometryBufferRender associated with the scene
  71330. */
  71331. disableGeometryBufferRenderer(): void;
  71332. }
  71333. /**
  71334. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71335. * in several rendering techniques.
  71336. */
  71337. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71338. /**
  71339. * The component name helpful to identify the component in the list of scene components.
  71340. */
  71341. readonly name: string;
  71342. /**
  71343. * The scene the component belongs to.
  71344. */
  71345. scene: Scene;
  71346. /**
  71347. * Creates a new instance of the component for the given scene
  71348. * @param scene Defines the scene to register the component in
  71349. */
  71350. constructor(scene: Scene);
  71351. /**
  71352. * Registers the component in a given scene
  71353. */
  71354. register(): void;
  71355. /**
  71356. * Rebuilds the elements related to this component in case of
  71357. * context lost for instance.
  71358. */
  71359. rebuild(): void;
  71360. /**
  71361. * Disposes the component and the associated ressources
  71362. */
  71363. dispose(): void;
  71364. private _gatherRenderTargets;
  71365. }
  71366. }
  71367. declare module BABYLON {
  71368. /** @hidden */
  71369. export var motionBlurPixelShader: {
  71370. name: string;
  71371. shader: string;
  71372. };
  71373. }
  71374. declare module BABYLON {
  71375. /**
  71376. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71377. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71378. * As an example, all you have to do is to create the post-process:
  71379. * var mb = new BABYLON.MotionBlurPostProcess(
  71380. * 'mb', // The name of the effect.
  71381. * scene, // The scene containing the objects to blur according to their velocity.
  71382. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71383. * camera // The camera to apply the render pass to.
  71384. * );
  71385. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71386. */
  71387. export class MotionBlurPostProcess extends PostProcess {
  71388. /**
  71389. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71390. */
  71391. motionStrength: number;
  71392. /**
  71393. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71394. */
  71395. get motionBlurSamples(): number;
  71396. /**
  71397. * Sets the number of iterations to be used for motion blur quality
  71398. */
  71399. set motionBlurSamples(samples: number);
  71400. private _motionBlurSamples;
  71401. /**
  71402. * Gets wether or not the motion blur post-process is in object based mode.
  71403. */
  71404. get isObjectBased(): boolean;
  71405. /**
  71406. * Sets wether or not the motion blur post-process is in object based mode.
  71407. */
  71408. set isObjectBased(value: boolean);
  71409. private _isObjectBased;
  71410. private _forceGeometryBuffer;
  71411. private _geometryBufferRenderer;
  71412. private _prePassRenderer;
  71413. private _invViewProjection;
  71414. private _previousViewProjection;
  71415. /**
  71416. * Gets a string identifying the name of the class
  71417. * @returns "MotionBlurPostProcess" string
  71418. */
  71419. getClassName(): string;
  71420. /**
  71421. * Creates a new instance MotionBlurPostProcess
  71422. * @param name The name of the effect.
  71423. * @param scene The scene containing the objects to blur according to their velocity.
  71424. * @param options The required width/height ratio to downsize to before computing the render pass.
  71425. * @param camera The camera to apply the render pass to.
  71426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71427. * @param engine The engine which the post process will be applied. (default: current engine)
  71428. * @param reusable If the post process can be reused on the same frame. (default: false)
  71429. * @param textureType Type of textures used when performing the post process. (default: 0)
  71430. * @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)
  71431. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71432. */
  71433. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71434. /**
  71435. * Excludes the given skinned mesh from computing bones velocities.
  71436. * 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.
  71437. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71438. */
  71439. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71440. /**
  71441. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71442. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71443. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71444. */
  71445. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71446. /**
  71447. * Disposes the post process.
  71448. * @param camera The camera to dispose the post process on.
  71449. */
  71450. dispose(camera?: Camera): void;
  71451. /**
  71452. * Called on the mode changed (object based or screen based).
  71453. */
  71454. private _applyMode;
  71455. /**
  71456. * Called on the effect is applied when the motion blur post-process is in object based mode.
  71457. */
  71458. private _onApplyObjectBased;
  71459. /**
  71460. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  71461. */
  71462. private _onApplyScreenBased;
  71463. /**
  71464. * Called on the effect must be updated (changed mode, samples count, etc.).
  71465. */
  71466. private _updateEffect;
  71467. /** @hidden */
  71468. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71469. }
  71470. }
  71471. declare module BABYLON {
  71472. /** @hidden */
  71473. export var refractionPixelShader: {
  71474. name: string;
  71475. shader: string;
  71476. };
  71477. }
  71478. declare module BABYLON {
  71479. /**
  71480. * Post process which applies a refractin texture
  71481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71482. */
  71483. export class RefractionPostProcess extends PostProcess {
  71484. private _refTexture;
  71485. private _ownRefractionTexture;
  71486. /** the base color of the refraction (used to taint the rendering) */
  71487. color: Color3;
  71488. /** simulated refraction depth */
  71489. depth: number;
  71490. /** the coefficient of the base color (0 to remove base color tainting) */
  71491. colorLevel: number;
  71492. /** Gets the url used to load the refraction texture */
  71493. refractionTextureUrl: string;
  71494. /**
  71495. * Gets or sets the refraction texture
  71496. * Please note that you are responsible for disposing the texture if you set it manually
  71497. */
  71498. get refractionTexture(): Texture;
  71499. set refractionTexture(value: Texture);
  71500. /**
  71501. * Gets a string identifying the name of the class
  71502. * @returns "RefractionPostProcess" string
  71503. */
  71504. getClassName(): string;
  71505. /**
  71506. * Initializes the RefractionPostProcess
  71507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71508. * @param name The name of the effect.
  71509. * @param refractionTextureUrl Url of the refraction texture to use
  71510. * @param color the base color of the refraction (used to taint the rendering)
  71511. * @param depth simulated refraction depth
  71512. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71513. * @param camera The camera to apply the render pass to.
  71514. * @param options The required width/height ratio to downsize to before computing the render pass.
  71515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71516. * @param engine The engine which the post process will be applied. (default: current engine)
  71517. * @param reusable If the post process can be reused on the same frame. (default: false)
  71518. */
  71519. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71520. /**
  71521. * Disposes of the post process
  71522. * @param camera Camera to dispose post process on
  71523. */
  71524. dispose(camera: Camera): void;
  71525. /** @hidden */
  71526. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71527. }
  71528. }
  71529. declare module BABYLON {
  71530. /** @hidden */
  71531. export var sharpenPixelShader: {
  71532. name: string;
  71533. shader: string;
  71534. };
  71535. }
  71536. declare module BABYLON {
  71537. /**
  71538. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71539. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71540. */
  71541. export class SharpenPostProcess extends PostProcess {
  71542. /**
  71543. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71544. */
  71545. colorAmount: number;
  71546. /**
  71547. * How much sharpness should be applied (default: 0.3)
  71548. */
  71549. edgeAmount: number;
  71550. /**
  71551. * Gets a string identifying the name of the class
  71552. * @returns "SharpenPostProcess" string
  71553. */
  71554. getClassName(): string;
  71555. /**
  71556. * Creates a new instance ConvolutionPostProcess
  71557. * @param name The name of the effect.
  71558. * @param options The required width/height ratio to downsize to before computing the render pass.
  71559. * @param camera The camera to apply the render pass to.
  71560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71561. * @param engine The engine which the post process will be applied. (default: current engine)
  71562. * @param reusable If the post process can be reused on the same frame. (default: false)
  71563. * @param textureType Type of textures used when performing the post process. (default: 0)
  71564. * @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)
  71565. */
  71566. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71567. /** @hidden */
  71568. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71569. }
  71570. }
  71571. declare module BABYLON {
  71572. /**
  71573. * PostProcessRenderPipeline
  71574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71575. */
  71576. export class PostProcessRenderPipeline {
  71577. private engine;
  71578. private _renderEffects;
  71579. private _renderEffectsForIsolatedPass;
  71580. /**
  71581. * List of inspectable custom properties (used by the Inspector)
  71582. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71583. */
  71584. inspectableCustomProperties: IInspectable[];
  71585. /**
  71586. * @hidden
  71587. */
  71588. protected _cameras: Camera[];
  71589. /** @hidden */
  71590. _name: string;
  71591. /**
  71592. * Gets pipeline name
  71593. */
  71594. get name(): string;
  71595. /** Gets the list of attached cameras */
  71596. get cameras(): Camera[];
  71597. /**
  71598. * Initializes a PostProcessRenderPipeline
  71599. * @param engine engine to add the pipeline to
  71600. * @param name name of the pipeline
  71601. */
  71602. constructor(engine: Engine, name: string);
  71603. /**
  71604. * Gets the class name
  71605. * @returns "PostProcessRenderPipeline"
  71606. */
  71607. getClassName(): string;
  71608. /**
  71609. * If all the render effects in the pipeline are supported
  71610. */
  71611. get isSupported(): boolean;
  71612. /**
  71613. * Adds an effect to the pipeline
  71614. * @param renderEffect the effect to add
  71615. */
  71616. addEffect(renderEffect: PostProcessRenderEffect): void;
  71617. /** @hidden */
  71618. _rebuild(): void;
  71619. /** @hidden */
  71620. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71621. /** @hidden */
  71622. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71623. /** @hidden */
  71624. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71625. /** @hidden */
  71626. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71627. /** @hidden */
  71628. _attachCameras(cameras: Camera, unique: boolean): void;
  71629. /** @hidden */
  71630. _attachCameras(cameras: Camera[], unique: boolean): void;
  71631. /** @hidden */
  71632. _detachCameras(cameras: Camera): void;
  71633. /** @hidden */
  71634. _detachCameras(cameras: Nullable<Camera[]>): void;
  71635. /** @hidden */
  71636. _update(): void;
  71637. /** @hidden */
  71638. _reset(): void;
  71639. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71640. /**
  71641. * Sets the required values to the prepass renderer.
  71642. * @param prePassRenderer defines the prepass renderer to setup.
  71643. * @returns true if the pre pass is needed.
  71644. */
  71645. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71646. /**
  71647. * Disposes of the pipeline
  71648. */
  71649. dispose(): void;
  71650. }
  71651. }
  71652. declare module BABYLON {
  71653. /**
  71654. * PostProcessRenderPipelineManager class
  71655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71656. */
  71657. export class PostProcessRenderPipelineManager {
  71658. private _renderPipelines;
  71659. /**
  71660. * Initializes a PostProcessRenderPipelineManager
  71661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71662. */
  71663. constructor();
  71664. /**
  71665. * Gets the list of supported render pipelines
  71666. */
  71667. get supportedPipelines(): PostProcessRenderPipeline[];
  71668. /**
  71669. * Adds a pipeline to the manager
  71670. * @param renderPipeline The pipeline to add
  71671. */
  71672. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71673. /**
  71674. * Attaches a camera to the pipeline
  71675. * @param renderPipelineName The name of the pipeline to attach to
  71676. * @param cameras the camera to attach
  71677. * @param unique if the camera can be attached multiple times to the pipeline
  71678. */
  71679. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71680. /**
  71681. * Detaches a camera from the pipeline
  71682. * @param renderPipelineName The name of the pipeline to detach from
  71683. * @param cameras the camera to detach
  71684. */
  71685. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71686. /**
  71687. * Enables an effect by name on a pipeline
  71688. * @param renderPipelineName the name of the pipeline to enable the effect in
  71689. * @param renderEffectName the name of the effect to enable
  71690. * @param cameras the cameras that the effect should be enabled on
  71691. */
  71692. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71693. /**
  71694. * Disables an effect by name on a pipeline
  71695. * @param renderPipelineName the name of the pipeline to disable the effect in
  71696. * @param renderEffectName the name of the effect to disable
  71697. * @param cameras the cameras that the effect should be disabled on
  71698. */
  71699. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71700. /**
  71701. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71702. */
  71703. update(): void;
  71704. /** @hidden */
  71705. _rebuild(): void;
  71706. /**
  71707. * Disposes of the manager and pipelines
  71708. */
  71709. dispose(): void;
  71710. }
  71711. }
  71712. declare module BABYLON {
  71713. interface Scene {
  71714. /** @hidden (Backing field) */
  71715. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71716. /**
  71717. * Gets the postprocess render pipeline manager
  71718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71719. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71720. */
  71721. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71722. }
  71723. /**
  71724. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71725. */
  71726. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71727. /**
  71728. * The component name helpfull to identify the component in the list of scene components.
  71729. */
  71730. readonly name: string;
  71731. /**
  71732. * The scene the component belongs to.
  71733. */
  71734. scene: Scene;
  71735. /**
  71736. * Creates a new instance of the component for the given scene
  71737. * @param scene Defines the scene to register the component in
  71738. */
  71739. constructor(scene: Scene);
  71740. /**
  71741. * Registers the component in a given scene
  71742. */
  71743. register(): void;
  71744. /**
  71745. * Rebuilds the elements related to this component in case of
  71746. * context lost for instance.
  71747. */
  71748. rebuild(): void;
  71749. /**
  71750. * Disposes the component and the associated ressources
  71751. */
  71752. dispose(): void;
  71753. private _gatherRenderTargets;
  71754. }
  71755. }
  71756. declare module BABYLON {
  71757. /**
  71758. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71759. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71760. */
  71761. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71762. private _scene;
  71763. private _camerasToBeAttached;
  71764. /**
  71765. * ID of the sharpen post process,
  71766. */
  71767. private readonly SharpenPostProcessId;
  71768. /**
  71769. * @ignore
  71770. * ID of the image processing post process;
  71771. */
  71772. readonly ImageProcessingPostProcessId: string;
  71773. /**
  71774. * @ignore
  71775. * ID of the Fast Approximate Anti-Aliasing post process;
  71776. */
  71777. readonly FxaaPostProcessId: string;
  71778. /**
  71779. * ID of the chromatic aberration post process,
  71780. */
  71781. private readonly ChromaticAberrationPostProcessId;
  71782. /**
  71783. * ID of the grain post process
  71784. */
  71785. private readonly GrainPostProcessId;
  71786. /**
  71787. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71788. */
  71789. sharpen: SharpenPostProcess;
  71790. private _sharpenEffect;
  71791. private bloom;
  71792. /**
  71793. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71794. */
  71795. depthOfField: DepthOfFieldEffect;
  71796. /**
  71797. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71798. */
  71799. fxaa: FxaaPostProcess;
  71800. /**
  71801. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71802. */
  71803. imageProcessing: ImageProcessingPostProcess;
  71804. /**
  71805. * Chromatic aberration post process which will shift rgb colors in the image
  71806. */
  71807. chromaticAberration: ChromaticAberrationPostProcess;
  71808. private _chromaticAberrationEffect;
  71809. /**
  71810. * Grain post process which add noise to the image
  71811. */
  71812. grain: GrainPostProcess;
  71813. private _grainEffect;
  71814. /**
  71815. * Glow post process which adds a glow to emissive areas of the image
  71816. */
  71817. private _glowLayer;
  71818. /**
  71819. * Animations which can be used to tweak settings over a period of time
  71820. */
  71821. animations: Animation[];
  71822. private _imageProcessingConfigurationObserver;
  71823. private _sharpenEnabled;
  71824. private _bloomEnabled;
  71825. private _depthOfFieldEnabled;
  71826. private _depthOfFieldBlurLevel;
  71827. private _fxaaEnabled;
  71828. private _imageProcessingEnabled;
  71829. private _defaultPipelineTextureType;
  71830. private _bloomScale;
  71831. private _chromaticAberrationEnabled;
  71832. private _grainEnabled;
  71833. private _buildAllowed;
  71834. /**
  71835. * This is triggered each time the pipeline has been built.
  71836. */
  71837. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71838. /**
  71839. * Gets active scene
  71840. */
  71841. get scene(): Scene;
  71842. /**
  71843. * Enable or disable the sharpen process from the pipeline
  71844. */
  71845. set sharpenEnabled(enabled: boolean);
  71846. get sharpenEnabled(): boolean;
  71847. private _resizeObserver;
  71848. private _hardwareScaleLevel;
  71849. private _bloomKernel;
  71850. /**
  71851. * Specifies the size of the bloom blur kernel, relative to the final output size
  71852. */
  71853. get bloomKernel(): number;
  71854. set bloomKernel(value: number);
  71855. /**
  71856. * Specifies the weight of the bloom in the final rendering
  71857. */
  71858. private _bloomWeight;
  71859. /**
  71860. * Specifies the luma threshold for the area that will be blurred by the bloom
  71861. */
  71862. private _bloomThreshold;
  71863. private _hdr;
  71864. /**
  71865. * The strength of the bloom.
  71866. */
  71867. set bloomWeight(value: number);
  71868. get bloomWeight(): number;
  71869. /**
  71870. * The strength of the bloom.
  71871. */
  71872. set bloomThreshold(value: number);
  71873. get bloomThreshold(): number;
  71874. /**
  71875. * The scale of the bloom, lower value will provide better performance.
  71876. */
  71877. set bloomScale(value: number);
  71878. get bloomScale(): number;
  71879. /**
  71880. * Enable or disable the bloom from the pipeline
  71881. */
  71882. set bloomEnabled(enabled: boolean);
  71883. get bloomEnabled(): boolean;
  71884. private _rebuildBloom;
  71885. /**
  71886. * If the depth of field is enabled.
  71887. */
  71888. get depthOfFieldEnabled(): boolean;
  71889. set depthOfFieldEnabled(enabled: boolean);
  71890. /**
  71891. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71892. */
  71893. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71894. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71895. /**
  71896. * If the anti aliasing is enabled.
  71897. */
  71898. set fxaaEnabled(enabled: boolean);
  71899. get fxaaEnabled(): boolean;
  71900. private _samples;
  71901. /**
  71902. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71903. */
  71904. set samples(sampleCount: number);
  71905. get samples(): number;
  71906. /**
  71907. * If image processing is enabled.
  71908. */
  71909. set imageProcessingEnabled(enabled: boolean);
  71910. get imageProcessingEnabled(): boolean;
  71911. /**
  71912. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71913. */
  71914. set glowLayerEnabled(enabled: boolean);
  71915. get glowLayerEnabled(): boolean;
  71916. /**
  71917. * Gets the glow layer (or null if not defined)
  71918. */
  71919. get glowLayer(): Nullable<GlowLayer>;
  71920. /**
  71921. * Enable or disable the chromaticAberration process from the pipeline
  71922. */
  71923. set chromaticAberrationEnabled(enabled: boolean);
  71924. get chromaticAberrationEnabled(): boolean;
  71925. /**
  71926. * Enable or disable the grain process from the pipeline
  71927. */
  71928. set grainEnabled(enabled: boolean);
  71929. get grainEnabled(): boolean;
  71930. /**
  71931. * @constructor
  71932. * @param name - The rendering pipeline name (default: "")
  71933. * @param hdr - If high dynamic range textures should be used (default: true)
  71934. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71935. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71936. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71937. */
  71938. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71939. /**
  71940. * Get the class name
  71941. * @returns "DefaultRenderingPipeline"
  71942. */
  71943. getClassName(): string;
  71944. /**
  71945. * Force the compilation of the entire pipeline.
  71946. */
  71947. prepare(): void;
  71948. private _hasCleared;
  71949. private _prevPostProcess;
  71950. private _prevPrevPostProcess;
  71951. private _setAutoClearAndTextureSharing;
  71952. private _depthOfFieldSceneObserver;
  71953. private _buildPipeline;
  71954. private _disposePostProcesses;
  71955. /**
  71956. * Adds a camera to the pipeline
  71957. * @param camera the camera to be added
  71958. */
  71959. addCamera(camera: Camera): void;
  71960. /**
  71961. * Removes a camera from the pipeline
  71962. * @param camera the camera to remove
  71963. */
  71964. removeCamera(camera: Camera): void;
  71965. /**
  71966. * Dispose of the pipeline and stop all post processes
  71967. */
  71968. dispose(): void;
  71969. /**
  71970. * Serialize the rendering pipeline (Used when exporting)
  71971. * @returns the serialized object
  71972. */
  71973. serialize(): any;
  71974. /**
  71975. * Parse the serialized pipeline
  71976. * @param source Source pipeline.
  71977. * @param scene The scene to load the pipeline to.
  71978. * @param rootUrl The URL of the serialized pipeline.
  71979. * @returns An instantiated pipeline from the serialized object.
  71980. */
  71981. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71982. }
  71983. }
  71984. declare module BABYLON {
  71985. /** @hidden */
  71986. export var lensHighlightsPixelShader: {
  71987. name: string;
  71988. shader: string;
  71989. };
  71990. }
  71991. declare module BABYLON {
  71992. /** @hidden */
  71993. export var depthOfFieldPixelShader: {
  71994. name: string;
  71995. shader: string;
  71996. };
  71997. }
  71998. declare module BABYLON {
  71999. /**
  72000. * BABYLON.JS Chromatic Aberration GLSL Shader
  72001. * Author: Olivier Guyot
  72002. * Separates very slightly R, G and B colors on the edges of the screen
  72003. * Inspired by Francois Tarlier & Martins Upitis
  72004. */
  72005. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72006. /**
  72007. * @ignore
  72008. * The chromatic aberration PostProcess id in the pipeline
  72009. */
  72010. LensChromaticAberrationEffect: string;
  72011. /**
  72012. * @ignore
  72013. * The highlights enhancing PostProcess id in the pipeline
  72014. */
  72015. HighlightsEnhancingEffect: string;
  72016. /**
  72017. * @ignore
  72018. * The depth-of-field PostProcess id in the pipeline
  72019. */
  72020. LensDepthOfFieldEffect: string;
  72021. private _scene;
  72022. private _depthTexture;
  72023. private _grainTexture;
  72024. private _chromaticAberrationPostProcess;
  72025. private _highlightsPostProcess;
  72026. private _depthOfFieldPostProcess;
  72027. private _edgeBlur;
  72028. private _grainAmount;
  72029. private _chromaticAberration;
  72030. private _distortion;
  72031. private _highlightsGain;
  72032. private _highlightsThreshold;
  72033. private _dofDistance;
  72034. private _dofAperture;
  72035. private _dofDarken;
  72036. private _dofPentagon;
  72037. private _blurNoise;
  72038. /**
  72039. * @constructor
  72040. *
  72041. * Effect parameters are as follow:
  72042. * {
  72043. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72044. * edge_blur: number; // from 0 to x (1 for realism)
  72045. * distortion: number; // from 0 to x (1 for realism)
  72046. * grain_amount: number; // from 0 to 1
  72047. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72048. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72049. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72050. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72051. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72052. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72053. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72054. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72055. * }
  72056. * Note: if an effect parameter is unset, effect is disabled
  72057. *
  72058. * @param name The rendering pipeline name
  72059. * @param parameters - An object containing all parameters (see above)
  72060. * @param scene The scene linked to this pipeline
  72061. * @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)
  72062. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72063. */
  72064. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72065. /**
  72066. * Get the class name
  72067. * @returns "LensRenderingPipeline"
  72068. */
  72069. getClassName(): string;
  72070. /**
  72071. * Gets associated scene
  72072. */
  72073. get scene(): Scene;
  72074. /**
  72075. * Gets or sets the edge blur
  72076. */
  72077. get edgeBlur(): number;
  72078. set edgeBlur(value: number);
  72079. /**
  72080. * Gets or sets the grain amount
  72081. */
  72082. get grainAmount(): number;
  72083. set grainAmount(value: number);
  72084. /**
  72085. * Gets or sets the chromatic aberration amount
  72086. */
  72087. get chromaticAberration(): number;
  72088. set chromaticAberration(value: number);
  72089. /**
  72090. * Gets or sets the depth of field aperture
  72091. */
  72092. get dofAperture(): number;
  72093. set dofAperture(value: number);
  72094. /**
  72095. * Gets or sets the edge distortion
  72096. */
  72097. get edgeDistortion(): number;
  72098. set edgeDistortion(value: number);
  72099. /**
  72100. * Gets or sets the depth of field distortion
  72101. */
  72102. get dofDistortion(): number;
  72103. set dofDistortion(value: number);
  72104. /**
  72105. * Gets or sets the darken out of focus amount
  72106. */
  72107. get darkenOutOfFocus(): number;
  72108. set darkenOutOfFocus(value: number);
  72109. /**
  72110. * Gets or sets a boolean indicating if blur noise is enabled
  72111. */
  72112. get blurNoise(): boolean;
  72113. set blurNoise(value: boolean);
  72114. /**
  72115. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72116. */
  72117. get pentagonBokeh(): boolean;
  72118. set pentagonBokeh(value: boolean);
  72119. /**
  72120. * Gets or sets the highlight grain amount
  72121. */
  72122. get highlightsGain(): number;
  72123. set highlightsGain(value: number);
  72124. /**
  72125. * Gets or sets the highlight threshold
  72126. */
  72127. get highlightsThreshold(): number;
  72128. set highlightsThreshold(value: number);
  72129. /**
  72130. * Sets the amount of blur at the edges
  72131. * @param amount blur amount
  72132. */
  72133. setEdgeBlur(amount: number): void;
  72134. /**
  72135. * Sets edge blur to 0
  72136. */
  72137. disableEdgeBlur(): void;
  72138. /**
  72139. * Sets the amout of grain
  72140. * @param amount Amount of grain
  72141. */
  72142. setGrainAmount(amount: number): void;
  72143. /**
  72144. * Set grain amount to 0
  72145. */
  72146. disableGrain(): void;
  72147. /**
  72148. * Sets the chromatic aberration amount
  72149. * @param amount amount of chromatic aberration
  72150. */
  72151. setChromaticAberration(amount: number): void;
  72152. /**
  72153. * Sets chromatic aberration amount to 0
  72154. */
  72155. disableChromaticAberration(): void;
  72156. /**
  72157. * Sets the EdgeDistortion amount
  72158. * @param amount amount of EdgeDistortion
  72159. */
  72160. setEdgeDistortion(amount: number): void;
  72161. /**
  72162. * Sets edge distortion to 0
  72163. */
  72164. disableEdgeDistortion(): void;
  72165. /**
  72166. * Sets the FocusDistance amount
  72167. * @param amount amount of FocusDistance
  72168. */
  72169. setFocusDistance(amount: number): void;
  72170. /**
  72171. * Disables depth of field
  72172. */
  72173. disableDepthOfField(): void;
  72174. /**
  72175. * Sets the Aperture amount
  72176. * @param amount amount of Aperture
  72177. */
  72178. setAperture(amount: number): void;
  72179. /**
  72180. * Sets the DarkenOutOfFocus amount
  72181. * @param amount amount of DarkenOutOfFocus
  72182. */
  72183. setDarkenOutOfFocus(amount: number): void;
  72184. private _pentagonBokehIsEnabled;
  72185. /**
  72186. * Creates a pentagon bokeh effect
  72187. */
  72188. enablePentagonBokeh(): void;
  72189. /**
  72190. * Disables the pentagon bokeh effect
  72191. */
  72192. disablePentagonBokeh(): void;
  72193. /**
  72194. * Enables noise blur
  72195. */
  72196. enableNoiseBlur(): void;
  72197. /**
  72198. * Disables noise blur
  72199. */
  72200. disableNoiseBlur(): void;
  72201. /**
  72202. * Sets the HighlightsGain amount
  72203. * @param amount amount of HighlightsGain
  72204. */
  72205. setHighlightsGain(amount: number): void;
  72206. /**
  72207. * Sets the HighlightsThreshold amount
  72208. * @param amount amount of HighlightsThreshold
  72209. */
  72210. setHighlightsThreshold(amount: number): void;
  72211. /**
  72212. * Disables highlights
  72213. */
  72214. disableHighlights(): void;
  72215. /**
  72216. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72217. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72218. */
  72219. dispose(disableDepthRender?: boolean): void;
  72220. private _createChromaticAberrationPostProcess;
  72221. private _createHighlightsPostProcess;
  72222. private _createDepthOfFieldPostProcess;
  72223. private _createGrainTexture;
  72224. }
  72225. }
  72226. declare module BABYLON {
  72227. /**
  72228. * Contains all parameters needed for the prepass to perform
  72229. * screen space subsurface scattering
  72230. */
  72231. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72232. /**
  72233. * Is subsurface enabled
  72234. */
  72235. enabled: boolean;
  72236. /**
  72237. * Name of the configuration
  72238. */
  72239. name: string;
  72240. /**
  72241. * Textures that should be present in the MRT for this effect to work
  72242. */
  72243. readonly texturesRequired: number[];
  72244. }
  72245. }
  72246. declare module BABYLON {
  72247. /** @hidden */
  72248. export var ssao2PixelShader: {
  72249. name: string;
  72250. shader: string;
  72251. };
  72252. }
  72253. declare module BABYLON {
  72254. /** @hidden */
  72255. export var ssaoCombinePixelShader: {
  72256. name: string;
  72257. shader: string;
  72258. };
  72259. }
  72260. declare module BABYLON {
  72261. /**
  72262. * Render pipeline to produce ssao effect
  72263. */
  72264. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72265. /**
  72266. * @ignore
  72267. * The PassPostProcess id in the pipeline that contains the original scene color
  72268. */
  72269. SSAOOriginalSceneColorEffect: string;
  72270. /**
  72271. * @ignore
  72272. * The SSAO PostProcess id in the pipeline
  72273. */
  72274. SSAORenderEffect: string;
  72275. /**
  72276. * @ignore
  72277. * The horizontal blur PostProcess id in the pipeline
  72278. */
  72279. SSAOBlurHRenderEffect: string;
  72280. /**
  72281. * @ignore
  72282. * The vertical blur PostProcess id in the pipeline
  72283. */
  72284. SSAOBlurVRenderEffect: string;
  72285. /**
  72286. * @ignore
  72287. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72288. */
  72289. SSAOCombineRenderEffect: string;
  72290. /**
  72291. * The output strength of the SSAO post-process. Default value is 1.0.
  72292. */
  72293. totalStrength: number;
  72294. /**
  72295. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72296. */
  72297. maxZ: number;
  72298. /**
  72299. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72300. */
  72301. minZAspect: number;
  72302. private _samples;
  72303. /**
  72304. * Number of samples used for the SSAO calculations. Default value is 8
  72305. */
  72306. set samples(n: number);
  72307. get samples(): number;
  72308. private _textureSamples;
  72309. /**
  72310. * Number of samples to use for antialiasing
  72311. */
  72312. set textureSamples(n: number);
  72313. get textureSamples(): number;
  72314. /**
  72315. * Force rendering the geometry through geometry buffer
  72316. */
  72317. private _forceGeometryBuffer;
  72318. /**
  72319. * Ratio object used for SSAO ratio and blur ratio
  72320. */
  72321. private _ratio;
  72322. /**
  72323. * Dynamically generated sphere sampler.
  72324. */
  72325. private _sampleSphere;
  72326. /**
  72327. * Blur filter offsets
  72328. */
  72329. private _samplerOffsets;
  72330. private _expensiveBlur;
  72331. /**
  72332. * If bilateral blur should be used
  72333. */
  72334. set expensiveBlur(b: boolean);
  72335. get expensiveBlur(): boolean;
  72336. /**
  72337. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72338. */
  72339. radius: number;
  72340. /**
  72341. * The base color of the SSAO post-process
  72342. * The final result is "base + ssao" between [0, 1]
  72343. */
  72344. base: number;
  72345. /**
  72346. * Support test.
  72347. */
  72348. static get IsSupported(): boolean;
  72349. private _scene;
  72350. private _randomTexture;
  72351. private _originalColorPostProcess;
  72352. private _ssaoPostProcess;
  72353. private _blurHPostProcess;
  72354. private _blurVPostProcess;
  72355. private _ssaoCombinePostProcess;
  72356. private _prePassRenderer;
  72357. /**
  72358. * Gets active scene
  72359. */
  72360. get scene(): Scene;
  72361. /**
  72362. * @constructor
  72363. * @param name The rendering pipeline name
  72364. * @param scene The scene linked to this pipeline
  72365. * @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 }
  72366. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72367. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72368. */
  72369. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72370. /**
  72371. * Get the class name
  72372. * @returns "SSAO2RenderingPipeline"
  72373. */
  72374. getClassName(): string;
  72375. /**
  72376. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72377. */
  72378. dispose(disableGeometryBufferRenderer?: boolean): void;
  72379. private _createBlurPostProcess;
  72380. /** @hidden */
  72381. _rebuild(): void;
  72382. private _bits;
  72383. private _radicalInverse_VdC;
  72384. private _hammersley;
  72385. private _hemisphereSample_uniform;
  72386. private _generateHemisphere;
  72387. private _getDefinesForSSAO;
  72388. private _createSSAOPostProcess;
  72389. private _createSSAOCombinePostProcess;
  72390. private _createRandomTexture;
  72391. /**
  72392. * Serialize the rendering pipeline (Used when exporting)
  72393. * @returns the serialized object
  72394. */
  72395. serialize(): any;
  72396. /**
  72397. * Parse the serialized pipeline
  72398. * @param source Source pipeline.
  72399. * @param scene The scene to load the pipeline to.
  72400. * @param rootUrl The URL of the serialized pipeline.
  72401. * @returns An instantiated pipeline from the serialized object.
  72402. */
  72403. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72404. }
  72405. }
  72406. declare module BABYLON {
  72407. /** @hidden */
  72408. export var ssaoPixelShader: {
  72409. name: string;
  72410. shader: string;
  72411. };
  72412. }
  72413. declare module BABYLON {
  72414. /**
  72415. * Render pipeline to produce ssao effect
  72416. */
  72417. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72418. /**
  72419. * @ignore
  72420. * The PassPostProcess id in the pipeline that contains the original scene color
  72421. */
  72422. SSAOOriginalSceneColorEffect: string;
  72423. /**
  72424. * @ignore
  72425. * The SSAO PostProcess id in the pipeline
  72426. */
  72427. SSAORenderEffect: string;
  72428. /**
  72429. * @ignore
  72430. * The horizontal blur PostProcess id in the pipeline
  72431. */
  72432. SSAOBlurHRenderEffect: string;
  72433. /**
  72434. * @ignore
  72435. * The vertical blur PostProcess id in the pipeline
  72436. */
  72437. SSAOBlurVRenderEffect: string;
  72438. /**
  72439. * @ignore
  72440. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72441. */
  72442. SSAOCombineRenderEffect: string;
  72443. /**
  72444. * The output strength of the SSAO post-process. Default value is 1.0.
  72445. */
  72446. totalStrength: number;
  72447. /**
  72448. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72449. */
  72450. radius: number;
  72451. /**
  72452. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72453. * Must not be equal to fallOff and superior to fallOff.
  72454. * Default value is 0.0075
  72455. */
  72456. area: number;
  72457. /**
  72458. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72459. * Must not be equal to area and inferior to area.
  72460. * Default value is 0.000001
  72461. */
  72462. fallOff: number;
  72463. /**
  72464. * The base color of the SSAO post-process
  72465. * The final result is "base + ssao" between [0, 1]
  72466. */
  72467. base: number;
  72468. private _scene;
  72469. private _depthTexture;
  72470. private _randomTexture;
  72471. private _originalColorPostProcess;
  72472. private _ssaoPostProcess;
  72473. private _blurHPostProcess;
  72474. private _blurVPostProcess;
  72475. private _ssaoCombinePostProcess;
  72476. private _firstUpdate;
  72477. /**
  72478. * Gets active scene
  72479. */
  72480. get scene(): Scene;
  72481. /**
  72482. * @constructor
  72483. * @param name - The rendering pipeline name
  72484. * @param scene - The scene linked to this pipeline
  72485. * @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 }
  72486. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72487. */
  72488. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72489. /**
  72490. * Get the class name
  72491. * @returns "SSAORenderingPipeline"
  72492. */
  72493. getClassName(): string;
  72494. /**
  72495. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72496. */
  72497. dispose(disableDepthRender?: boolean): void;
  72498. private _createBlurPostProcess;
  72499. /** @hidden */
  72500. _rebuild(): void;
  72501. private _createSSAOPostProcess;
  72502. private _createSSAOCombinePostProcess;
  72503. private _createRandomTexture;
  72504. }
  72505. }
  72506. declare module BABYLON {
  72507. /**
  72508. * Contains all parameters needed for the prepass to perform
  72509. * screen space reflections
  72510. */
  72511. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72512. /**
  72513. * Is ssr enabled
  72514. */
  72515. enabled: boolean;
  72516. /**
  72517. * Name of the configuration
  72518. */
  72519. name: string;
  72520. /**
  72521. * Textures that should be present in the MRT for this effect to work
  72522. */
  72523. readonly texturesRequired: number[];
  72524. }
  72525. }
  72526. declare module BABYLON {
  72527. /** @hidden */
  72528. export var screenSpaceReflectionPixelShader: {
  72529. name: string;
  72530. shader: string;
  72531. };
  72532. }
  72533. declare module BABYLON {
  72534. /**
  72535. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72536. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72537. */
  72538. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72539. /**
  72540. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72541. */
  72542. threshold: number;
  72543. /**
  72544. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72545. */
  72546. strength: number;
  72547. /**
  72548. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72549. */
  72550. reflectionSpecularFalloffExponent: number;
  72551. /**
  72552. * 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]
  72553. */
  72554. step: number;
  72555. /**
  72556. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72557. */
  72558. roughnessFactor: number;
  72559. private _forceGeometryBuffer;
  72560. private _geometryBufferRenderer;
  72561. private _prePassRenderer;
  72562. private _enableSmoothReflections;
  72563. private _reflectionSamples;
  72564. private _smoothSteps;
  72565. /**
  72566. * Gets a string identifying the name of the class
  72567. * @returns "ScreenSpaceReflectionPostProcess" string
  72568. */
  72569. getClassName(): string;
  72570. /**
  72571. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72572. * @param name The name of the effect.
  72573. * @param scene The scene containing the objects to calculate reflections.
  72574. * @param options The required width/height ratio to downsize to before computing the render pass.
  72575. * @param camera The camera to apply the render pass to.
  72576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72577. * @param engine The engine which the post process will be applied. (default: current engine)
  72578. * @param reusable If the post process can be reused on the same frame. (default: false)
  72579. * @param textureType Type of textures used when performing the post process. (default: 0)
  72580. * @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)
  72581. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72582. */
  72583. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72584. /**
  72585. * Gets wether or not smoothing reflections is enabled.
  72586. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72587. */
  72588. get enableSmoothReflections(): boolean;
  72589. /**
  72590. * Sets wether or not smoothing reflections is enabled.
  72591. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72592. */
  72593. set enableSmoothReflections(enabled: boolean);
  72594. /**
  72595. * Gets the number of samples taken while computing reflections. More samples count is high,
  72596. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72597. */
  72598. get reflectionSamples(): number;
  72599. /**
  72600. * Sets the number of samples taken while computing reflections. More samples count is high,
  72601. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72602. */
  72603. set reflectionSamples(samples: number);
  72604. /**
  72605. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72606. * more the post-process will require GPU power and can generate a drop in FPS.
  72607. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72608. */
  72609. get smoothSteps(): number;
  72610. set smoothSteps(steps: number);
  72611. private _updateEffectDefines;
  72612. /** @hidden */
  72613. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72614. }
  72615. }
  72616. declare module BABYLON {
  72617. /** @hidden */
  72618. export var standardPixelShader: {
  72619. name: string;
  72620. shader: string;
  72621. };
  72622. }
  72623. declare module BABYLON {
  72624. /**
  72625. * Standard rendering pipeline
  72626. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72627. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72628. */
  72629. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72630. /**
  72631. * Public members
  72632. */
  72633. /**
  72634. * Post-process which contains the original scene color before the pipeline applies all the effects
  72635. */
  72636. originalPostProcess: Nullable<PostProcess>;
  72637. /**
  72638. * Post-process used to down scale an image x4
  72639. */
  72640. downSampleX4PostProcess: Nullable<PostProcess>;
  72641. /**
  72642. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72643. */
  72644. brightPassPostProcess: Nullable<PostProcess>;
  72645. /**
  72646. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72647. */
  72648. blurHPostProcesses: PostProcess[];
  72649. /**
  72650. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72651. */
  72652. blurVPostProcesses: PostProcess[];
  72653. /**
  72654. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72655. */
  72656. textureAdderPostProcess: Nullable<PostProcess>;
  72657. /**
  72658. * Post-process used to create volumetric lighting effect
  72659. */
  72660. volumetricLightPostProcess: Nullable<PostProcess>;
  72661. /**
  72662. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72663. */
  72664. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72665. /**
  72666. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72667. */
  72668. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72669. /**
  72670. * Post-process used to merge the volumetric light effect and the real scene color
  72671. */
  72672. volumetricLightMergePostProces: Nullable<PostProcess>;
  72673. /**
  72674. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72675. */
  72676. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72677. /**
  72678. * Base post-process used to calculate the average luminance of the final image for HDR
  72679. */
  72680. luminancePostProcess: Nullable<PostProcess>;
  72681. /**
  72682. * Post-processes used to create down sample post-processes in order to get
  72683. * the average luminance of the final image for HDR
  72684. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72685. */
  72686. luminanceDownSamplePostProcesses: PostProcess[];
  72687. /**
  72688. * Post-process used to create a HDR effect (light adaptation)
  72689. */
  72690. hdrPostProcess: Nullable<PostProcess>;
  72691. /**
  72692. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72693. */
  72694. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72695. /**
  72696. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72697. */
  72698. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72699. /**
  72700. * Post-process used to merge the final HDR post-process and the real scene color
  72701. */
  72702. hdrFinalPostProcess: Nullable<PostProcess>;
  72703. /**
  72704. * Post-process used to create a lens flare effect
  72705. */
  72706. lensFlarePostProcess: Nullable<PostProcess>;
  72707. /**
  72708. * Post-process that merges the result of the lens flare post-process and the real scene color
  72709. */
  72710. lensFlareComposePostProcess: Nullable<PostProcess>;
  72711. /**
  72712. * Post-process used to create a motion blur effect
  72713. */
  72714. motionBlurPostProcess: Nullable<PostProcess>;
  72715. /**
  72716. * Post-process used to create a depth of field effect
  72717. */
  72718. depthOfFieldPostProcess: Nullable<PostProcess>;
  72719. /**
  72720. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72721. */
  72722. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72723. /**
  72724. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72725. */
  72726. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72727. /**
  72728. * Represents the brightness threshold in order to configure the illuminated surfaces
  72729. */
  72730. brightThreshold: number;
  72731. /**
  72732. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72733. */
  72734. blurWidth: number;
  72735. /**
  72736. * Sets if the blur for highlighted surfaces must be only horizontal
  72737. */
  72738. horizontalBlur: boolean;
  72739. /**
  72740. * Gets the overall exposure used by the pipeline
  72741. */
  72742. get exposure(): number;
  72743. /**
  72744. * Sets the overall exposure used by the pipeline
  72745. */
  72746. set exposure(value: number);
  72747. /**
  72748. * Texture used typically to simulate "dirty" on camera lens
  72749. */
  72750. lensTexture: Nullable<Texture>;
  72751. /**
  72752. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72753. */
  72754. volumetricLightCoefficient: number;
  72755. /**
  72756. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72757. */
  72758. volumetricLightPower: number;
  72759. /**
  72760. * Used the set the blur intensity to smooth the volumetric lights
  72761. */
  72762. volumetricLightBlurScale: number;
  72763. /**
  72764. * Light (spot or directional) used to generate the volumetric lights rays
  72765. * The source light must have a shadow generate so the pipeline can get its
  72766. * depth map
  72767. */
  72768. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72769. /**
  72770. * For eye adaptation, represents the minimum luminance the eye can see
  72771. */
  72772. hdrMinimumLuminance: number;
  72773. /**
  72774. * For eye adaptation, represents the decrease luminance speed
  72775. */
  72776. hdrDecreaseRate: number;
  72777. /**
  72778. * For eye adaptation, represents the increase luminance speed
  72779. */
  72780. hdrIncreaseRate: number;
  72781. /**
  72782. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72783. */
  72784. get hdrAutoExposure(): boolean;
  72785. /**
  72786. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72787. */
  72788. set hdrAutoExposure(value: boolean);
  72789. /**
  72790. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72791. */
  72792. lensColorTexture: Nullable<Texture>;
  72793. /**
  72794. * The overall strengh for the lens flare effect
  72795. */
  72796. lensFlareStrength: number;
  72797. /**
  72798. * Dispersion coefficient for lens flare ghosts
  72799. */
  72800. lensFlareGhostDispersal: number;
  72801. /**
  72802. * Main lens flare halo width
  72803. */
  72804. lensFlareHaloWidth: number;
  72805. /**
  72806. * Based on the lens distortion effect, defines how much the lens flare result
  72807. * is distorted
  72808. */
  72809. lensFlareDistortionStrength: number;
  72810. /**
  72811. * Configures the blur intensity used for for lens flare (halo)
  72812. */
  72813. lensFlareBlurWidth: number;
  72814. /**
  72815. * Lens star texture must be used to simulate rays on the flares and is available
  72816. * in the documentation
  72817. */
  72818. lensStarTexture: Nullable<Texture>;
  72819. /**
  72820. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72821. * flare effect by taking account of the dirt texture
  72822. */
  72823. lensFlareDirtTexture: Nullable<Texture>;
  72824. /**
  72825. * Represents the focal length for the depth of field effect
  72826. */
  72827. depthOfFieldDistance: number;
  72828. /**
  72829. * Represents the blur intensity for the blurred part of the depth of field effect
  72830. */
  72831. depthOfFieldBlurWidth: number;
  72832. /**
  72833. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72834. */
  72835. get motionStrength(): number;
  72836. /**
  72837. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72838. */
  72839. set motionStrength(strength: number);
  72840. /**
  72841. * Gets wether or not the motion blur post-process is object based or screen based.
  72842. */
  72843. get objectBasedMotionBlur(): boolean;
  72844. /**
  72845. * Sets wether or not the motion blur post-process should be object based or screen based
  72846. */
  72847. set objectBasedMotionBlur(value: boolean);
  72848. /**
  72849. * List of animations for the pipeline (IAnimatable implementation)
  72850. */
  72851. animations: Animation[];
  72852. /**
  72853. * Private members
  72854. */
  72855. private _scene;
  72856. private _currentDepthOfFieldSource;
  72857. private _basePostProcess;
  72858. private _fixedExposure;
  72859. private _currentExposure;
  72860. private _hdrAutoExposure;
  72861. private _hdrCurrentLuminance;
  72862. private _motionStrength;
  72863. private _isObjectBasedMotionBlur;
  72864. private _floatTextureType;
  72865. private _camerasToBeAttached;
  72866. private _ratio;
  72867. private _bloomEnabled;
  72868. private _depthOfFieldEnabled;
  72869. private _vlsEnabled;
  72870. private _lensFlareEnabled;
  72871. private _hdrEnabled;
  72872. private _motionBlurEnabled;
  72873. private _fxaaEnabled;
  72874. private _screenSpaceReflectionsEnabled;
  72875. private _motionBlurSamples;
  72876. private _volumetricLightStepsCount;
  72877. private _samples;
  72878. /**
  72879. * @ignore
  72880. * Specifies if the bloom pipeline is enabled
  72881. */
  72882. get BloomEnabled(): boolean;
  72883. set BloomEnabled(enabled: boolean);
  72884. /**
  72885. * @ignore
  72886. * Specifies if the depth of field pipeline is enabed
  72887. */
  72888. get DepthOfFieldEnabled(): boolean;
  72889. set DepthOfFieldEnabled(enabled: boolean);
  72890. /**
  72891. * @ignore
  72892. * Specifies if the lens flare pipeline is enabed
  72893. */
  72894. get LensFlareEnabled(): boolean;
  72895. set LensFlareEnabled(enabled: boolean);
  72896. /**
  72897. * @ignore
  72898. * Specifies if the HDR pipeline is enabled
  72899. */
  72900. get HDREnabled(): boolean;
  72901. set HDREnabled(enabled: boolean);
  72902. /**
  72903. * @ignore
  72904. * Specifies if the volumetric lights scattering effect is enabled
  72905. */
  72906. get VLSEnabled(): boolean;
  72907. set VLSEnabled(enabled: boolean);
  72908. /**
  72909. * @ignore
  72910. * Specifies if the motion blur effect is enabled
  72911. */
  72912. get MotionBlurEnabled(): boolean;
  72913. set MotionBlurEnabled(enabled: boolean);
  72914. /**
  72915. * Specifies if anti-aliasing is enabled
  72916. */
  72917. get fxaaEnabled(): boolean;
  72918. set fxaaEnabled(enabled: boolean);
  72919. /**
  72920. * Specifies if screen space reflections are enabled.
  72921. */
  72922. get screenSpaceReflectionsEnabled(): boolean;
  72923. set screenSpaceReflectionsEnabled(enabled: boolean);
  72924. /**
  72925. * Specifies the number of steps used to calculate the volumetric lights
  72926. * Typically in interval [50, 200]
  72927. */
  72928. get volumetricLightStepsCount(): number;
  72929. set volumetricLightStepsCount(count: number);
  72930. /**
  72931. * Specifies the number of samples used for the motion blur effect
  72932. * Typically in interval [16, 64]
  72933. */
  72934. get motionBlurSamples(): number;
  72935. set motionBlurSamples(samples: number);
  72936. /**
  72937. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72938. */
  72939. get samples(): number;
  72940. set samples(sampleCount: number);
  72941. /**
  72942. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72943. * @constructor
  72944. * @param name The rendering pipeline name
  72945. * @param scene The scene linked to this pipeline
  72946. * @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)
  72947. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72948. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72949. */
  72950. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72951. private _buildPipeline;
  72952. private _createDownSampleX4PostProcess;
  72953. private _createBrightPassPostProcess;
  72954. private _createBlurPostProcesses;
  72955. private _createTextureAdderPostProcess;
  72956. private _createVolumetricLightPostProcess;
  72957. private _createLuminancePostProcesses;
  72958. private _createHdrPostProcess;
  72959. private _createLensFlarePostProcess;
  72960. private _createDepthOfFieldPostProcess;
  72961. private _createMotionBlurPostProcess;
  72962. private _getDepthTexture;
  72963. private _disposePostProcesses;
  72964. /**
  72965. * Dispose of the pipeline and stop all post processes
  72966. */
  72967. dispose(): void;
  72968. /**
  72969. * Serialize the rendering pipeline (Used when exporting)
  72970. * @returns the serialized object
  72971. */
  72972. serialize(): any;
  72973. /**
  72974. * Parse the serialized pipeline
  72975. * @param source Source pipeline.
  72976. * @param scene The scene to load the pipeline to.
  72977. * @param rootUrl The URL of the serialized pipeline.
  72978. * @returns An instantiated pipeline from the serialized object.
  72979. */
  72980. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72981. /**
  72982. * Luminance steps
  72983. */
  72984. static LuminanceSteps: number;
  72985. }
  72986. }
  72987. declare module BABYLON {
  72988. /** @hidden */
  72989. export var stereoscopicInterlacePixelShader: {
  72990. name: string;
  72991. shader: string;
  72992. };
  72993. }
  72994. declare module BABYLON {
  72995. /**
  72996. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72997. */
  72998. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72999. private _stepSize;
  73000. private _passedProcess;
  73001. /**
  73002. * Gets a string identifying the name of the class
  73003. * @returns "StereoscopicInterlacePostProcessI" string
  73004. */
  73005. getClassName(): string;
  73006. /**
  73007. * Initializes a StereoscopicInterlacePostProcessI
  73008. * @param name The name of the effect.
  73009. * @param rigCameras The rig cameras to be appled to the post process
  73010. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73011. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73013. * @param engine The engine which the post process will be applied. (default: current engine)
  73014. * @param reusable If the post process can be reused on the same frame. (default: false)
  73015. */
  73016. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73017. }
  73018. /**
  73019. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73020. */
  73021. export class StereoscopicInterlacePostProcess extends PostProcess {
  73022. private _stepSize;
  73023. private _passedProcess;
  73024. /**
  73025. * Gets a string identifying the name of the class
  73026. * @returns "StereoscopicInterlacePostProcess" string
  73027. */
  73028. getClassName(): string;
  73029. /**
  73030. * Initializes a StereoscopicInterlacePostProcess
  73031. * @param name The name of the effect.
  73032. * @param rigCameras The rig cameras to be appled to the post process
  73033. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73035. * @param engine The engine which the post process will be applied. (default: current engine)
  73036. * @param reusable If the post process can be reused on the same frame. (default: false)
  73037. */
  73038. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73039. }
  73040. }
  73041. declare module BABYLON {
  73042. /** @hidden */
  73043. export var tonemapPixelShader: {
  73044. name: string;
  73045. shader: string;
  73046. };
  73047. }
  73048. declare module BABYLON {
  73049. /** Defines operator used for tonemapping */
  73050. export enum TonemappingOperator {
  73051. /** Hable */
  73052. Hable = 0,
  73053. /** Reinhard */
  73054. Reinhard = 1,
  73055. /** HejiDawson */
  73056. HejiDawson = 2,
  73057. /** Photographic */
  73058. Photographic = 3
  73059. }
  73060. /**
  73061. * Defines a post process to apply tone mapping
  73062. */
  73063. export class TonemapPostProcess extends PostProcess {
  73064. private _operator;
  73065. /** Defines the required exposure adjustement */
  73066. exposureAdjustment: number;
  73067. /**
  73068. * Gets a string identifying the name of the class
  73069. * @returns "TonemapPostProcess" string
  73070. */
  73071. getClassName(): string;
  73072. /**
  73073. * Creates a new TonemapPostProcess
  73074. * @param name defines the name of the postprocess
  73075. * @param _operator defines the operator to use
  73076. * @param exposureAdjustment defines the required exposure adjustement
  73077. * @param camera defines the camera to use (can be null)
  73078. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73079. * @param engine defines the hosting engine (can be ignore if camera is set)
  73080. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73081. */
  73082. constructor(name: string, _operator: TonemappingOperator,
  73083. /** Defines the required exposure adjustement */
  73084. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73085. }
  73086. }
  73087. declare module BABYLON {
  73088. /** @hidden */
  73089. export var volumetricLightScatteringPixelShader: {
  73090. name: string;
  73091. shader: string;
  73092. };
  73093. }
  73094. declare module BABYLON {
  73095. /** @hidden */
  73096. export var volumetricLightScatteringPassVertexShader: {
  73097. name: string;
  73098. shader: string;
  73099. };
  73100. }
  73101. declare module BABYLON {
  73102. /** @hidden */
  73103. export var volumetricLightScatteringPassPixelShader: {
  73104. name: string;
  73105. shader: string;
  73106. };
  73107. }
  73108. declare module BABYLON {
  73109. /**
  73110. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73111. */
  73112. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73113. private _volumetricLightScatteringPass;
  73114. private _volumetricLightScatteringRTT;
  73115. private _viewPort;
  73116. private _screenCoordinates;
  73117. private _cachedDefines;
  73118. /**
  73119. * If not undefined, the mesh position is computed from the attached node position
  73120. */
  73121. attachedNode: {
  73122. position: Vector3;
  73123. };
  73124. /**
  73125. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73126. */
  73127. customMeshPosition: Vector3;
  73128. /**
  73129. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73130. */
  73131. useCustomMeshPosition: boolean;
  73132. /**
  73133. * If the post-process should inverse the light scattering direction
  73134. */
  73135. invert: boolean;
  73136. /**
  73137. * The internal mesh used by the post-process
  73138. */
  73139. mesh: Mesh;
  73140. /**
  73141. * @hidden
  73142. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73143. */
  73144. get useDiffuseColor(): boolean;
  73145. set useDiffuseColor(useDiffuseColor: boolean);
  73146. /**
  73147. * Array containing the excluded meshes not rendered in the internal pass
  73148. */
  73149. excludedMeshes: AbstractMesh[];
  73150. /**
  73151. * Controls the overall intensity of the post-process
  73152. */
  73153. exposure: number;
  73154. /**
  73155. * Dissipates each sample's contribution in range [0, 1]
  73156. */
  73157. decay: number;
  73158. /**
  73159. * Controls the overall intensity of each sample
  73160. */
  73161. weight: number;
  73162. /**
  73163. * Controls the density of each sample
  73164. */
  73165. density: number;
  73166. /**
  73167. * @constructor
  73168. * @param name The post-process name
  73169. * @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)
  73170. * @param camera The camera that the post-process will be attached to
  73171. * @param mesh The mesh used to create the light scattering
  73172. * @param samples The post-process quality, default 100
  73173. * @param samplingModeThe post-process filtering mode
  73174. * @param engine The babylon engine
  73175. * @param reusable If the post-process is reusable
  73176. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73177. */
  73178. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73179. /**
  73180. * Returns the string "VolumetricLightScatteringPostProcess"
  73181. * @returns "VolumetricLightScatteringPostProcess"
  73182. */
  73183. getClassName(): string;
  73184. private _isReady;
  73185. /**
  73186. * Sets the new light position for light scattering effect
  73187. * @param position The new custom light position
  73188. */
  73189. setCustomMeshPosition(position: Vector3): void;
  73190. /**
  73191. * Returns the light position for light scattering effect
  73192. * @return Vector3 The custom light position
  73193. */
  73194. getCustomMeshPosition(): Vector3;
  73195. /**
  73196. * Disposes the internal assets and detaches the post-process from the camera
  73197. */
  73198. dispose(camera: Camera): void;
  73199. /**
  73200. * Returns the render target texture used by the post-process
  73201. * @return the render target texture used by the post-process
  73202. */
  73203. getPass(): RenderTargetTexture;
  73204. private _meshExcluded;
  73205. private _createPass;
  73206. private _updateMeshScreenCoordinates;
  73207. /**
  73208. * Creates a default mesh for the Volumeric Light Scattering post-process
  73209. * @param name The mesh name
  73210. * @param scene The scene where to create the mesh
  73211. * @return the default mesh
  73212. */
  73213. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73214. }
  73215. }
  73216. declare module BABYLON {
  73217. /** @hidden */
  73218. export var screenSpaceCurvaturePixelShader: {
  73219. name: string;
  73220. shader: string;
  73221. };
  73222. }
  73223. declare module BABYLON {
  73224. /**
  73225. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73226. */
  73227. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73228. /**
  73229. * Defines how much ridge the curvature effect displays.
  73230. */
  73231. ridge: number;
  73232. /**
  73233. * Defines how much valley the curvature effect displays.
  73234. */
  73235. valley: number;
  73236. private _geometryBufferRenderer;
  73237. /**
  73238. * Gets a string identifying the name of the class
  73239. * @returns "ScreenSpaceCurvaturePostProcess" string
  73240. */
  73241. getClassName(): string;
  73242. /**
  73243. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73244. * @param name The name of the effect.
  73245. * @param scene The scene containing the objects to blur according to their velocity.
  73246. * @param options The required width/height ratio to downsize to before computing the render pass.
  73247. * @param camera The camera to apply the render pass to.
  73248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73249. * @param engine The engine which the post process will be applied. (default: current engine)
  73250. * @param reusable If the post process can be reused on the same frame. (default: false)
  73251. * @param textureType Type of textures used when performing the post process. (default: 0)
  73252. * @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)
  73253. */
  73254. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73255. /**
  73256. * Support test.
  73257. */
  73258. static get IsSupported(): boolean;
  73259. /** @hidden */
  73260. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73261. }
  73262. }
  73263. declare module BABYLON {
  73264. interface Scene {
  73265. /** @hidden (Backing field) */
  73266. _boundingBoxRenderer: BoundingBoxRenderer;
  73267. /** @hidden (Backing field) */
  73268. _forceShowBoundingBoxes: boolean;
  73269. /**
  73270. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73271. */
  73272. forceShowBoundingBoxes: boolean;
  73273. /**
  73274. * Gets the bounding box renderer associated with the scene
  73275. * @returns a BoundingBoxRenderer
  73276. */
  73277. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73278. }
  73279. interface AbstractMesh {
  73280. /** @hidden (Backing field) */
  73281. _showBoundingBox: boolean;
  73282. /**
  73283. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73284. */
  73285. showBoundingBox: boolean;
  73286. }
  73287. /**
  73288. * Component responsible of rendering the bounding box of the meshes in a scene.
  73289. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73290. */
  73291. export class BoundingBoxRenderer implements ISceneComponent {
  73292. /**
  73293. * The component name helpfull to identify the component in the list of scene components.
  73294. */
  73295. readonly name: string;
  73296. /**
  73297. * The scene the component belongs to.
  73298. */
  73299. scene: Scene;
  73300. /**
  73301. * Color of the bounding box lines placed in front of an object
  73302. */
  73303. frontColor: Color3;
  73304. /**
  73305. * Color of the bounding box lines placed behind an object
  73306. */
  73307. backColor: Color3;
  73308. /**
  73309. * Defines if the renderer should show the back lines or not
  73310. */
  73311. showBackLines: boolean;
  73312. /**
  73313. * Observable raised before rendering a bounding box
  73314. */
  73315. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73316. /**
  73317. * Observable raised after rendering a bounding box
  73318. */
  73319. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73320. /**
  73321. * Observable raised after resources are created
  73322. */
  73323. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73324. /**
  73325. * When false, no bounding boxes will be rendered
  73326. */
  73327. enabled: boolean;
  73328. /**
  73329. * @hidden
  73330. */
  73331. renderList: SmartArray<BoundingBox>;
  73332. private _colorShader;
  73333. private _vertexBuffers;
  73334. private _indexBuffer;
  73335. private _fillIndexBuffer;
  73336. private _fillIndexData;
  73337. /**
  73338. * Instantiates a new bounding box renderer in a scene.
  73339. * @param scene the scene the renderer renders in
  73340. */
  73341. constructor(scene: Scene);
  73342. /**
  73343. * Registers the component in a given scene
  73344. */
  73345. register(): void;
  73346. private _evaluateSubMesh;
  73347. private _preActiveMesh;
  73348. private _prepareResources;
  73349. private _createIndexBuffer;
  73350. /**
  73351. * Rebuilds the elements related to this component in case of
  73352. * context lost for instance.
  73353. */
  73354. rebuild(): void;
  73355. /**
  73356. * @hidden
  73357. */
  73358. reset(): void;
  73359. /**
  73360. * Render the bounding boxes of a specific rendering group
  73361. * @param renderingGroupId defines the rendering group to render
  73362. */
  73363. render(renderingGroupId: number): void;
  73364. /**
  73365. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73366. * @param mesh Define the mesh to render the occlusion bounding box for
  73367. */
  73368. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73369. /**
  73370. * Dispose and release the resources attached to this renderer.
  73371. */
  73372. dispose(): void;
  73373. }
  73374. }
  73375. declare module BABYLON {
  73376. interface Scene {
  73377. /** @hidden (Backing field) */
  73378. _depthRenderer: {
  73379. [id: string]: DepthRenderer;
  73380. };
  73381. /**
  73382. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73383. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73384. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73385. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73386. * @returns the created depth renderer
  73387. */
  73388. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73389. /**
  73390. * Disables a depth renderer for a given camera
  73391. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73392. */
  73393. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73394. }
  73395. /**
  73396. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73397. * in several rendering techniques.
  73398. */
  73399. export class DepthRendererSceneComponent implements ISceneComponent {
  73400. /**
  73401. * The component name helpfull to identify the component in the list of scene components.
  73402. */
  73403. readonly name: string;
  73404. /**
  73405. * The scene the component belongs to.
  73406. */
  73407. scene: Scene;
  73408. /**
  73409. * Creates a new instance of the component for the given scene
  73410. * @param scene Defines the scene to register the component in
  73411. */
  73412. constructor(scene: Scene);
  73413. /**
  73414. * Registers the component in a given scene
  73415. */
  73416. register(): void;
  73417. /**
  73418. * Rebuilds the elements related to this component in case of
  73419. * context lost for instance.
  73420. */
  73421. rebuild(): void;
  73422. /**
  73423. * Disposes the component and the associated ressources
  73424. */
  73425. dispose(): void;
  73426. private _gatherRenderTargets;
  73427. private _gatherActiveCameraRenderTargets;
  73428. }
  73429. }
  73430. declare module BABYLON {
  73431. interface AbstractScene {
  73432. /** @hidden (Backing field) */
  73433. _prePassRenderer: Nullable<PrePassRenderer>;
  73434. /**
  73435. * Gets or Sets the current prepass renderer associated to the scene.
  73436. */
  73437. prePassRenderer: Nullable<PrePassRenderer>;
  73438. /**
  73439. * Enables the prepass and associates it with the scene
  73440. * @returns the PrePassRenderer
  73441. */
  73442. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73443. /**
  73444. * Disables the prepass associated with the scene
  73445. */
  73446. disablePrePassRenderer(): void;
  73447. }
  73448. /**
  73449. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73450. * in several rendering techniques.
  73451. */
  73452. export class PrePassRendererSceneComponent implements ISceneComponent {
  73453. /**
  73454. * The component name helpful to identify the component in the list of scene components.
  73455. */
  73456. readonly name: string;
  73457. /**
  73458. * The scene the component belongs to.
  73459. */
  73460. scene: Scene;
  73461. /**
  73462. * Creates a new instance of the component for the given scene
  73463. * @param scene Defines the scene to register the component in
  73464. */
  73465. constructor(scene: Scene);
  73466. /**
  73467. * Registers the component in a given scene
  73468. */
  73469. register(): void;
  73470. private _beforeCameraDraw;
  73471. private _afterCameraDraw;
  73472. private _beforeClearStage;
  73473. private _beforeRenderingMeshStage;
  73474. private _afterRenderingMeshStage;
  73475. /**
  73476. * Rebuilds the elements related to this component in case of
  73477. * context lost for instance.
  73478. */
  73479. rebuild(): void;
  73480. /**
  73481. * Disposes the component and the associated ressources
  73482. */
  73483. dispose(): void;
  73484. }
  73485. }
  73486. declare module BABYLON {
  73487. /** @hidden */
  73488. export var fibonacci: {
  73489. name: string;
  73490. shader: string;
  73491. };
  73492. }
  73493. declare module BABYLON {
  73494. /** @hidden */
  73495. export var diffusionProfile: {
  73496. name: string;
  73497. shader: string;
  73498. };
  73499. }
  73500. declare module BABYLON {
  73501. /** @hidden */
  73502. export var subSurfaceScatteringPixelShader: {
  73503. name: string;
  73504. shader: string;
  73505. };
  73506. }
  73507. declare module BABYLON {
  73508. /**
  73509. * Sub surface scattering post process
  73510. */
  73511. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73512. /**
  73513. * Gets a string identifying the name of the class
  73514. * @returns "SubSurfaceScatteringPostProcess" string
  73515. */
  73516. getClassName(): string;
  73517. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73518. }
  73519. }
  73520. declare module BABYLON {
  73521. /**
  73522. * Contains all parameters needed for the prepass to perform
  73523. * screen space subsurface scattering
  73524. */
  73525. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73526. /** @hidden */
  73527. static _SceneComponentInitialization: (scene: Scene) => void;
  73528. private _ssDiffusionS;
  73529. private _ssFilterRadii;
  73530. private _ssDiffusionD;
  73531. /**
  73532. * Post process to attach for screen space subsurface scattering
  73533. */
  73534. postProcess: SubSurfaceScatteringPostProcess;
  73535. /**
  73536. * Diffusion profile color for subsurface scattering
  73537. */
  73538. get ssDiffusionS(): number[];
  73539. /**
  73540. * Diffusion profile max color channel value for subsurface scattering
  73541. */
  73542. get ssDiffusionD(): number[];
  73543. /**
  73544. * Diffusion profile filter radius for subsurface scattering
  73545. */
  73546. get ssFilterRadii(): number[];
  73547. /**
  73548. * Is subsurface enabled
  73549. */
  73550. enabled: boolean;
  73551. /**
  73552. * Name of the configuration
  73553. */
  73554. name: string;
  73555. /**
  73556. * Diffusion profile colors for subsurface scattering
  73557. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73558. * See ...
  73559. * Note that you can only store up to 5 of them
  73560. */
  73561. ssDiffusionProfileColors: Color3[];
  73562. /**
  73563. * Defines the ratio real world => scene units.
  73564. * Used for subsurface scattering
  73565. */
  73566. metersPerUnit: number;
  73567. /**
  73568. * Textures that should be present in the MRT for this effect to work
  73569. */
  73570. readonly texturesRequired: number[];
  73571. private _scene;
  73572. /**
  73573. * Builds a subsurface configuration object
  73574. * @param scene The scene
  73575. */
  73576. constructor(scene: Scene);
  73577. /**
  73578. * Adds a new diffusion profile.
  73579. * Useful for more realistic subsurface scattering on diverse materials.
  73580. * @param color The color of the diffusion profile. Should be the average color of the material.
  73581. * @return The index of the diffusion profile for the material subsurface configuration
  73582. */
  73583. addDiffusionProfile(color: Color3): number;
  73584. /**
  73585. * Creates the sss post process
  73586. * @return The created post process
  73587. */
  73588. createPostProcess(): SubSurfaceScatteringPostProcess;
  73589. /**
  73590. * Deletes all diffusion profiles.
  73591. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73592. */
  73593. clearAllDiffusionProfiles(): void;
  73594. /**
  73595. * Disposes this object
  73596. */
  73597. dispose(): void;
  73598. /**
  73599. * @hidden
  73600. * https://zero-radiance.github.io/post/sampling-diffusion/
  73601. *
  73602. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73603. * ------------------------------------------------------------------------------------
  73604. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73605. * PDF[r, phi, s] = r * R[r, phi, s]
  73606. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73607. * ------------------------------------------------------------------------------------
  73608. * We importance sample the color channel with the widest scattering distance.
  73609. */
  73610. getDiffusionProfileParameters(color: Color3): number;
  73611. /**
  73612. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73613. * 'u' is the random number (the value of the CDF): [0, 1).
  73614. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73615. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73616. */
  73617. private _sampleBurleyDiffusionProfile;
  73618. }
  73619. }
  73620. declare module BABYLON {
  73621. interface AbstractScene {
  73622. /** @hidden (Backing field) */
  73623. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73624. /**
  73625. * Gets or Sets the current prepass renderer associated to the scene.
  73626. */
  73627. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73628. /**
  73629. * Enables the subsurface effect for prepass
  73630. * @returns the SubSurfaceConfiguration
  73631. */
  73632. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73633. /**
  73634. * Disables the subsurface effect for prepass
  73635. */
  73636. disableSubSurfaceForPrePass(): void;
  73637. }
  73638. /**
  73639. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73640. * in several rendering techniques.
  73641. */
  73642. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73643. /**
  73644. * The component name helpful to identify the component in the list of scene components.
  73645. */
  73646. readonly name: string;
  73647. /**
  73648. * The scene the component belongs to.
  73649. */
  73650. scene: Scene;
  73651. /**
  73652. * Creates a new instance of the component for the given scene
  73653. * @param scene Defines the scene to register the component in
  73654. */
  73655. constructor(scene: Scene);
  73656. /**
  73657. * Registers the component in a given scene
  73658. */
  73659. register(): void;
  73660. /**
  73661. * Serializes the component data to the specified json object
  73662. * @param serializationObject The object to serialize to
  73663. */
  73664. serialize(serializationObject: any): void;
  73665. /**
  73666. * Adds all the elements from the container to the scene
  73667. * @param container the container holding the elements
  73668. */
  73669. addFromContainer(container: AbstractScene): void;
  73670. /**
  73671. * Removes all the elements in the container from the scene
  73672. * @param container contains the elements to remove
  73673. * @param dispose if the removed element should be disposed (default: false)
  73674. */
  73675. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73676. /**
  73677. * Rebuilds the elements related to this component in case of
  73678. * context lost for instance.
  73679. */
  73680. rebuild(): void;
  73681. /**
  73682. * Disposes the component and the associated ressources
  73683. */
  73684. dispose(): void;
  73685. }
  73686. }
  73687. declare module BABYLON {
  73688. /** @hidden */
  73689. export var outlinePixelShader: {
  73690. name: string;
  73691. shader: string;
  73692. };
  73693. }
  73694. declare module BABYLON {
  73695. /** @hidden */
  73696. export var outlineVertexShader: {
  73697. name: string;
  73698. shader: string;
  73699. };
  73700. }
  73701. declare module BABYLON {
  73702. interface Scene {
  73703. /** @hidden */
  73704. _outlineRenderer: OutlineRenderer;
  73705. /**
  73706. * Gets the outline renderer associated with the scene
  73707. * @returns a OutlineRenderer
  73708. */
  73709. getOutlineRenderer(): OutlineRenderer;
  73710. }
  73711. interface AbstractMesh {
  73712. /** @hidden (Backing field) */
  73713. _renderOutline: boolean;
  73714. /**
  73715. * Gets or sets a boolean indicating if the outline must be rendered as well
  73716. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73717. */
  73718. renderOutline: boolean;
  73719. /** @hidden (Backing field) */
  73720. _renderOverlay: boolean;
  73721. /**
  73722. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73723. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73724. */
  73725. renderOverlay: boolean;
  73726. }
  73727. /**
  73728. * This class is responsible to draw bothe outline/overlay of meshes.
  73729. * It should not be used directly but through the available method on mesh.
  73730. */
  73731. export class OutlineRenderer implements ISceneComponent {
  73732. /**
  73733. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73734. */
  73735. private static _StencilReference;
  73736. /**
  73737. * The name of the component. Each component must have a unique name.
  73738. */
  73739. name: string;
  73740. /**
  73741. * The scene the component belongs to.
  73742. */
  73743. scene: Scene;
  73744. /**
  73745. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73746. */
  73747. zOffset: number;
  73748. private _engine;
  73749. private _effect;
  73750. private _cachedDefines;
  73751. private _savedDepthWrite;
  73752. /**
  73753. * Instantiates a new outline renderer. (There could be only one per scene).
  73754. * @param scene Defines the scene it belongs to
  73755. */
  73756. constructor(scene: Scene);
  73757. /**
  73758. * Register the component to one instance of a scene.
  73759. */
  73760. register(): void;
  73761. /**
  73762. * Rebuilds the elements related to this component in case of
  73763. * context lost for instance.
  73764. */
  73765. rebuild(): void;
  73766. /**
  73767. * Disposes the component and the associated ressources.
  73768. */
  73769. dispose(): void;
  73770. /**
  73771. * Renders the outline in the canvas.
  73772. * @param subMesh Defines the sumesh to render
  73773. * @param batch Defines the batch of meshes in case of instances
  73774. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73775. */
  73776. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73777. /**
  73778. * Returns whether or not the outline renderer is ready for a given submesh.
  73779. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73780. * @param subMesh Defines the submesh to check readyness for
  73781. * @param useInstances Defines wheter wee are trying to render instances or not
  73782. * @returns true if ready otherwise false
  73783. */
  73784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73785. private _beforeRenderingMesh;
  73786. private _afterRenderingMesh;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Defines the basic options interface of a Sprite Frame Source Size.
  73792. */
  73793. export interface ISpriteJSONSpriteSourceSize {
  73794. /**
  73795. * number of the original width of the Frame
  73796. */
  73797. w: number;
  73798. /**
  73799. * number of the original height of the Frame
  73800. */
  73801. h: number;
  73802. }
  73803. /**
  73804. * Defines the basic options interface of a Sprite Frame Data.
  73805. */
  73806. export interface ISpriteJSONSpriteFrameData {
  73807. /**
  73808. * number of the x offset of the Frame
  73809. */
  73810. x: number;
  73811. /**
  73812. * number of the y offset of the Frame
  73813. */
  73814. y: number;
  73815. /**
  73816. * number of the width of the Frame
  73817. */
  73818. w: number;
  73819. /**
  73820. * number of the height of the Frame
  73821. */
  73822. h: number;
  73823. }
  73824. /**
  73825. * Defines the basic options interface of a JSON Sprite.
  73826. */
  73827. export interface ISpriteJSONSprite {
  73828. /**
  73829. * string name of the Frame
  73830. */
  73831. filename: string;
  73832. /**
  73833. * ISpriteJSONSpriteFrame basic object of the frame data
  73834. */
  73835. frame: ISpriteJSONSpriteFrameData;
  73836. /**
  73837. * boolean to flag is the frame was rotated.
  73838. */
  73839. rotated: boolean;
  73840. /**
  73841. * boolean to flag is the frame was trimmed.
  73842. */
  73843. trimmed: boolean;
  73844. /**
  73845. * ISpriteJSONSpriteFrame basic object of the source data
  73846. */
  73847. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73848. /**
  73849. * ISpriteJSONSpriteFrame basic object of the source data
  73850. */
  73851. sourceSize: ISpriteJSONSpriteSourceSize;
  73852. }
  73853. /**
  73854. * Defines the basic options interface of a JSON atlas.
  73855. */
  73856. export interface ISpriteJSONAtlas {
  73857. /**
  73858. * Array of objects that contain the frame data.
  73859. */
  73860. frames: Array<ISpriteJSONSprite>;
  73861. /**
  73862. * object basic object containing the sprite meta data.
  73863. */
  73864. meta?: object;
  73865. }
  73866. }
  73867. declare module BABYLON {
  73868. /** @hidden */
  73869. export var spriteMapPixelShader: {
  73870. name: string;
  73871. shader: string;
  73872. };
  73873. }
  73874. declare module BABYLON {
  73875. /** @hidden */
  73876. export var spriteMapVertexShader: {
  73877. name: string;
  73878. shader: string;
  73879. };
  73880. }
  73881. declare module BABYLON {
  73882. /**
  73883. * Defines the basic options interface of a SpriteMap
  73884. */
  73885. export interface ISpriteMapOptions {
  73886. /**
  73887. * Vector2 of the number of cells in the grid.
  73888. */
  73889. stageSize?: Vector2;
  73890. /**
  73891. * Vector2 of the size of the output plane in World Units.
  73892. */
  73893. outputSize?: Vector2;
  73894. /**
  73895. * Vector3 of the position of the output plane in World Units.
  73896. */
  73897. outputPosition?: Vector3;
  73898. /**
  73899. * Vector3 of the rotation of the output plane.
  73900. */
  73901. outputRotation?: Vector3;
  73902. /**
  73903. * number of layers that the system will reserve in resources.
  73904. */
  73905. layerCount?: number;
  73906. /**
  73907. * number of max animation frames a single cell will reserve in resources.
  73908. */
  73909. maxAnimationFrames?: number;
  73910. /**
  73911. * number cell index of the base tile when the system compiles.
  73912. */
  73913. baseTile?: number;
  73914. /**
  73915. * boolean flip the sprite after its been repositioned by the framing data.
  73916. */
  73917. flipU?: boolean;
  73918. /**
  73919. * Vector3 scalar of the global RGB values of the SpriteMap.
  73920. */
  73921. colorMultiply?: Vector3;
  73922. }
  73923. /**
  73924. * Defines the IDisposable interface in order to be cleanable from resources.
  73925. */
  73926. export interface ISpriteMap extends IDisposable {
  73927. /**
  73928. * String name of the SpriteMap.
  73929. */
  73930. name: string;
  73931. /**
  73932. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73933. */
  73934. atlasJSON: ISpriteJSONAtlas;
  73935. /**
  73936. * Texture of the SpriteMap.
  73937. */
  73938. spriteSheet: Texture;
  73939. /**
  73940. * The parameters to initialize the SpriteMap with.
  73941. */
  73942. options: ISpriteMapOptions;
  73943. }
  73944. /**
  73945. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73946. */
  73947. export class SpriteMap implements ISpriteMap {
  73948. /** The Name of the spriteMap */
  73949. name: string;
  73950. /** The JSON file with the frame and meta data */
  73951. atlasJSON: ISpriteJSONAtlas;
  73952. /** The systems Sprite Sheet Texture */
  73953. spriteSheet: Texture;
  73954. /** Arguments passed with the Constructor */
  73955. options: ISpriteMapOptions;
  73956. /** Public Sprite Storage array, parsed from atlasJSON */
  73957. sprites: Array<ISpriteJSONSprite>;
  73958. /** Returns the Number of Sprites in the System */
  73959. get spriteCount(): number;
  73960. /** Returns the Position of Output Plane*/
  73961. get position(): Vector3;
  73962. /** Returns the Position of Output Plane*/
  73963. set position(v: Vector3);
  73964. /** Returns the Rotation of Output Plane*/
  73965. get rotation(): Vector3;
  73966. /** Returns the Rotation of Output Plane*/
  73967. set rotation(v: Vector3);
  73968. /** Sets the AnimationMap*/
  73969. get animationMap(): RawTexture;
  73970. /** Sets the AnimationMap*/
  73971. set animationMap(v: RawTexture);
  73972. /** Scene that the SpriteMap was created in */
  73973. private _scene;
  73974. /** Texture Buffer of Float32 that holds tile frame data*/
  73975. private _frameMap;
  73976. /** Texture Buffers of Float32 that holds tileMap data*/
  73977. private _tileMaps;
  73978. /** Texture Buffer of Float32 that holds Animation Data*/
  73979. private _animationMap;
  73980. /** Custom ShaderMaterial Central to the System*/
  73981. private _material;
  73982. /** Custom ShaderMaterial Central to the System*/
  73983. private _output;
  73984. /** Systems Time Ticker*/
  73985. private _time;
  73986. /**
  73987. * Creates a new SpriteMap
  73988. * @param name defines the SpriteMaps Name
  73989. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73990. * @param spriteSheet is the Texture that the Sprites are on.
  73991. * @param options a basic deployment configuration
  73992. * @param scene The Scene that the map is deployed on
  73993. */
  73994. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73995. /**
  73996. * Returns tileID location
  73997. * @returns Vector2 the cell position ID
  73998. */
  73999. getTileID(): Vector2;
  74000. /**
  74001. * Gets the UV location of the mouse over the SpriteMap.
  74002. * @returns Vector2 the UV position of the mouse interaction
  74003. */
  74004. getMousePosition(): Vector2;
  74005. /**
  74006. * Creates the "frame" texture Buffer
  74007. * -------------------------------------
  74008. * Structure of frames
  74009. * "filename": "Falling-Water-2.png",
  74010. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74011. * "rotated": true,
  74012. * "trimmed": true,
  74013. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74014. * "sourceSize": {"w":32,"h":32}
  74015. * @returns RawTexture of the frameMap
  74016. */
  74017. private _createFrameBuffer;
  74018. /**
  74019. * Creates the tileMap texture Buffer
  74020. * @param buffer normally and array of numbers, or a false to generate from scratch
  74021. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74022. * @returns RawTexture of the tileMap
  74023. */
  74024. private _createTileBuffer;
  74025. /**
  74026. * Modifies the data of the tileMaps
  74027. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74028. * @param pos is the iVector2 Coordinates of the Tile
  74029. * @param tile The SpriteIndex of the new Tile
  74030. */
  74031. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74032. /**
  74033. * Creates the animationMap texture Buffer
  74034. * @param buffer normally and array of numbers, or a false to generate from scratch
  74035. * @returns RawTexture of the animationMap
  74036. */
  74037. private _createTileAnimationBuffer;
  74038. /**
  74039. * Modifies the data of the animationMap
  74040. * @param cellID is the Index of the Sprite
  74041. * @param _frame is the target Animation frame
  74042. * @param toCell is the Target Index of the next frame of the animation
  74043. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74044. * @param speed is a global scalar of the time variable on the map.
  74045. */
  74046. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74047. /**
  74048. * Exports the .tilemaps file
  74049. */
  74050. saveTileMaps(): void;
  74051. /**
  74052. * Imports the .tilemaps file
  74053. * @param url of the .tilemaps file
  74054. */
  74055. loadTileMaps(url: string): void;
  74056. /**
  74057. * Release associated resources
  74058. */
  74059. dispose(): void;
  74060. }
  74061. }
  74062. declare module BABYLON {
  74063. /**
  74064. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74065. * @see https://doc.babylonjs.com/babylon101/sprites
  74066. */
  74067. export class SpritePackedManager extends SpriteManager {
  74068. /** defines the packed manager's name */
  74069. name: string;
  74070. /**
  74071. * Creates a new sprite manager from a packed sprite sheet
  74072. * @param name defines the manager's name
  74073. * @param imgUrl defines the sprite sheet url
  74074. * @param capacity defines the maximum allowed number of sprites
  74075. * @param scene defines the hosting scene
  74076. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74077. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74078. * @param samplingMode defines the smapling mode to use with spritesheet
  74079. * @param fromPacked set to true; do not alter
  74080. */
  74081. constructor(
  74082. /** defines the packed manager's name */
  74083. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74084. }
  74085. }
  74086. declare module BABYLON {
  74087. /**
  74088. * Defines the list of states available for a task inside a AssetsManager
  74089. */
  74090. export enum AssetTaskState {
  74091. /**
  74092. * Initialization
  74093. */
  74094. INIT = 0,
  74095. /**
  74096. * Running
  74097. */
  74098. RUNNING = 1,
  74099. /**
  74100. * Done
  74101. */
  74102. DONE = 2,
  74103. /**
  74104. * Error
  74105. */
  74106. ERROR = 3
  74107. }
  74108. /**
  74109. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74110. */
  74111. export abstract class AbstractAssetTask {
  74112. /**
  74113. * Task name
  74114. */ name: string;
  74115. /**
  74116. * Callback called when the task is successful
  74117. */
  74118. onSuccess: (task: any) => void;
  74119. /**
  74120. * Callback called when the task is not successful
  74121. */
  74122. onError: (task: any, message?: string, exception?: any) => void;
  74123. /**
  74124. * Creates a new AssetsManager
  74125. * @param name defines the name of the task
  74126. */
  74127. constructor(
  74128. /**
  74129. * Task name
  74130. */ name: string);
  74131. private _isCompleted;
  74132. private _taskState;
  74133. private _errorObject;
  74134. /**
  74135. * Get if the task is completed
  74136. */
  74137. get isCompleted(): boolean;
  74138. /**
  74139. * Gets the current state of the task
  74140. */
  74141. get taskState(): AssetTaskState;
  74142. /**
  74143. * Gets the current error object (if task is in error)
  74144. */
  74145. get errorObject(): {
  74146. message?: string;
  74147. exception?: any;
  74148. };
  74149. /**
  74150. * Internal only
  74151. * @hidden
  74152. */
  74153. _setErrorObject(message?: string, exception?: any): void;
  74154. /**
  74155. * Execute the current task
  74156. * @param scene defines the scene where you want your assets to be loaded
  74157. * @param onSuccess is a callback called when the task is successfully executed
  74158. * @param onError is a callback called if an error occurs
  74159. */
  74160. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74161. /**
  74162. * Execute the current task
  74163. * @param scene defines the scene where you want your assets to be loaded
  74164. * @param onSuccess is a callback called when the task is successfully executed
  74165. * @param onError is a callback called if an error occurs
  74166. */
  74167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74168. /**
  74169. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74170. * This can be used with failed tasks that have the reason for failure fixed.
  74171. */
  74172. reset(): void;
  74173. private onErrorCallback;
  74174. private onDoneCallback;
  74175. }
  74176. /**
  74177. * Define the interface used by progress events raised during assets loading
  74178. */
  74179. export interface IAssetsProgressEvent {
  74180. /**
  74181. * Defines the number of remaining tasks to process
  74182. */
  74183. remainingCount: number;
  74184. /**
  74185. * Defines the total number of tasks
  74186. */
  74187. totalCount: number;
  74188. /**
  74189. * Defines the task that was just processed
  74190. */
  74191. task: AbstractAssetTask;
  74192. }
  74193. /**
  74194. * Class used to share progress information about assets loading
  74195. */
  74196. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74197. /**
  74198. * Defines the number of remaining tasks to process
  74199. */
  74200. remainingCount: number;
  74201. /**
  74202. * Defines the total number of tasks
  74203. */
  74204. totalCount: number;
  74205. /**
  74206. * Defines the task that was just processed
  74207. */
  74208. task: AbstractAssetTask;
  74209. /**
  74210. * Creates a AssetsProgressEvent
  74211. * @param remainingCount defines the number of remaining tasks to process
  74212. * @param totalCount defines the total number of tasks
  74213. * @param task defines the task that was just processed
  74214. */
  74215. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74216. }
  74217. /**
  74218. * Define a task used by AssetsManager to load assets into a container
  74219. */
  74220. export class ContainerAssetTask extends AbstractAssetTask {
  74221. /**
  74222. * Defines the name of the task
  74223. */
  74224. name: string;
  74225. /**
  74226. * Defines the list of mesh's names you want to load
  74227. */
  74228. meshesNames: any;
  74229. /**
  74230. * Defines the root url to use as a base to load your meshes and associated resources
  74231. */
  74232. rootUrl: string;
  74233. /**
  74234. * Defines the filename or File of the scene to load from
  74235. */
  74236. sceneFilename: string | File;
  74237. /**
  74238. * Get the loaded asset container
  74239. */
  74240. loadedContainer: AssetContainer;
  74241. /**
  74242. * Gets the list of loaded meshes
  74243. */
  74244. loadedMeshes: Array<AbstractMesh>;
  74245. /**
  74246. * Gets the list of loaded particle systems
  74247. */
  74248. loadedParticleSystems: Array<IParticleSystem>;
  74249. /**
  74250. * Gets the list of loaded skeletons
  74251. */
  74252. loadedSkeletons: Array<Skeleton>;
  74253. /**
  74254. * Gets the list of loaded animation groups
  74255. */
  74256. loadedAnimationGroups: Array<AnimationGroup>;
  74257. /**
  74258. * Callback called when the task is successful
  74259. */
  74260. onSuccess: (task: ContainerAssetTask) => void;
  74261. /**
  74262. * Callback called when the task is successful
  74263. */
  74264. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74265. /**
  74266. * Creates a new ContainerAssetTask
  74267. * @param name defines the name of the task
  74268. * @param meshesNames defines the list of mesh's names you want to load
  74269. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74270. * @param sceneFilename defines the filename or File of the scene to load from
  74271. */
  74272. constructor(
  74273. /**
  74274. * Defines the name of the task
  74275. */
  74276. name: string,
  74277. /**
  74278. * Defines the list of mesh's names you want to load
  74279. */
  74280. meshesNames: any,
  74281. /**
  74282. * Defines the root url to use as a base to load your meshes and associated resources
  74283. */
  74284. rootUrl: string,
  74285. /**
  74286. * Defines the filename or File of the scene to load from
  74287. */
  74288. sceneFilename: string | File);
  74289. /**
  74290. * Execute the current task
  74291. * @param scene defines the scene where you want your assets to be loaded
  74292. * @param onSuccess is a callback called when the task is successfully executed
  74293. * @param onError is a callback called if an error occurs
  74294. */
  74295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74296. }
  74297. /**
  74298. * Define a task used by AssetsManager to load meshes
  74299. */
  74300. export class MeshAssetTask extends AbstractAssetTask {
  74301. /**
  74302. * Defines the name of the task
  74303. */
  74304. name: string;
  74305. /**
  74306. * Defines the list of mesh's names you want to load
  74307. */
  74308. meshesNames: any;
  74309. /**
  74310. * Defines the root url to use as a base to load your meshes and associated resources
  74311. */
  74312. rootUrl: string;
  74313. /**
  74314. * Defines the filename or File of the scene to load from
  74315. */
  74316. sceneFilename: string | File;
  74317. /**
  74318. * Gets the list of loaded meshes
  74319. */
  74320. loadedMeshes: Array<AbstractMesh>;
  74321. /**
  74322. * Gets the list of loaded particle systems
  74323. */
  74324. loadedParticleSystems: Array<IParticleSystem>;
  74325. /**
  74326. * Gets the list of loaded skeletons
  74327. */
  74328. loadedSkeletons: Array<Skeleton>;
  74329. /**
  74330. * Gets the list of loaded animation groups
  74331. */
  74332. loadedAnimationGroups: Array<AnimationGroup>;
  74333. /**
  74334. * Callback called when the task is successful
  74335. */
  74336. onSuccess: (task: MeshAssetTask) => void;
  74337. /**
  74338. * Callback called when the task is successful
  74339. */
  74340. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74341. /**
  74342. * Creates a new MeshAssetTask
  74343. * @param name defines the name of the task
  74344. * @param meshesNames defines the list of mesh's names you want to load
  74345. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74346. * @param sceneFilename defines the filename or File of the scene to load from
  74347. */
  74348. constructor(
  74349. /**
  74350. * Defines the name of the task
  74351. */
  74352. name: string,
  74353. /**
  74354. * Defines the list of mesh's names you want to load
  74355. */
  74356. meshesNames: any,
  74357. /**
  74358. * Defines the root url to use as a base to load your meshes and associated resources
  74359. */
  74360. rootUrl: string,
  74361. /**
  74362. * Defines the filename or File of the scene to load from
  74363. */
  74364. sceneFilename: string | File);
  74365. /**
  74366. * Execute the current task
  74367. * @param scene defines the scene where you want your assets to be loaded
  74368. * @param onSuccess is a callback called when the task is successfully executed
  74369. * @param onError is a callback called if an error occurs
  74370. */
  74371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74372. }
  74373. /**
  74374. * Define a task used by AssetsManager to load text content
  74375. */
  74376. export class TextFileAssetTask extends AbstractAssetTask {
  74377. /**
  74378. * Defines the name of the task
  74379. */
  74380. name: string;
  74381. /**
  74382. * Defines the location of the file to load
  74383. */
  74384. url: string;
  74385. /**
  74386. * Gets the loaded text string
  74387. */
  74388. text: string;
  74389. /**
  74390. * Callback called when the task is successful
  74391. */
  74392. onSuccess: (task: TextFileAssetTask) => void;
  74393. /**
  74394. * Callback called when the task is successful
  74395. */
  74396. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74397. /**
  74398. * Creates a new TextFileAssetTask object
  74399. * @param name defines the name of the task
  74400. * @param url defines the location of the file to load
  74401. */
  74402. constructor(
  74403. /**
  74404. * Defines the name of the task
  74405. */
  74406. name: string,
  74407. /**
  74408. * Defines the location of the file to load
  74409. */
  74410. url: string);
  74411. /**
  74412. * Execute the current task
  74413. * @param scene defines the scene where you want your assets to be loaded
  74414. * @param onSuccess is a callback called when the task is successfully executed
  74415. * @param onError is a callback called if an error occurs
  74416. */
  74417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74418. }
  74419. /**
  74420. * Define a task used by AssetsManager to load binary data
  74421. */
  74422. export class BinaryFileAssetTask extends AbstractAssetTask {
  74423. /**
  74424. * Defines the name of the task
  74425. */
  74426. name: string;
  74427. /**
  74428. * Defines the location of the file to load
  74429. */
  74430. url: string;
  74431. /**
  74432. * Gets the lodaded data (as an array buffer)
  74433. */
  74434. data: ArrayBuffer;
  74435. /**
  74436. * Callback called when the task is successful
  74437. */
  74438. onSuccess: (task: BinaryFileAssetTask) => void;
  74439. /**
  74440. * Callback called when the task is successful
  74441. */
  74442. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74443. /**
  74444. * Creates a new BinaryFileAssetTask object
  74445. * @param name defines the name of the new task
  74446. * @param url defines the location of the file to load
  74447. */
  74448. constructor(
  74449. /**
  74450. * Defines the name of the task
  74451. */
  74452. name: string,
  74453. /**
  74454. * Defines the location of the file to load
  74455. */
  74456. url: string);
  74457. /**
  74458. * Execute the current task
  74459. * @param scene defines the scene where you want your assets to be loaded
  74460. * @param onSuccess is a callback called when the task is successfully executed
  74461. * @param onError is a callback called if an error occurs
  74462. */
  74463. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74464. }
  74465. /**
  74466. * Define a task used by AssetsManager to load images
  74467. */
  74468. export class ImageAssetTask extends AbstractAssetTask {
  74469. /**
  74470. * Defines the name of the task
  74471. */
  74472. name: string;
  74473. /**
  74474. * Defines the location of the image to load
  74475. */
  74476. url: string;
  74477. /**
  74478. * Gets the loaded images
  74479. */
  74480. image: HTMLImageElement;
  74481. /**
  74482. * Callback called when the task is successful
  74483. */
  74484. onSuccess: (task: ImageAssetTask) => void;
  74485. /**
  74486. * Callback called when the task is successful
  74487. */
  74488. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74489. /**
  74490. * Creates a new ImageAssetTask
  74491. * @param name defines the name of the task
  74492. * @param url defines the location of the image to load
  74493. */
  74494. constructor(
  74495. /**
  74496. * Defines the name of the task
  74497. */
  74498. name: string,
  74499. /**
  74500. * Defines the location of the image to load
  74501. */
  74502. url: string);
  74503. /**
  74504. * Execute the current task
  74505. * @param scene defines the scene where you want your assets to be loaded
  74506. * @param onSuccess is a callback called when the task is successfully executed
  74507. * @param onError is a callback called if an error occurs
  74508. */
  74509. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74510. }
  74511. /**
  74512. * Defines the interface used by texture loading tasks
  74513. */
  74514. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74515. /**
  74516. * Gets the loaded texture
  74517. */
  74518. texture: TEX;
  74519. }
  74520. /**
  74521. * Define a task used by AssetsManager to load 2D textures
  74522. */
  74523. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74524. /**
  74525. * Defines the name of the task
  74526. */
  74527. name: string;
  74528. /**
  74529. * Defines the location of the file to load
  74530. */
  74531. url: string;
  74532. /**
  74533. * Defines if mipmap should not be generated (default is false)
  74534. */
  74535. noMipmap?: boolean | undefined;
  74536. /**
  74537. * Defines if texture must be inverted on Y axis (default is true)
  74538. */
  74539. invertY: boolean;
  74540. /**
  74541. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74542. */
  74543. samplingMode: number;
  74544. /**
  74545. * Gets the loaded texture
  74546. */
  74547. texture: Texture;
  74548. /**
  74549. * Callback called when the task is successful
  74550. */
  74551. onSuccess: (task: TextureAssetTask) => void;
  74552. /**
  74553. * Callback called when the task is successful
  74554. */
  74555. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74556. /**
  74557. * Creates a new TextureAssetTask object
  74558. * @param name defines the name of the task
  74559. * @param url defines the location of the file to load
  74560. * @param noMipmap defines if mipmap should not be generated (default is false)
  74561. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74562. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74563. */
  74564. constructor(
  74565. /**
  74566. * Defines the name of the task
  74567. */
  74568. name: string,
  74569. /**
  74570. * Defines the location of the file to load
  74571. */
  74572. url: string,
  74573. /**
  74574. * Defines if mipmap should not be generated (default is false)
  74575. */
  74576. noMipmap?: boolean | undefined,
  74577. /**
  74578. * Defines if texture must be inverted on Y axis (default is true)
  74579. */
  74580. invertY?: boolean,
  74581. /**
  74582. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74583. */
  74584. samplingMode?: number);
  74585. /**
  74586. * Execute the current task
  74587. * @param scene defines the scene where you want your assets to be loaded
  74588. * @param onSuccess is a callback called when the task is successfully executed
  74589. * @param onError is a callback called if an error occurs
  74590. */
  74591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74592. }
  74593. /**
  74594. * Define a task used by AssetsManager to load cube textures
  74595. */
  74596. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74597. /**
  74598. * Defines the name of the task
  74599. */
  74600. name: string;
  74601. /**
  74602. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74603. */
  74604. url: string;
  74605. /**
  74606. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74607. */
  74608. extensions?: string[] | undefined;
  74609. /**
  74610. * Defines if mipmaps should not be generated (default is false)
  74611. */
  74612. noMipmap?: boolean | undefined;
  74613. /**
  74614. * Defines the explicit list of files (undefined by default)
  74615. */
  74616. files?: string[] | undefined;
  74617. /**
  74618. * Gets the loaded texture
  74619. */
  74620. texture: CubeTexture;
  74621. /**
  74622. * Callback called when the task is successful
  74623. */
  74624. onSuccess: (task: CubeTextureAssetTask) => void;
  74625. /**
  74626. * Callback called when the task is successful
  74627. */
  74628. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74629. /**
  74630. * Creates a new CubeTextureAssetTask
  74631. * @param name defines the name of the task
  74632. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74633. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74634. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74635. * @param files defines the explicit list of files (undefined by default)
  74636. */
  74637. constructor(
  74638. /**
  74639. * Defines the name of the task
  74640. */
  74641. name: string,
  74642. /**
  74643. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74644. */
  74645. url: string,
  74646. /**
  74647. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74648. */
  74649. extensions?: string[] | undefined,
  74650. /**
  74651. * Defines if mipmaps should not be generated (default is false)
  74652. */
  74653. noMipmap?: boolean | undefined,
  74654. /**
  74655. * Defines the explicit list of files (undefined by default)
  74656. */
  74657. files?: string[] | undefined);
  74658. /**
  74659. * Execute the current task
  74660. * @param scene defines the scene where you want your assets to be loaded
  74661. * @param onSuccess is a callback called when the task is successfully executed
  74662. * @param onError is a callback called if an error occurs
  74663. */
  74664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74665. }
  74666. /**
  74667. * Define a task used by AssetsManager to load HDR cube textures
  74668. */
  74669. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74670. /**
  74671. * Defines the name of the task
  74672. */
  74673. name: string;
  74674. /**
  74675. * Defines the location of the file to load
  74676. */
  74677. url: string;
  74678. /**
  74679. * Defines the desired size (the more it increases the longer the generation will be)
  74680. */
  74681. size: number;
  74682. /**
  74683. * Defines if mipmaps should not be generated (default is false)
  74684. */
  74685. noMipmap: boolean;
  74686. /**
  74687. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74688. */
  74689. generateHarmonics: boolean;
  74690. /**
  74691. * 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)
  74692. */
  74693. gammaSpace: boolean;
  74694. /**
  74695. * Internal Use Only
  74696. */
  74697. reserved: boolean;
  74698. /**
  74699. * Gets the loaded texture
  74700. */
  74701. texture: HDRCubeTexture;
  74702. /**
  74703. * Callback called when the task is successful
  74704. */
  74705. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74706. /**
  74707. * Callback called when the task is successful
  74708. */
  74709. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74710. /**
  74711. * Creates a new HDRCubeTextureAssetTask object
  74712. * @param name defines the name of the task
  74713. * @param url defines the location of the file to load
  74714. * @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.
  74715. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74716. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74717. * @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)
  74718. * @param reserved Internal use only
  74719. */
  74720. constructor(
  74721. /**
  74722. * Defines the name of the task
  74723. */
  74724. name: string,
  74725. /**
  74726. * Defines the location of the file to load
  74727. */
  74728. url: string,
  74729. /**
  74730. * Defines the desired size (the more it increases the longer the generation will be)
  74731. */
  74732. size: number,
  74733. /**
  74734. * Defines if mipmaps should not be generated (default is false)
  74735. */
  74736. noMipmap?: boolean,
  74737. /**
  74738. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74739. */
  74740. generateHarmonics?: boolean,
  74741. /**
  74742. * 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)
  74743. */
  74744. gammaSpace?: boolean,
  74745. /**
  74746. * Internal Use Only
  74747. */
  74748. reserved?: boolean);
  74749. /**
  74750. * Execute the current task
  74751. * @param scene defines the scene where you want your assets to be loaded
  74752. * @param onSuccess is a callback called when the task is successfully executed
  74753. * @param onError is a callback called if an error occurs
  74754. */
  74755. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74756. }
  74757. /**
  74758. * Define a task used by AssetsManager to load Equirectangular cube textures
  74759. */
  74760. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74761. /**
  74762. * Defines the name of the task
  74763. */
  74764. name: string;
  74765. /**
  74766. * Defines the location of the file to load
  74767. */
  74768. url: string;
  74769. /**
  74770. * Defines the desired size (the more it increases the longer the generation will be)
  74771. */
  74772. size: number;
  74773. /**
  74774. * Defines if mipmaps should not be generated (default is false)
  74775. */
  74776. noMipmap: boolean;
  74777. /**
  74778. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74779. * but the standard material would require them in Gamma space) (default is true)
  74780. */
  74781. gammaSpace: boolean;
  74782. /**
  74783. * Gets the loaded texture
  74784. */
  74785. texture: EquiRectangularCubeTexture;
  74786. /**
  74787. * Callback called when the task is successful
  74788. */
  74789. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74790. /**
  74791. * Callback called when the task is successful
  74792. */
  74793. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74794. /**
  74795. * Creates a new EquiRectangularCubeTextureAssetTask object
  74796. * @param name defines the name of the task
  74797. * @param url defines the location of the file to load
  74798. * @param size defines the desired size (the more it increases the longer the generation will be)
  74799. * If the size is omitted this implies you are using a preprocessed cubemap.
  74800. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74801. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74802. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74803. * (default is true)
  74804. */
  74805. constructor(
  74806. /**
  74807. * Defines the name of the task
  74808. */
  74809. name: string,
  74810. /**
  74811. * Defines the location of the file to load
  74812. */
  74813. url: string,
  74814. /**
  74815. * Defines the desired size (the more it increases the longer the generation will be)
  74816. */
  74817. size: number,
  74818. /**
  74819. * Defines if mipmaps should not be generated (default is false)
  74820. */
  74821. noMipmap?: boolean,
  74822. /**
  74823. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74824. * but the standard material would require them in Gamma space) (default is true)
  74825. */
  74826. gammaSpace?: boolean);
  74827. /**
  74828. * Execute the current task
  74829. * @param scene defines the scene where you want your assets to be loaded
  74830. * @param onSuccess is a callback called when the task is successfully executed
  74831. * @param onError is a callback called if an error occurs
  74832. */
  74833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74834. }
  74835. /**
  74836. * This class can be used to easily import assets into a scene
  74837. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74838. */
  74839. export class AssetsManager {
  74840. private _scene;
  74841. private _isLoading;
  74842. protected _tasks: AbstractAssetTask[];
  74843. protected _waitingTasksCount: number;
  74844. protected _totalTasksCount: number;
  74845. /**
  74846. * Callback called when all tasks are processed
  74847. */
  74848. onFinish: (tasks: AbstractAssetTask[]) => void;
  74849. /**
  74850. * Callback called when a task is successful
  74851. */
  74852. onTaskSuccess: (task: AbstractAssetTask) => void;
  74853. /**
  74854. * Callback called when a task had an error
  74855. */
  74856. onTaskError: (task: AbstractAssetTask) => void;
  74857. /**
  74858. * Callback called when a task is done (whatever the result is)
  74859. */
  74860. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74861. /**
  74862. * Observable called when all tasks are processed
  74863. */
  74864. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74865. /**
  74866. * Observable called when a task had an error
  74867. */
  74868. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74869. /**
  74870. * Observable called when all tasks were executed
  74871. */
  74872. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74873. /**
  74874. * Observable called when a task is done (whatever the result is)
  74875. */
  74876. onProgressObservable: Observable<IAssetsProgressEvent>;
  74877. /**
  74878. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74879. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74880. */
  74881. useDefaultLoadingScreen: boolean;
  74882. /**
  74883. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74884. * when all assets have been downloaded.
  74885. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74886. */
  74887. autoHideLoadingUI: boolean;
  74888. /**
  74889. * Creates a new AssetsManager
  74890. * @param scene defines the scene to work on
  74891. */
  74892. constructor(scene: Scene);
  74893. /**
  74894. * Add a ContainerAssetTask to the list of active tasks
  74895. * @param taskName defines the name of the new task
  74896. * @param meshesNames defines the name of meshes to load
  74897. * @param rootUrl defines the root url to use to locate files
  74898. * @param sceneFilename defines the filename of the scene file
  74899. * @returns a new ContainerAssetTask object
  74900. */
  74901. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74902. /**
  74903. * Add a MeshAssetTask to the list of active tasks
  74904. * @param taskName defines the name of the new task
  74905. * @param meshesNames defines the name of meshes to load
  74906. * @param rootUrl defines the root url to use to locate files
  74907. * @param sceneFilename defines the filename of the scene file
  74908. * @returns a new MeshAssetTask object
  74909. */
  74910. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74911. /**
  74912. * Add a TextFileAssetTask to the list of active tasks
  74913. * @param taskName defines the name of the new task
  74914. * @param url defines the url of the file to load
  74915. * @returns a new TextFileAssetTask object
  74916. */
  74917. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74918. /**
  74919. * Add a BinaryFileAssetTask to the list of active tasks
  74920. * @param taskName defines the name of the new task
  74921. * @param url defines the url of the file to load
  74922. * @returns a new BinaryFileAssetTask object
  74923. */
  74924. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74925. /**
  74926. * Add a ImageAssetTask to the list of active tasks
  74927. * @param taskName defines the name of the new task
  74928. * @param url defines the url of the file to load
  74929. * @returns a new ImageAssetTask object
  74930. */
  74931. addImageTask(taskName: string, url: string): ImageAssetTask;
  74932. /**
  74933. * Add a TextureAssetTask to the list of active tasks
  74934. * @param taskName defines the name of the new task
  74935. * @param url defines the url of the file to load
  74936. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74937. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74938. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74939. * @returns a new TextureAssetTask object
  74940. */
  74941. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74942. /**
  74943. * Add a CubeTextureAssetTask to the list of active tasks
  74944. * @param taskName defines the name of the new task
  74945. * @param url defines the url of the file to load
  74946. * @param extensions defines the extension to use to load the cube map (can be null)
  74947. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74948. * @param files defines the list of files to load (can be null)
  74949. * @returns a new CubeTextureAssetTask object
  74950. */
  74951. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74952. /**
  74953. *
  74954. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74955. * @param taskName defines the name of the new task
  74956. * @param url defines the url of the file to load
  74957. * @param size defines the size you want for the cubemap (can be null)
  74958. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74959. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74960. * @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)
  74961. * @param reserved Internal use only
  74962. * @returns a new HDRCubeTextureAssetTask object
  74963. */
  74964. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74965. /**
  74966. *
  74967. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74968. * @param taskName defines the name of the new task
  74969. * @param url defines the url of the file to load
  74970. * @param size defines the size you want for the cubemap (can be null)
  74971. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74972. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74973. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74974. * @returns a new EquiRectangularCubeTextureAssetTask object
  74975. */
  74976. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74977. /**
  74978. * Remove a task from the assets manager.
  74979. * @param task the task to remove
  74980. */
  74981. removeTask(task: AbstractAssetTask): void;
  74982. private _decreaseWaitingTasksCount;
  74983. private _runTask;
  74984. /**
  74985. * Reset the AssetsManager and remove all tasks
  74986. * @return the current instance of the AssetsManager
  74987. */
  74988. reset(): AssetsManager;
  74989. /**
  74990. * Start the loading process
  74991. * @return the current instance of the AssetsManager
  74992. */
  74993. load(): AssetsManager;
  74994. /**
  74995. * Start the loading process as an async operation
  74996. * @return a promise returning the list of failed tasks
  74997. */
  74998. loadAsync(): Promise<void>;
  74999. }
  75000. }
  75001. declare module BABYLON {
  75002. /**
  75003. * Wrapper class for promise with external resolve and reject.
  75004. */
  75005. export class Deferred<T> {
  75006. /**
  75007. * The promise associated with this deferred object.
  75008. */
  75009. readonly promise: Promise<T>;
  75010. private _resolve;
  75011. private _reject;
  75012. /**
  75013. * The resolve method of the promise associated with this deferred object.
  75014. */
  75015. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75016. /**
  75017. * The reject method of the promise associated with this deferred object.
  75018. */
  75019. get reject(): (reason?: any) => void;
  75020. /**
  75021. * Constructor for this deferred object.
  75022. */
  75023. constructor();
  75024. }
  75025. }
  75026. declare module BABYLON {
  75027. /**
  75028. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75029. */
  75030. export class MeshExploder {
  75031. private _centerMesh;
  75032. private _meshes;
  75033. private _meshesOrigins;
  75034. private _toCenterVectors;
  75035. private _scaledDirection;
  75036. private _newPosition;
  75037. private _centerPosition;
  75038. /**
  75039. * Explodes meshes from a center mesh.
  75040. * @param meshes The meshes to explode.
  75041. * @param centerMesh The mesh to be center of explosion.
  75042. */
  75043. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75044. private _setCenterMesh;
  75045. /**
  75046. * Get class name
  75047. * @returns "MeshExploder"
  75048. */
  75049. getClassName(): string;
  75050. /**
  75051. * "Exploded meshes"
  75052. * @returns Array of meshes with the centerMesh at index 0.
  75053. */
  75054. getMeshes(): Array<Mesh>;
  75055. /**
  75056. * Explodes meshes giving a specific direction
  75057. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75058. */
  75059. explode(direction?: number): void;
  75060. }
  75061. }
  75062. declare module BABYLON {
  75063. /**
  75064. * Class used to help managing file picking and drag'n'drop
  75065. */
  75066. export class FilesInput {
  75067. /**
  75068. * List of files ready to be loaded
  75069. */
  75070. static get FilesToLoad(): {
  75071. [key: string]: File;
  75072. };
  75073. /**
  75074. * Callback called when a file is processed
  75075. */
  75076. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  75077. private _engine;
  75078. private _currentScene;
  75079. private _sceneLoadedCallback;
  75080. private _progressCallback;
  75081. private _additionalRenderLoopLogicCallback;
  75082. private _textureLoadingCallback;
  75083. private _startingProcessingFilesCallback;
  75084. private _onReloadCallback;
  75085. private _errorCallback;
  75086. private _elementToMonitor;
  75087. private _sceneFileToLoad;
  75088. private _filesToLoad;
  75089. /**
  75090. * Creates a new FilesInput
  75091. * @param engine defines the rendering engine
  75092. * @param scene defines the hosting scene
  75093. * @param sceneLoadedCallback callback called when scene is loaded
  75094. * @param progressCallback callback called to track progress
  75095. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75096. * @param textureLoadingCallback callback called when a texture is loading
  75097. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75098. * @param onReloadCallback callback called when a reload is requested
  75099. * @param errorCallback callback call if an error occurs
  75100. */
  75101. 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>);
  75102. private _dragEnterHandler;
  75103. private _dragOverHandler;
  75104. private _dropHandler;
  75105. /**
  75106. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75107. * @param elementToMonitor defines the DOM element to track
  75108. */
  75109. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75110. /** Gets the current list of files to load */
  75111. get filesToLoad(): File[];
  75112. /**
  75113. * Release all associated resources
  75114. */
  75115. dispose(): void;
  75116. private renderFunction;
  75117. private drag;
  75118. private drop;
  75119. private _traverseFolder;
  75120. private _processFiles;
  75121. /**
  75122. * Load files from a drop event
  75123. * @param event defines the drop event to use as source
  75124. */
  75125. loadFiles(event: any): void;
  75126. private _processReload;
  75127. /**
  75128. * Reload the current scene from the loaded files
  75129. */
  75130. reload(): void;
  75131. }
  75132. }
  75133. declare module BABYLON {
  75134. /**
  75135. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75136. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75137. */
  75138. export class SceneOptimization {
  75139. /**
  75140. * Defines the priority of this optimization (0 by default which means first in the list)
  75141. */
  75142. priority: number;
  75143. /**
  75144. * Gets a string describing the action executed by the current optimization
  75145. * @returns description string
  75146. */
  75147. getDescription(): string;
  75148. /**
  75149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75150. * @param scene defines the current scene where to apply this optimization
  75151. * @param optimizer defines the current optimizer
  75152. * @returns true if everything that can be done was applied
  75153. */
  75154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75155. /**
  75156. * Creates the SceneOptimization object
  75157. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75158. * @param desc defines the description associated with the optimization
  75159. */
  75160. constructor(
  75161. /**
  75162. * Defines the priority of this optimization (0 by default which means first in the list)
  75163. */
  75164. priority?: number);
  75165. }
  75166. /**
  75167. * Defines an optimization used to reduce the size of render target textures
  75168. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75169. */
  75170. export class TextureOptimization extends SceneOptimization {
  75171. /**
  75172. * Defines the priority of this optimization (0 by default which means first in the list)
  75173. */
  75174. priority: number;
  75175. /**
  75176. * 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
  75177. */
  75178. maximumSize: number;
  75179. /**
  75180. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75181. */
  75182. step: number;
  75183. /**
  75184. * Gets a string describing the action executed by the current optimization
  75185. * @returns description string
  75186. */
  75187. getDescription(): string;
  75188. /**
  75189. * Creates the TextureOptimization object
  75190. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75191. * @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
  75192. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75193. */
  75194. constructor(
  75195. /**
  75196. * Defines the priority of this optimization (0 by default which means first in the list)
  75197. */
  75198. priority?: number,
  75199. /**
  75200. * 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
  75201. */
  75202. maximumSize?: number,
  75203. /**
  75204. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75205. */
  75206. step?: number);
  75207. /**
  75208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75209. * @param scene defines the current scene where to apply this optimization
  75210. * @param optimizer defines the current optimizer
  75211. * @returns true if everything that can be done was applied
  75212. */
  75213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75214. }
  75215. /**
  75216. * Defines an optimization used to increase or decrease the rendering resolution
  75217. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75218. */
  75219. export class HardwareScalingOptimization extends SceneOptimization {
  75220. /**
  75221. * Defines the priority of this optimization (0 by default which means first in the list)
  75222. */
  75223. priority: number;
  75224. /**
  75225. * Defines the maximum scale to use (2 by default)
  75226. */
  75227. maximumScale: number;
  75228. /**
  75229. * Defines the step to use between two passes (0.5 by default)
  75230. */
  75231. step: number;
  75232. private _currentScale;
  75233. private _directionOffset;
  75234. /**
  75235. * Gets a string describing the action executed by the current optimization
  75236. * @return description string
  75237. */
  75238. getDescription(): string;
  75239. /**
  75240. * Creates the HardwareScalingOptimization object
  75241. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75242. * @param maximumScale defines the maximum scale to use (2 by default)
  75243. * @param step defines the step to use between two passes (0.5 by default)
  75244. */
  75245. constructor(
  75246. /**
  75247. * Defines the priority of this optimization (0 by default which means first in the list)
  75248. */
  75249. priority?: number,
  75250. /**
  75251. * Defines the maximum scale to use (2 by default)
  75252. */
  75253. maximumScale?: number,
  75254. /**
  75255. * Defines the step to use between two passes (0.5 by default)
  75256. */
  75257. step?: number);
  75258. /**
  75259. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75260. * @param scene defines the current scene where to apply this optimization
  75261. * @param optimizer defines the current optimizer
  75262. * @returns true if everything that can be done was applied
  75263. */
  75264. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75265. }
  75266. /**
  75267. * Defines an optimization used to remove shadows
  75268. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75269. */
  75270. export class ShadowsOptimization extends SceneOptimization {
  75271. /**
  75272. * Gets a string describing the action executed by the current optimization
  75273. * @return description string
  75274. */
  75275. getDescription(): string;
  75276. /**
  75277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75278. * @param scene defines the current scene where to apply this optimization
  75279. * @param optimizer defines the current optimizer
  75280. * @returns true if everything that can be done was applied
  75281. */
  75282. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75283. }
  75284. /**
  75285. * Defines an optimization used to turn post-processes off
  75286. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75287. */
  75288. export class PostProcessesOptimization extends SceneOptimization {
  75289. /**
  75290. * Gets a string describing the action executed by the current optimization
  75291. * @return description string
  75292. */
  75293. getDescription(): string;
  75294. /**
  75295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75296. * @param scene defines the current scene where to apply this optimization
  75297. * @param optimizer defines the current optimizer
  75298. * @returns true if everything that can be done was applied
  75299. */
  75300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75301. }
  75302. /**
  75303. * Defines an optimization used to turn lens flares off
  75304. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75305. */
  75306. export class LensFlaresOptimization extends SceneOptimization {
  75307. /**
  75308. * Gets a string describing the action executed by the current optimization
  75309. * @return description string
  75310. */
  75311. getDescription(): string;
  75312. /**
  75313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75314. * @param scene defines the current scene where to apply this optimization
  75315. * @param optimizer defines the current optimizer
  75316. * @returns true if everything that can be done was applied
  75317. */
  75318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75319. }
  75320. /**
  75321. * Defines an optimization based on user defined callback.
  75322. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75323. */
  75324. export class CustomOptimization extends SceneOptimization {
  75325. /**
  75326. * Callback called to apply the custom optimization.
  75327. */
  75328. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75329. /**
  75330. * Callback called to get custom description
  75331. */
  75332. onGetDescription: () => string;
  75333. /**
  75334. * Gets a string describing the action executed by the current optimization
  75335. * @returns description string
  75336. */
  75337. getDescription(): string;
  75338. /**
  75339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75340. * @param scene defines the current scene where to apply this optimization
  75341. * @param optimizer defines the current optimizer
  75342. * @returns true if everything that can be done was applied
  75343. */
  75344. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75345. }
  75346. /**
  75347. * Defines an optimization used to turn particles off
  75348. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75349. */
  75350. export class ParticlesOptimization extends SceneOptimization {
  75351. /**
  75352. * Gets a string describing the action executed by the current optimization
  75353. * @return description string
  75354. */
  75355. getDescription(): string;
  75356. /**
  75357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75358. * @param scene defines the current scene where to apply this optimization
  75359. * @param optimizer defines the current optimizer
  75360. * @returns true if everything that can be done was applied
  75361. */
  75362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75363. }
  75364. /**
  75365. * Defines an optimization used to turn render targets off
  75366. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75367. */
  75368. export class RenderTargetsOptimization extends SceneOptimization {
  75369. /**
  75370. * Gets a string describing the action executed by the current optimization
  75371. * @return description string
  75372. */
  75373. getDescription(): string;
  75374. /**
  75375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75376. * @param scene defines the current scene where to apply this optimization
  75377. * @param optimizer defines the current optimizer
  75378. * @returns true if everything that can be done was applied
  75379. */
  75380. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75381. }
  75382. /**
  75383. * Defines an optimization used to merge meshes with compatible materials
  75384. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75385. */
  75386. export class MergeMeshesOptimization extends SceneOptimization {
  75387. private static _UpdateSelectionTree;
  75388. /**
  75389. * Gets or sets a boolean which defines if optimization octree has to be updated
  75390. */
  75391. static get UpdateSelectionTree(): boolean;
  75392. /**
  75393. * Gets or sets a boolean which defines if optimization octree has to be updated
  75394. */
  75395. static set UpdateSelectionTree(value: boolean);
  75396. /**
  75397. * Gets a string describing the action executed by the current optimization
  75398. * @return description string
  75399. */
  75400. getDescription(): string;
  75401. private _canBeMerged;
  75402. /**
  75403. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75404. * @param scene defines the current scene where to apply this optimization
  75405. * @param optimizer defines the current optimizer
  75406. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75407. * @returns true if everything that can be done was applied
  75408. */
  75409. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75410. }
  75411. /**
  75412. * Defines a list of options used by SceneOptimizer
  75413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75414. */
  75415. export class SceneOptimizerOptions {
  75416. /**
  75417. * Defines the target frame rate to reach (60 by default)
  75418. */
  75419. targetFrameRate: number;
  75420. /**
  75421. * Defines the interval between two checkes (2000ms by default)
  75422. */
  75423. trackerDuration: number;
  75424. /**
  75425. * Gets the list of optimizations to apply
  75426. */
  75427. optimizations: SceneOptimization[];
  75428. /**
  75429. * Creates a new list of options used by SceneOptimizer
  75430. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75431. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75432. */
  75433. constructor(
  75434. /**
  75435. * Defines the target frame rate to reach (60 by default)
  75436. */
  75437. targetFrameRate?: number,
  75438. /**
  75439. * Defines the interval between two checkes (2000ms by default)
  75440. */
  75441. trackerDuration?: number);
  75442. /**
  75443. * Add a new optimization
  75444. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75445. * @returns the current SceneOptimizerOptions
  75446. */
  75447. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75448. /**
  75449. * Add a new custom optimization
  75450. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75451. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75452. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75453. * @returns the current SceneOptimizerOptions
  75454. */
  75455. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75456. /**
  75457. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75458. * @param targetFrameRate defines the target frame rate (60 by default)
  75459. * @returns a SceneOptimizerOptions object
  75460. */
  75461. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75462. /**
  75463. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75464. * @param targetFrameRate defines the target frame rate (60 by default)
  75465. * @returns a SceneOptimizerOptions object
  75466. */
  75467. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75468. /**
  75469. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75470. * @param targetFrameRate defines the target frame rate (60 by default)
  75471. * @returns a SceneOptimizerOptions object
  75472. */
  75473. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75474. }
  75475. /**
  75476. * Class used to run optimizations in order to reach a target frame rate
  75477. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75478. */
  75479. export class SceneOptimizer implements IDisposable {
  75480. private _isRunning;
  75481. private _options;
  75482. private _scene;
  75483. private _currentPriorityLevel;
  75484. private _targetFrameRate;
  75485. private _trackerDuration;
  75486. private _currentFrameRate;
  75487. private _sceneDisposeObserver;
  75488. private _improvementMode;
  75489. /**
  75490. * Defines an observable called when the optimizer reaches the target frame rate
  75491. */
  75492. onSuccessObservable: Observable<SceneOptimizer>;
  75493. /**
  75494. * Defines an observable called when the optimizer enables an optimization
  75495. */
  75496. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75497. /**
  75498. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75499. */
  75500. onFailureObservable: Observable<SceneOptimizer>;
  75501. /**
  75502. * Gets a boolean indicating if the optimizer is in improvement mode
  75503. */
  75504. get isInImprovementMode(): boolean;
  75505. /**
  75506. * Gets the current priority level (0 at start)
  75507. */
  75508. get currentPriorityLevel(): number;
  75509. /**
  75510. * Gets the current frame rate checked by the SceneOptimizer
  75511. */
  75512. get currentFrameRate(): number;
  75513. /**
  75514. * Gets or sets the current target frame rate (60 by default)
  75515. */
  75516. get targetFrameRate(): number;
  75517. /**
  75518. * Gets or sets the current target frame rate (60 by default)
  75519. */
  75520. set targetFrameRate(value: number);
  75521. /**
  75522. * Gets or sets the current interval between two checks (every 2000ms by default)
  75523. */
  75524. get trackerDuration(): number;
  75525. /**
  75526. * Gets or sets the current interval between two checks (every 2000ms by default)
  75527. */
  75528. set trackerDuration(value: number);
  75529. /**
  75530. * Gets the list of active optimizations
  75531. */
  75532. get optimizations(): SceneOptimization[];
  75533. /**
  75534. * Creates a new SceneOptimizer
  75535. * @param scene defines the scene to work on
  75536. * @param options defines the options to use with the SceneOptimizer
  75537. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75538. * @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)
  75539. */
  75540. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75541. /**
  75542. * Stops the current optimizer
  75543. */
  75544. stop(): void;
  75545. /**
  75546. * Reset the optimizer to initial step (current priority level = 0)
  75547. */
  75548. reset(): void;
  75549. /**
  75550. * Start the optimizer. By default it will try to reach a specific framerate
  75551. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75552. */
  75553. start(): void;
  75554. private _checkCurrentState;
  75555. /**
  75556. * Release all resources
  75557. */
  75558. dispose(): void;
  75559. /**
  75560. * Helper function to create a SceneOptimizer with one single line of code
  75561. * @param scene defines the scene to work on
  75562. * @param options defines the options to use with the SceneOptimizer
  75563. * @param onSuccess defines a callback to call on success
  75564. * @param onFailure defines a callback to call on failure
  75565. * @returns the new SceneOptimizer object
  75566. */
  75567. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75568. }
  75569. }
  75570. declare module BABYLON {
  75571. /**
  75572. * Class used to serialize a scene into a string
  75573. */
  75574. export class SceneSerializer {
  75575. /**
  75576. * Clear cache used by a previous serialization
  75577. */
  75578. static ClearCache(): void;
  75579. /**
  75580. * Serialize a scene into a JSON compatible object
  75581. * @param scene defines the scene to serialize
  75582. * @returns a JSON compatible object
  75583. */
  75584. static Serialize(scene: Scene): any;
  75585. /**
  75586. * Serialize a mesh into a JSON compatible object
  75587. * @param toSerialize defines the mesh to serialize
  75588. * @param withParents defines if parents must be serialized as well
  75589. * @param withChildren defines if children must be serialized as well
  75590. * @returns a JSON compatible object
  75591. */
  75592. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75593. }
  75594. }
  75595. declare module BABYLON {
  75596. /**
  75597. * Class used to host texture specific utilities
  75598. */
  75599. export class TextureTools {
  75600. /**
  75601. * Uses the GPU to create a copy texture rescaled at a given size
  75602. * @param texture Texture to copy from
  75603. * @param width defines the desired width
  75604. * @param height defines the desired height
  75605. * @param useBilinearMode defines if bilinear mode has to be used
  75606. * @return the generated texture
  75607. */
  75608. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75609. }
  75610. }
  75611. declare module BABYLON {
  75612. /**
  75613. * This represents the different options available for the video capture.
  75614. */
  75615. export interface VideoRecorderOptions {
  75616. /** Defines the mime type of the video. */
  75617. mimeType: string;
  75618. /** Defines the FPS the video should be recorded at. */
  75619. fps: number;
  75620. /** Defines the chunk size for the recording data. */
  75621. recordChunckSize: number;
  75622. /** The audio tracks to attach to the recording. */
  75623. audioTracks?: MediaStreamTrack[];
  75624. }
  75625. /**
  75626. * This can help with recording videos from BabylonJS.
  75627. * This is based on the available WebRTC functionalities of the browser.
  75628. *
  75629. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75630. */
  75631. export class VideoRecorder {
  75632. private static readonly _defaultOptions;
  75633. /**
  75634. * Returns whether or not the VideoRecorder is available in your browser.
  75635. * @param engine Defines the Babylon Engine.
  75636. * @returns true if supported otherwise false.
  75637. */
  75638. static IsSupported(engine: Engine): boolean;
  75639. private readonly _options;
  75640. private _canvas;
  75641. private _mediaRecorder;
  75642. private _recordedChunks;
  75643. private _fileName;
  75644. private _resolve;
  75645. private _reject;
  75646. /**
  75647. * True when a recording is already in progress.
  75648. */
  75649. get isRecording(): boolean;
  75650. /**
  75651. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75652. * @param engine Defines the BabylonJS Engine you wish to record.
  75653. * @param options Defines options that can be used to customize the capture.
  75654. */
  75655. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75656. /**
  75657. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75658. */
  75659. stopRecording(): void;
  75660. /**
  75661. * Starts recording the canvas for a max duration specified in parameters.
  75662. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75663. * If null no automatic download will start and you can rely on the promise to get the data back.
  75664. * @param maxDuration Defines the maximum recording time in seconds.
  75665. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75666. * @return A promise callback at the end of the recording with the video data in Blob.
  75667. */
  75668. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75669. /**
  75670. * Releases internal resources used during the recording.
  75671. */
  75672. dispose(): void;
  75673. private _handleDataAvailable;
  75674. private _handleError;
  75675. private _handleStop;
  75676. }
  75677. }
  75678. declare module BABYLON {
  75679. /**
  75680. * Class containing a set of static utilities functions for screenshots
  75681. */
  75682. export class ScreenshotTools {
  75683. /**
  75684. * Captures a screenshot of the current rendering
  75685. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75686. * @param engine defines the rendering engine
  75687. * @param camera defines the source camera
  75688. * @param size This parameter can be set to a single number or to an object with the
  75689. * following (optional) properties: precision, width, height. If a single number is passed,
  75690. * it will be used for both width and height. If an object is passed, the screenshot size
  75691. * will be derived from the parameters. The precision property is a multiplier allowing
  75692. * rendering at a higher or lower resolution
  75693. * @param successCallback defines the callback receives a single parameter which contains the
  75694. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75695. * src parameter of an <img> to display it
  75696. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75697. * Check your browser for supported MIME types
  75698. */
  75699. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75700. /**
  75701. * Captures a screenshot of the current rendering
  75702. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75703. * @param engine defines the rendering engine
  75704. * @param camera defines the source camera
  75705. * @param size This parameter can be set to a single number or to an object with the
  75706. * following (optional) properties: precision, width, height. If a single number is passed,
  75707. * it will be used for both width and height. If an object is passed, the screenshot size
  75708. * will be derived from the parameters. The precision property is a multiplier allowing
  75709. * rendering at a higher or lower resolution
  75710. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75711. * Check your browser for supported MIME types
  75712. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75713. * to the src parameter of an <img> to display it
  75714. */
  75715. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75716. /**
  75717. * Generates an image screenshot from the specified camera.
  75718. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75719. * @param engine The engine to use for rendering
  75720. * @param camera The camera to use for rendering
  75721. * @param size This parameter can be set to a single number or to an object with the
  75722. * following (optional) properties: precision, width, height. If a single number is passed,
  75723. * it will be used for both width and height. If an object is passed, the screenshot size
  75724. * will be derived from the parameters. The precision property is a multiplier allowing
  75725. * rendering at a higher or lower resolution
  75726. * @param successCallback The callback receives a single parameter which contains the
  75727. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75728. * src parameter of an <img> to display it
  75729. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75730. * Check your browser for supported MIME types
  75731. * @param samples Texture samples (default: 1)
  75732. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75733. * @param fileName A name for for the downloaded file.
  75734. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75735. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75736. */
  75737. 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;
  75738. /**
  75739. * Generates an image screenshot from the specified camera.
  75740. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75741. * @param engine The engine to use for rendering
  75742. * @param camera The camera to use for rendering
  75743. * @param size This parameter can be set to a single number or to an object with the
  75744. * following (optional) properties: precision, width, height. If a single number is passed,
  75745. * it will be used for both width and height. If an object is passed, the screenshot size
  75746. * will be derived from the parameters. The precision property is a multiplier allowing
  75747. * rendering at a higher or lower resolution
  75748. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75749. * Check your browser for supported MIME types
  75750. * @param samples Texture samples (default: 1)
  75751. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75752. * @param fileName A name for for the downloaded file.
  75753. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75754. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75755. * to the src parameter of an <img> to display it
  75756. */
  75757. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75758. /**
  75759. * Gets height and width for screenshot size
  75760. * @private
  75761. */
  75762. private static _getScreenshotSize;
  75763. }
  75764. }
  75765. declare module BABYLON {
  75766. /**
  75767. * Interface for a data buffer
  75768. */
  75769. export interface IDataBuffer {
  75770. /**
  75771. * Reads bytes from the data buffer.
  75772. * @param byteOffset The byte offset to read
  75773. * @param byteLength The byte length to read
  75774. * @returns A promise that resolves when the bytes are read
  75775. */
  75776. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75777. /**
  75778. * The byte length of the buffer.
  75779. */
  75780. readonly byteLength: number;
  75781. }
  75782. /**
  75783. * Utility class for reading from a data buffer
  75784. */
  75785. export class DataReader {
  75786. /**
  75787. * The data buffer associated with this data reader.
  75788. */
  75789. readonly buffer: IDataBuffer;
  75790. /**
  75791. * The current byte offset from the beginning of the data buffer.
  75792. */
  75793. byteOffset: number;
  75794. private _dataView;
  75795. private _dataByteOffset;
  75796. /**
  75797. * Constructor
  75798. * @param buffer The buffer to read
  75799. */
  75800. constructor(buffer: IDataBuffer);
  75801. /**
  75802. * Loads the given byte length.
  75803. * @param byteLength The byte length to load
  75804. * @returns A promise that resolves when the load is complete
  75805. */
  75806. loadAsync(byteLength: number): Promise<void>;
  75807. /**
  75808. * Read a unsigned 32-bit integer from the currently loaded data range.
  75809. * @returns The 32-bit integer read
  75810. */
  75811. readUint32(): number;
  75812. /**
  75813. * Read a byte array from the currently loaded data range.
  75814. * @param byteLength The byte length to read
  75815. * @returns The byte array read
  75816. */
  75817. readUint8Array(byteLength: number): Uint8Array;
  75818. /**
  75819. * Read a string from the currently loaded data range.
  75820. * @param byteLength The byte length to read
  75821. * @returns The string read
  75822. */
  75823. readString(byteLength: number): string;
  75824. /**
  75825. * Skips the given byte length the currently loaded data range.
  75826. * @param byteLength The byte length to skip
  75827. */
  75828. skipBytes(byteLength: number): void;
  75829. }
  75830. }
  75831. declare module BABYLON {
  75832. /**
  75833. * Class for storing data to local storage if available or in-memory storage otherwise
  75834. */
  75835. export class DataStorage {
  75836. private static _Storage;
  75837. private static _GetStorage;
  75838. /**
  75839. * Reads a string from the data storage
  75840. * @param key The key to read
  75841. * @param defaultValue The value if the key doesn't exist
  75842. * @returns The string value
  75843. */
  75844. static ReadString(key: string, defaultValue: string): string;
  75845. /**
  75846. * Writes a string to the data storage
  75847. * @param key The key to write
  75848. * @param value The value to write
  75849. */
  75850. static WriteString(key: string, value: string): void;
  75851. /**
  75852. * Reads a boolean from the data storage
  75853. * @param key The key to read
  75854. * @param defaultValue The value if the key doesn't exist
  75855. * @returns The boolean value
  75856. */
  75857. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75858. /**
  75859. * Writes a boolean to the data storage
  75860. * @param key The key to write
  75861. * @param value The value to write
  75862. */
  75863. static WriteBoolean(key: string, value: boolean): void;
  75864. /**
  75865. * Reads a number from the data storage
  75866. * @param key The key to read
  75867. * @param defaultValue The value if the key doesn't exist
  75868. * @returns The number value
  75869. */
  75870. static ReadNumber(key: string, defaultValue: number): number;
  75871. /**
  75872. * Writes a number to the data storage
  75873. * @param key The key to write
  75874. * @param value The value to write
  75875. */
  75876. static WriteNumber(key: string, value: number): void;
  75877. }
  75878. }
  75879. declare module BABYLON {
  75880. /**
  75881. * Class used to record delta files between 2 scene states
  75882. */
  75883. export class SceneRecorder {
  75884. private _trackedScene;
  75885. private _savedJSON;
  75886. /**
  75887. * Track a given scene. This means the current scene state will be considered the original state
  75888. * @param scene defines the scene to track
  75889. */
  75890. track(scene: Scene): void;
  75891. /**
  75892. * Get the delta between current state and original state
  75893. * @returns a string containing the delta
  75894. */
  75895. getDelta(): any;
  75896. private _compareArray;
  75897. private _compareObjects;
  75898. private _compareCollections;
  75899. private static GetShadowGeneratorById;
  75900. /**
  75901. * Apply a given delta to a given scene
  75902. * @param deltaJSON defines the JSON containing the delta
  75903. * @param scene defines the scene to apply the delta to
  75904. */
  75905. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75906. private static _ApplyPropertiesToEntity;
  75907. private static _ApplyDeltaForEntity;
  75908. }
  75909. }
  75910. declare module BABYLON {
  75911. /**
  75912. * A 3D trajectory consisting of an order list of vectors describing a
  75913. * path of motion through 3D space.
  75914. */
  75915. export class Trajectory {
  75916. private _points;
  75917. private readonly _segmentLength;
  75918. /**
  75919. * Serialize to JSON.
  75920. * @returns serialized JSON string
  75921. */
  75922. serialize(): string;
  75923. /**
  75924. * Deserialize from JSON.
  75925. * @param json serialized JSON string
  75926. * @returns deserialized Trajectory
  75927. */
  75928. static Deserialize(json: string): Trajectory;
  75929. /**
  75930. * Create a new empty Trajectory.
  75931. * @param segmentLength radius of discretization for Trajectory points
  75932. */
  75933. constructor(segmentLength?: number);
  75934. /**
  75935. * Get the length of the Trajectory.
  75936. * @returns length of the Trajectory
  75937. */
  75938. getLength(): number;
  75939. /**
  75940. * Append a new point to the Trajectory.
  75941. * NOTE: This implementation has many allocations.
  75942. * @param point point to append to the Trajectory
  75943. */
  75944. add(point: DeepImmutable<Vector3>): void;
  75945. /**
  75946. * Create a new Trajectory with a segment length chosen to make it
  75947. * probable that the new Trajectory will have a specified number of
  75948. * segments. This operation is imprecise.
  75949. * @param targetResolution number of segments desired
  75950. * @returns new Trajectory with approximately the requested number of segments
  75951. */
  75952. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75953. /**
  75954. * Convert Trajectory segments into tokenized representation. This
  75955. * representation is an array of numbers where each nth number is the
  75956. * index of the token which is most similar to the nth segment of the
  75957. * Trajectory.
  75958. * @param tokens list of vectors which serve as discrete tokens
  75959. * @returns list of indices of most similar token per segment
  75960. */
  75961. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75962. private static _forwardDir;
  75963. private static _inverseFromVec;
  75964. private static _upDir;
  75965. private static _fromToVec;
  75966. private static _lookMatrix;
  75967. /**
  75968. * Transform the rotation (i.e., direction) of a segment to isolate
  75969. * the relative transformation represented by the segment. This operation
  75970. * may or may not succeed due to singularities in the equations that define
  75971. * motion relativity in this context.
  75972. * @param priorVec the origin of the prior segment
  75973. * @param fromVec the origin of the current segment
  75974. * @param toVec the destination of the current segment
  75975. * @param result reference to output variable
  75976. * @returns whether or not transformation was successful
  75977. */
  75978. private static _transformSegmentDirToRef;
  75979. private static _bestMatch;
  75980. private static _score;
  75981. private static _bestScore;
  75982. /**
  75983. * Determine which token vector is most similar to the
  75984. * segment vector.
  75985. * @param segment segment vector
  75986. * @param tokens token vector list
  75987. * @returns index of the most similar token to the segment
  75988. */
  75989. private static _tokenizeSegment;
  75990. }
  75991. /**
  75992. * Class representing a set of known, named trajectories to which Trajectories can be
  75993. * added and using which Trajectories can be recognized.
  75994. */
  75995. export class TrajectoryClassifier {
  75996. private _maximumAllowableMatchCost;
  75997. private _vector3Alphabet;
  75998. private _levenshteinAlphabet;
  75999. private _nameToDescribedTrajectory;
  76000. /**
  76001. * Serialize to JSON.
  76002. * @returns JSON serialization
  76003. */
  76004. serialize(): string;
  76005. /**
  76006. * Deserialize from JSON.
  76007. * @param json JSON serialization
  76008. * @returns deserialized TrajectorySet
  76009. */
  76010. static Deserialize(json: string): TrajectoryClassifier;
  76011. /**
  76012. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  76013. * VERY naive, need to be generating these things from known
  76014. * sets. Better version later, probably eliminating this one.
  76015. * @returns auto-generated TrajectorySet
  76016. */
  76017. static Generate(): TrajectoryClassifier;
  76018. private constructor();
  76019. /**
  76020. * Add a new Trajectory to the set with a given name.
  76021. * @param trajectory new Trajectory to be added
  76022. * @param classification name to which to add the Trajectory
  76023. */
  76024. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  76025. /**
  76026. * Remove a known named trajectory and all Trajectories associated with it.
  76027. * @param classification name to remove
  76028. * @returns whether anything was removed
  76029. */
  76030. deleteClassification(classification: string): boolean;
  76031. /**
  76032. * Attempt to recognize a Trajectory from among all the classifications
  76033. * already known to the classifier.
  76034. * @param trajectory Trajectory to be recognized
  76035. * @returns classification of Trajectory if recognized, null otherwise
  76036. */
  76037. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  76038. }
  76039. }
  76040. declare module BABYLON {
  76041. /**
  76042. * An interface for all Hit test features
  76043. */
  76044. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76045. /**
  76046. * Triggered when new babylon (transformed) hit test results are available
  76047. */
  76048. onHitTestResultObservable: Observable<T[]>;
  76049. }
  76050. /**
  76051. * Options used for hit testing
  76052. */
  76053. export interface IWebXRLegacyHitTestOptions {
  76054. /**
  76055. * Only test when user interacted with the scene. Default - hit test every frame
  76056. */
  76057. testOnPointerDownOnly?: boolean;
  76058. /**
  76059. * The node to use to transform the local results to world coordinates
  76060. */
  76061. worldParentNode?: TransformNode;
  76062. }
  76063. /**
  76064. * Interface defining the babylon result of raycasting/hit-test
  76065. */
  76066. export interface IWebXRLegacyHitResult {
  76067. /**
  76068. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76069. */
  76070. transformationMatrix: Matrix;
  76071. /**
  76072. * The native hit test result
  76073. */
  76074. xrHitResult: XRHitResult | XRHitTestResult;
  76075. }
  76076. /**
  76077. * The currently-working hit-test module.
  76078. * Hit test (or Ray-casting) is used to interact with the real world.
  76079. * For further information read here - https://github.com/immersive-web/hit-test
  76080. */
  76081. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76082. /**
  76083. * options to use when constructing this feature
  76084. */
  76085. readonly options: IWebXRLegacyHitTestOptions;
  76086. private _direction;
  76087. private _mat;
  76088. private _onSelectEnabled;
  76089. private _origin;
  76090. /**
  76091. * The module's name
  76092. */
  76093. static readonly Name: string;
  76094. /**
  76095. * The (Babylon) version of this module.
  76096. * This is an integer representing the implementation version.
  76097. * This number does not correspond to the WebXR specs version
  76098. */
  76099. static readonly Version: number;
  76100. /**
  76101. * Populated with the last native XR Hit Results
  76102. */
  76103. lastNativeXRHitResults: XRHitResult[];
  76104. /**
  76105. * Triggered when new babylon (transformed) hit test results are available
  76106. */
  76107. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76108. /**
  76109. * Creates a new instance of the (legacy version) hit test feature
  76110. * @param _xrSessionManager an instance of WebXRSessionManager
  76111. * @param options options to use when constructing this feature
  76112. */
  76113. constructor(_xrSessionManager: WebXRSessionManager,
  76114. /**
  76115. * options to use when constructing this feature
  76116. */
  76117. options?: IWebXRLegacyHitTestOptions);
  76118. /**
  76119. * execute a hit test with an XR Ray
  76120. *
  76121. * @param xrSession a native xrSession that will execute this hit test
  76122. * @param xrRay the ray (position and direction) to use for ray-casting
  76123. * @param referenceSpace native XR reference space to use for the hit-test
  76124. * @param filter filter function that will filter the results
  76125. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76126. */
  76127. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76128. /**
  76129. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76130. * @param event the (select) event to use to select with
  76131. * @param referenceSpace the reference space to use for this hit test
  76132. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76133. */
  76134. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76135. /**
  76136. * attach this feature
  76137. * Will usually be called by the features manager
  76138. *
  76139. * @returns true if successful.
  76140. */
  76141. attach(): boolean;
  76142. /**
  76143. * detach this feature.
  76144. * Will usually be called by the features manager
  76145. *
  76146. * @returns true if successful.
  76147. */
  76148. detach(): boolean;
  76149. /**
  76150. * Dispose this feature and all of the resources attached
  76151. */
  76152. dispose(): void;
  76153. protected _onXRFrame(frame: XRFrame): void;
  76154. private _onHitTestResults;
  76155. private _onSelect;
  76156. }
  76157. }
  76158. declare module BABYLON {
  76159. /**
  76160. * Options used for hit testing (version 2)
  76161. */
  76162. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76163. /**
  76164. * Do not create a permanent hit test. Will usually be used when only
  76165. * transient inputs are needed.
  76166. */
  76167. disablePermanentHitTest?: boolean;
  76168. /**
  76169. * Enable transient (for example touch-based) hit test inspections
  76170. */
  76171. enableTransientHitTest?: boolean;
  76172. /**
  76173. * Offset ray for the permanent hit test
  76174. */
  76175. offsetRay?: Vector3;
  76176. /**
  76177. * Offset ray for the transient hit test
  76178. */
  76179. transientOffsetRay?: Vector3;
  76180. /**
  76181. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76182. */
  76183. useReferenceSpace?: boolean;
  76184. /**
  76185. * Override the default entity type(s) of the hit-test result
  76186. */
  76187. entityTypes?: XRHitTestTrackableType[];
  76188. }
  76189. /**
  76190. * Interface defining the babylon result of hit-test
  76191. */
  76192. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76193. /**
  76194. * The input source that generated this hit test (if transient)
  76195. */
  76196. inputSource?: XRInputSource;
  76197. /**
  76198. * Is this a transient hit test
  76199. */
  76200. isTransient?: boolean;
  76201. /**
  76202. * Position of the hit test result
  76203. */
  76204. position: Vector3;
  76205. /**
  76206. * Rotation of the hit test result
  76207. */
  76208. rotationQuaternion: Quaternion;
  76209. /**
  76210. * The native hit test result
  76211. */
  76212. xrHitResult: XRHitTestResult;
  76213. }
  76214. /**
  76215. * The currently-working hit-test module.
  76216. * Hit test (or Ray-casting) is used to interact with the real world.
  76217. * For further information read here - https://github.com/immersive-web/hit-test
  76218. *
  76219. * Tested on chrome (mobile) 80.
  76220. */
  76221. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76222. /**
  76223. * options to use when constructing this feature
  76224. */
  76225. readonly options: IWebXRHitTestOptions;
  76226. private _tmpMat;
  76227. private _tmpPos;
  76228. private _tmpQuat;
  76229. private _transientXrHitTestSource;
  76230. private _xrHitTestSource;
  76231. private initHitTestSource;
  76232. /**
  76233. * The module's name
  76234. */
  76235. static readonly Name: string;
  76236. /**
  76237. * The (Babylon) version of this module.
  76238. * This is an integer representing the implementation version.
  76239. * This number does not correspond to the WebXR specs version
  76240. */
  76241. static readonly Version: number;
  76242. /**
  76243. * When set to true, each hit test will have its own position/rotation objects
  76244. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76245. * the developers will clone them or copy them as they see fit.
  76246. */
  76247. autoCloneTransformation: boolean;
  76248. /**
  76249. * Triggered when new babylon (transformed) hit test results are available
  76250. * Note - this will be called when results come back from the device. It can be an empty array!!
  76251. */
  76252. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76253. /**
  76254. * Use this to temporarily pause hit test checks.
  76255. */
  76256. paused: boolean;
  76257. /**
  76258. * Creates a new instance of the hit test feature
  76259. * @param _xrSessionManager an instance of WebXRSessionManager
  76260. * @param options options to use when constructing this feature
  76261. */
  76262. constructor(_xrSessionManager: WebXRSessionManager,
  76263. /**
  76264. * options to use when constructing this feature
  76265. */
  76266. options?: IWebXRHitTestOptions);
  76267. /**
  76268. * attach this feature
  76269. * Will usually be called by the features manager
  76270. *
  76271. * @returns true if successful.
  76272. */
  76273. attach(): boolean;
  76274. /**
  76275. * detach this feature.
  76276. * Will usually be called by the features manager
  76277. *
  76278. * @returns true if successful.
  76279. */
  76280. detach(): boolean;
  76281. /**
  76282. * Dispose this feature and all of the resources attached
  76283. */
  76284. dispose(): void;
  76285. protected _onXRFrame(frame: XRFrame): void;
  76286. private _processWebXRHitTestResult;
  76287. }
  76288. }
  76289. declare module BABYLON {
  76290. /**
  76291. * Configuration options of the anchor system
  76292. */
  76293. export interface IWebXRAnchorSystemOptions {
  76294. /**
  76295. * a node that will be used to convert local to world coordinates
  76296. */
  76297. worldParentNode?: TransformNode;
  76298. /**
  76299. * If set to true a reference of the created anchors will be kept until the next session starts
  76300. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76301. */
  76302. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76303. }
  76304. /**
  76305. * A babylon container for an XR Anchor
  76306. */
  76307. export interface IWebXRAnchor {
  76308. /**
  76309. * A babylon-assigned ID for this anchor
  76310. */
  76311. id: number;
  76312. /**
  76313. * Transformation matrix to apply to an object attached to this anchor
  76314. */
  76315. transformationMatrix: Matrix;
  76316. /**
  76317. * The native anchor object
  76318. */
  76319. xrAnchor: XRAnchor;
  76320. /**
  76321. * if defined, this object will be constantly updated by the anchor's position and rotation
  76322. */
  76323. attachedNode?: TransformNode;
  76324. /**
  76325. * Remove this anchor from the scene
  76326. */
  76327. remove(): void;
  76328. }
  76329. /**
  76330. * An implementation of the anchor system for WebXR.
  76331. * For further information see https://github.com/immersive-web/anchors/
  76332. */
  76333. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76334. private _options;
  76335. private _lastFrameDetected;
  76336. private _trackedAnchors;
  76337. private _referenceSpaceForFrameAnchors;
  76338. private _futureAnchors;
  76339. /**
  76340. * The module's name
  76341. */
  76342. static readonly Name: string;
  76343. /**
  76344. * The (Babylon) version of this module.
  76345. * This is an integer representing the implementation version.
  76346. * This number does not correspond to the WebXR specs version
  76347. */
  76348. static readonly Version: number;
  76349. /**
  76350. * Observers registered here will be executed when a new anchor was added to the session
  76351. */
  76352. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76353. /**
  76354. * Observers registered here will be executed when an anchor was removed from the session
  76355. */
  76356. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76357. /**
  76358. * Observers registered here will be executed when an existing anchor updates
  76359. * This can execute N times every frame
  76360. */
  76361. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76362. /**
  76363. * Set the reference space to use for anchor creation, when not using a hit test.
  76364. * Will default to the session's reference space if not defined
  76365. */
  76366. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76367. /**
  76368. * constructs a new anchor system
  76369. * @param _xrSessionManager an instance of WebXRSessionManager
  76370. * @param _options configuration object for this feature
  76371. */
  76372. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76373. private _tmpVector;
  76374. private _tmpQuaternion;
  76375. private _populateTmpTransformation;
  76376. /**
  76377. * Create a new anchor point using a hit test result at a specific point in the scene
  76378. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76379. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76380. *
  76381. * @param hitTestResult The hit test result to use for this anchor creation
  76382. * @param position an optional position offset for this anchor
  76383. * @param rotationQuaternion an optional rotation offset for this anchor
  76384. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76385. */
  76386. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76387. /**
  76388. * Add a new anchor at a specific position and rotation
  76389. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76390. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76391. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76392. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76393. *
  76394. * @param position the position in which to add an anchor
  76395. * @param rotationQuaternion an optional rotation for the anchor transformation
  76396. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76397. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76398. */
  76399. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76400. /**
  76401. * Get the list of anchors currently being tracked by the system
  76402. */
  76403. get anchors(): IWebXRAnchor[];
  76404. /**
  76405. * detach this feature.
  76406. * Will usually be called by the features manager
  76407. *
  76408. * @returns true if successful.
  76409. */
  76410. detach(): boolean;
  76411. /**
  76412. * Dispose this feature and all of the resources attached
  76413. */
  76414. dispose(): void;
  76415. protected _onXRFrame(frame: XRFrame): void;
  76416. /**
  76417. * avoiding using Array.find for global support.
  76418. * @param xrAnchor the plane to find in the array
  76419. */
  76420. private _findIndexInAnchorArray;
  76421. private _updateAnchorWithXRFrame;
  76422. private _createAnchorAtTransformation;
  76423. }
  76424. }
  76425. declare module BABYLON {
  76426. /**
  76427. * Options used in the plane detector module
  76428. */
  76429. export interface IWebXRPlaneDetectorOptions {
  76430. /**
  76431. * The node to use to transform the local results to world coordinates
  76432. */
  76433. worldParentNode?: TransformNode;
  76434. /**
  76435. * If set to true a reference of the created planes will be kept until the next session starts
  76436. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76437. */
  76438. doNotRemovePlanesOnSessionEnded?: boolean;
  76439. }
  76440. /**
  76441. * A babylon interface for a WebXR plane.
  76442. * A Plane is actually a polygon, built from N points in space
  76443. *
  76444. * Supported in chrome 79, not supported in canary 81 ATM
  76445. */
  76446. export interface IWebXRPlane {
  76447. /**
  76448. * a babylon-assigned ID for this polygon
  76449. */
  76450. id: number;
  76451. /**
  76452. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76453. */
  76454. polygonDefinition: Array<Vector3>;
  76455. /**
  76456. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76457. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76458. */
  76459. transformationMatrix: Matrix;
  76460. /**
  76461. * the native xr-plane object
  76462. */
  76463. xrPlane: XRPlane;
  76464. }
  76465. /**
  76466. * The plane detector is used to detect planes in the real world when in AR
  76467. * For more information see https://github.com/immersive-web/real-world-geometry/
  76468. */
  76469. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76470. private _options;
  76471. private _detectedPlanes;
  76472. private _enabled;
  76473. private _lastFrameDetected;
  76474. /**
  76475. * The module's name
  76476. */
  76477. static readonly Name: string;
  76478. /**
  76479. * The (Babylon) version of this module.
  76480. * This is an integer representing the implementation version.
  76481. * This number does not correspond to the WebXR specs version
  76482. */
  76483. static readonly Version: number;
  76484. /**
  76485. * Observers registered here will be executed when a new plane was added to the session
  76486. */
  76487. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76488. /**
  76489. * Observers registered here will be executed when a plane is no longer detected in the session
  76490. */
  76491. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76492. /**
  76493. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76494. * This can execute N times every frame
  76495. */
  76496. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76497. /**
  76498. * construct a new Plane Detector
  76499. * @param _xrSessionManager an instance of xr Session manager
  76500. * @param _options configuration to use when constructing this feature
  76501. */
  76502. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76503. /**
  76504. * detach this feature.
  76505. * Will usually be called by the features manager
  76506. *
  76507. * @returns true if successful.
  76508. */
  76509. detach(): boolean;
  76510. /**
  76511. * Dispose this feature and all of the resources attached
  76512. */
  76513. dispose(): void;
  76514. /**
  76515. * Check if the needed objects are defined.
  76516. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76517. */
  76518. isCompatible(): boolean;
  76519. protected _onXRFrame(frame: XRFrame): void;
  76520. private _init;
  76521. private _updatePlaneWithXRPlane;
  76522. /**
  76523. * avoiding using Array.find for global support.
  76524. * @param xrPlane the plane to find in the array
  76525. */
  76526. private findIndexInPlaneArray;
  76527. }
  76528. }
  76529. declare module BABYLON {
  76530. /**
  76531. * Options interface for the background remover plugin
  76532. */
  76533. export interface IWebXRBackgroundRemoverOptions {
  76534. /**
  76535. * Further background meshes to disable when entering AR
  76536. */
  76537. backgroundMeshes?: AbstractMesh[];
  76538. /**
  76539. * flags to configure the removal of the environment helper.
  76540. * If not set, the entire background will be removed. If set, flags should be set as well.
  76541. */
  76542. environmentHelperRemovalFlags?: {
  76543. /**
  76544. * Should the skybox be removed (default false)
  76545. */
  76546. skyBox?: boolean;
  76547. /**
  76548. * Should the ground be removed (default false)
  76549. */
  76550. ground?: boolean;
  76551. };
  76552. /**
  76553. * don't disable the environment helper
  76554. */
  76555. ignoreEnvironmentHelper?: boolean;
  76556. }
  76557. /**
  76558. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76559. */
  76560. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76561. /**
  76562. * read-only options to be used in this module
  76563. */
  76564. readonly options: IWebXRBackgroundRemoverOptions;
  76565. /**
  76566. * The module's name
  76567. */
  76568. static readonly Name: string;
  76569. /**
  76570. * The (Babylon) version of this module.
  76571. * This is an integer representing the implementation version.
  76572. * This number does not correspond to the WebXR specs version
  76573. */
  76574. static readonly Version: number;
  76575. /**
  76576. * registered observers will be triggered when the background state changes
  76577. */
  76578. onBackgroundStateChangedObservable: Observable<boolean>;
  76579. /**
  76580. * constructs a new background remover module
  76581. * @param _xrSessionManager the session manager for this module
  76582. * @param options read-only options to be used in this module
  76583. */
  76584. constructor(_xrSessionManager: WebXRSessionManager,
  76585. /**
  76586. * read-only options to be used in this module
  76587. */
  76588. options?: IWebXRBackgroundRemoverOptions);
  76589. /**
  76590. * attach this feature
  76591. * Will usually be called by the features manager
  76592. *
  76593. * @returns true if successful.
  76594. */
  76595. attach(): boolean;
  76596. /**
  76597. * detach this feature.
  76598. * Will usually be called by the features manager
  76599. *
  76600. * @returns true if successful.
  76601. */
  76602. detach(): boolean;
  76603. /**
  76604. * Dispose this feature and all of the resources attached
  76605. */
  76606. dispose(): void;
  76607. protected _onXRFrame(_xrFrame: XRFrame): void;
  76608. private _setBackgroundState;
  76609. }
  76610. }
  76611. declare module BABYLON {
  76612. /**
  76613. * Options for the controller physics feature
  76614. */
  76615. export class IWebXRControllerPhysicsOptions {
  76616. /**
  76617. * Should the headset get its own impostor
  76618. */
  76619. enableHeadsetImpostor?: boolean;
  76620. /**
  76621. * Optional parameters for the headset impostor
  76622. */
  76623. headsetImpostorParams?: {
  76624. /**
  76625. * The type of impostor to create. Default is sphere
  76626. */
  76627. impostorType: number;
  76628. /**
  76629. * the size of the impostor. Defaults to 10cm
  76630. */
  76631. impostorSize?: number | {
  76632. width: number;
  76633. height: number;
  76634. depth: number;
  76635. };
  76636. /**
  76637. * Friction definitions
  76638. */
  76639. friction?: number;
  76640. /**
  76641. * Restitution
  76642. */
  76643. restitution?: number;
  76644. };
  76645. /**
  76646. * The physics properties of the future impostors
  76647. */
  76648. physicsProperties?: {
  76649. /**
  76650. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76651. * Note that this requires a physics engine that supports mesh impostors!
  76652. */
  76653. useControllerMesh?: boolean;
  76654. /**
  76655. * The type of impostor to create. Default is sphere
  76656. */
  76657. impostorType?: number;
  76658. /**
  76659. * the size of the impostor. Defaults to 10cm
  76660. */
  76661. impostorSize?: number | {
  76662. width: number;
  76663. height: number;
  76664. depth: number;
  76665. };
  76666. /**
  76667. * Friction definitions
  76668. */
  76669. friction?: number;
  76670. /**
  76671. * Restitution
  76672. */
  76673. restitution?: number;
  76674. };
  76675. /**
  76676. * the xr input to use with this pointer selection
  76677. */
  76678. xrInput: WebXRInput;
  76679. }
  76680. /**
  76681. * Add physics impostor to your webxr controllers,
  76682. * including naive calculation of their linear and angular velocity
  76683. */
  76684. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76685. private readonly _options;
  76686. private _attachController;
  76687. private _controllers;
  76688. private _debugMode;
  76689. private _delta;
  76690. private _headsetImpostor?;
  76691. private _headsetMesh?;
  76692. private _lastTimestamp;
  76693. private _tmpQuaternion;
  76694. private _tmpVector;
  76695. /**
  76696. * The module's name
  76697. */
  76698. static readonly Name: string;
  76699. /**
  76700. * The (Babylon) version of this module.
  76701. * This is an integer representing the implementation version.
  76702. * This number does not correspond to the webxr specs version
  76703. */
  76704. static readonly Version: number;
  76705. /**
  76706. * Construct a new Controller Physics Feature
  76707. * @param _xrSessionManager the corresponding xr session manager
  76708. * @param _options options to create this feature with
  76709. */
  76710. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76711. /**
  76712. * @hidden
  76713. * enable debugging - will show console outputs and the impostor mesh
  76714. */
  76715. _enablePhysicsDebug(): void;
  76716. /**
  76717. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76718. * @param xrController the controller to add
  76719. */
  76720. addController(xrController: WebXRInputSource): void;
  76721. /**
  76722. * attach this feature
  76723. * Will usually be called by the features manager
  76724. *
  76725. * @returns true if successful.
  76726. */
  76727. attach(): boolean;
  76728. /**
  76729. * detach this feature.
  76730. * Will usually be called by the features manager
  76731. *
  76732. * @returns true if successful.
  76733. */
  76734. detach(): boolean;
  76735. /**
  76736. * Get the headset impostor, if enabled
  76737. * @returns the impostor
  76738. */
  76739. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76740. /**
  76741. * Get the physics impostor of a specific controller.
  76742. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76743. * @param controller the controller or the controller id of which to get the impostor
  76744. * @returns the impostor or null
  76745. */
  76746. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76747. /**
  76748. * Update the physics properties provided in the constructor
  76749. * @param newProperties the new properties object
  76750. */
  76751. setPhysicsProperties(newProperties: {
  76752. impostorType?: number;
  76753. impostorSize?: number | {
  76754. width: number;
  76755. height: number;
  76756. depth: number;
  76757. };
  76758. friction?: number;
  76759. restitution?: number;
  76760. }): void;
  76761. protected _onXRFrame(_xrFrame: any): void;
  76762. private _detachController;
  76763. }
  76764. }
  76765. declare module BABYLON {
  76766. /**
  76767. * A babylon interface for a "WebXR" feature point.
  76768. * Represents the position and confidence value of a given feature point.
  76769. */
  76770. export interface IWebXRFeaturePoint {
  76771. /**
  76772. * Represents the position of the feature point in world space.
  76773. */
  76774. position: Vector3;
  76775. /**
  76776. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76777. */
  76778. confidenceValue: number;
  76779. }
  76780. /**
  76781. * The feature point system is used to detect feature points from real world geometry.
  76782. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76783. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76784. */
  76785. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76786. private _enabled;
  76787. private _featurePointCloud;
  76788. /**
  76789. * The module's name
  76790. */
  76791. static readonly Name: string;
  76792. /**
  76793. * The (Babylon) version of this module.
  76794. * This is an integer representing the implementation version.
  76795. * This number does not correspond to the WebXR specs version
  76796. */
  76797. static readonly Version: number;
  76798. /**
  76799. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76800. * Will notify the observers about which feature points have been added.
  76801. */
  76802. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76803. /**
  76804. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76805. * Will notify the observers about which feature points have been updated.
  76806. */
  76807. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76808. /**
  76809. * The current feature point cloud maintained across frames.
  76810. */
  76811. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76812. /**
  76813. * construct the feature point system
  76814. * @param _xrSessionManager an instance of xr Session manager
  76815. */
  76816. constructor(_xrSessionManager: WebXRSessionManager);
  76817. /**
  76818. * Detach this feature.
  76819. * Will usually be called by the features manager
  76820. *
  76821. * @returns true if successful.
  76822. */
  76823. detach(): boolean;
  76824. /**
  76825. * Dispose this feature and all of the resources attached
  76826. */
  76827. dispose(): void;
  76828. /**
  76829. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76830. */
  76831. protected _onXRFrame(frame: XRFrame): void;
  76832. /**
  76833. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76834. */
  76835. private _init;
  76836. }
  76837. }
  76838. declare module BABYLON {
  76839. /**
  76840. * Configuration interface for the hand tracking feature
  76841. */
  76842. export interface IWebXRHandTrackingOptions {
  76843. /**
  76844. * The xrInput that will be used as source for new hands
  76845. */
  76846. xrInput: WebXRInput;
  76847. /**
  76848. * Configuration object for the joint meshes
  76849. */
  76850. jointMeshes?: {
  76851. /**
  76852. * Should the meshes created be invisible (defaults to false)
  76853. */
  76854. invisible?: boolean;
  76855. /**
  76856. * A source mesh to be used to create instances. Defaults to a sphere.
  76857. * This mesh will be the source for all other (25) meshes.
  76858. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76859. */
  76860. sourceMesh?: Mesh;
  76861. /**
  76862. * This function will be called after a mesh was created for a specific joint.
  76863. * Using this function you can either manipulate the instance or return a new mesh.
  76864. * When returning a new mesh the instance created before will be disposed
  76865. */
  76866. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76867. /**
  76868. * Should the source mesh stay visible. Defaults to false
  76869. */
  76870. keepOriginalVisible?: boolean;
  76871. /**
  76872. * Scale factor for all instances (defaults to 2)
  76873. */
  76874. scaleFactor?: number;
  76875. /**
  76876. * Should each instance have its own physics impostor
  76877. */
  76878. enablePhysics?: boolean;
  76879. /**
  76880. * If enabled, override default physics properties
  76881. */
  76882. physicsProps?: {
  76883. friction?: number;
  76884. restitution?: number;
  76885. impostorType?: number;
  76886. };
  76887. /**
  76888. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  76889. */
  76890. disableDefaultHandMesh?: boolean;
  76891. /**
  76892. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  76893. */
  76894. handMeshes?: {
  76895. right: AbstractMesh;
  76896. left: AbstractMesh;
  76897. };
  76898. /**
  76899. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  76900. */
  76901. rigMapping?: {
  76902. right: string[];
  76903. left: string[];
  76904. };
  76905. };
  76906. }
  76907. /**
  76908. * Parts of the hands divided to writs and finger names
  76909. */
  76910. export const enum HandPart {
  76911. /**
  76912. * HandPart - Wrist
  76913. */
  76914. WRIST = "wrist",
  76915. /**
  76916. * HandPart - The THumb
  76917. */
  76918. THUMB = "thumb",
  76919. /**
  76920. * HandPart - Index finger
  76921. */
  76922. INDEX = "index",
  76923. /**
  76924. * HandPart - Middle finger
  76925. */
  76926. MIDDLE = "middle",
  76927. /**
  76928. * HandPart - Ring finger
  76929. */
  76930. RING = "ring",
  76931. /**
  76932. * HandPart - Little finger
  76933. */
  76934. LITTLE = "little"
  76935. }
  76936. /**
  76937. * Representing a single hand (with its corresponding native XRHand object)
  76938. */
  76939. export class WebXRHand implements IDisposable {
  76940. /** the controller to which the hand correlates */
  76941. readonly xrController: WebXRInputSource;
  76942. /** the meshes to be used to track the hand joints */
  76943. readonly trackedMeshes: AbstractMesh[];
  76944. private _handMesh?;
  76945. private _rigMapping?;
  76946. private _scene;
  76947. private _defaultHandMesh;
  76948. private _transformNodeMapping;
  76949. /**
  76950. * Hand-parts definition (key is HandPart)
  76951. */
  76952. handPartsDefinition: {
  76953. [key: string]: number[];
  76954. };
  76955. /**
  76956. * Populate the HandPartsDefinition object.
  76957. * This is called as a side effect since certain browsers don't have XRHand defined.
  76958. */
  76959. private generateHandPartsDefinition;
  76960. /**
  76961. * Construct a new hand object
  76962. * @param xrController the controller to which the hand correlates
  76963. * @param trackedMeshes the meshes to be used to track the hand joints
  76964. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  76965. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  76966. * @param disableDefaultHandMesh should the default mesh creation be disabled
  76967. */
  76968. constructor(
  76969. /** the controller to which the hand correlates */
  76970. xrController: WebXRInputSource,
  76971. /** the meshes to be used to track the hand joints */
  76972. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  76973. /**
  76974. * Update this hand from the latest xr frame
  76975. * @param xrFrame xrFrame to update from
  76976. * @param referenceSpace The current viewer reference space
  76977. * @param scaleFactor optional scale factor for the meshes
  76978. */
  76979. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76980. /**
  76981. * Get meshes of part of the hand
  76982. * @param part the part of hand to get
  76983. * @returns An array of meshes that correlate to the hand part requested
  76984. */
  76985. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76986. /**
  76987. * Dispose this Hand object
  76988. */
  76989. dispose(): void;
  76990. private _generateDefaultHandMesh;
  76991. }
  76992. /**
  76993. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76994. */
  76995. export class WebXRHandTracking extends WebXRAbstractFeature {
  76996. /**
  76997. * options to use when constructing this feature
  76998. */
  76999. readonly options: IWebXRHandTrackingOptions;
  77000. private static _idCounter;
  77001. /**
  77002. * The module's name
  77003. */
  77004. static readonly Name: string;
  77005. /**
  77006. * The (Babylon) version of this module.
  77007. * This is an integer representing the implementation version.
  77008. * This number does not correspond to the WebXR specs version
  77009. */
  77010. static readonly Version: number;
  77011. /**
  77012. * This observable will notify registered observers when a new hand object was added and initialized
  77013. */
  77014. onHandAddedObservable: Observable<WebXRHand>;
  77015. /**
  77016. * This observable will notify its observers right before the hand object is disposed
  77017. */
  77018. onHandRemovedObservable: Observable<WebXRHand>;
  77019. private _hands;
  77020. /**
  77021. * Creates a new instance of the hit test feature
  77022. * @param _xrSessionManager an instance of WebXRSessionManager
  77023. * @param options options to use when constructing this feature
  77024. */
  77025. constructor(_xrSessionManager: WebXRSessionManager,
  77026. /**
  77027. * options to use when constructing this feature
  77028. */
  77029. options: IWebXRHandTrackingOptions);
  77030. /**
  77031. * Check if the needed objects are defined.
  77032. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  77033. */
  77034. isCompatible(): boolean;
  77035. /**
  77036. * attach this feature
  77037. * Will usually be called by the features manager
  77038. *
  77039. * @returns true if successful.
  77040. */
  77041. attach(): boolean;
  77042. /**
  77043. * detach this feature.
  77044. * Will usually be called by the features manager
  77045. *
  77046. * @returns true if successful.
  77047. */
  77048. detach(): boolean;
  77049. /**
  77050. * Dispose this feature and all of the resources attached
  77051. */
  77052. dispose(): void;
  77053. /**
  77054. * Get the hand object according to the controller id
  77055. * @param controllerId the controller id to which we want to get the hand
  77056. * @returns null if not found or the WebXRHand object if found
  77057. */
  77058. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  77059. /**
  77060. * Get a hand object according to the requested handedness
  77061. * @param handedness the handedness to request
  77062. * @returns null if not found or the WebXRHand object if found
  77063. */
  77064. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  77065. protected _onXRFrame(_xrFrame: XRFrame): void;
  77066. private _attachHand;
  77067. private _detachHand;
  77068. }
  77069. }
  77070. declare module BABYLON {
  77071. /**
  77072. * The motion controller class for all microsoft mixed reality controllers
  77073. */
  77074. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77075. protected readonly _mapping: {
  77076. defaultButton: {
  77077. valueNodeName: string;
  77078. unpressedNodeName: string;
  77079. pressedNodeName: string;
  77080. };
  77081. defaultAxis: {
  77082. valueNodeName: string;
  77083. minNodeName: string;
  77084. maxNodeName: string;
  77085. };
  77086. buttons: {
  77087. "xr-standard-trigger": {
  77088. rootNodeName: string;
  77089. componentProperty: string;
  77090. states: string[];
  77091. };
  77092. "xr-standard-squeeze": {
  77093. rootNodeName: string;
  77094. componentProperty: string;
  77095. states: string[];
  77096. };
  77097. "xr-standard-touchpad": {
  77098. rootNodeName: string;
  77099. labelAnchorNodeName: string;
  77100. touchPointNodeName: string;
  77101. };
  77102. "xr-standard-thumbstick": {
  77103. rootNodeName: string;
  77104. componentProperty: string;
  77105. states: string[];
  77106. };
  77107. };
  77108. axes: {
  77109. "xr-standard-touchpad": {
  77110. "x-axis": {
  77111. rootNodeName: string;
  77112. };
  77113. "y-axis": {
  77114. rootNodeName: string;
  77115. };
  77116. };
  77117. "xr-standard-thumbstick": {
  77118. "x-axis": {
  77119. rootNodeName: string;
  77120. };
  77121. "y-axis": {
  77122. rootNodeName: string;
  77123. };
  77124. };
  77125. };
  77126. };
  77127. /**
  77128. * The base url used to load the left and right controller models
  77129. */
  77130. static MODEL_BASE_URL: string;
  77131. /**
  77132. * The name of the left controller model file
  77133. */
  77134. static MODEL_LEFT_FILENAME: string;
  77135. /**
  77136. * The name of the right controller model file
  77137. */
  77138. static MODEL_RIGHT_FILENAME: string;
  77139. profileId: string;
  77140. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77141. protected _getFilenameAndPath(): {
  77142. filename: string;
  77143. path: string;
  77144. };
  77145. protected _getModelLoadingConstraints(): boolean;
  77146. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77147. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77148. protected _updateModel(): void;
  77149. }
  77150. }
  77151. declare module BABYLON {
  77152. /**
  77153. * The motion controller class for oculus touch (quest, rift).
  77154. * This class supports legacy mapping as well the standard xr mapping
  77155. */
  77156. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77157. private _forceLegacyControllers;
  77158. private _modelRootNode;
  77159. /**
  77160. * The base url used to load the left and right controller models
  77161. */
  77162. static MODEL_BASE_URL: string;
  77163. /**
  77164. * The name of the left controller model file
  77165. */
  77166. static MODEL_LEFT_FILENAME: string;
  77167. /**
  77168. * The name of the right controller model file
  77169. */
  77170. static MODEL_RIGHT_FILENAME: string;
  77171. /**
  77172. * Base Url for the Quest controller model.
  77173. */
  77174. static QUEST_MODEL_BASE_URL: string;
  77175. profileId: string;
  77176. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77177. protected _getFilenameAndPath(): {
  77178. filename: string;
  77179. path: string;
  77180. };
  77181. protected _getModelLoadingConstraints(): boolean;
  77182. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77183. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77184. protected _updateModel(): void;
  77185. /**
  77186. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77187. * between the touch and touch 2.
  77188. */
  77189. private _isQuest;
  77190. }
  77191. }
  77192. declare module BABYLON {
  77193. /**
  77194. * The motion controller class for the standard HTC-Vive controllers
  77195. */
  77196. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77197. private _modelRootNode;
  77198. /**
  77199. * The base url used to load the left and right controller models
  77200. */
  77201. static MODEL_BASE_URL: string;
  77202. /**
  77203. * File name for the controller model.
  77204. */
  77205. static MODEL_FILENAME: string;
  77206. profileId: string;
  77207. /**
  77208. * Create a new Vive motion controller object
  77209. * @param scene the scene to use to create this controller
  77210. * @param gamepadObject the corresponding gamepad object
  77211. * @param handedness the handedness of the controller
  77212. */
  77213. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77214. protected _getFilenameAndPath(): {
  77215. filename: string;
  77216. path: string;
  77217. };
  77218. protected _getModelLoadingConstraints(): boolean;
  77219. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77220. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77221. protected _updateModel(): void;
  77222. }
  77223. }
  77224. declare module BABYLON {
  77225. /**
  77226. * A cursor which tracks a point on a path
  77227. */
  77228. export class PathCursor {
  77229. private path;
  77230. /**
  77231. * Stores path cursor callbacks for when an onchange event is triggered
  77232. */
  77233. private _onchange;
  77234. /**
  77235. * The value of the path cursor
  77236. */
  77237. value: number;
  77238. /**
  77239. * The animation array of the path cursor
  77240. */
  77241. animations: Animation[];
  77242. /**
  77243. * Initializes the path cursor
  77244. * @param path The path to track
  77245. */
  77246. constructor(path: Path2);
  77247. /**
  77248. * Gets the cursor point on the path
  77249. * @returns A point on the path cursor at the cursor location
  77250. */
  77251. getPoint(): Vector3;
  77252. /**
  77253. * Moves the cursor ahead by the step amount
  77254. * @param step The amount to move the cursor forward
  77255. * @returns This path cursor
  77256. */
  77257. moveAhead(step?: number): PathCursor;
  77258. /**
  77259. * Moves the cursor behind by the step amount
  77260. * @param step The amount to move the cursor back
  77261. * @returns This path cursor
  77262. */
  77263. moveBack(step?: number): PathCursor;
  77264. /**
  77265. * Moves the cursor by the step amount
  77266. * If the step amount is greater than one, an exception is thrown
  77267. * @param step The amount to move the cursor
  77268. * @returns This path cursor
  77269. */
  77270. move(step: number): PathCursor;
  77271. /**
  77272. * Ensures that the value is limited between zero and one
  77273. * @returns This path cursor
  77274. */
  77275. private ensureLimits;
  77276. /**
  77277. * Runs onchange callbacks on change (used by the animation engine)
  77278. * @returns This path cursor
  77279. */
  77280. private raiseOnChange;
  77281. /**
  77282. * Executes a function on change
  77283. * @param f A path cursor onchange callback
  77284. * @returns This path cursor
  77285. */
  77286. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77287. }
  77288. }
  77289. declare module BABYLON {
  77290. /** @hidden */
  77291. export var blurPixelShader: {
  77292. name: string;
  77293. shader: string;
  77294. };
  77295. }
  77296. declare module BABYLON {
  77297. /** @hidden */
  77298. export var pointCloudVertexDeclaration: {
  77299. name: string;
  77300. shader: string;
  77301. };
  77302. }
  77303. // Mixins
  77304. interface Window {
  77305. mozIndexedDB: IDBFactory;
  77306. webkitIndexedDB: IDBFactory;
  77307. msIndexedDB: IDBFactory;
  77308. webkitURL: typeof URL;
  77309. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77310. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77311. WebGLRenderingContext: WebGLRenderingContext;
  77312. MSGesture: MSGesture;
  77313. CANNON: any;
  77314. AudioContext: AudioContext;
  77315. webkitAudioContext: AudioContext;
  77316. PointerEvent: any;
  77317. Math: Math;
  77318. Uint8Array: Uint8ArrayConstructor;
  77319. Float32Array: Float32ArrayConstructor;
  77320. mozURL: typeof URL;
  77321. msURL: typeof URL;
  77322. VRFrameData: any; // WebVR, from specs 1.1
  77323. DracoDecoderModule: any;
  77324. setImmediate(handler: (...args: any[]) => void): number;
  77325. }
  77326. interface HTMLCanvasElement {
  77327. requestPointerLock(): void;
  77328. msRequestPointerLock?(): void;
  77329. mozRequestPointerLock?(): void;
  77330. webkitRequestPointerLock?(): void;
  77331. /** Track wether a record is in progress */
  77332. isRecording: boolean;
  77333. /** Capture Stream method defined by some browsers */
  77334. captureStream(fps?: number): MediaStream;
  77335. }
  77336. interface CanvasRenderingContext2D {
  77337. msImageSmoothingEnabled: boolean;
  77338. }
  77339. interface MouseEvent {
  77340. mozMovementX: number;
  77341. mozMovementY: number;
  77342. webkitMovementX: number;
  77343. webkitMovementY: number;
  77344. msMovementX: number;
  77345. msMovementY: number;
  77346. }
  77347. interface Navigator {
  77348. mozGetVRDevices: (any: any) => any;
  77349. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77350. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77351. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77352. webkitGetGamepads(): Gamepad[];
  77353. msGetGamepads(): Gamepad[];
  77354. webkitGamepads(): Gamepad[];
  77355. }
  77356. interface HTMLVideoElement {
  77357. mozSrcObject: any;
  77358. }
  77359. interface Math {
  77360. fround(x: number): number;
  77361. imul(a: number, b: number): number;
  77362. }
  77363. interface WebGLRenderingContext {
  77364. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77365. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77366. vertexAttribDivisor(index: number, divisor: number): void;
  77367. createVertexArray(): any;
  77368. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77369. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77370. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77371. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77372. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77373. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77374. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77375. // Queries
  77376. createQuery(): WebGLQuery;
  77377. deleteQuery(query: WebGLQuery): void;
  77378. beginQuery(target: number, query: WebGLQuery): void;
  77379. endQuery(target: number): void;
  77380. getQueryParameter(query: WebGLQuery, pname: number): any;
  77381. getQuery(target: number, pname: number): any;
  77382. MAX_SAMPLES: number;
  77383. RGBA8: number;
  77384. READ_FRAMEBUFFER: number;
  77385. DRAW_FRAMEBUFFER: number;
  77386. UNIFORM_BUFFER: number;
  77387. HALF_FLOAT_OES: number;
  77388. RGBA16F: number;
  77389. RGBA32F: number;
  77390. R32F: number;
  77391. RG32F: number;
  77392. RGB32F: number;
  77393. R16F: number;
  77394. RG16F: number;
  77395. RGB16F: number;
  77396. RED: number;
  77397. RG: number;
  77398. R8: number;
  77399. RG8: number;
  77400. UNSIGNED_INT_24_8: number;
  77401. DEPTH24_STENCIL8: number;
  77402. MIN: number;
  77403. MAX: number;
  77404. /* Multiple Render Targets */
  77405. drawBuffers(buffers: number[]): void;
  77406. readBuffer(src: number): void;
  77407. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77408. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77409. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77410. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77411. // Occlusion Query
  77412. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77413. ANY_SAMPLES_PASSED: number;
  77414. QUERY_RESULT_AVAILABLE: number;
  77415. QUERY_RESULT: number;
  77416. }
  77417. interface WebGLProgram {
  77418. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77419. }
  77420. interface EXT_disjoint_timer_query {
  77421. QUERY_COUNTER_BITS_EXT: number;
  77422. TIME_ELAPSED_EXT: number;
  77423. TIMESTAMP_EXT: number;
  77424. GPU_DISJOINT_EXT: number;
  77425. QUERY_RESULT_EXT: number;
  77426. QUERY_RESULT_AVAILABLE_EXT: number;
  77427. queryCounterEXT(query: WebGLQuery, target: number): void;
  77428. createQueryEXT(): WebGLQuery;
  77429. beginQueryEXT(target: number, query: WebGLQuery): void;
  77430. endQueryEXT(target: number): void;
  77431. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77432. deleteQueryEXT(query: WebGLQuery): void;
  77433. }
  77434. interface WebGLUniformLocation {
  77435. _currentState: any;
  77436. }
  77437. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77438. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77439. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77440. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77441. interface WebGLRenderingContext {
  77442. readonly RASTERIZER_DISCARD: number;
  77443. readonly DEPTH_COMPONENT24: number;
  77444. readonly TEXTURE_3D: number;
  77445. readonly TEXTURE_2D_ARRAY: number;
  77446. readonly TEXTURE_COMPARE_FUNC: number;
  77447. readonly TEXTURE_COMPARE_MODE: number;
  77448. readonly COMPARE_REF_TO_TEXTURE: number;
  77449. readonly TEXTURE_WRAP_R: number;
  77450. readonly HALF_FLOAT: number;
  77451. readonly RGB8: number;
  77452. readonly RED_INTEGER: number;
  77453. readonly RG_INTEGER: number;
  77454. readonly RGB_INTEGER: number;
  77455. readonly RGBA_INTEGER: number;
  77456. readonly R8_SNORM: number;
  77457. readonly RG8_SNORM: number;
  77458. readonly RGB8_SNORM: number;
  77459. readonly RGBA8_SNORM: number;
  77460. readonly R8I: number;
  77461. readonly RG8I: number;
  77462. readonly RGB8I: number;
  77463. readonly RGBA8I: number;
  77464. readonly R8UI: number;
  77465. readonly RG8UI: number;
  77466. readonly RGB8UI: number;
  77467. readonly RGBA8UI: number;
  77468. readonly R16I: number;
  77469. readonly RG16I: number;
  77470. readonly RGB16I: number;
  77471. readonly RGBA16I: number;
  77472. readonly R16UI: number;
  77473. readonly RG16UI: number;
  77474. readonly RGB16UI: number;
  77475. readonly RGBA16UI: number;
  77476. readonly R32I: number;
  77477. readonly RG32I: number;
  77478. readonly RGB32I: number;
  77479. readonly RGBA32I: number;
  77480. readonly R32UI: number;
  77481. readonly RG32UI: number;
  77482. readonly RGB32UI: number;
  77483. readonly RGBA32UI: number;
  77484. readonly RGB10_A2UI: number;
  77485. readonly R11F_G11F_B10F: number;
  77486. readonly RGB9_E5: number;
  77487. readonly RGB10_A2: number;
  77488. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77489. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77490. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77491. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77492. readonly DEPTH_COMPONENT32F: number;
  77493. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77494. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77495. 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;
  77496. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77497. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77498. readonly TRANSFORM_FEEDBACK: number;
  77499. readonly INTERLEAVED_ATTRIBS: number;
  77500. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77501. createTransformFeedback(): WebGLTransformFeedback;
  77502. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77503. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77504. beginTransformFeedback(primitiveMode: number): void;
  77505. endTransformFeedback(): void;
  77506. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77507. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77508. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77509. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77510. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77511. }
  77512. interface ImageBitmap {
  77513. readonly width: number;
  77514. readonly height: number;
  77515. close(): void;
  77516. }
  77517. interface WebGLQuery extends WebGLObject {
  77518. }
  77519. declare var WebGLQuery: {
  77520. prototype: WebGLQuery;
  77521. new(): WebGLQuery;
  77522. };
  77523. interface WebGLSampler extends WebGLObject {
  77524. }
  77525. declare var WebGLSampler: {
  77526. prototype: WebGLSampler;
  77527. new(): WebGLSampler;
  77528. };
  77529. interface WebGLSync extends WebGLObject {
  77530. }
  77531. declare var WebGLSync: {
  77532. prototype: WebGLSync;
  77533. new(): WebGLSync;
  77534. };
  77535. interface WebGLTransformFeedback extends WebGLObject {
  77536. }
  77537. declare var WebGLTransformFeedback: {
  77538. prototype: WebGLTransformFeedback;
  77539. new(): WebGLTransformFeedback;
  77540. };
  77541. interface WebGLVertexArrayObject extends WebGLObject {
  77542. }
  77543. declare var WebGLVertexArrayObject: {
  77544. prototype: WebGLVertexArrayObject;
  77545. new(): WebGLVertexArrayObject;
  77546. };
  77547. // Type definitions for WebVR API
  77548. // Project: https://w3c.github.io/webvr/
  77549. // Definitions by: six a <https://github.com/lostfictions>
  77550. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77551. interface VRDisplay extends EventTarget {
  77552. /**
  77553. * Dictionary of capabilities describing the VRDisplay.
  77554. */
  77555. readonly capabilities: VRDisplayCapabilities;
  77556. /**
  77557. * z-depth defining the far plane of the eye view frustum
  77558. * enables mapping of values in the render target depth
  77559. * attachment to scene coordinates. Initially set to 10000.0.
  77560. */
  77561. depthFar: number;
  77562. /**
  77563. * z-depth defining the near plane of the eye view frustum
  77564. * enables mapping of values in the render target depth
  77565. * attachment to scene coordinates. Initially set to 0.01.
  77566. */
  77567. depthNear: number;
  77568. /**
  77569. * An identifier for this distinct VRDisplay. Used as an
  77570. * association point in the Gamepad API.
  77571. */
  77572. readonly displayId: number;
  77573. /**
  77574. * A display name, a user-readable name identifying it.
  77575. */
  77576. readonly displayName: string;
  77577. readonly isConnected: boolean;
  77578. readonly isPresenting: boolean;
  77579. /**
  77580. * If this VRDisplay supports room-scale experiences, the optional
  77581. * stage attribute contains details on the room-scale parameters.
  77582. */
  77583. readonly stageParameters: VRStageParameters | null;
  77584. /**
  77585. * Passing the value returned by `requestAnimationFrame` to
  77586. * `cancelAnimationFrame` will unregister the callback.
  77587. * @param handle Define the hanle of the request to cancel
  77588. */
  77589. cancelAnimationFrame(handle: number): void;
  77590. /**
  77591. * Stops presenting to the VRDisplay.
  77592. * @returns a promise to know when it stopped
  77593. */
  77594. exitPresent(): Promise<void>;
  77595. /**
  77596. * Return the current VREyeParameters for the given eye.
  77597. * @param whichEye Define the eye we want the parameter for
  77598. * @returns the eye parameters
  77599. */
  77600. getEyeParameters(whichEye: string): VREyeParameters;
  77601. /**
  77602. * Populates the passed VRFrameData with the information required to render
  77603. * the current frame.
  77604. * @param frameData Define the data structure to populate
  77605. * @returns true if ok otherwise false
  77606. */
  77607. getFrameData(frameData: VRFrameData): boolean;
  77608. /**
  77609. * Get the layers currently being presented.
  77610. * @returns the list of VR layers
  77611. */
  77612. getLayers(): VRLayer[];
  77613. /**
  77614. * Return a VRPose containing the future predicted pose of the VRDisplay
  77615. * when the current frame will be presented. The value returned will not
  77616. * change until JavaScript has returned control to the browser.
  77617. *
  77618. * The VRPose will contain the position, orientation, velocity,
  77619. * and acceleration of each of these properties.
  77620. * @returns the pose object
  77621. */
  77622. getPose(): VRPose;
  77623. /**
  77624. * Return the current instantaneous pose of the VRDisplay, with no
  77625. * prediction applied.
  77626. * @returns the current instantaneous pose
  77627. */
  77628. getImmediatePose(): VRPose;
  77629. /**
  77630. * The callback passed to `requestAnimationFrame` will be called
  77631. * any time a new frame should be rendered. When the VRDisplay is
  77632. * presenting the callback will be called at the native refresh
  77633. * rate of the HMD. When not presenting this function acts
  77634. * identically to how window.requestAnimationFrame acts. Content should
  77635. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77636. * asynchronously from other displays and at differing refresh rates.
  77637. * @param callback Define the eaction to run next frame
  77638. * @returns the request handle it
  77639. */
  77640. requestAnimationFrame(callback: FrameRequestCallback): number;
  77641. /**
  77642. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77643. * Repeat calls while already presenting will update the VRLayers being displayed.
  77644. * @param layers Define the list of layer to present
  77645. * @returns a promise to know when the request has been fulfilled
  77646. */
  77647. requestPresent(layers: VRLayer[]): Promise<void>;
  77648. /**
  77649. * Reset the pose for this display, treating its current position and
  77650. * orientation as the "origin/zero" values. VRPose.position,
  77651. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77652. * updated when calling resetPose(). This should be called in only
  77653. * sitting-space experiences.
  77654. */
  77655. resetPose(): void;
  77656. /**
  77657. * The VRLayer provided to the VRDisplay will be captured and presented
  77658. * in the HMD. Calling this function has the same effect on the source
  77659. * canvas as any other operation that uses its source image, and canvases
  77660. * created without preserveDrawingBuffer set to true will be cleared.
  77661. * @param pose Define the pose to submit
  77662. */
  77663. submitFrame(pose?: VRPose): void;
  77664. }
  77665. declare var VRDisplay: {
  77666. prototype: VRDisplay;
  77667. new(): VRDisplay;
  77668. };
  77669. interface VRLayer {
  77670. leftBounds?: number[] | Float32Array | null;
  77671. rightBounds?: number[] | Float32Array | null;
  77672. source?: HTMLCanvasElement | null;
  77673. }
  77674. interface VRDisplayCapabilities {
  77675. readonly canPresent: boolean;
  77676. readonly hasExternalDisplay: boolean;
  77677. readonly hasOrientation: boolean;
  77678. readonly hasPosition: boolean;
  77679. readonly maxLayers: number;
  77680. }
  77681. interface VREyeParameters {
  77682. /** @deprecated */
  77683. readonly fieldOfView: VRFieldOfView;
  77684. readonly offset: Float32Array;
  77685. readonly renderHeight: number;
  77686. readonly renderWidth: number;
  77687. }
  77688. interface VRFieldOfView {
  77689. readonly downDegrees: number;
  77690. readonly leftDegrees: number;
  77691. readonly rightDegrees: number;
  77692. readonly upDegrees: number;
  77693. }
  77694. interface VRFrameData {
  77695. readonly leftProjectionMatrix: Float32Array;
  77696. readonly leftViewMatrix: Float32Array;
  77697. readonly pose: VRPose;
  77698. readonly rightProjectionMatrix: Float32Array;
  77699. readonly rightViewMatrix: Float32Array;
  77700. readonly timestamp: number;
  77701. }
  77702. interface VRPose {
  77703. readonly angularAcceleration: Float32Array | null;
  77704. readonly angularVelocity: Float32Array | null;
  77705. readonly linearAcceleration: Float32Array | null;
  77706. readonly linearVelocity: Float32Array | null;
  77707. readonly orientation: Float32Array | null;
  77708. readonly position: Float32Array | null;
  77709. readonly timestamp: number;
  77710. }
  77711. interface VRStageParameters {
  77712. sittingToStandingTransform?: Float32Array;
  77713. sizeX?: number;
  77714. sizeY?: number;
  77715. }
  77716. interface Navigator {
  77717. getVRDisplays(): Promise<VRDisplay[]>;
  77718. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77719. }
  77720. interface Window {
  77721. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77722. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77723. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77724. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77725. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77726. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77727. }
  77728. interface Gamepad {
  77729. readonly displayId: number;
  77730. }
  77731. /**
  77732. * Available session modes
  77733. */
  77734. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77735. /**
  77736. * Reference space types
  77737. */
  77738. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77739. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77740. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77741. /**
  77742. * Handedness types
  77743. */
  77744. type XRHandedness = "none" | "left" | "right";
  77745. /**
  77746. * InputSource target ray modes
  77747. */
  77748. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77749. /**
  77750. * Eye types
  77751. */
  77752. type XREye = "none" | "left" | "right";
  77753. /**
  77754. * Type of XR events available
  77755. */
  77756. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77757. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77758. type XRPlaneSet = Set<XRPlane>;
  77759. type XRAnchorSet = Set<XRAnchor>;
  77760. type XREventHandler = (callback: any) => void;
  77761. interface XRLayer extends EventTarget {}
  77762. interface XRSessionInit {
  77763. optionalFeatures?: string[];
  77764. requiredFeatures?: string[];
  77765. }
  77766. interface XRSessionEvent extends Event {
  77767. readonly session: XRSession;
  77768. }
  77769. interface XRSystem {
  77770. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77771. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77772. }
  77773. interface XRViewport {
  77774. readonly x: number;
  77775. readonly y: number;
  77776. readonly width: number;
  77777. readonly height: number;
  77778. }
  77779. interface XRWebGLLayerInit {
  77780. antialias?: boolean;
  77781. depth?: boolean;
  77782. stencil?: boolean;
  77783. alpha?: boolean;
  77784. multiview?: boolean;
  77785. framebufferScaleFactor?: number;
  77786. }
  77787. declare class XRWebGLLayer {
  77788. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77789. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77790. readonly antialias: boolean;
  77791. readonly framebuffer: WebGLFramebuffer;
  77792. readonly framebufferWidth: number;
  77793. readonly framebufferHeight: number;
  77794. readonly ignoreDepthValues: boolean;
  77795. getViewport: (view: XRView) => XRViewport;
  77796. }
  77797. // tslint:disable-next-line no-empty-interface
  77798. interface XRSpace extends EventTarget {}
  77799. interface XRRenderState {
  77800. readonly baseLayer?: XRWebGLLayer;
  77801. readonly depthFar: number;
  77802. readonly depthNear: number;
  77803. readonly inlineVerticalFieldOfView?: number;
  77804. }
  77805. interface XRRenderStateInit extends XRRenderState {
  77806. baseLayer: XRWebGLLayer;
  77807. depthFar: number;
  77808. depthNear: number;
  77809. inlineVerticalFieldOfView?: number;
  77810. layers?: XRLayer[];
  77811. }
  77812. interface XRReferenceSpace extends XRSpace {
  77813. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77814. onreset: XREventHandler;
  77815. }
  77816. interface XRBoundedReferenceSpace extends XRSpace {
  77817. readonly boundsGeometry: DOMPointReadOnly[];
  77818. }
  77819. interface XRInputSource {
  77820. readonly handedness: XRHandedness;
  77821. readonly targetRayMode: XRTargetRayMode;
  77822. readonly targetRaySpace: XRSpace;
  77823. readonly gripSpace?: XRSpace;
  77824. readonly gamepad?: Gamepad;
  77825. readonly profiles: Array<string>;
  77826. readonly hand?: XRHand;
  77827. }
  77828. interface XRPose {
  77829. readonly transform: XRRigidTransform;
  77830. readonly emulatedPosition: boolean;
  77831. }
  77832. interface XRFrame {
  77833. readonly session: XRSession;
  77834. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77835. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77836. // AR
  77837. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77838. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77839. // Anchors
  77840. trackedAnchors?: XRAnchorSet;
  77841. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77842. // Planes
  77843. worldInformation?: {
  77844. detectedPlanes?: XRPlaneSet;
  77845. };
  77846. // Hand tracking
  77847. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77848. }
  77849. interface XRInputSourceEvent extends Event {
  77850. readonly frame: XRFrame;
  77851. readonly inputSource: XRInputSource;
  77852. }
  77853. type XRInputSourceArray = XRInputSource[];
  77854. interface XRSession {
  77855. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77856. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77857. /**
  77858. * Returns a list of this session's XRInputSources, each representing an input device
  77859. * used to control the camera and/or scene.
  77860. */
  77861. readonly inputSources: Array<XRInputSource>;
  77862. /**
  77863. * object which contains options affecting how the imagery is rendered.
  77864. * This includes things such as the near and far clipping planes
  77865. */
  77866. readonly renderState: XRRenderState;
  77867. readonly visibilityState: XRVisibilityState;
  77868. /**
  77869. * Removes a callback from the animation frame painting callback from
  77870. * XRSession's set of animation frame rendering callbacks, given the
  77871. * identifying handle returned by a previous call to requestAnimationFrame().
  77872. */
  77873. cancelAnimationFrame: (handle: number) => void;
  77874. /**
  77875. * Ends the WebXR session. Returns a promise which resolves when the
  77876. * session has been shut down.
  77877. */
  77878. end(): Promise<void>;
  77879. /**
  77880. * Schedules the specified method to be called the next time the user agent
  77881. * is working on rendering an animation frame for the WebXR device. Returns an
  77882. * integer value which can be used to identify the request for the purposes of
  77883. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77884. * to the Window.requestAnimationFrame() method.
  77885. */
  77886. requestAnimationFrame: XRFrameRequestCallback;
  77887. /**
  77888. * Requests that a new XRReferenceSpace of the specified type be created.
  77889. * Returns a promise which resolves with the XRReferenceSpace or
  77890. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77891. * the requested space type isn't supported by the device.
  77892. */
  77893. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77894. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77895. onend: XREventHandler;
  77896. oninputsourceschange: XREventHandler;
  77897. onselect: XREventHandler;
  77898. onselectstart: XREventHandler;
  77899. onselectend: XREventHandler;
  77900. onsqueeze: XREventHandler;
  77901. onsqueezestart: XREventHandler;
  77902. onsqueezeend: XREventHandler;
  77903. onvisibilitychange: XREventHandler;
  77904. // hit test
  77905. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77906. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77907. // legacy AR hit test
  77908. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77909. // legacy plane detection
  77910. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77911. }
  77912. interface XRViewerPose extends XRPose {
  77913. readonly views: Array<XRView>;
  77914. }
  77915. declare class XRRigidTransform {
  77916. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77917. position: DOMPointReadOnly;
  77918. orientation: DOMPointReadOnly;
  77919. matrix: Float32Array;
  77920. inverse: XRRigidTransform;
  77921. }
  77922. interface XRView {
  77923. readonly eye: XREye;
  77924. readonly projectionMatrix: Float32Array;
  77925. readonly transform: XRRigidTransform;
  77926. readonly recommendedViewportScale?: number;
  77927. requestViewportScale(scale: number): void;
  77928. }
  77929. interface XRInputSourceChangeEvent extends Event {
  77930. session: XRSession;
  77931. removed: Array<XRInputSource>;
  77932. added: Array<XRInputSource>;
  77933. }
  77934. // Experimental/Draft features
  77935. declare class XRRay {
  77936. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77937. origin: DOMPointReadOnly;
  77938. direction: DOMPointReadOnly;
  77939. matrix: Float32Array;
  77940. }
  77941. declare enum XRHitTestTrackableType {
  77942. "point",
  77943. "plane",
  77944. "mesh",
  77945. }
  77946. interface XRHitResult {
  77947. hitMatrix: Float32Array;
  77948. }
  77949. interface XRTransientInputHitTestResult {
  77950. readonly inputSource: XRInputSource;
  77951. readonly results: Array<XRHitTestResult>;
  77952. }
  77953. interface XRHitTestResult {
  77954. getPose(baseSpace: XRSpace): XRPose | undefined;
  77955. // When anchor system is enabled
  77956. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77957. }
  77958. interface XRHitTestSource {
  77959. cancel(): void;
  77960. }
  77961. interface XRTransientInputHitTestSource {
  77962. cancel(): void;
  77963. }
  77964. interface XRHitTestOptionsInit {
  77965. space: XRSpace;
  77966. entityTypes?: Array<XRHitTestTrackableType>;
  77967. offsetRay?: XRRay;
  77968. }
  77969. interface XRTransientInputHitTestOptionsInit {
  77970. profile: string;
  77971. entityTypes?: Array<XRHitTestTrackableType>;
  77972. offsetRay?: XRRay;
  77973. }
  77974. interface XRAnchor {
  77975. anchorSpace: XRSpace;
  77976. delete(): void;
  77977. }
  77978. interface XRPlane {
  77979. orientation: "Horizontal" | "Vertical";
  77980. planeSpace: XRSpace;
  77981. polygon: Array<DOMPointReadOnly>;
  77982. lastChangedTime: number;
  77983. }
  77984. interface XRJointSpace extends XRSpace {}
  77985. interface XRJointPose extends XRPose {
  77986. radius: number | undefined;
  77987. }
  77988. interface XRHand extends Iterable<XRJointSpace> {
  77989. readonly length: number;
  77990. [index: number]: XRJointSpace;
  77991. readonly WRIST: number;
  77992. readonly THUMB_METACARPAL: number;
  77993. readonly THUMB_PHALANX_PROXIMAL: number;
  77994. readonly THUMB_PHALANX_DISTAL: number;
  77995. readonly THUMB_PHALANX_TIP: number;
  77996. readonly INDEX_METACARPAL: number;
  77997. readonly INDEX_PHALANX_PROXIMAL: number;
  77998. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77999. readonly INDEX_PHALANX_DISTAL: number;
  78000. readonly INDEX_PHALANX_TIP: number;
  78001. readonly MIDDLE_METACARPAL: number;
  78002. readonly MIDDLE_PHALANX_PROXIMAL: number;
  78003. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  78004. readonly MIDDLE_PHALANX_DISTAL: number;
  78005. readonly MIDDLE_PHALANX_TIP: number;
  78006. readonly RING_METACARPAL: number;
  78007. readonly RING_PHALANX_PROXIMAL: number;
  78008. readonly RING_PHALANX_INTERMEDIATE: number;
  78009. readonly RING_PHALANX_DISTAL: number;
  78010. readonly RING_PHALANX_TIP: number;
  78011. readonly LITTLE_METACARPAL: number;
  78012. readonly LITTLE_PHALANX_PROXIMAL: number;
  78013. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  78014. readonly LITTLE_PHALANX_DISTAL: number;
  78015. readonly LITTLE_PHALANX_TIP: number;
  78016. }
  78017. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  78018. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  78019. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  78020. interface XRSession {
  78021. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  78022. }
  78023. interface XRFrame {
  78024. featurePointCloud? : Array<number>;
  78025. }
  78026. /**
  78027. * @ignore
  78028. */
  78029. declare module BABYLON.GLTF2.Exporter {
  78030. }
  78031. /**
  78032. * @ignore
  78033. */
  78034. declare module BABYLON.GLTF1 {
  78035. }
  78036. declare module BABYLON.GUI {
  78037. /**
  78038. * Class used to specific a value and its associated unit
  78039. */
  78040. export class ValueAndUnit {
  78041. /** defines the unit to store */
  78042. unit: number;
  78043. /** defines a boolean indicating if the value can be negative */
  78044. negativeValueAllowed: boolean;
  78045. private _value;
  78046. private _originalUnit;
  78047. /**
  78048. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  78049. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78050. */
  78051. ignoreAdaptiveScaling: boolean;
  78052. /**
  78053. * Creates a new ValueAndUnit
  78054. * @param value defines the value to store
  78055. * @param unit defines the unit to store
  78056. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  78057. */
  78058. constructor(value: number,
  78059. /** defines the unit to store */
  78060. unit?: number,
  78061. /** defines a boolean indicating if the value can be negative */
  78062. negativeValueAllowed?: boolean);
  78063. /** Gets a boolean indicating if the value is a percentage */
  78064. get isPercentage(): boolean;
  78065. /** Gets a boolean indicating if the value is store as pixel */
  78066. get isPixel(): boolean;
  78067. /** Gets direct internal value */
  78068. get internalValue(): number;
  78069. /**
  78070. * Gets value as pixel
  78071. * @param host defines the root host
  78072. * @param refValue defines the reference value for percentages
  78073. * @returns the value as pixel
  78074. */
  78075. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  78076. /**
  78077. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  78078. * @param value defines the value to store
  78079. * @param unit defines the unit to store
  78080. * @returns the current ValueAndUnit
  78081. */
  78082. updateInPlace(value: number, unit?: number): ValueAndUnit;
  78083. /**
  78084. * Gets the value accordingly to its unit
  78085. * @param host defines the root host
  78086. * @returns the value
  78087. */
  78088. getValue(host: AdvancedDynamicTexture): number;
  78089. /**
  78090. * Gets a string representation of the value
  78091. * @param host defines the root host
  78092. * @param decimals defines an optional number of decimals to display
  78093. * @returns a string
  78094. */
  78095. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  78096. /**
  78097. * Store a value parsed from a string
  78098. * @param source defines the source string
  78099. * @returns true if the value was successfully parsed
  78100. */
  78101. fromString(source: string | number): boolean;
  78102. private static _Regex;
  78103. private static _UNITMODE_PERCENTAGE;
  78104. private static _UNITMODE_PIXEL;
  78105. /** UNITMODE_PERCENTAGE */
  78106. static get UNITMODE_PERCENTAGE(): number;
  78107. /** UNITMODE_PIXEL */
  78108. static get UNITMODE_PIXEL(): number;
  78109. }
  78110. }
  78111. declare module BABYLON.GUI {
  78112. /**
  78113. * Define a style used by control to automatically setup properties based on a template.
  78114. * Only support font related properties so far
  78115. */
  78116. export class Style implements BABYLON.IDisposable {
  78117. private _fontFamily;
  78118. private _fontStyle;
  78119. private _fontWeight;
  78120. /** @hidden */
  78121. _host: AdvancedDynamicTexture;
  78122. /** @hidden */
  78123. _fontSize: ValueAndUnit;
  78124. /**
  78125. * BABYLON.Observable raised when the style values are changed
  78126. */
  78127. onChangedObservable: BABYLON.Observable<Style>;
  78128. /**
  78129. * Creates a new style object
  78130. * @param host defines the AdvancedDynamicTexture which hosts this style
  78131. */
  78132. constructor(host: AdvancedDynamicTexture);
  78133. /**
  78134. * Gets or sets the font size
  78135. */
  78136. get fontSize(): string | number;
  78137. set fontSize(value: string | number);
  78138. /**
  78139. * Gets or sets the font family
  78140. */
  78141. get fontFamily(): string;
  78142. set fontFamily(value: string);
  78143. /**
  78144. * Gets or sets the font style
  78145. */
  78146. get fontStyle(): string;
  78147. set fontStyle(value: string);
  78148. /** Gets or sets font weight */
  78149. get fontWeight(): string;
  78150. set fontWeight(value: string);
  78151. /** Dispose all associated resources */
  78152. dispose(): void;
  78153. }
  78154. }
  78155. declare module BABYLON.GUI {
  78156. /**
  78157. * Class used to transport BABYLON.Vector2 information for pointer events
  78158. */
  78159. export class Vector2WithInfo extends BABYLON.Vector2 {
  78160. /** defines the current mouse button index */
  78161. buttonIndex: number;
  78162. /**
  78163. * Creates a new Vector2WithInfo
  78164. * @param source defines the vector2 data to transport
  78165. * @param buttonIndex defines the current mouse button index
  78166. */
  78167. constructor(source: BABYLON.Vector2,
  78168. /** defines the current mouse button index */
  78169. buttonIndex?: number);
  78170. }
  78171. /** Class used to provide 2D matrix features */
  78172. export class Matrix2D {
  78173. /** Gets the internal array of 6 floats used to store matrix data */
  78174. m: Float32Array;
  78175. /**
  78176. * Creates a new matrix
  78177. * @param m00 defines value for (0, 0)
  78178. * @param m01 defines value for (0, 1)
  78179. * @param m10 defines value for (1, 0)
  78180. * @param m11 defines value for (1, 1)
  78181. * @param m20 defines value for (2, 0)
  78182. * @param m21 defines value for (2, 1)
  78183. */
  78184. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78185. /**
  78186. * Fills the matrix from direct values
  78187. * @param m00 defines value for (0, 0)
  78188. * @param m01 defines value for (0, 1)
  78189. * @param m10 defines value for (1, 0)
  78190. * @param m11 defines value for (1, 1)
  78191. * @param m20 defines value for (2, 0)
  78192. * @param m21 defines value for (2, 1)
  78193. * @returns the current modified matrix
  78194. */
  78195. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78196. /**
  78197. * Gets matrix determinant
  78198. * @returns the determinant
  78199. */
  78200. determinant(): number;
  78201. /**
  78202. * Inverses the matrix and stores it in a target matrix
  78203. * @param result defines the target matrix
  78204. * @returns the current matrix
  78205. */
  78206. invertToRef(result: Matrix2D): Matrix2D;
  78207. /**
  78208. * Multiplies the current matrix with another one
  78209. * @param other defines the second operand
  78210. * @param result defines the target matrix
  78211. * @returns the current matrix
  78212. */
  78213. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78214. /**
  78215. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78216. * @param x defines the x coordinate to transform
  78217. * @param y defines the x coordinate to transform
  78218. * @param result defines the target vector2
  78219. * @returns the current matrix
  78220. */
  78221. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78222. /**
  78223. * Creates an identity matrix
  78224. * @returns a new matrix
  78225. */
  78226. static Identity(): Matrix2D;
  78227. /**
  78228. * Creates a translation matrix and stores it in a target matrix
  78229. * @param x defines the x coordinate of the translation
  78230. * @param y defines the y coordinate of the translation
  78231. * @param result defines the target matrix
  78232. */
  78233. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78234. /**
  78235. * Creates a scaling matrix and stores it in a target matrix
  78236. * @param x defines the x coordinate of the scaling
  78237. * @param y defines the y coordinate of the scaling
  78238. * @param result defines the target matrix
  78239. */
  78240. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78241. /**
  78242. * Creates a rotation matrix and stores it in a target matrix
  78243. * @param angle defines the rotation angle
  78244. * @param result defines the target matrix
  78245. */
  78246. static RotationToRef(angle: number, result: Matrix2D): void;
  78247. private static _TempPreTranslationMatrix;
  78248. private static _TempPostTranslationMatrix;
  78249. private static _TempRotationMatrix;
  78250. private static _TempScalingMatrix;
  78251. private static _TempCompose0;
  78252. private static _TempCompose1;
  78253. private static _TempCompose2;
  78254. /**
  78255. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78256. * @param tx defines the x coordinate of the translation
  78257. * @param ty defines the y coordinate of the translation
  78258. * @param angle defines the rotation angle
  78259. * @param scaleX defines the x coordinate of the scaling
  78260. * @param scaleY defines the y coordinate of the scaling
  78261. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78262. * @param result defines the target matrix
  78263. */
  78264. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78265. }
  78266. }
  78267. declare module BABYLON.GUI {
  78268. /**
  78269. * Class used to store 2D control sizes
  78270. */
  78271. export class Measure {
  78272. /** defines left coordinate */
  78273. left: number;
  78274. /** defines top coordinate */
  78275. top: number;
  78276. /** defines width dimension */
  78277. width: number;
  78278. /** defines height dimension */
  78279. height: number;
  78280. /**
  78281. * Creates a new measure
  78282. * @param left defines left coordinate
  78283. * @param top defines top coordinate
  78284. * @param width defines width dimension
  78285. * @param height defines height dimension
  78286. */
  78287. constructor(
  78288. /** defines left coordinate */
  78289. left: number,
  78290. /** defines top coordinate */
  78291. top: number,
  78292. /** defines width dimension */
  78293. width: number,
  78294. /** defines height dimension */
  78295. height: number);
  78296. /**
  78297. * Copy from another measure
  78298. * @param other defines the other measure to copy from
  78299. */
  78300. copyFrom(other: Measure): void;
  78301. /**
  78302. * Copy from a group of 4 floats
  78303. * @param left defines left coordinate
  78304. * @param top defines top coordinate
  78305. * @param width defines width dimension
  78306. * @param height defines height dimension
  78307. */
  78308. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78309. /**
  78310. * Computes the axis aligned bounding box measure for two given measures
  78311. * @param a Input measure
  78312. * @param b Input measure
  78313. * @param result the resulting bounding measure
  78314. */
  78315. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78316. /**
  78317. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78318. * @param transform the matrix to transform the measure before computing the AABB
  78319. * @param addX number to add to left
  78320. * @param addY number to add to top
  78321. * @param addWidth number to add to width
  78322. * @param addHeight number to add to height
  78323. * @param result the resulting AABB
  78324. */
  78325. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78326. /**
  78327. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78328. * @param transform the matrix to transform the measure before computing the AABB
  78329. * @param result the resulting AABB
  78330. */
  78331. transformToRef(transform: Matrix2D, result: Measure): void;
  78332. /**
  78333. * Check equality between this measure and another one
  78334. * @param other defines the other measures
  78335. * @returns true if both measures are equals
  78336. */
  78337. isEqualsTo(other: Measure): boolean;
  78338. /**
  78339. * Creates an empty measure
  78340. * @returns a new measure
  78341. */
  78342. static Empty(): Measure;
  78343. }
  78344. }
  78345. declare module BABYLON.GUI {
  78346. /**
  78347. * Interface used to define a control that can receive focus
  78348. */
  78349. export interface IFocusableControl {
  78350. /**
  78351. * Function called when the control receives the focus
  78352. */
  78353. onFocus(): void;
  78354. /**
  78355. * Function called when the control loses the focus
  78356. */
  78357. onBlur(): void;
  78358. /**
  78359. * Function called to let the control handle keyboard events
  78360. * @param evt defines the current keyboard event
  78361. */
  78362. processKeyboard(evt: KeyboardEvent): void;
  78363. /**
  78364. * Function called to get the list of controls that should not steal the focus from this control
  78365. * @returns an array of controls
  78366. */
  78367. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78368. }
  78369. /**
  78370. * Class used to create texture to support 2D GUI elements
  78371. * @see https://doc.babylonjs.com/how_to/gui
  78372. */
  78373. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78374. private _isDirty;
  78375. private _renderObserver;
  78376. private _resizeObserver;
  78377. private _preKeyboardObserver;
  78378. private _pointerMoveObserver;
  78379. private _pointerObserver;
  78380. private _canvasPointerOutObserver;
  78381. private _canvasBlurObserver;
  78382. private _background;
  78383. /** @hidden */
  78384. _rootContainer: Container;
  78385. /** @hidden */
  78386. _lastPickedControl: Control;
  78387. /** @hidden */
  78388. _lastControlOver: {
  78389. [pointerId: number]: Control;
  78390. };
  78391. /** @hidden */
  78392. _lastControlDown: {
  78393. [pointerId: number]: Control;
  78394. };
  78395. /** @hidden */
  78396. _capturingControl: {
  78397. [pointerId: number]: Control;
  78398. };
  78399. /** @hidden */
  78400. _shouldBlockPointer: boolean;
  78401. /** @hidden */
  78402. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78403. /** @hidden */
  78404. _linkedControls: Control[];
  78405. private _isFullscreen;
  78406. private _fullscreenViewport;
  78407. private _idealWidth;
  78408. private _idealHeight;
  78409. private _useSmallestIdeal;
  78410. private _renderAtIdealSize;
  78411. private _focusedControl;
  78412. private _blockNextFocusCheck;
  78413. private _renderScale;
  78414. private _rootElement;
  78415. private _cursorChanged;
  78416. private _defaultMousePointerId;
  78417. /** @hidden */
  78418. _numLayoutCalls: number;
  78419. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78420. get numLayoutCalls(): number;
  78421. /** @hidden */
  78422. _numRenderCalls: number;
  78423. /** Gets the number of render calls made the last time the ADT has been rendered */
  78424. get numRenderCalls(): number;
  78425. /**
  78426. * Define type to string to ensure compatibility across browsers
  78427. * Safari doesn't support DataTransfer constructor
  78428. */
  78429. private _clipboardData;
  78430. /**
  78431. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78432. */
  78433. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78434. /**
  78435. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78436. */
  78437. onControlPickedObservable: BABYLON.Observable<Control>;
  78438. /**
  78439. * BABYLON.Observable event triggered before layout is evaluated
  78440. */
  78441. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78442. /**
  78443. * BABYLON.Observable event triggered after the layout was evaluated
  78444. */
  78445. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78446. /**
  78447. * BABYLON.Observable event triggered before the texture is rendered
  78448. */
  78449. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78450. /**
  78451. * BABYLON.Observable event triggered after the texture was rendered
  78452. */
  78453. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78454. /**
  78455. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78456. */
  78457. premulAlpha: boolean;
  78458. /**
  78459. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78460. */
  78461. applyYInversionOnUpdate: boolean;
  78462. /**
  78463. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78464. * Useful when you want more antialiasing
  78465. */
  78466. get renderScale(): number;
  78467. set renderScale(value: number);
  78468. /** Gets or sets the background color */
  78469. get background(): string;
  78470. set background(value: string);
  78471. /**
  78472. * Gets or sets the ideal width used to design controls.
  78473. * The GUI will then rescale everything accordingly
  78474. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78475. */
  78476. get idealWidth(): number;
  78477. set idealWidth(value: number);
  78478. /**
  78479. * Gets or sets the ideal height used to design controls.
  78480. * The GUI will then rescale everything accordingly
  78481. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78482. */
  78483. get idealHeight(): number;
  78484. set idealHeight(value: number);
  78485. /**
  78486. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78487. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78488. */
  78489. get useSmallestIdeal(): boolean;
  78490. set useSmallestIdeal(value: boolean);
  78491. /**
  78492. * Gets or sets a boolean indicating if adaptive scaling must be used
  78493. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78494. */
  78495. get renderAtIdealSize(): boolean;
  78496. set renderAtIdealSize(value: boolean);
  78497. /**
  78498. * Gets the ratio used when in "ideal mode"
  78499. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78500. * */
  78501. get idealRatio(): number;
  78502. /**
  78503. * Gets the underlying layer used to render the texture when in fullscreen mode
  78504. */
  78505. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78506. /**
  78507. * Gets the root container control
  78508. */
  78509. get rootContainer(): Container;
  78510. /**
  78511. * Returns an array containing the root container.
  78512. * This is mostly used to let the Inspector introspects the ADT
  78513. * @returns an array containing the rootContainer
  78514. */
  78515. getChildren(): Array<Container>;
  78516. /**
  78517. * Will return all controls that are inside this texture
  78518. * @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
  78519. * @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
  78520. * @return all child controls
  78521. */
  78522. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78523. /**
  78524. * Gets or sets the current focused control
  78525. */
  78526. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78527. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78528. /**
  78529. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78530. */
  78531. get isForeground(): boolean;
  78532. set isForeground(value: boolean);
  78533. /**
  78534. * Gets or set information about clipboardData
  78535. */
  78536. get clipboardData(): string;
  78537. set clipboardData(value: string);
  78538. /**
  78539. * Creates a new AdvancedDynamicTexture
  78540. * @param name defines the name of the texture
  78541. * @param width defines the width of the texture
  78542. * @param height defines the height of the texture
  78543. * @param scene defines the hosting scene
  78544. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78545. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78546. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78547. */
  78548. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78549. /**
  78550. * Get the current class name of the texture useful for serialization or dynamic coding.
  78551. * @returns "AdvancedDynamicTexture"
  78552. */
  78553. getClassName(): string;
  78554. /**
  78555. * Function used to execute a function on all controls
  78556. * @param func defines the function to execute
  78557. * @param container defines the container where controls belong. If null the root container will be used
  78558. */
  78559. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78560. private _useInvalidateRectOptimization;
  78561. /**
  78562. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78563. */
  78564. get useInvalidateRectOptimization(): boolean;
  78565. set useInvalidateRectOptimization(value: boolean);
  78566. private _invalidatedRectangle;
  78567. /**
  78568. * Invalidates a rectangle area on the gui texture
  78569. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78570. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78571. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78572. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78573. */
  78574. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78575. /**
  78576. * Marks the texture as dirty forcing a complete update
  78577. */
  78578. markAsDirty(): void;
  78579. /**
  78580. * Helper function used to create a new style
  78581. * @returns a new style
  78582. * @see https://doc.babylonjs.com/how_to/gui#styles
  78583. */
  78584. createStyle(): Style;
  78585. /**
  78586. * Adds a new control to the root container
  78587. * @param control defines the control to add
  78588. * @returns the current texture
  78589. */
  78590. addControl(control: Control): AdvancedDynamicTexture;
  78591. /**
  78592. * Removes a control from the root container
  78593. * @param control defines the control to remove
  78594. * @returns the current texture
  78595. */
  78596. removeControl(control: Control): AdvancedDynamicTexture;
  78597. /**
  78598. * Release all resources
  78599. */
  78600. dispose(): void;
  78601. private _onResize;
  78602. /** @hidden */
  78603. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78604. /**
  78605. * Get screen coordinates for a vector3
  78606. * @param position defines the position to project
  78607. * @param worldMatrix defines the world matrix to use
  78608. * @returns the projected position
  78609. */
  78610. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78611. /**
  78612. * Get screen coordinates for a vector3
  78613. * @param position defines the position to project
  78614. * @param worldMatrix defines the world matrix to use
  78615. * @returns the projected position with Z
  78616. */
  78617. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78618. private _checkUpdate;
  78619. private _clearMeasure;
  78620. private _render;
  78621. /** @hidden */
  78622. _changeCursor(cursor: string): void;
  78623. /** @hidden */
  78624. _registerLastControlDown(control: Control, pointerId: number): void;
  78625. private _doPicking;
  78626. /** @hidden */
  78627. _cleanControlAfterRemovalFromList(list: {
  78628. [pointerId: number]: Control;
  78629. }, control: Control): void;
  78630. /** @hidden */
  78631. _cleanControlAfterRemoval(control: Control): void;
  78632. /** Attach to all scene events required to support pointer events */
  78633. attach(): void;
  78634. /** @hidden */
  78635. private onClipboardCopy;
  78636. /** @hidden */
  78637. private onClipboardCut;
  78638. /** @hidden */
  78639. private onClipboardPaste;
  78640. /**
  78641. * Register the clipboard Events onto the canvas
  78642. */
  78643. registerClipboardEvents(): void;
  78644. /**
  78645. * Unregister the clipboard Events from the canvas
  78646. */
  78647. unRegisterClipboardEvents(): void;
  78648. /**
  78649. * Connect the texture to a hosting mesh to enable interactions
  78650. * @param mesh defines the mesh to attach to
  78651. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78652. */
  78653. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78654. /**
  78655. * Move the focus to a specific control
  78656. * @param control defines the control which will receive the focus
  78657. */
  78658. moveFocusToControl(control: IFocusableControl): void;
  78659. private _manageFocus;
  78660. private _attachToOnPointerOut;
  78661. private _attachToOnBlur;
  78662. /**
  78663. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78664. * @param mesh defines the mesh which will receive the texture
  78665. * @param width defines the texture width (1024 by default)
  78666. * @param height defines the texture height (1024 by default)
  78667. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78668. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78669. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78670. * @returns a new AdvancedDynamicTexture
  78671. */
  78672. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78673. /**
  78674. * 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
  78675. * @param mesh defines the mesh which will receive the texture
  78676. * @param width defines the texture width (1024 by default)
  78677. * @param height defines the texture height (1024 by default)
  78678. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78679. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78680. * @returns a new AdvancedDynamicTexture
  78681. */
  78682. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78683. /**
  78684. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78685. * In this mode the texture will rely on a layer for its rendering.
  78686. * This allows it to be treated like any other layer.
  78687. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78688. * LayerMask is set through advancedTexture.layer.layerMask
  78689. * @param name defines name for the texture
  78690. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78691. * @param scene defines the hsoting scene
  78692. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78693. * @returns a new AdvancedDynamicTexture
  78694. */
  78695. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78696. }
  78697. }
  78698. declare module BABYLON.GUI {
  78699. /**
  78700. * Root class used for all 2D controls
  78701. * @see https://doc.babylonjs.com/how_to/gui#controls
  78702. */
  78703. export class Control {
  78704. /** defines the name of the control */
  78705. name?: string | undefined;
  78706. /**
  78707. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78708. */
  78709. static AllowAlphaInheritance: boolean;
  78710. private _alpha;
  78711. private _alphaSet;
  78712. private _zIndex;
  78713. /** @hidden */
  78714. _host: AdvancedDynamicTexture;
  78715. /** Gets or sets the control parent */
  78716. parent: BABYLON.Nullable<Container>;
  78717. /** @hidden */
  78718. _currentMeasure: Measure;
  78719. private _fontFamily;
  78720. private _fontStyle;
  78721. private _fontWeight;
  78722. private _fontSize;
  78723. private _font;
  78724. /** @hidden */
  78725. _width: ValueAndUnit;
  78726. /** @hidden */
  78727. _height: ValueAndUnit;
  78728. /** @hidden */
  78729. protected _fontOffset: {
  78730. ascent: number;
  78731. height: number;
  78732. descent: number;
  78733. };
  78734. private _color;
  78735. private _style;
  78736. private _styleObserver;
  78737. /** @hidden */
  78738. protected _horizontalAlignment: number;
  78739. /** @hidden */
  78740. protected _verticalAlignment: number;
  78741. /** @hidden */
  78742. protected _isDirty: boolean;
  78743. /** @hidden */
  78744. protected _wasDirty: boolean;
  78745. /** @hidden */
  78746. _tempParentMeasure: Measure;
  78747. /** @hidden */
  78748. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78749. /** @hidden */
  78750. protected _cachedParentMeasure: Measure;
  78751. private _paddingLeft;
  78752. private _paddingRight;
  78753. private _paddingTop;
  78754. private _paddingBottom;
  78755. /** @hidden */
  78756. _left: ValueAndUnit;
  78757. /** @hidden */
  78758. _top: ValueAndUnit;
  78759. private _scaleX;
  78760. private _scaleY;
  78761. private _rotation;
  78762. private _transformCenterX;
  78763. private _transformCenterY;
  78764. /** @hidden */
  78765. _transformMatrix: Matrix2D;
  78766. /** @hidden */
  78767. protected _invertTransformMatrix: Matrix2D;
  78768. /** @hidden */
  78769. protected _transformedPosition: BABYLON.Vector2;
  78770. private _isMatrixDirty;
  78771. private _cachedOffsetX;
  78772. private _cachedOffsetY;
  78773. private _isVisible;
  78774. private _isHighlighted;
  78775. /** @hidden */
  78776. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78777. private _fontSet;
  78778. private _dummyVector2;
  78779. private _downCount;
  78780. private _enterCount;
  78781. private _doNotRender;
  78782. private _downPointerIds;
  78783. protected _isEnabled: boolean;
  78784. protected _disabledColor: string;
  78785. protected _disabledColorItem: string;
  78786. /** @hidden */
  78787. protected _rebuildLayout: boolean;
  78788. /** @hidden */
  78789. _customData: any;
  78790. /** @hidden */
  78791. _isClipped: boolean;
  78792. /** @hidden */
  78793. _automaticSize: boolean;
  78794. /** @hidden */
  78795. _tag: any;
  78796. /**
  78797. * 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
  78798. */
  78799. uniqueId: number;
  78800. /**
  78801. * Gets or sets an object used to store user defined information for the node
  78802. */
  78803. metadata: any;
  78804. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78805. isHitTestVisible: boolean;
  78806. /** Gets or sets a boolean indicating if the control can block pointer events */
  78807. isPointerBlocker: boolean;
  78808. /** Gets or sets a boolean indicating if the control can be focusable */
  78809. isFocusInvisible: boolean;
  78810. /**
  78811. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78812. * 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
  78813. */
  78814. clipChildren: boolean;
  78815. /**
  78816. * Gets or sets a boolean indicating that control content must be clipped
  78817. * 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
  78818. */
  78819. clipContent: boolean;
  78820. /**
  78821. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78822. */
  78823. useBitmapCache: boolean;
  78824. private _cacheData;
  78825. private _shadowOffsetX;
  78826. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78827. get shadowOffsetX(): number;
  78828. set shadowOffsetX(value: number);
  78829. private _shadowOffsetY;
  78830. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78831. get shadowOffsetY(): number;
  78832. set shadowOffsetY(value: number);
  78833. private _shadowBlur;
  78834. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78835. get shadowBlur(): number;
  78836. set shadowBlur(value: number);
  78837. private _shadowColor;
  78838. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78839. get shadowColor(): string;
  78840. set shadowColor(value: string);
  78841. /** Gets or sets the cursor to use when the control is hovered */
  78842. hoverCursor: string;
  78843. /** @hidden */
  78844. protected _linkOffsetX: ValueAndUnit;
  78845. /** @hidden */
  78846. protected _linkOffsetY: ValueAndUnit;
  78847. /** Gets the control type name */
  78848. get typeName(): string;
  78849. /**
  78850. * Get the current class name of the control.
  78851. * @returns current class name
  78852. */
  78853. getClassName(): string;
  78854. /**
  78855. * An event triggered when pointer wheel is scrolled
  78856. */
  78857. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78858. /**
  78859. * An event triggered when the pointer move over the control.
  78860. */
  78861. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78862. /**
  78863. * An event triggered when the pointer move out of the control.
  78864. */
  78865. onPointerOutObservable: BABYLON.Observable<Control>;
  78866. /**
  78867. * An event triggered when the pointer taps the control
  78868. */
  78869. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78870. /**
  78871. * An event triggered when pointer up
  78872. */
  78873. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78874. /**
  78875. * An event triggered when a control is clicked on
  78876. */
  78877. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78878. /**
  78879. * An event triggered when pointer enters the control
  78880. */
  78881. onPointerEnterObservable: BABYLON.Observable<Control>;
  78882. /**
  78883. * An event triggered when the control is marked as dirty
  78884. */
  78885. onDirtyObservable: BABYLON.Observable<Control>;
  78886. /**
  78887. * An event triggered before drawing the control
  78888. */
  78889. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78890. /**
  78891. * An event triggered after the control was drawn
  78892. */
  78893. onAfterDrawObservable: BABYLON.Observable<Control>;
  78894. /**
  78895. * An event triggered when the control has been disposed
  78896. */
  78897. onDisposeObservable: BABYLON.Observable<Control>;
  78898. /**
  78899. * Get the hosting AdvancedDynamicTexture
  78900. */
  78901. get host(): AdvancedDynamicTexture;
  78902. /** Gets or set information about font offsets (used to render and align text) */
  78903. get fontOffset(): {
  78904. ascent: number;
  78905. height: number;
  78906. descent: number;
  78907. };
  78908. set fontOffset(offset: {
  78909. ascent: number;
  78910. height: number;
  78911. descent: number;
  78912. });
  78913. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78914. get alpha(): number;
  78915. set alpha(value: number);
  78916. /**
  78917. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78918. */
  78919. get isHighlighted(): boolean;
  78920. set isHighlighted(value: boolean);
  78921. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78922. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78923. */
  78924. get scaleX(): number;
  78925. set scaleX(value: number);
  78926. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78927. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78928. */
  78929. get scaleY(): number;
  78930. set scaleY(value: number);
  78931. /** Gets or sets the rotation angle (0 by default)
  78932. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78933. */
  78934. get rotation(): number;
  78935. set rotation(value: number);
  78936. /** Gets or sets the transformation center on Y axis (0 by default)
  78937. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78938. */
  78939. get transformCenterY(): number;
  78940. set transformCenterY(value: number);
  78941. /** Gets or sets the transformation center on X axis (0 by default)
  78942. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78943. */
  78944. get transformCenterX(): number;
  78945. set transformCenterX(value: number);
  78946. /**
  78947. * Gets or sets the horizontal alignment
  78948. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78949. */
  78950. get horizontalAlignment(): number;
  78951. set horizontalAlignment(value: number);
  78952. /**
  78953. * Gets or sets the vertical alignment
  78954. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78955. */
  78956. get verticalAlignment(): number;
  78957. set verticalAlignment(value: number);
  78958. /**
  78959. * Gets or sets a fixed ratio for this control.
  78960. * When different from 0, the ratio is used to compute the "second" dimension.
  78961. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78962. * second dimension is computed as first dimension * fixedRatio
  78963. */
  78964. fixedRatio: number;
  78965. private _fixedRatioMasterIsWidth;
  78966. /**
  78967. * Gets or sets control width
  78968. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78969. */
  78970. get width(): string | number;
  78971. set width(value: string | number);
  78972. /**
  78973. * Gets or sets the control width in pixel
  78974. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78975. */
  78976. get widthInPixels(): number;
  78977. set widthInPixels(value: number);
  78978. /**
  78979. * Gets or sets control height
  78980. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78981. */
  78982. get height(): string | number;
  78983. set height(value: string | number);
  78984. /**
  78985. * Gets or sets control height in pixel
  78986. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78987. */
  78988. get heightInPixels(): number;
  78989. set heightInPixels(value: number);
  78990. /** Gets or set font family */
  78991. get fontFamily(): string;
  78992. set fontFamily(value: string);
  78993. /** Gets or sets font style */
  78994. get fontStyle(): string;
  78995. set fontStyle(value: string);
  78996. /** Gets or sets font weight */
  78997. get fontWeight(): string;
  78998. set fontWeight(value: string);
  78999. /**
  79000. * Gets or sets style
  79001. * @see https://doc.babylonjs.com/how_to/gui#styles
  79002. */
  79003. get style(): BABYLON.Nullable<Style>;
  79004. set style(value: BABYLON.Nullable<Style>);
  79005. /** @hidden */
  79006. get _isFontSizeInPercentage(): boolean;
  79007. /** Gets or sets font size in pixels */
  79008. get fontSizeInPixels(): number;
  79009. set fontSizeInPixels(value: number);
  79010. /** Gets or sets font size */
  79011. get fontSize(): string | number;
  79012. set fontSize(value: string | number);
  79013. /** Gets or sets foreground color */
  79014. get color(): string;
  79015. set color(value: string);
  79016. /** Gets or sets z index which is used to reorder controls on the z axis */
  79017. get zIndex(): number;
  79018. set zIndex(value: number);
  79019. /** Gets or sets a boolean indicating if the control can be rendered */
  79020. get notRenderable(): boolean;
  79021. set notRenderable(value: boolean);
  79022. /** Gets or sets a boolean indicating if the control is visible */
  79023. get isVisible(): boolean;
  79024. set isVisible(value: boolean);
  79025. /** Gets a boolean indicating that the control needs to update its rendering */
  79026. get isDirty(): boolean;
  79027. /**
  79028. * Gets the current linked mesh (or null if none)
  79029. */
  79030. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  79031. /**
  79032. * Gets or sets a value indicating the padding to use on the left of the control
  79033. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79034. */
  79035. get paddingLeft(): string | number;
  79036. set paddingLeft(value: string | number);
  79037. /**
  79038. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  79039. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79040. */
  79041. get paddingLeftInPixels(): number;
  79042. set paddingLeftInPixels(value: number);
  79043. /**
  79044. * Gets or sets a value indicating the padding to use on the right of the control
  79045. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79046. */
  79047. get paddingRight(): string | number;
  79048. set paddingRight(value: string | number);
  79049. /**
  79050. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  79051. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79052. */
  79053. get paddingRightInPixels(): number;
  79054. set paddingRightInPixels(value: number);
  79055. /**
  79056. * Gets or sets a value indicating the padding to use on the top of the control
  79057. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79058. */
  79059. get paddingTop(): string | number;
  79060. set paddingTop(value: string | number);
  79061. /**
  79062. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  79063. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79064. */
  79065. get paddingTopInPixels(): number;
  79066. set paddingTopInPixels(value: number);
  79067. /**
  79068. * Gets or sets a value indicating the padding to use on the bottom of the control
  79069. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79070. */
  79071. get paddingBottom(): string | number;
  79072. set paddingBottom(value: string | number);
  79073. /**
  79074. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  79075. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79076. */
  79077. get paddingBottomInPixels(): number;
  79078. set paddingBottomInPixels(value: number);
  79079. /**
  79080. * Gets or sets a value indicating the left coordinate of the control
  79081. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79082. */
  79083. get left(): string | number;
  79084. set left(value: string | number);
  79085. /**
  79086. * Gets or sets a value indicating the left coordinate in pixels of the control
  79087. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79088. */
  79089. get leftInPixels(): number;
  79090. set leftInPixels(value: number);
  79091. /**
  79092. * Gets or sets a value indicating the top coordinate of the control
  79093. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79094. */
  79095. get top(): string | number;
  79096. set top(value: string | number);
  79097. /**
  79098. * Gets or sets a value indicating the top coordinate in pixels of the control
  79099. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79100. */
  79101. get topInPixels(): number;
  79102. set topInPixels(value: number);
  79103. /**
  79104. * Gets or sets a value indicating the offset on X axis to the linked mesh
  79105. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79106. */
  79107. get linkOffsetX(): string | number;
  79108. set linkOffsetX(value: string | number);
  79109. /**
  79110. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  79111. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79112. */
  79113. get linkOffsetXInPixels(): number;
  79114. set linkOffsetXInPixels(value: number);
  79115. /**
  79116. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  79117. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79118. */
  79119. get linkOffsetY(): string | number;
  79120. set linkOffsetY(value: string | number);
  79121. /**
  79122. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  79123. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79124. */
  79125. get linkOffsetYInPixels(): number;
  79126. set linkOffsetYInPixels(value: number);
  79127. /** Gets the center coordinate on X axis */
  79128. get centerX(): number;
  79129. /** Gets the center coordinate on Y axis */
  79130. get centerY(): number;
  79131. /** Gets or sets if control is Enabled*/
  79132. get isEnabled(): boolean;
  79133. set isEnabled(value: boolean);
  79134. /** Gets or sets background color of control if it's disabled*/
  79135. get disabledColor(): string;
  79136. set disabledColor(value: string);
  79137. /** Gets or sets front color of control if it's disabled*/
  79138. get disabledColorItem(): string;
  79139. set disabledColorItem(value: string);
  79140. /**
  79141. * Creates a new control
  79142. * @param name defines the name of the control
  79143. */
  79144. constructor(
  79145. /** defines the name of the control */
  79146. name?: string | undefined);
  79147. /** @hidden */
  79148. protected _getTypeName(): string;
  79149. /**
  79150. * Gets the first ascendant in the hierarchy of the given type
  79151. * @param className defines the required type
  79152. * @returns the ascendant or null if not found
  79153. */
  79154. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  79155. /** @hidden */
  79156. _resetFontCache(): void;
  79157. /**
  79158. * Determines if a container is an ascendant of the current control
  79159. * @param container defines the container to look for
  79160. * @returns true if the container is one of the ascendant of the control
  79161. */
  79162. isAscendant(container: Control): boolean;
  79163. /**
  79164. * Gets coordinates in local control space
  79165. * @param globalCoordinates defines the coordinates to transform
  79166. * @returns the new coordinates in local space
  79167. */
  79168. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79169. /**
  79170. * Gets coordinates in local control space
  79171. * @param globalCoordinates defines the coordinates to transform
  79172. * @param result defines the target vector2 where to store the result
  79173. * @returns the current control
  79174. */
  79175. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79176. /**
  79177. * Gets coordinates in parent local control space
  79178. * @param globalCoordinates defines the coordinates to transform
  79179. * @returns the new coordinates in parent local space
  79180. */
  79181. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79182. /**
  79183. * Move the current control to a vector3 position projected onto the screen.
  79184. * @param position defines the target position
  79185. * @param scene defines the hosting scene
  79186. */
  79187. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79188. /**
  79189. * Will store all controls that have this control as ascendant in a given array
  79190. * @param results defines the array where to store the descendants
  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. */
  79194. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79195. /**
  79196. * Will return all controls that have this control as ascendant
  79197. * @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
  79198. * @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
  79199. * @return all child controls
  79200. */
  79201. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79202. /**
  79203. * Link current control with a target mesh
  79204. * @param mesh defines the mesh to link with
  79205. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79206. */
  79207. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79208. /** @hidden */
  79209. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79210. /** @hidden */
  79211. _offsetLeft(offset: number): void;
  79212. /** @hidden */
  79213. _offsetTop(offset: number): void;
  79214. /** @hidden */
  79215. _markMatrixAsDirty(): void;
  79216. /** @hidden */
  79217. _flagDescendantsAsMatrixDirty(): void;
  79218. /** @hidden */
  79219. _intersectsRect(rect: Measure): boolean;
  79220. /** @hidden */
  79221. protected invalidateRect(): void;
  79222. /** @hidden */
  79223. _markAsDirty(force?: boolean): void;
  79224. /** @hidden */
  79225. _markAllAsDirty(): void;
  79226. /** @hidden */
  79227. _link(host: AdvancedDynamicTexture): void;
  79228. /** @hidden */
  79229. protected _transform(context?: CanvasRenderingContext2D): void;
  79230. /** @hidden */
  79231. _renderHighlight(context: CanvasRenderingContext2D): void;
  79232. /** @hidden */
  79233. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79234. /** @hidden */
  79235. protected _applyStates(context: CanvasRenderingContext2D): void;
  79236. /** @hidden */
  79237. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79238. /** @hidden */
  79239. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79240. protected _evaluateClippingState(parentMeasure: Measure): void;
  79241. /** @hidden */
  79242. _measure(): void;
  79243. /** @hidden */
  79244. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79245. /** @hidden */
  79246. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79247. /** @hidden */
  79248. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79249. /** @hidden */
  79250. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79251. private static _ClipMeasure;
  79252. private _tmpMeasureA;
  79253. private _clip;
  79254. /** @hidden */
  79255. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79256. /** @hidden */
  79257. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79258. /**
  79259. * Tests if a given coordinates belong to the current control
  79260. * @param x defines x coordinate to test
  79261. * @param y defines y coordinate to test
  79262. * @returns true if the coordinates are inside the control
  79263. */
  79264. contains(x: number, y: number): boolean;
  79265. /** @hidden */
  79266. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79267. /** @hidden */
  79268. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79269. /** @hidden */
  79270. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79271. /** @hidden */
  79272. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79273. /** @hidden */
  79274. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79275. /** @hidden */
  79276. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79277. /** @hidden */
  79278. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79279. /** @hidden */
  79280. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79281. /** @hidden */
  79282. _onCanvasBlur(): void;
  79283. /** @hidden */
  79284. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79285. private _prepareFont;
  79286. /** Releases associated resources */
  79287. dispose(): void;
  79288. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79289. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79290. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79291. private static _VERTICAL_ALIGNMENT_TOP;
  79292. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79293. private static _VERTICAL_ALIGNMENT_CENTER;
  79294. /** HORIZONTAL_ALIGNMENT_LEFT */
  79295. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79296. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79297. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79298. /** HORIZONTAL_ALIGNMENT_CENTER */
  79299. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79300. /** VERTICAL_ALIGNMENT_TOP */
  79301. static get VERTICAL_ALIGNMENT_TOP(): number;
  79302. /** VERTICAL_ALIGNMENT_BOTTOM */
  79303. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79304. /** VERTICAL_ALIGNMENT_CENTER */
  79305. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79306. private static _FontHeightSizes;
  79307. /** @hidden */
  79308. static _GetFontOffset(font: string): {
  79309. ascent: number;
  79310. height: number;
  79311. descent: number;
  79312. };
  79313. /**
  79314. * Creates a stack panel that can be used to render headers
  79315. * @param control defines the control to associate with the header
  79316. * @param text defines the text of the header
  79317. * @param size defines the size of the header
  79318. * @param options defines options used to configure the header
  79319. * @returns a new StackPanel
  79320. * @ignore
  79321. * @hidden
  79322. */
  79323. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79324. isHorizontal: boolean;
  79325. controlFirst: boolean;
  79326. }) => any;
  79327. /** @hidden */
  79328. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79329. }
  79330. }
  79331. declare module BABYLON.GUI {
  79332. /**
  79333. * Root class for 2D containers
  79334. * @see https://doc.babylonjs.com/how_to/gui#containers
  79335. */
  79336. export class Container extends Control {
  79337. name?: string | undefined;
  79338. /** @hidden */
  79339. _children: Control[];
  79340. /** @hidden */
  79341. protected _measureForChildren: Measure;
  79342. /** @hidden */
  79343. protected _background: string;
  79344. /** @hidden */
  79345. protected _adaptWidthToChildren: boolean;
  79346. /** @hidden */
  79347. protected _adaptHeightToChildren: boolean;
  79348. /**
  79349. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79350. */
  79351. logLayoutCycleErrors: boolean;
  79352. /**
  79353. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79354. */
  79355. maxLayoutCycle: number;
  79356. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79357. get adaptHeightToChildren(): boolean;
  79358. set adaptHeightToChildren(value: boolean);
  79359. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79360. get adaptWidthToChildren(): boolean;
  79361. set adaptWidthToChildren(value: boolean);
  79362. /** Gets or sets background color */
  79363. get background(): string;
  79364. set background(value: string);
  79365. /** Gets the list of children */
  79366. get children(): Control[];
  79367. /**
  79368. * Creates a new Container
  79369. * @param name defines the name of the container
  79370. */
  79371. constructor(name?: string | undefined);
  79372. protected _getTypeName(): string;
  79373. _flagDescendantsAsMatrixDirty(): void;
  79374. /**
  79375. * Gets a child using its name
  79376. * @param name defines the child name to look for
  79377. * @returns the child control if found
  79378. */
  79379. getChildByName(name: string): BABYLON.Nullable<Control>;
  79380. /**
  79381. * Gets a child using its type and its name
  79382. * @param name defines the child name to look for
  79383. * @param type defines the child type to look for
  79384. * @returns the child control if found
  79385. */
  79386. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79387. /**
  79388. * Search for a specific control in children
  79389. * @param control defines the control to look for
  79390. * @returns true if the control is in child list
  79391. */
  79392. containsControl(control: Control): boolean;
  79393. /**
  79394. * Adds a new control to the current container
  79395. * @param control defines the control to add
  79396. * @returns the current container
  79397. */
  79398. addControl(control: BABYLON.Nullable<Control>): Container;
  79399. /**
  79400. * Removes all controls from the current container
  79401. * @returns the current container
  79402. */
  79403. clearControls(): Container;
  79404. /**
  79405. * Removes a control from the current container
  79406. * @param control defines the control to remove
  79407. * @returns the current container
  79408. */
  79409. removeControl(control: Control): Container;
  79410. /** @hidden */
  79411. _reOrderControl(control: Control): void;
  79412. /** @hidden */
  79413. _offsetLeft(offset: number): void;
  79414. /** @hidden */
  79415. _offsetTop(offset: number): void;
  79416. /** @hidden */
  79417. _markAllAsDirty(): void;
  79418. /** @hidden */
  79419. protected _localDraw(context: CanvasRenderingContext2D): void;
  79420. /** @hidden */
  79421. _link(host: AdvancedDynamicTexture): void;
  79422. /** @hidden */
  79423. protected _beforeLayout(): void;
  79424. /** @hidden */
  79425. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79426. /** @hidden */
  79427. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79428. protected _postMeasure(): void;
  79429. /** @hidden */
  79430. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79431. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79432. /** @hidden */
  79433. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79434. /** @hidden */
  79435. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79436. /** Releases associated resources */
  79437. dispose(): void;
  79438. }
  79439. }
  79440. declare module BABYLON.GUI {
  79441. /** Class used to create rectangle container */
  79442. export class Rectangle extends Container {
  79443. name?: string | undefined;
  79444. private _thickness;
  79445. private _cornerRadius;
  79446. /** Gets or sets border thickness */
  79447. get thickness(): number;
  79448. set thickness(value: number);
  79449. /** Gets or sets the corner radius angle */
  79450. get cornerRadius(): number;
  79451. set cornerRadius(value: number);
  79452. /**
  79453. * Creates a new Rectangle
  79454. * @param name defines the control name
  79455. */
  79456. constructor(name?: string | undefined);
  79457. protected _getTypeName(): string;
  79458. protected _localDraw(context: CanvasRenderingContext2D): void;
  79459. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79460. private _drawRoundedRect;
  79461. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79462. }
  79463. }
  79464. declare module BABYLON.GUI {
  79465. /**
  79466. * Enum that determines the text-wrapping mode to use.
  79467. */
  79468. export enum TextWrapping {
  79469. /**
  79470. * Clip the text when it's larger than Control.width; this is the default mode.
  79471. */
  79472. Clip = 0,
  79473. /**
  79474. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79475. */
  79476. WordWrap = 1,
  79477. /**
  79478. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79479. */
  79480. Ellipsis = 2
  79481. }
  79482. /**
  79483. * Class used to create text block control
  79484. */
  79485. export class TextBlock extends Control {
  79486. /**
  79487. * Defines the name of the control
  79488. */
  79489. name?: string | undefined;
  79490. private _text;
  79491. private _textWrapping;
  79492. private _textHorizontalAlignment;
  79493. private _textVerticalAlignment;
  79494. private _lines;
  79495. private _resizeToFit;
  79496. private _lineSpacing;
  79497. private _outlineWidth;
  79498. private _outlineColor;
  79499. private _underline;
  79500. private _lineThrough;
  79501. /**
  79502. * An event triggered after the text is changed
  79503. */
  79504. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79505. /**
  79506. * An event triggered after the text was broken up into lines
  79507. */
  79508. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79509. /**
  79510. * Function used to split a string into words. By default, a string is split at each space character found
  79511. */
  79512. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79513. /**
  79514. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79515. */
  79516. get lines(): any[];
  79517. /**
  79518. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79519. */
  79520. get resizeToFit(): boolean;
  79521. /**
  79522. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79523. */
  79524. set resizeToFit(value: boolean);
  79525. /**
  79526. * Gets or sets a boolean indicating if text must be wrapped
  79527. */
  79528. get textWrapping(): TextWrapping | boolean;
  79529. /**
  79530. * Gets or sets a boolean indicating if text must be wrapped
  79531. */
  79532. set textWrapping(value: TextWrapping | boolean);
  79533. /**
  79534. * Gets or sets text to display
  79535. */
  79536. get text(): string;
  79537. /**
  79538. * Gets or sets text to display
  79539. */
  79540. set text(value: string);
  79541. /**
  79542. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79543. */
  79544. get textHorizontalAlignment(): number;
  79545. /**
  79546. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79547. */
  79548. set textHorizontalAlignment(value: number);
  79549. /**
  79550. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79551. */
  79552. get textVerticalAlignment(): number;
  79553. /**
  79554. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79555. */
  79556. set textVerticalAlignment(value: number);
  79557. /**
  79558. * Gets or sets line spacing value
  79559. */
  79560. set lineSpacing(value: string | number);
  79561. /**
  79562. * Gets or sets line spacing value
  79563. */
  79564. get lineSpacing(): string | number;
  79565. /**
  79566. * Gets or sets outlineWidth of the text to display
  79567. */
  79568. get outlineWidth(): number;
  79569. /**
  79570. * Gets or sets outlineWidth of the text to display
  79571. */
  79572. set outlineWidth(value: number);
  79573. /**
  79574. * Gets or sets a boolean indicating that text must have underline
  79575. */
  79576. get underline(): boolean;
  79577. /**
  79578. * Gets or sets a boolean indicating that text must have underline
  79579. */
  79580. set underline(value: boolean);
  79581. /**
  79582. * Gets or sets an boolean indicating that text must be crossed out
  79583. */
  79584. get lineThrough(): boolean;
  79585. /**
  79586. * Gets or sets an boolean indicating that text must be crossed out
  79587. */
  79588. set lineThrough(value: boolean);
  79589. /**
  79590. * Gets or sets outlineColor of the text to display
  79591. */
  79592. get outlineColor(): string;
  79593. /**
  79594. * Gets or sets outlineColor of the text to display
  79595. */
  79596. set outlineColor(value: string);
  79597. /**
  79598. * Creates a new TextBlock object
  79599. * @param name defines the name of the control
  79600. * @param text defines the text to display (emptry string by default)
  79601. */
  79602. constructor(
  79603. /**
  79604. * Defines the name of the control
  79605. */
  79606. name?: string | undefined, text?: string);
  79607. protected _getTypeName(): string;
  79608. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79609. private _drawText;
  79610. /** @hidden */
  79611. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79612. protected _applyStates(context: CanvasRenderingContext2D): void;
  79613. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79614. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79615. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79616. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79617. protected _renderLines(context: CanvasRenderingContext2D): void;
  79618. /**
  79619. * Given a width constraint applied on the text block, find the expected height
  79620. * @returns expected height
  79621. */
  79622. computeExpectedHeight(): number;
  79623. dispose(): void;
  79624. }
  79625. }
  79626. declare module BABYLON.GUI {
  79627. /**
  79628. * Class used to create 2D images
  79629. */
  79630. export class Image extends Control {
  79631. name?: string | undefined;
  79632. private _workingCanvas;
  79633. private _domImage;
  79634. private _imageWidth;
  79635. private _imageHeight;
  79636. private _loaded;
  79637. private _stretch;
  79638. private _source;
  79639. private _autoScale;
  79640. private _sourceLeft;
  79641. private _sourceTop;
  79642. private _sourceWidth;
  79643. private _sourceHeight;
  79644. private _svgAttributesComputationCompleted;
  79645. private _isSVG;
  79646. private _cellWidth;
  79647. private _cellHeight;
  79648. private _cellId;
  79649. private _populateNinePatchSlicesFromImage;
  79650. private _sliceLeft;
  79651. private _sliceRight;
  79652. private _sliceTop;
  79653. private _sliceBottom;
  79654. private _detectPointerOnOpaqueOnly;
  79655. private _imageDataCache;
  79656. /**
  79657. * BABYLON.Observable notified when the content is loaded
  79658. */
  79659. onImageLoadedObservable: BABYLON.Observable<Image>;
  79660. /**
  79661. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79662. */
  79663. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79664. /**
  79665. * Gets a boolean indicating that the content is loaded
  79666. */
  79667. get isLoaded(): boolean;
  79668. /**
  79669. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79670. */
  79671. get populateNinePatchSlicesFromImage(): boolean;
  79672. set populateNinePatchSlicesFromImage(value: boolean);
  79673. /**
  79674. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79675. * Beware using this as this will comsume more memory as the image has to be stored twice
  79676. */
  79677. get detectPointerOnOpaqueOnly(): boolean;
  79678. set detectPointerOnOpaqueOnly(value: boolean);
  79679. /**
  79680. * Gets or sets the left value for slicing (9-patch)
  79681. */
  79682. get sliceLeft(): number;
  79683. set sliceLeft(value: number);
  79684. /**
  79685. * Gets or sets the right value for slicing (9-patch)
  79686. */
  79687. get sliceRight(): number;
  79688. set sliceRight(value: number);
  79689. /**
  79690. * Gets or sets the top value for slicing (9-patch)
  79691. */
  79692. get sliceTop(): number;
  79693. set sliceTop(value: number);
  79694. /**
  79695. * Gets or sets the bottom value for slicing (9-patch)
  79696. */
  79697. get sliceBottom(): number;
  79698. set sliceBottom(value: number);
  79699. /**
  79700. * Gets or sets the left coordinate in the source image
  79701. */
  79702. get sourceLeft(): number;
  79703. set sourceLeft(value: number);
  79704. /**
  79705. * Gets or sets the top coordinate in the source image
  79706. */
  79707. get sourceTop(): number;
  79708. set sourceTop(value: number);
  79709. /**
  79710. * Gets or sets the width to capture in the source image
  79711. */
  79712. get sourceWidth(): number;
  79713. set sourceWidth(value: number);
  79714. /**
  79715. * Gets or sets the height to capture in the source image
  79716. */
  79717. get sourceHeight(): number;
  79718. set sourceHeight(value: number);
  79719. /** Indicates if the format of the image is SVG */
  79720. get isSVG(): boolean;
  79721. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79722. get svgAttributesComputationCompleted(): boolean;
  79723. /**
  79724. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79725. * @see https://doc.babylonjs.com/how_to/gui#image
  79726. */
  79727. get autoScale(): boolean;
  79728. set autoScale(value: boolean);
  79729. /** Gets or sets the streching mode used by the image */
  79730. get stretch(): number;
  79731. set stretch(value: number);
  79732. /** @hidden */
  79733. _rotate90(n: number, preserveProperties?: boolean): Image;
  79734. private _handleRotationForSVGImage;
  79735. private _rotate90SourceProperties;
  79736. /**
  79737. * Gets or sets the internal DOM image used to render the control
  79738. */
  79739. set domImage(value: HTMLImageElement);
  79740. get domImage(): HTMLImageElement;
  79741. private _onImageLoaded;
  79742. private _extractNinePatchSliceDataFromImage;
  79743. /**
  79744. * Gets or sets image source url
  79745. */
  79746. set source(value: BABYLON.Nullable<string>);
  79747. /**
  79748. * Checks for svg document with icon id present
  79749. */
  79750. private _svgCheck;
  79751. /**
  79752. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79753. * given external svg file and icon id
  79754. */
  79755. private _getSVGAttribs;
  79756. /**
  79757. * Gets or sets the cell width to use when animation sheet is enabled
  79758. * @see https://doc.babylonjs.com/how_to/gui#image
  79759. */
  79760. get cellWidth(): number;
  79761. set cellWidth(value: number);
  79762. /**
  79763. * Gets or sets the cell height to use when animation sheet is enabled
  79764. * @see https://doc.babylonjs.com/how_to/gui#image
  79765. */
  79766. get cellHeight(): number;
  79767. set cellHeight(value: number);
  79768. /**
  79769. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79770. * @see https://doc.babylonjs.com/how_to/gui#image
  79771. */
  79772. get cellId(): number;
  79773. set cellId(value: number);
  79774. /**
  79775. * Creates a new Image
  79776. * @param name defines the control name
  79777. * @param url defines the image url
  79778. */
  79779. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79780. /**
  79781. * Tests if a given coordinates belong to the current control
  79782. * @param x defines x coordinate to test
  79783. * @param y defines y coordinate to test
  79784. * @returns true if the coordinates are inside the control
  79785. */
  79786. contains(x: number, y: number): boolean;
  79787. protected _getTypeName(): string;
  79788. /** Force the control to synchronize with its content */
  79789. synchronizeSizeWithContent(): void;
  79790. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79791. private _prepareWorkingCanvasForOpaqueDetection;
  79792. private _drawImage;
  79793. _draw(context: CanvasRenderingContext2D): void;
  79794. private _renderCornerPatch;
  79795. private _renderNinePatch;
  79796. dispose(): void;
  79797. /** STRETCH_NONE */
  79798. static readonly STRETCH_NONE: number;
  79799. /** STRETCH_FILL */
  79800. static readonly STRETCH_FILL: number;
  79801. /** STRETCH_UNIFORM */
  79802. static readonly STRETCH_UNIFORM: number;
  79803. /** STRETCH_EXTEND */
  79804. static readonly STRETCH_EXTEND: number;
  79805. /** NINE_PATCH */
  79806. static readonly STRETCH_NINE_PATCH: number;
  79807. }
  79808. }
  79809. declare module BABYLON.GUI {
  79810. /**
  79811. * Class used to create 2D buttons
  79812. */
  79813. export class Button extends Rectangle {
  79814. name?: string | undefined;
  79815. /**
  79816. * Function called to generate a pointer enter animation
  79817. */
  79818. pointerEnterAnimation: () => void;
  79819. /**
  79820. * Function called to generate a pointer out animation
  79821. */
  79822. pointerOutAnimation: () => void;
  79823. /**
  79824. * Function called to generate a pointer down animation
  79825. */
  79826. pointerDownAnimation: () => void;
  79827. /**
  79828. * Function called to generate a pointer up animation
  79829. */
  79830. pointerUpAnimation: () => void;
  79831. /**
  79832. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79833. */
  79834. delegatePickingToChildren: boolean;
  79835. private _image;
  79836. /**
  79837. * Returns the image part of the button (if any)
  79838. */
  79839. get image(): BABYLON.Nullable<Image>;
  79840. private _textBlock;
  79841. /**
  79842. * Returns the image part of the button (if any)
  79843. */
  79844. get textBlock(): BABYLON.Nullable<TextBlock>;
  79845. /**
  79846. * Creates a new Button
  79847. * @param name defines the name of the button
  79848. */
  79849. constructor(name?: string | undefined);
  79850. protected _getTypeName(): string;
  79851. /** @hidden */
  79852. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79853. /** @hidden */
  79854. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79855. /** @hidden */
  79856. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79857. /** @hidden */
  79858. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79859. /** @hidden */
  79860. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79861. /**
  79862. * Creates a new button made with an image and a text
  79863. * @param name defines the name of the button
  79864. * @param text defines the text of the button
  79865. * @param imageUrl defines the url of the image
  79866. * @returns a new Button
  79867. */
  79868. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79869. /**
  79870. * Creates a new button made with an image
  79871. * @param name defines the name of the button
  79872. * @param imageUrl defines the url of the image
  79873. * @returns a new Button
  79874. */
  79875. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79876. /**
  79877. * Creates a new button made with a text
  79878. * @param name defines the name of the button
  79879. * @param text defines the text of the button
  79880. * @returns a new Button
  79881. */
  79882. static CreateSimpleButton(name: string, text: string): Button;
  79883. /**
  79884. * Creates a new button made with an image and a centered text
  79885. * @param name defines the name of the button
  79886. * @param text defines the text of the button
  79887. * @param imageUrl defines the url of the image
  79888. * @returns a new Button
  79889. */
  79890. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79891. }
  79892. }
  79893. declare module BABYLON.GUI {
  79894. /**
  79895. * Class used to create a 2D stack panel container
  79896. */
  79897. export class StackPanel extends Container {
  79898. name?: string | undefined;
  79899. private _isVertical;
  79900. private _manualWidth;
  79901. private _manualHeight;
  79902. private _doNotTrackManualChanges;
  79903. /**
  79904. * Gets or sets a boolean indicating that layou warnings should be ignored
  79905. */
  79906. ignoreLayoutWarnings: boolean;
  79907. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79908. get isVertical(): boolean;
  79909. set isVertical(value: boolean);
  79910. /**
  79911. * Gets or sets panel width.
  79912. * This value should not be set when in horizontal mode as it will be computed automatically
  79913. */
  79914. set width(value: string | number);
  79915. get width(): string | number;
  79916. /**
  79917. * Gets or sets panel height.
  79918. * This value should not be set when in vertical mode as it will be computed automatically
  79919. */
  79920. set height(value: string | number);
  79921. get height(): string | number;
  79922. /**
  79923. * Creates a new StackPanel
  79924. * @param name defines control name
  79925. */
  79926. constructor(name?: string | undefined);
  79927. protected _getTypeName(): string;
  79928. /** @hidden */
  79929. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79930. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79931. protected _postMeasure(): void;
  79932. }
  79933. }
  79934. declare module BABYLON.GUI {
  79935. /**
  79936. * Class used to represent a 2D checkbox
  79937. */
  79938. export class Checkbox extends Control {
  79939. name?: string | undefined;
  79940. private _isChecked;
  79941. private _background;
  79942. private _checkSizeRatio;
  79943. private _thickness;
  79944. /** Gets or sets border thickness */
  79945. get thickness(): number;
  79946. set thickness(value: number);
  79947. /**
  79948. * BABYLON.Observable raised when isChecked property changes
  79949. */
  79950. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79951. /** Gets or sets a value indicating the ratio between overall size and check size */
  79952. get checkSizeRatio(): number;
  79953. set checkSizeRatio(value: number);
  79954. /** Gets or sets background color */
  79955. get background(): string;
  79956. set background(value: string);
  79957. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79958. get isChecked(): boolean;
  79959. set isChecked(value: boolean);
  79960. /**
  79961. * Creates a new CheckBox
  79962. * @param name defines the control name
  79963. */
  79964. constructor(name?: string | undefined);
  79965. protected _getTypeName(): string;
  79966. /** @hidden */
  79967. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79968. /** @hidden */
  79969. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79970. /**
  79971. * Utility function to easily create a checkbox with a header
  79972. * @param title defines the label to use for the header
  79973. * @param onValueChanged defines the callback to call when value changes
  79974. * @returns a StackPanel containing the checkbox and a textBlock
  79975. */
  79976. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79977. }
  79978. }
  79979. declare module BABYLON.GUI {
  79980. /**
  79981. * Class used to store key control properties
  79982. */
  79983. export class KeyPropertySet {
  79984. /** Width */
  79985. width?: string;
  79986. /** Height */
  79987. height?: string;
  79988. /** Left padding */
  79989. paddingLeft?: string;
  79990. /** Right padding */
  79991. paddingRight?: string;
  79992. /** Top padding */
  79993. paddingTop?: string;
  79994. /** Bottom padding */
  79995. paddingBottom?: string;
  79996. /** Foreground color */
  79997. color?: string;
  79998. /** Background color */
  79999. background?: string;
  80000. }
  80001. /**
  80002. * Class used to create virtual keyboard
  80003. */
  80004. export class VirtualKeyboard extends StackPanel {
  80005. /** BABYLON.Observable raised when a key is pressed */
  80006. onKeyPressObservable: BABYLON.Observable<string>;
  80007. /** Gets or sets default key button width */
  80008. defaultButtonWidth: string;
  80009. /** Gets or sets default key button height */
  80010. defaultButtonHeight: string;
  80011. /** Gets or sets default key button left padding */
  80012. defaultButtonPaddingLeft: string;
  80013. /** Gets or sets default key button right padding */
  80014. defaultButtonPaddingRight: string;
  80015. /** Gets or sets default key button top padding */
  80016. defaultButtonPaddingTop: string;
  80017. /** Gets or sets default key button bottom padding */
  80018. defaultButtonPaddingBottom: string;
  80019. /** Gets or sets default key button foreground color */
  80020. defaultButtonColor: string;
  80021. /** Gets or sets default key button background color */
  80022. defaultButtonBackground: string;
  80023. /** Gets or sets shift button foreground color */
  80024. shiftButtonColor: string;
  80025. /** Gets or sets shift button thickness*/
  80026. selectedShiftThickness: number;
  80027. /** Gets shift key state */
  80028. shiftState: number;
  80029. protected _getTypeName(): string;
  80030. private _createKey;
  80031. /**
  80032. * Adds a new row of keys
  80033. * @param keys defines the list of keys to add
  80034. * @param propertySets defines the associated property sets
  80035. */
  80036. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  80037. /**
  80038. * Set the shift key to a specific state
  80039. * @param shiftState defines the new shift state
  80040. */
  80041. applyShiftState(shiftState: number): void;
  80042. private _currentlyConnectedInputText;
  80043. private _connectedInputTexts;
  80044. private _onKeyPressObserver;
  80045. /** Gets the input text control currently attached to the keyboard */
  80046. get connectedInputText(): BABYLON.Nullable<InputText>;
  80047. /**
  80048. * Connects the keyboard with an input text control
  80049. *
  80050. * @param input defines the target control
  80051. */
  80052. connect(input: InputText): void;
  80053. /**
  80054. * Disconnects the keyboard from connected InputText controls
  80055. *
  80056. * @param input optionally defines a target control, otherwise all are disconnected
  80057. */
  80058. disconnect(input?: InputText): void;
  80059. private _removeConnectedInputObservables;
  80060. /**
  80061. * Release all resources
  80062. */
  80063. dispose(): void;
  80064. /**
  80065. * Creates a new keyboard using a default layout
  80066. *
  80067. * @param name defines control name
  80068. * @returns a new VirtualKeyboard
  80069. */
  80070. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  80071. }
  80072. }
  80073. declare module BABYLON.GUI {
  80074. /** @hidden */
  80075. export class TextWrapper {
  80076. private _text;
  80077. private _characters;
  80078. get text(): string;
  80079. set text(txt: string);
  80080. get length(): number;
  80081. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  80082. charAt(idx: number): string;
  80083. substr(from: number, length?: number): string;
  80084. substring(from: number, to?: number): string;
  80085. isWord(index: number): boolean;
  80086. }
  80087. }
  80088. declare module BABYLON.GUI {
  80089. /**
  80090. * Class used to create input text control
  80091. */
  80092. export class InputText extends Control implements IFocusableControl {
  80093. name?: string | undefined;
  80094. private _textWrapper;
  80095. private _placeholderText;
  80096. private _background;
  80097. private _focusedBackground;
  80098. private _focusedColor;
  80099. private _placeholderColor;
  80100. private _thickness;
  80101. private _margin;
  80102. private _autoStretchWidth;
  80103. private _maxWidth;
  80104. private _isFocused;
  80105. private _blinkTimeout;
  80106. private _blinkIsEven;
  80107. private _cursorOffset;
  80108. private _scrollLeft;
  80109. private _textWidth;
  80110. private _clickedCoordinate;
  80111. private _deadKey;
  80112. private _addKey;
  80113. private _currentKey;
  80114. private _isTextHighlightOn;
  80115. private _textHighlightColor;
  80116. private _highligherOpacity;
  80117. private _highlightedText;
  80118. private _startHighlightIndex;
  80119. private _endHighlightIndex;
  80120. private _cursorIndex;
  80121. private _onFocusSelectAll;
  80122. private _isPointerDown;
  80123. private _onClipboardObserver;
  80124. private _onPointerDblTapObserver;
  80125. /** @hidden */
  80126. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  80127. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  80128. promptMessage: string;
  80129. /** Force disable prompt on mobile device */
  80130. disableMobilePrompt: boolean;
  80131. /** BABYLON.Observable raised when the text changes */
  80132. onTextChangedObservable: BABYLON.Observable<InputText>;
  80133. /** BABYLON.Observable raised just before an entered character is to be added */
  80134. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  80135. /** BABYLON.Observable raised when the control gets the focus */
  80136. onFocusObservable: BABYLON.Observable<InputText>;
  80137. /** BABYLON.Observable raised when the control loses the focus */
  80138. onBlurObservable: BABYLON.Observable<InputText>;
  80139. /**Observable raised when the text is highlighted */
  80140. onTextHighlightObservable: BABYLON.Observable<InputText>;
  80141. /**Observable raised when copy event is triggered */
  80142. onTextCopyObservable: BABYLON.Observable<InputText>;
  80143. /** BABYLON.Observable raised when cut event is triggered */
  80144. onTextCutObservable: BABYLON.Observable<InputText>;
  80145. /** BABYLON.Observable raised when paste event is triggered */
  80146. onTextPasteObservable: BABYLON.Observable<InputText>;
  80147. /** BABYLON.Observable raised when a key event was processed */
  80148. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80149. /** Gets or sets the maximum width allowed by the control */
  80150. get maxWidth(): string | number;
  80151. /** Gets the maximum width allowed by the control in pixels */
  80152. get maxWidthInPixels(): number;
  80153. set maxWidth(value: string | number);
  80154. /** Gets or sets the text highlighter transparency; default: 0.4 */
  80155. get highligherOpacity(): number;
  80156. set highligherOpacity(value: number);
  80157. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  80158. get onFocusSelectAll(): boolean;
  80159. set onFocusSelectAll(value: boolean);
  80160. /** Gets or sets the text hightlight color */
  80161. get textHighlightColor(): string;
  80162. set textHighlightColor(value: string);
  80163. /** Gets or sets control margin */
  80164. get margin(): string;
  80165. /** Gets control margin in pixels */
  80166. get marginInPixels(): number;
  80167. set margin(value: string);
  80168. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80169. get autoStretchWidth(): boolean;
  80170. set autoStretchWidth(value: boolean);
  80171. /** Gets or sets border thickness */
  80172. get thickness(): number;
  80173. set thickness(value: number);
  80174. /** Gets or sets the background color when focused */
  80175. get focusedBackground(): string;
  80176. set focusedBackground(value: string);
  80177. /** Gets or sets the background color when focused */
  80178. get focusedColor(): string;
  80179. set focusedColor(value: string);
  80180. /** Gets or sets the background color */
  80181. get background(): string;
  80182. set background(value: string);
  80183. /** Gets or sets the placeholder color */
  80184. get placeholderColor(): string;
  80185. set placeholderColor(value: string);
  80186. /** Gets or sets the text displayed when the control is empty */
  80187. get placeholderText(): string;
  80188. set placeholderText(value: string);
  80189. /** Gets or sets the dead key flag */
  80190. get deadKey(): boolean;
  80191. set deadKey(flag: boolean);
  80192. /** Gets or sets the highlight text */
  80193. get highlightedText(): string;
  80194. set highlightedText(text: string);
  80195. /** Gets or sets if the current key should be added */
  80196. get addKey(): boolean;
  80197. set addKey(flag: boolean);
  80198. /** Gets or sets the value of the current key being entered */
  80199. get currentKey(): string;
  80200. set currentKey(key: string);
  80201. /** Gets or sets the text displayed in the control */
  80202. get text(): string;
  80203. set text(value: string);
  80204. private _textHasChanged;
  80205. /** Gets or sets control width */
  80206. get width(): string | number;
  80207. set width(value: string | number);
  80208. /**
  80209. * Creates a new InputText
  80210. * @param name defines the control name
  80211. * @param text defines the text of the control
  80212. */
  80213. constructor(name?: string | undefined, text?: string);
  80214. /** @hidden */
  80215. onBlur(): void;
  80216. /** @hidden */
  80217. onFocus(): void;
  80218. protected _getTypeName(): string;
  80219. /**
  80220. * Function called to get the list of controls that should not steal the focus from this control
  80221. * @returns an array of controls
  80222. */
  80223. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80224. /** @hidden */
  80225. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80226. /** @hidden */
  80227. private _updateValueFromCursorIndex;
  80228. /** @hidden */
  80229. private _processDblClick;
  80230. /** @hidden */
  80231. private _selectAllText;
  80232. /**
  80233. * Handles the keyboard event
  80234. * @param evt Defines the KeyboardEvent
  80235. */
  80236. processKeyboard(evt: KeyboardEvent): void;
  80237. /** @hidden */
  80238. private _onCopyText;
  80239. /** @hidden */
  80240. private _onCutText;
  80241. /** @hidden */
  80242. private _onPasteText;
  80243. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80244. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80245. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80246. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80247. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80248. dispose(): void;
  80249. }
  80250. }
  80251. declare module BABYLON.GUI {
  80252. /**
  80253. * Class used to create a 2D grid container
  80254. */
  80255. export class Grid extends Container {
  80256. name?: string | undefined;
  80257. private _rowDefinitions;
  80258. private _columnDefinitions;
  80259. private _cells;
  80260. private _childControls;
  80261. /**
  80262. * Gets the number of columns
  80263. */
  80264. get columnCount(): number;
  80265. /**
  80266. * Gets the number of rows
  80267. */
  80268. get rowCount(): number;
  80269. /** Gets the list of children */
  80270. get children(): Control[];
  80271. /** Gets the list of cells (e.g. the containers) */
  80272. get cells(): {
  80273. [key: string]: Container;
  80274. };
  80275. /**
  80276. * Gets the definition of a specific row
  80277. * @param index defines the index of the row
  80278. * @returns the row definition
  80279. */
  80280. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80281. /**
  80282. * Gets the definition of a specific column
  80283. * @param index defines the index of the column
  80284. * @returns the column definition
  80285. */
  80286. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80287. /**
  80288. * Adds a new row to the grid
  80289. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80290. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80291. * @returns the current grid
  80292. */
  80293. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80294. /**
  80295. * Adds a new column to the grid
  80296. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80297. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80298. * @returns the current grid
  80299. */
  80300. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80301. /**
  80302. * Update a row definition
  80303. * @param index defines the index of the row to update
  80304. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80305. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80306. * @returns the current grid
  80307. */
  80308. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80309. /**
  80310. * Update a column definition
  80311. * @param index defines the index of the column to update
  80312. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80313. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80314. * @returns the current grid
  80315. */
  80316. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80317. /**
  80318. * Gets the list of children stored in a specific cell
  80319. * @param row defines the row to check
  80320. * @param column defines the column to check
  80321. * @returns the list of controls
  80322. */
  80323. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80324. /**
  80325. * Gets a string representing the child cell info (row x column)
  80326. * @param child defines the control to get info from
  80327. * @returns a string containing the child cell info (row x column)
  80328. */
  80329. getChildCellInfo(child: Control): string;
  80330. private _removeCell;
  80331. private _offsetCell;
  80332. /**
  80333. * Remove a column definition at specified index
  80334. * @param index defines the index of the column to remove
  80335. * @returns the current grid
  80336. */
  80337. removeColumnDefinition(index: number): Grid;
  80338. /**
  80339. * Remove a row definition at specified index
  80340. * @param index defines the index of the row to remove
  80341. * @returns the current grid
  80342. */
  80343. removeRowDefinition(index: number): Grid;
  80344. /**
  80345. * Adds a new control to the current grid
  80346. * @param control defines the control to add
  80347. * @param row defines the row where to add the control (0 by default)
  80348. * @param column defines the column where to add the control (0 by default)
  80349. * @returns the current grid
  80350. */
  80351. addControl(control: Control, row?: number, column?: number): Grid;
  80352. /**
  80353. * Removes a control from the current container
  80354. * @param control defines the control to remove
  80355. * @returns the current container
  80356. */
  80357. removeControl(control: Control): Container;
  80358. /**
  80359. * Creates a new Grid
  80360. * @param name defines control name
  80361. */
  80362. constructor(name?: string | undefined);
  80363. protected _getTypeName(): string;
  80364. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80365. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80366. _flagDescendantsAsMatrixDirty(): void;
  80367. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80368. /** Releases associated resources */
  80369. dispose(): void;
  80370. }
  80371. }
  80372. declare module BABYLON.GUI {
  80373. /** Class used to create color pickers */
  80374. export class ColorPicker extends Control {
  80375. name?: string | undefined;
  80376. private static _Epsilon;
  80377. private _colorWheelCanvas;
  80378. private _value;
  80379. private _tmpColor;
  80380. private _pointerStartedOnSquare;
  80381. private _pointerStartedOnWheel;
  80382. private _squareLeft;
  80383. private _squareTop;
  80384. private _squareSize;
  80385. private _h;
  80386. private _s;
  80387. private _v;
  80388. private _lastPointerDownID;
  80389. /**
  80390. * BABYLON.Observable raised when the value changes
  80391. */
  80392. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80393. /** Gets or sets the color of the color picker */
  80394. get value(): BABYLON.Color3;
  80395. set value(value: BABYLON.Color3);
  80396. /**
  80397. * Gets or sets control width
  80398. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80399. */
  80400. get width(): string | number;
  80401. set width(value: string | number);
  80402. /**
  80403. * Gets or sets control height
  80404. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80405. */
  80406. get height(): string | number;
  80407. /** Gets or sets control height */
  80408. set height(value: string | number);
  80409. /** Gets or sets control size */
  80410. get size(): string | number;
  80411. set size(value: string | number);
  80412. /**
  80413. * Creates a new ColorPicker
  80414. * @param name defines the control name
  80415. */
  80416. constructor(name?: string | undefined);
  80417. protected _getTypeName(): string;
  80418. /** @hidden */
  80419. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80420. private _updateSquareProps;
  80421. private _drawGradientSquare;
  80422. private _drawCircle;
  80423. private _createColorWheelCanvas;
  80424. /** @hidden */
  80425. _draw(context: CanvasRenderingContext2D): void;
  80426. private _pointerIsDown;
  80427. private _updateValueFromPointer;
  80428. private _isPointOnSquare;
  80429. private _isPointOnWheel;
  80430. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80431. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80432. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80433. _onCanvasBlur(): void;
  80434. /**
  80435. * This function expands the color picker by creating a color picker dialog with manual
  80436. * color value input and the ability to save colors into an array to be used later in
  80437. * subsequent launches of the dialogue.
  80438. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80439. * @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.
  80440. * @returns picked color as a hex string and the saved colors array as hex strings.
  80441. */
  80442. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80443. pickerWidth?: string;
  80444. pickerHeight?: string;
  80445. headerHeight?: string;
  80446. lastColor?: string;
  80447. swatchLimit?: number;
  80448. numSwatchesPerLine?: number;
  80449. savedColors?: Array<string>;
  80450. }): Promise<{
  80451. savedColors?: string[];
  80452. pickedColor: string;
  80453. }>;
  80454. }
  80455. }
  80456. declare module BABYLON.GUI {
  80457. /** Class used to create 2D ellipse containers */
  80458. export class Ellipse extends Container {
  80459. name?: string | undefined;
  80460. private _thickness;
  80461. /** Gets or sets border thickness */
  80462. get thickness(): number;
  80463. set thickness(value: number);
  80464. /**
  80465. * Creates a new Ellipse
  80466. * @param name defines the control name
  80467. */
  80468. constructor(name?: string | undefined);
  80469. protected _getTypeName(): string;
  80470. protected _localDraw(context: CanvasRenderingContext2D): void;
  80471. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80472. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80473. }
  80474. }
  80475. declare module BABYLON.GUI {
  80476. /**
  80477. * Class used to create a password control
  80478. */
  80479. export class InputPassword extends InputText {
  80480. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80481. }
  80482. }
  80483. declare module BABYLON.GUI {
  80484. /** Class used to render 2D lines */
  80485. export class Line extends Control {
  80486. name?: string | undefined;
  80487. private _lineWidth;
  80488. private _x1;
  80489. private _y1;
  80490. private _x2;
  80491. private _y2;
  80492. private _dash;
  80493. private _connectedControl;
  80494. private _connectedControlDirtyObserver;
  80495. /** Gets or sets the dash pattern */
  80496. get dash(): Array<number>;
  80497. set dash(value: Array<number>);
  80498. /** Gets or sets the control connected with the line end */
  80499. get connectedControl(): Control;
  80500. set connectedControl(value: Control);
  80501. /** Gets or sets start coordinates on X axis */
  80502. get x1(): string | number;
  80503. set x1(value: string | number);
  80504. /** Gets or sets start coordinates on Y axis */
  80505. get y1(): string | number;
  80506. set y1(value: string | number);
  80507. /** Gets or sets end coordinates on X axis */
  80508. get x2(): string | number;
  80509. set x2(value: string | number);
  80510. /** Gets or sets end coordinates on Y axis */
  80511. get y2(): string | number;
  80512. set y2(value: string | number);
  80513. /** Gets or sets line width */
  80514. get lineWidth(): number;
  80515. set lineWidth(value: number);
  80516. /** Gets or sets horizontal alignment */
  80517. set horizontalAlignment(value: number);
  80518. /** Gets or sets vertical alignment */
  80519. set verticalAlignment(value: number);
  80520. private get _effectiveX2();
  80521. private get _effectiveY2();
  80522. /**
  80523. * Creates a new Line
  80524. * @param name defines the control name
  80525. */
  80526. constructor(name?: string | undefined);
  80527. protected _getTypeName(): string;
  80528. _draw(context: CanvasRenderingContext2D): void;
  80529. _measure(): void;
  80530. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80531. /**
  80532. * Move one end of the line given 3D cartesian coordinates.
  80533. * @param position Targeted world position
  80534. * @param scene BABYLON.Scene
  80535. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80536. */
  80537. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80538. /**
  80539. * Move one end of the line to a position in screen absolute space.
  80540. * @param projectedPosition Position in screen absolute space (X, Y)
  80541. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80542. */
  80543. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80544. }
  80545. }
  80546. declare module BABYLON.GUI {
  80547. /**
  80548. * Class used to store a point for a MultiLine object.
  80549. * The point can be pure 2D coordinates, a mesh or a control
  80550. */
  80551. export class MultiLinePoint {
  80552. private _multiLine;
  80553. private _x;
  80554. private _y;
  80555. private _control;
  80556. private _mesh;
  80557. private _controlObserver;
  80558. private _meshObserver;
  80559. /** @hidden */
  80560. _point: BABYLON.Vector3;
  80561. /**
  80562. * Creates a new MultiLinePoint
  80563. * @param multiLine defines the source MultiLine object
  80564. */
  80565. constructor(multiLine: MultiLine);
  80566. /** Gets or sets x coordinate */
  80567. get x(): string | number;
  80568. set x(value: string | number);
  80569. /** Gets or sets y coordinate */
  80570. get y(): string | number;
  80571. set y(value: string | number);
  80572. /** Gets or sets the control associated with this point */
  80573. get control(): BABYLON.Nullable<Control>;
  80574. set control(value: BABYLON.Nullable<Control>);
  80575. /** Gets or sets the mesh associated with this point */
  80576. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80577. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80578. /** Resets links */
  80579. resetLinks(): void;
  80580. /**
  80581. * Gets a translation vector with Z component
  80582. * @returns the translation vector
  80583. */
  80584. translate(): BABYLON.Vector3;
  80585. private _translatePoint;
  80586. /** Release associated resources */
  80587. dispose(): void;
  80588. }
  80589. }
  80590. declare module BABYLON.GUI {
  80591. /**
  80592. * Class used to create multi line control
  80593. */
  80594. export class MultiLine extends Control {
  80595. name?: string | undefined;
  80596. private _lineWidth;
  80597. private _dash;
  80598. private _points;
  80599. private _minX;
  80600. private _minY;
  80601. private _maxX;
  80602. private _maxY;
  80603. /**
  80604. * Creates a new MultiLine
  80605. * @param name defines the control name
  80606. */
  80607. constructor(name?: string | undefined);
  80608. /** Gets or sets dash pattern */
  80609. get dash(): Array<number>;
  80610. set dash(value: Array<number>);
  80611. /**
  80612. * Gets point stored at specified index
  80613. * @param index defines the index to look for
  80614. * @returns the requested point if found
  80615. */
  80616. getAt(index: number): MultiLinePoint;
  80617. /** Function called when a point is updated */
  80618. onPointUpdate: () => void;
  80619. /**
  80620. * Adds new points to the point collection
  80621. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80622. * @returns the list of created MultiLinePoint
  80623. */
  80624. add(...items: (AbstractMesh | Control | {
  80625. x: string | number;
  80626. y: string | number;
  80627. })[]): MultiLinePoint[];
  80628. /**
  80629. * Adds a new point to the point collection
  80630. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80631. * @returns the created MultiLinePoint
  80632. */
  80633. push(item?: (AbstractMesh | Control | {
  80634. x: string | number;
  80635. y: string | number;
  80636. })): MultiLinePoint;
  80637. /**
  80638. * Remove a specific value or point from the active point collection
  80639. * @param value defines the value or point to remove
  80640. */
  80641. remove(value: number | MultiLinePoint): void;
  80642. /**
  80643. * Resets this object to initial state (no point)
  80644. */
  80645. reset(): void;
  80646. /**
  80647. * Resets all links
  80648. */
  80649. resetLinks(): void;
  80650. /** Gets or sets line width */
  80651. get lineWidth(): number;
  80652. set lineWidth(value: number);
  80653. set horizontalAlignment(value: number);
  80654. set verticalAlignment(value: number);
  80655. protected _getTypeName(): string;
  80656. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80657. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80658. _measure(): void;
  80659. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80660. dispose(): void;
  80661. }
  80662. }
  80663. declare module BABYLON.GUI {
  80664. /**
  80665. * Class used to create radio button controls
  80666. */
  80667. export class RadioButton extends Control {
  80668. name?: string | undefined;
  80669. private _isChecked;
  80670. private _background;
  80671. private _checkSizeRatio;
  80672. private _thickness;
  80673. /** Gets or sets border thickness */
  80674. get thickness(): number;
  80675. set thickness(value: number);
  80676. /** Gets or sets group name */
  80677. group: string;
  80678. /** BABYLON.Observable raised when isChecked is changed */
  80679. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80680. /** Gets or sets a value indicating the ratio between overall size and check size */
  80681. get checkSizeRatio(): number;
  80682. set checkSizeRatio(value: number);
  80683. /** Gets or sets background color */
  80684. get background(): string;
  80685. set background(value: string);
  80686. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80687. get isChecked(): boolean;
  80688. set isChecked(value: boolean);
  80689. /**
  80690. * Creates a new RadioButton
  80691. * @param name defines the control name
  80692. */
  80693. constructor(name?: string | undefined);
  80694. protected _getTypeName(): string;
  80695. _draw(context: CanvasRenderingContext2D): void;
  80696. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80697. /**
  80698. * Utility function to easily create a radio button with a header
  80699. * @param title defines the label to use for the header
  80700. * @param group defines the group to use for the radio button
  80701. * @param isChecked defines the initial state of the radio button
  80702. * @param onValueChanged defines the callback to call when value changes
  80703. * @returns a StackPanel containing the radio button and a textBlock
  80704. */
  80705. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80706. }
  80707. }
  80708. declare module BABYLON.GUI {
  80709. /**
  80710. * Class used to create slider controls
  80711. */
  80712. export class BaseSlider extends Control {
  80713. name?: string | undefined;
  80714. protected _thumbWidth: ValueAndUnit;
  80715. private _minimum;
  80716. private _maximum;
  80717. private _value;
  80718. private _isVertical;
  80719. protected _barOffset: ValueAndUnit;
  80720. private _isThumbClamped;
  80721. protected _displayThumb: boolean;
  80722. private _step;
  80723. private _lastPointerDownID;
  80724. protected _effectiveBarOffset: number;
  80725. protected _renderLeft: number;
  80726. protected _renderTop: number;
  80727. protected _renderWidth: number;
  80728. protected _renderHeight: number;
  80729. protected _backgroundBoxLength: number;
  80730. protected _backgroundBoxThickness: number;
  80731. protected _effectiveThumbThickness: number;
  80732. /** BABYLON.Observable raised when the sldier value changes */
  80733. onValueChangedObservable: BABYLON.Observable<number>;
  80734. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80735. get displayThumb(): boolean;
  80736. set displayThumb(value: boolean);
  80737. /** Gets or sets a step to apply to values (0 by default) */
  80738. get step(): number;
  80739. set step(value: number);
  80740. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80741. get barOffset(): string | number;
  80742. /** Gets main bar offset in pixels*/
  80743. get barOffsetInPixels(): number;
  80744. set barOffset(value: string | number);
  80745. /** Gets or sets thumb width */
  80746. get thumbWidth(): string | number;
  80747. /** Gets thumb width in pixels */
  80748. get thumbWidthInPixels(): number;
  80749. set thumbWidth(value: string | number);
  80750. /** Gets or sets minimum value */
  80751. get minimum(): number;
  80752. set minimum(value: number);
  80753. /** Gets or sets maximum value */
  80754. get maximum(): number;
  80755. set maximum(value: number);
  80756. /** Gets or sets current value */
  80757. get value(): number;
  80758. set value(value: number);
  80759. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80760. get isVertical(): boolean;
  80761. set isVertical(value: boolean);
  80762. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80763. get isThumbClamped(): boolean;
  80764. set isThumbClamped(value: boolean);
  80765. /**
  80766. * Creates a new BaseSlider
  80767. * @param name defines the control name
  80768. */
  80769. constructor(name?: string | undefined);
  80770. protected _getTypeName(): string;
  80771. protected _getThumbPosition(): number;
  80772. protected _getThumbThickness(type: string): number;
  80773. protected _prepareRenderingData(type: string): void;
  80774. private _pointerIsDown;
  80775. /** @hidden */
  80776. protected _updateValueFromPointer(x: number, y: number): void;
  80777. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80778. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80779. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80780. _onCanvasBlur(): void;
  80781. }
  80782. }
  80783. declare module BABYLON.GUI {
  80784. /**
  80785. * Class used to create slider controls
  80786. */
  80787. export class Slider extends BaseSlider {
  80788. name?: string | undefined;
  80789. private _background;
  80790. private _borderColor;
  80791. private _thumbColor;
  80792. private _isThumbCircle;
  80793. protected _displayValueBar: boolean;
  80794. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80795. get displayValueBar(): boolean;
  80796. set displayValueBar(value: boolean);
  80797. /** Gets or sets border color */
  80798. get borderColor(): string;
  80799. set borderColor(value: string);
  80800. /** Gets or sets background color */
  80801. get background(): string;
  80802. set background(value: string);
  80803. /** Gets or sets thumb's color */
  80804. get thumbColor(): string;
  80805. set thumbColor(value: string);
  80806. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80807. get isThumbCircle(): boolean;
  80808. set isThumbCircle(value: boolean);
  80809. /**
  80810. * Creates a new Slider
  80811. * @param name defines the control name
  80812. */
  80813. constructor(name?: string | undefined);
  80814. protected _getTypeName(): string;
  80815. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80816. }
  80817. }
  80818. declare module BABYLON.GUI {
  80819. /** Class used to create a RadioGroup
  80820. * which contains groups of radio buttons
  80821. */
  80822. export class SelectorGroup {
  80823. /** name of SelectorGroup */
  80824. name: string;
  80825. private _groupPanel;
  80826. private _selectors;
  80827. private _groupHeader;
  80828. /**
  80829. * Creates a new SelectorGroup
  80830. * @param name of group, used as a group heading
  80831. */
  80832. constructor(
  80833. /** name of SelectorGroup */
  80834. name: string);
  80835. /** Gets the groupPanel of the SelectorGroup */
  80836. get groupPanel(): StackPanel;
  80837. /** Gets the selectors array */
  80838. get selectors(): StackPanel[];
  80839. /** Gets and sets the group header */
  80840. get header(): string;
  80841. set header(label: string);
  80842. /** @hidden */
  80843. private _addGroupHeader;
  80844. /** @hidden*/
  80845. _getSelector(selectorNb: number): StackPanel | undefined;
  80846. /** Removes the selector at the given position
  80847. * @param selectorNb the position of the selector within the group
  80848. */
  80849. removeSelector(selectorNb: number): void;
  80850. }
  80851. /** Class used to create a CheckboxGroup
  80852. * which contains groups of checkbox buttons
  80853. */
  80854. export class CheckboxGroup extends SelectorGroup {
  80855. /** Adds a checkbox as a control
  80856. * @param text is the label for the selector
  80857. * @param func is the function called when the Selector is checked
  80858. * @param checked is true when Selector is checked
  80859. */
  80860. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80861. /** @hidden */
  80862. _setSelectorLabel(selectorNb: number, label: string): void;
  80863. /** @hidden */
  80864. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80865. /** @hidden */
  80866. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80867. /** @hidden */
  80868. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80869. }
  80870. /** Class used to create a RadioGroup
  80871. * which contains groups of radio buttons
  80872. */
  80873. export class RadioGroup extends SelectorGroup {
  80874. private _selectNb;
  80875. /** Adds a radio button as a control
  80876. * @param label is the label for the selector
  80877. * @param func is the function called when the Selector is checked
  80878. * @param checked is true when Selector is checked
  80879. */
  80880. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80881. /** @hidden */
  80882. _setSelectorLabel(selectorNb: number, label: string): void;
  80883. /** @hidden */
  80884. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80885. /** @hidden */
  80886. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80887. /** @hidden */
  80888. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80889. }
  80890. /** Class used to create a SliderGroup
  80891. * which contains groups of slider buttons
  80892. */
  80893. export class SliderGroup extends SelectorGroup {
  80894. /**
  80895. * Adds a slider to the SelectorGroup
  80896. * @param label is the label for the SliderBar
  80897. * @param func is the function called when the Slider moves
  80898. * @param unit is a string describing the units used, eg degrees or metres
  80899. * @param min is the minimum value for the Slider
  80900. * @param max is the maximum value for the Slider
  80901. * @param value is the start value for the Slider between min and max
  80902. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80903. */
  80904. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80905. /** @hidden */
  80906. _setSelectorLabel(selectorNb: number, label: string): void;
  80907. /** @hidden */
  80908. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80909. /** @hidden */
  80910. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80911. /** @hidden */
  80912. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80913. }
  80914. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80915. * @see https://doc.babylonjs.com/how_to/selector
  80916. */
  80917. export class SelectionPanel extends Rectangle {
  80918. /** name of SelectionPanel */
  80919. name: string;
  80920. /** an array of SelectionGroups */
  80921. groups: SelectorGroup[];
  80922. private _panel;
  80923. private _buttonColor;
  80924. private _buttonBackground;
  80925. private _headerColor;
  80926. private _barColor;
  80927. private _barHeight;
  80928. private _spacerHeight;
  80929. private _labelColor;
  80930. private _groups;
  80931. private _bars;
  80932. /**
  80933. * Creates a new SelectionPanel
  80934. * @param name of SelectionPanel
  80935. * @param groups is an array of SelectionGroups
  80936. */
  80937. constructor(
  80938. /** name of SelectionPanel */
  80939. name: string,
  80940. /** an array of SelectionGroups */
  80941. groups?: SelectorGroup[]);
  80942. protected _getTypeName(): string;
  80943. /** Gets the (stack) panel of the SelectionPanel */
  80944. get panel(): StackPanel;
  80945. /** Gets or sets the headerColor */
  80946. get headerColor(): string;
  80947. set headerColor(color: string);
  80948. private _setHeaderColor;
  80949. /** Gets or sets the button color */
  80950. get buttonColor(): string;
  80951. set buttonColor(color: string);
  80952. private _setbuttonColor;
  80953. /** Gets or sets the label color */
  80954. get labelColor(): string;
  80955. set labelColor(color: string);
  80956. private _setLabelColor;
  80957. /** Gets or sets the button background */
  80958. get buttonBackground(): string;
  80959. set buttonBackground(color: string);
  80960. private _setButtonBackground;
  80961. /** Gets or sets the color of separator bar */
  80962. get barColor(): string;
  80963. set barColor(color: string);
  80964. private _setBarColor;
  80965. /** Gets or sets the height of separator bar */
  80966. get barHeight(): string;
  80967. set barHeight(value: string);
  80968. private _setBarHeight;
  80969. /** Gets or sets the height of spacers*/
  80970. get spacerHeight(): string;
  80971. set spacerHeight(value: string);
  80972. private _setSpacerHeight;
  80973. /** Adds a bar between groups */
  80974. private _addSpacer;
  80975. /** Add a group to the selection panel
  80976. * @param group is the selector group to add
  80977. */
  80978. addGroup(group: SelectorGroup): void;
  80979. /** Remove the group from the given position
  80980. * @param groupNb is the position of the group in the list
  80981. */
  80982. removeGroup(groupNb: number): void;
  80983. /** Change a group header label
  80984. * @param label is the new group header label
  80985. * @param groupNb is the number of the group to relabel
  80986. * */
  80987. setHeaderName(label: string, groupNb: number): void;
  80988. /** Change selector label to the one given
  80989. * @param label is the new selector label
  80990. * @param groupNb is the number of the groupcontaining the selector
  80991. * @param selectorNb is the number of the selector within a group to relabel
  80992. * */
  80993. relabel(label: string, groupNb: number, selectorNb: number): void;
  80994. /** For a given group position remove the selector at the given position
  80995. * @param groupNb is the number of the group to remove the selector from
  80996. * @param selectorNb is the number of the selector within the group
  80997. */
  80998. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80999. /** For a given group position of correct type add a checkbox button
  81000. * @param groupNb is the number of the group to remove the selector from
  81001. * @param label is the label for the selector
  81002. * @param func is the function called when the Selector is checked
  81003. * @param checked is true when Selector is checked
  81004. */
  81005. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81006. /** For a given group position of correct type add a radio button
  81007. * @param groupNb is the number of the group to remove the selector from
  81008. * @param label is the label for the selector
  81009. * @param func is the function called when the Selector is checked
  81010. * @param checked is true when Selector is checked
  81011. */
  81012. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81013. /**
  81014. * For a given slider group add a slider
  81015. * @param groupNb is the number of the group to add the slider to
  81016. * @param label is the label for the Slider
  81017. * @param func is the function called when the Slider moves
  81018. * @param unit is a string describing the units used, eg degrees or metres
  81019. * @param min is the minimum value for the Slider
  81020. * @param max is the maximum value for the Slider
  81021. * @param value is the start value for the Slider between min and max
  81022. * @param onVal is the function used to format the value displayed, eg radians to degrees
  81023. */
  81024. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  81025. }
  81026. }
  81027. declare module BABYLON.GUI {
  81028. /**
  81029. * Class used to hold a the container for ScrollViewer
  81030. * @hidden
  81031. */
  81032. export class _ScrollViewerWindow extends Container {
  81033. parentClientWidth: number;
  81034. parentClientHeight: number;
  81035. private _freezeControls;
  81036. private _parentMeasure;
  81037. private _oldLeft;
  81038. private _oldTop;
  81039. get freezeControls(): boolean;
  81040. set freezeControls(value: boolean);
  81041. private _bucketWidth;
  81042. private _bucketHeight;
  81043. private _buckets;
  81044. private _bucketLen;
  81045. get bucketWidth(): number;
  81046. get bucketHeight(): number;
  81047. setBucketSizes(width: number, height: number): void;
  81048. private _useBuckets;
  81049. private _makeBuckets;
  81050. private _dispatchInBuckets;
  81051. private _updateMeasures;
  81052. private _updateChildrenMeasures;
  81053. private _restoreMeasures;
  81054. /**
  81055. * Creates a new ScrollViewerWindow
  81056. * @param name of ScrollViewerWindow
  81057. */
  81058. constructor(name?: string);
  81059. protected _getTypeName(): string;
  81060. /** @hidden */
  81061. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81062. /** @hidden */
  81063. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  81064. private _scrollChildren;
  81065. private _scrollChildrenWithBuckets;
  81066. /** @hidden */
  81067. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  81068. protected _postMeasure(): void;
  81069. }
  81070. }
  81071. declare module BABYLON.GUI {
  81072. /**
  81073. * Class used to create slider controls
  81074. */
  81075. export class ScrollBar extends BaseSlider {
  81076. name?: string | undefined;
  81077. private _background;
  81078. private _borderColor;
  81079. private _tempMeasure;
  81080. /** Gets or sets border color */
  81081. get borderColor(): string;
  81082. set borderColor(value: string);
  81083. /** Gets or sets background color */
  81084. get background(): string;
  81085. set background(value: string);
  81086. /**
  81087. * Creates a new Slider
  81088. * @param name defines the control name
  81089. */
  81090. constructor(name?: string | undefined);
  81091. protected _getTypeName(): string;
  81092. protected _getThumbThickness(): number;
  81093. _draw(context: CanvasRenderingContext2D): void;
  81094. private _first;
  81095. private _originX;
  81096. private _originY;
  81097. /** @hidden */
  81098. protected _updateValueFromPointer(x: number, y: number): void;
  81099. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81100. }
  81101. }
  81102. declare module BABYLON.GUI {
  81103. /**
  81104. * Class used to create slider controls
  81105. */
  81106. export class ImageScrollBar extends BaseSlider {
  81107. name?: string | undefined;
  81108. private _backgroundBaseImage;
  81109. private _backgroundImage;
  81110. private _thumbImage;
  81111. private _thumbBaseImage;
  81112. private _thumbLength;
  81113. private _thumbHeight;
  81114. private _barImageHeight;
  81115. private _tempMeasure;
  81116. /** Number of 90° rotation to apply on the images when in vertical mode */
  81117. num90RotationInVerticalMode: number;
  81118. /**
  81119. * Gets or sets the image used to render the background for horizontal bar
  81120. */
  81121. get backgroundImage(): Image;
  81122. set backgroundImage(value: Image);
  81123. /**
  81124. * Gets or sets the image used to render the thumb
  81125. */
  81126. get thumbImage(): Image;
  81127. set thumbImage(value: Image);
  81128. /**
  81129. * Gets or sets the length of the thumb
  81130. */
  81131. get thumbLength(): number;
  81132. set thumbLength(value: number);
  81133. /**
  81134. * Gets or sets the height of the thumb
  81135. */
  81136. get thumbHeight(): number;
  81137. set thumbHeight(value: number);
  81138. /**
  81139. * Gets or sets the height of the bar image
  81140. */
  81141. get barImageHeight(): number;
  81142. set barImageHeight(value: number);
  81143. /**
  81144. * Creates a new ImageScrollBar
  81145. * @param name defines the control name
  81146. */
  81147. constructor(name?: string | undefined);
  81148. protected _getTypeName(): string;
  81149. protected _getThumbThickness(): number;
  81150. _draw(context: CanvasRenderingContext2D): void;
  81151. private _first;
  81152. private _originX;
  81153. private _originY;
  81154. /** @hidden */
  81155. protected _updateValueFromPointer(x: number, y: number): void;
  81156. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81157. }
  81158. }
  81159. declare module BABYLON.GUI {
  81160. /**
  81161. * Class used to hold a viewer window and sliders in a grid
  81162. */
  81163. export class ScrollViewer extends Rectangle {
  81164. private _grid;
  81165. private _horizontalBarSpace;
  81166. private _verticalBarSpace;
  81167. private _dragSpace;
  81168. private _horizontalBar;
  81169. private _verticalBar;
  81170. private _barColor;
  81171. private _barBackground;
  81172. private _barImage;
  81173. private _horizontalBarImage;
  81174. private _verticalBarImage;
  81175. private _barBackgroundImage;
  81176. private _horizontalBarBackgroundImage;
  81177. private _verticalBarBackgroundImage;
  81178. private _barSize;
  81179. private _window;
  81180. private _pointerIsOver;
  81181. private _wheelPrecision;
  81182. private _onWheelObserver;
  81183. private _clientWidth;
  81184. private _clientHeight;
  81185. private _useImageBar;
  81186. private _thumbLength;
  81187. private _thumbHeight;
  81188. private _barImageHeight;
  81189. private _horizontalBarImageHeight;
  81190. private _verticalBarImageHeight;
  81191. private _oldWindowContentsWidth;
  81192. private _oldWindowContentsHeight;
  81193. /**
  81194. * Gets the horizontal scrollbar
  81195. */
  81196. get horizontalBar(): ScrollBar | ImageScrollBar;
  81197. /**
  81198. * Gets the vertical scrollbar
  81199. */
  81200. get verticalBar(): ScrollBar | ImageScrollBar;
  81201. /**
  81202. * Adds a new control to the current container
  81203. * @param control defines the control to add
  81204. * @returns the current container
  81205. */
  81206. addControl(control: BABYLON.Nullable<Control>): Container;
  81207. /**
  81208. * Removes a control from the current container
  81209. * @param control defines the control to remove
  81210. * @returns the current container
  81211. */
  81212. removeControl(control: Control): Container;
  81213. /** Gets the list of children */
  81214. get children(): Control[];
  81215. _flagDescendantsAsMatrixDirty(): void;
  81216. /**
  81217. * Freezes or unfreezes the controls in the window.
  81218. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81219. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81220. */
  81221. get freezeControls(): boolean;
  81222. set freezeControls(value: boolean);
  81223. /** Gets the bucket width */
  81224. get bucketWidth(): number;
  81225. /** Gets the bucket height */
  81226. get bucketHeight(): number;
  81227. /**
  81228. * Sets the bucket sizes.
  81229. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81230. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81231. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81232. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81233. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81234. * used), that's why it is not enabled by default.
  81235. * @param width width of the bucket
  81236. * @param height height of the bucket
  81237. */
  81238. setBucketSizes(width: number, height: number): void;
  81239. private _forceHorizontalBar;
  81240. private _forceVerticalBar;
  81241. /**
  81242. * Forces the horizontal scroll bar to be displayed
  81243. */
  81244. get forceHorizontalBar(): boolean;
  81245. set forceHorizontalBar(value: boolean);
  81246. /**
  81247. * Forces the vertical scroll bar to be displayed
  81248. */
  81249. get forceVerticalBar(): boolean;
  81250. set forceVerticalBar(value: boolean);
  81251. /**
  81252. * Creates a new ScrollViewer
  81253. * @param name of ScrollViewer
  81254. */
  81255. constructor(name?: string, isImageBased?: boolean);
  81256. /** Reset the scroll viewer window to initial size */
  81257. resetWindow(): void;
  81258. protected _getTypeName(): string;
  81259. private _buildClientSizes;
  81260. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81261. protected _postMeasure(): void;
  81262. /**
  81263. * Gets or sets the mouse wheel precision
  81264. * from 0 to 1 with a default value of 0.05
  81265. * */
  81266. get wheelPrecision(): number;
  81267. set wheelPrecision(value: number);
  81268. /** Gets or sets the scroll bar container background color */
  81269. get scrollBackground(): string;
  81270. set scrollBackground(color: string);
  81271. /** Gets or sets the bar color */
  81272. get barColor(): string;
  81273. set barColor(color: string);
  81274. /** Gets or sets the bar image */
  81275. get thumbImage(): Image;
  81276. set thumbImage(value: Image);
  81277. /** Gets or sets the horizontal bar image */
  81278. get horizontalThumbImage(): Image;
  81279. set horizontalThumbImage(value: Image);
  81280. /** Gets or sets the vertical bar image */
  81281. get verticalThumbImage(): Image;
  81282. set verticalThumbImage(value: Image);
  81283. /** Gets or sets the size of the bar */
  81284. get barSize(): number;
  81285. set barSize(value: number);
  81286. /** Gets or sets the length of the thumb */
  81287. get thumbLength(): number;
  81288. set thumbLength(value: number);
  81289. /** Gets or sets the height of the thumb */
  81290. get thumbHeight(): number;
  81291. set thumbHeight(value: number);
  81292. /** Gets or sets the height of the bar image */
  81293. get barImageHeight(): number;
  81294. set barImageHeight(value: number);
  81295. /** Gets or sets the height of the horizontal bar image */
  81296. get horizontalBarImageHeight(): number;
  81297. set horizontalBarImageHeight(value: number);
  81298. /** Gets or sets the height of the vertical bar image */
  81299. get verticalBarImageHeight(): number;
  81300. set verticalBarImageHeight(value: number);
  81301. /** Gets or sets the bar background */
  81302. get barBackground(): string;
  81303. set barBackground(color: string);
  81304. /** Gets or sets the bar background image */
  81305. get barImage(): Image;
  81306. set barImage(value: Image);
  81307. /** Gets or sets the horizontal bar background image */
  81308. get horizontalBarImage(): Image;
  81309. set horizontalBarImage(value: Image);
  81310. /** Gets or sets the vertical bar background image */
  81311. get verticalBarImage(): Image;
  81312. set verticalBarImage(value: Image);
  81313. private _setWindowPosition;
  81314. /** @hidden */
  81315. private _updateScroller;
  81316. _link(host: AdvancedDynamicTexture): void;
  81317. /** @hidden */
  81318. private _addBar;
  81319. /** @hidden */
  81320. private _attachWheel;
  81321. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81322. /** Releases associated resources */
  81323. dispose(): void;
  81324. }
  81325. }
  81326. declare module BABYLON.GUI {
  81327. /** Class used to render a grid */
  81328. export class DisplayGrid extends Control {
  81329. name?: string | undefined;
  81330. private _cellWidth;
  81331. private _cellHeight;
  81332. private _minorLineTickness;
  81333. private _minorLineColor;
  81334. private _majorLineTickness;
  81335. private _majorLineColor;
  81336. private _majorLineFrequency;
  81337. private _background;
  81338. private _displayMajorLines;
  81339. private _displayMinorLines;
  81340. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81341. get displayMinorLines(): boolean;
  81342. set displayMinorLines(value: boolean);
  81343. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81344. get displayMajorLines(): boolean;
  81345. set displayMajorLines(value: boolean);
  81346. /** Gets or sets background color (Black by default) */
  81347. get background(): string;
  81348. set background(value: string);
  81349. /** Gets or sets the width of each cell (20 by default) */
  81350. get cellWidth(): number;
  81351. set cellWidth(value: number);
  81352. /** Gets or sets the height of each cell (20 by default) */
  81353. get cellHeight(): number;
  81354. set cellHeight(value: number);
  81355. /** Gets or sets the tickness of minor lines (1 by default) */
  81356. get minorLineTickness(): number;
  81357. set minorLineTickness(value: number);
  81358. /** Gets or sets the color of minor lines (DarkGray by default) */
  81359. get minorLineColor(): string;
  81360. set minorLineColor(value: string);
  81361. /** Gets or sets the tickness of major lines (2 by default) */
  81362. get majorLineTickness(): number;
  81363. set majorLineTickness(value: number);
  81364. /** Gets or sets the color of major lines (White by default) */
  81365. get majorLineColor(): string;
  81366. set majorLineColor(value: string);
  81367. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81368. get majorLineFrequency(): number;
  81369. set majorLineFrequency(value: number);
  81370. /**
  81371. * Creates a new GridDisplayRectangle
  81372. * @param name defines the control name
  81373. */
  81374. constructor(name?: string | undefined);
  81375. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81376. protected _getTypeName(): string;
  81377. }
  81378. }
  81379. declare module BABYLON.GUI {
  81380. /**
  81381. * Class used to create slider controls based on images
  81382. */
  81383. export class ImageBasedSlider extends BaseSlider {
  81384. name?: string | undefined;
  81385. private _backgroundImage;
  81386. private _thumbImage;
  81387. private _valueBarImage;
  81388. private _tempMeasure;
  81389. get displayThumb(): boolean;
  81390. set displayThumb(value: boolean);
  81391. /**
  81392. * Gets or sets the image used to render the background
  81393. */
  81394. get backgroundImage(): Image;
  81395. set backgroundImage(value: Image);
  81396. /**
  81397. * Gets or sets the image used to render the value bar
  81398. */
  81399. get valueBarImage(): Image;
  81400. set valueBarImage(value: Image);
  81401. /**
  81402. * Gets or sets the image used to render the thumb
  81403. */
  81404. get thumbImage(): Image;
  81405. set thumbImage(value: Image);
  81406. /**
  81407. * Creates a new ImageBasedSlider
  81408. * @param name defines the control name
  81409. */
  81410. constructor(name?: string | undefined);
  81411. protected _getTypeName(): string;
  81412. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81413. }
  81414. }
  81415. declare module BABYLON.GUI {
  81416. /**
  81417. * Forcing an export so that this code will execute
  81418. * @hidden
  81419. */
  81420. const name = "Statics";
  81421. }
  81422. declare module BABYLON.GUI {
  81423. /**
  81424. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81425. */
  81426. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81427. /**
  81428. * Define the instrumented AdvancedDynamicTexture.
  81429. */
  81430. texture: AdvancedDynamicTexture;
  81431. private _captureRenderTime;
  81432. private _renderTime;
  81433. private _captureLayoutTime;
  81434. private _layoutTime;
  81435. private _onBeginRenderObserver;
  81436. private _onEndRenderObserver;
  81437. private _onBeginLayoutObserver;
  81438. private _onEndLayoutObserver;
  81439. /**
  81440. * Gets the perf counter used to capture render time
  81441. */
  81442. get renderTimeCounter(): BABYLON.PerfCounter;
  81443. /**
  81444. * Gets the perf counter used to capture layout time
  81445. */
  81446. get layoutTimeCounter(): BABYLON.PerfCounter;
  81447. /**
  81448. * Enable or disable the render time capture
  81449. */
  81450. get captureRenderTime(): boolean;
  81451. set captureRenderTime(value: boolean);
  81452. /**
  81453. * Enable or disable the layout time capture
  81454. */
  81455. get captureLayoutTime(): boolean;
  81456. set captureLayoutTime(value: boolean);
  81457. /**
  81458. * Instantiates a new advanced dynamic texture instrumentation.
  81459. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81460. * @param texture Defines the AdvancedDynamicTexture to instrument
  81461. */
  81462. constructor(
  81463. /**
  81464. * Define the instrumented AdvancedDynamicTexture.
  81465. */
  81466. texture: AdvancedDynamicTexture);
  81467. /**
  81468. * Dispose and release associated resources.
  81469. */
  81470. dispose(): void;
  81471. }
  81472. }
  81473. declare module BABYLON.GUI {
  81474. /**
  81475. * Class used to load GUI via XML.
  81476. */
  81477. export class XmlLoader {
  81478. private _nodes;
  81479. private _nodeTypes;
  81480. private _isLoaded;
  81481. private _objectAttributes;
  81482. private _parentClass;
  81483. /**
  81484. * Create a new xml loader
  81485. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81486. */
  81487. constructor(parentClass?: null);
  81488. private _getChainElement;
  81489. private _getClassAttribute;
  81490. private _createGuiElement;
  81491. private _parseGrid;
  81492. private _parseElement;
  81493. private _prepareSourceElement;
  81494. private _parseElementsFromSource;
  81495. private _parseXml;
  81496. /**
  81497. * Gets if the loading has finished.
  81498. * @returns whether the loading has finished or not
  81499. */
  81500. isLoaded(): boolean;
  81501. /**
  81502. * Gets a loaded node / control by id.
  81503. * @param id the Controls id set in the xml
  81504. * @returns element of type Control
  81505. */
  81506. getNodeById(id: string): any;
  81507. /**
  81508. * Gets all loaded nodes / controls
  81509. * @returns Array of controls
  81510. */
  81511. getNodes(): any;
  81512. /**
  81513. * Initiates the xml layout loading
  81514. * @param xmlFile defines the xml layout to load
  81515. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81516. * @param callback defines the callback called on layout load.
  81517. */
  81518. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81519. }
  81520. }
  81521. declare module BABYLON.GUI {
  81522. /**
  81523. * Class used to create containers for controls
  81524. */
  81525. export class Container3D extends Control3D {
  81526. private _blockLayout;
  81527. /**
  81528. * Gets the list of child controls
  81529. */
  81530. protected _children: Control3D[];
  81531. /**
  81532. * Gets the list of child controls
  81533. */
  81534. get children(): Array<Control3D>;
  81535. /**
  81536. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81537. * This is helpful to optimize layout operation when adding multiple children in a row
  81538. */
  81539. get blockLayout(): boolean;
  81540. set blockLayout(value: boolean);
  81541. /**
  81542. * Creates a new container
  81543. * @param name defines the container name
  81544. */
  81545. constructor(name?: string);
  81546. /**
  81547. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81548. * @returns the current container
  81549. */
  81550. updateLayout(): Container3D;
  81551. /**
  81552. * Gets a boolean indicating if the given control is in the children of this control
  81553. * @param control defines the control to check
  81554. * @returns true if the control is in the child list
  81555. */
  81556. containsControl(control: Control3D): boolean;
  81557. /**
  81558. * Adds a control to the children of this control
  81559. * @param control defines the control to add
  81560. * @returns the current container
  81561. */
  81562. addControl(control: Control3D): Container3D;
  81563. /**
  81564. * This function will be called everytime a new control is added
  81565. */
  81566. protected _arrangeChildren(): void;
  81567. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81568. /**
  81569. * Removes a control from the children of this control
  81570. * @param control defines the control to remove
  81571. * @returns the current container
  81572. */
  81573. removeControl(control: Control3D): Container3D;
  81574. protected _getTypeName(): string;
  81575. /**
  81576. * Releases all associated resources
  81577. */
  81578. dispose(): void;
  81579. /** Control rotation will remain unchanged */
  81580. static readonly UNSET_ORIENTATION: number;
  81581. /** Control will rotate to make it look at sphere central axis */
  81582. static readonly FACEORIGIN_ORIENTATION: number;
  81583. /** Control will rotate to make it look back at sphere central axis */
  81584. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81585. /** Control will rotate to look at z axis (0, 0, 1) */
  81586. static readonly FACEFORWARD_ORIENTATION: number;
  81587. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81588. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81589. }
  81590. }
  81591. declare module BABYLON.GUI {
  81592. /**
  81593. * Class used to manage 3D user interface
  81594. * @see https://doc.babylonjs.com/how_to/gui3d
  81595. */
  81596. export class GUI3DManager implements BABYLON.IDisposable {
  81597. private _scene;
  81598. private _sceneDisposeObserver;
  81599. private _utilityLayer;
  81600. private _rootContainer;
  81601. private _pointerObserver;
  81602. private _pointerOutObserver;
  81603. /** @hidden */
  81604. _lastPickedControl: Control3D;
  81605. /** @hidden */
  81606. _lastControlOver: {
  81607. [pointerId: number]: Control3D;
  81608. };
  81609. /** @hidden */
  81610. _lastControlDown: {
  81611. [pointerId: number]: Control3D;
  81612. };
  81613. /**
  81614. * BABYLON.Observable raised when the point picked by the pointer events changed
  81615. */
  81616. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81617. /** @hidden */
  81618. _sharedMaterials: {
  81619. [key: string]: BABYLON.Material;
  81620. };
  81621. /** Gets the hosting scene */
  81622. get scene(): BABYLON.Scene;
  81623. /** Gets associated utility layer */
  81624. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81625. /**
  81626. * Creates a new GUI3DManager
  81627. * @param scene
  81628. */
  81629. constructor(scene?: BABYLON.Scene);
  81630. private _handlePointerOut;
  81631. private _doPicking;
  81632. /**
  81633. * Gets the root container
  81634. */
  81635. get rootContainer(): Container3D;
  81636. /**
  81637. * Gets a boolean indicating if the given control is in the root child list
  81638. * @param control defines the control to check
  81639. * @returns true if the control is in the root child list
  81640. */
  81641. containsControl(control: Control3D): boolean;
  81642. /**
  81643. * Adds a control to the root child list
  81644. * @param control defines the control to add
  81645. * @returns the current manager
  81646. */
  81647. addControl(control: Control3D): GUI3DManager;
  81648. /**
  81649. * Removes a control from the root child list
  81650. * @param control defines the control to remove
  81651. * @returns the current container
  81652. */
  81653. removeControl(control: Control3D): GUI3DManager;
  81654. /**
  81655. * Releases all associated resources
  81656. */
  81657. dispose(): void;
  81658. }
  81659. }
  81660. declare module BABYLON.GUI {
  81661. /**
  81662. * Class used to transport BABYLON.Vector3 information for pointer events
  81663. */
  81664. export class Vector3WithInfo extends BABYLON.Vector3 {
  81665. /** defines the current mouse button index */
  81666. buttonIndex: number;
  81667. /**
  81668. * Creates a new Vector3WithInfo
  81669. * @param source defines the vector3 data to transport
  81670. * @param buttonIndex defines the current mouse button index
  81671. */
  81672. constructor(source: BABYLON.Vector3,
  81673. /** defines the current mouse button index */
  81674. buttonIndex?: number);
  81675. }
  81676. }
  81677. declare module BABYLON.GUI {
  81678. /**
  81679. * Class used as base class for controls
  81680. */
  81681. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81682. /** Defines the control name */
  81683. name?: string | undefined;
  81684. /** @hidden */
  81685. _host: GUI3DManager;
  81686. private _node;
  81687. private _downCount;
  81688. private _enterCount;
  81689. private _downPointerIds;
  81690. private _isVisible;
  81691. /** Gets or sets the control position in world space */
  81692. get position(): BABYLON.Vector3;
  81693. set position(value: BABYLON.Vector3);
  81694. /** Gets or sets the control scaling in world space */
  81695. get scaling(): BABYLON.Vector3;
  81696. set scaling(value: BABYLON.Vector3);
  81697. /** Callback used to start pointer enter animation */
  81698. pointerEnterAnimation: () => void;
  81699. /** Callback used to start pointer out animation */
  81700. pointerOutAnimation: () => void;
  81701. /** Callback used to start pointer down animation */
  81702. pointerDownAnimation: () => void;
  81703. /** Callback used to start pointer up animation */
  81704. pointerUpAnimation: () => void;
  81705. /**
  81706. * An event triggered when the pointer move over the control
  81707. */
  81708. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81709. /**
  81710. * An event triggered when the pointer move out of the control
  81711. */
  81712. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81713. /**
  81714. * An event triggered when the pointer taps the control
  81715. */
  81716. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81717. /**
  81718. * An event triggered when pointer is up
  81719. */
  81720. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81721. /**
  81722. * An event triggered when a control is clicked on (with a mouse)
  81723. */
  81724. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81725. /**
  81726. * An event triggered when pointer enters the control
  81727. */
  81728. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81729. /**
  81730. * Gets or sets the parent container
  81731. */
  81732. parent: BABYLON.Nullable<Container3D>;
  81733. private _behaviors;
  81734. /**
  81735. * Gets the list of attached behaviors
  81736. * @see https://doc.babylonjs.com/features/behaviour
  81737. */
  81738. get behaviors(): BABYLON.Behavior<Control3D>[];
  81739. /**
  81740. * Attach a behavior to the control
  81741. * @see https://doc.babylonjs.com/features/behaviour
  81742. * @param behavior defines the behavior to attach
  81743. * @returns the current control
  81744. */
  81745. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81746. /**
  81747. * Remove an attached behavior
  81748. * @see https://doc.babylonjs.com/features/behaviour
  81749. * @param behavior defines the behavior to attach
  81750. * @returns the current control
  81751. */
  81752. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81753. /**
  81754. * Gets an attached behavior by name
  81755. * @param name defines the name of the behavior to look for
  81756. * @see https://doc.babylonjs.com/features/behaviour
  81757. * @returns null if behavior was not found else the requested behavior
  81758. */
  81759. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81760. /** Gets or sets a boolean indicating if the control is visible */
  81761. get isVisible(): boolean;
  81762. set isVisible(value: boolean);
  81763. /**
  81764. * Creates a new control
  81765. * @param name defines the control name
  81766. */
  81767. constructor(
  81768. /** Defines the control name */
  81769. name?: string | undefined);
  81770. /**
  81771. * Gets a string representing the class name
  81772. */
  81773. get typeName(): string;
  81774. /**
  81775. * Get the current class name of the control.
  81776. * @returns current class name
  81777. */
  81778. getClassName(): string;
  81779. protected _getTypeName(): string;
  81780. /**
  81781. * Gets the transform node used by this control
  81782. */
  81783. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81784. /**
  81785. * Gets the mesh used to render this control
  81786. */
  81787. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81788. /**
  81789. * Link the control as child of the given node
  81790. * @param node defines the node to link to. Use null to unlink the control
  81791. * @returns the current control
  81792. */
  81793. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81794. /** @hidden **/
  81795. _prepareNode(scene: BABYLON.Scene): void;
  81796. /**
  81797. * Node creation.
  81798. * Can be overriden by children
  81799. * @param scene defines the scene where the node must be attached
  81800. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81801. */
  81802. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81803. /**
  81804. * Affect a material to the given mesh
  81805. * @param mesh defines the mesh which will represent the control
  81806. */
  81807. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81808. /** @hidden */
  81809. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81810. /** @hidden */
  81811. _onPointerEnter(target: Control3D): boolean;
  81812. /** @hidden */
  81813. _onPointerOut(target: Control3D): void;
  81814. /** @hidden */
  81815. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81816. /** @hidden */
  81817. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81818. /** @hidden */
  81819. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81820. /** @hidden */
  81821. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81822. /** @hidden */
  81823. _disposeNode(): void;
  81824. /**
  81825. * Releases all associated resources
  81826. */
  81827. dispose(): void;
  81828. }
  81829. }
  81830. declare module BABYLON.GUI {
  81831. /**
  81832. * Class used as a root to all buttons
  81833. */
  81834. export class AbstractButton3D extends Control3D {
  81835. /**
  81836. * Creates a new button
  81837. * @param name defines the control name
  81838. */
  81839. constructor(name?: string);
  81840. protected _getTypeName(): string;
  81841. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81842. }
  81843. }
  81844. declare module BABYLON.GUI {
  81845. /**
  81846. * Class used to create a button in 3D
  81847. */
  81848. export class Button3D extends AbstractButton3D {
  81849. /** @hidden */
  81850. protected _currentMaterial: BABYLON.Material;
  81851. private _facadeTexture;
  81852. private _content;
  81853. private _contentResolution;
  81854. private _contentScaleRatio;
  81855. /**
  81856. * Gets or sets the texture resolution used to render content (512 by default)
  81857. */
  81858. get contentResolution(): BABYLON.int;
  81859. set contentResolution(value: BABYLON.int);
  81860. /**
  81861. * Gets or sets the texture scale ratio used to render content (2 by default)
  81862. */
  81863. get contentScaleRatio(): number;
  81864. set contentScaleRatio(value: number);
  81865. protected _disposeFacadeTexture(): void;
  81866. protected _resetContent(): void;
  81867. /**
  81868. * Creates a new button
  81869. * @param name defines the control name
  81870. */
  81871. constructor(name?: string);
  81872. /**
  81873. * Gets or sets the GUI 2D content used to display the button's facade
  81874. */
  81875. get content(): Control;
  81876. set content(value: Control);
  81877. /**
  81878. * Apply the facade texture (created from the content property).
  81879. * This function can be overloaded by child classes
  81880. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81881. */
  81882. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81883. protected _getTypeName(): string;
  81884. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81885. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81886. /**
  81887. * Releases all associated resources
  81888. */
  81889. dispose(): void;
  81890. }
  81891. }
  81892. declare module BABYLON.GUI {
  81893. /**
  81894. * Abstract class used to create a container panel deployed on the surface of a volume
  81895. */
  81896. export abstract class VolumeBasedPanel extends Container3D {
  81897. private _columns;
  81898. private _rows;
  81899. private _rowThenColum;
  81900. private _orientation;
  81901. protected _cellWidth: number;
  81902. protected _cellHeight: number;
  81903. /**
  81904. * Gets or sets the distance between elements
  81905. */
  81906. margin: number;
  81907. /**
  81908. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81909. * | Value | Type | Description |
  81910. * | ----- | ----------------------------------- | ----------- |
  81911. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81912. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81913. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81914. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81915. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81916. */
  81917. get orientation(): number;
  81918. set orientation(value: number);
  81919. /**
  81920. * Gets or sets the number of columns requested (10 by default).
  81921. * The panel will automatically compute the number of rows based on number of child controls.
  81922. */
  81923. get columns(): BABYLON.int;
  81924. set columns(value: BABYLON.int);
  81925. /**
  81926. * Gets or sets a the number of rows requested.
  81927. * The panel will automatically compute the number of columns based on number of child controls.
  81928. */
  81929. get rows(): BABYLON.int;
  81930. set rows(value: BABYLON.int);
  81931. /**
  81932. * Creates new VolumeBasedPanel
  81933. */
  81934. constructor();
  81935. protected _arrangeChildren(): void;
  81936. /** Child classes must implement this function to provide correct control positioning */
  81937. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81938. /** Child classes can implement this function to provide additional processing */
  81939. protected _finalProcessing(): void;
  81940. }
  81941. }
  81942. declare module BABYLON.GUI {
  81943. /**
  81944. * Class used to create a container panel deployed on the surface of a cylinder
  81945. */
  81946. export class CylinderPanel extends VolumeBasedPanel {
  81947. private _radius;
  81948. /**
  81949. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81950. */
  81951. get radius(): BABYLON.float;
  81952. set radius(value: BABYLON.float);
  81953. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81954. private _cylindricalMapping;
  81955. }
  81956. }
  81957. declare module BABYLON.GUI {
  81958. /** @hidden */
  81959. export var fluentVertexShader: {
  81960. name: string;
  81961. shader: string;
  81962. };
  81963. }
  81964. declare module BABYLON.GUI {
  81965. /** @hidden */
  81966. export var fluentPixelShader: {
  81967. name: string;
  81968. shader: string;
  81969. };
  81970. }
  81971. declare module BABYLON.GUI {
  81972. /** @hidden */
  81973. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81974. INNERGLOW: boolean;
  81975. BORDER: boolean;
  81976. HOVERLIGHT: boolean;
  81977. TEXTURE: boolean;
  81978. constructor();
  81979. }
  81980. /**
  81981. * Class used to render controls with fluent desgin
  81982. */
  81983. export class FluentMaterial extends BABYLON.PushMaterial {
  81984. /**
  81985. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81986. */
  81987. innerGlowColorIntensity: number;
  81988. /**
  81989. * Gets or sets the inner glow color (white by default)
  81990. */
  81991. innerGlowColor: BABYLON.Color3;
  81992. /**
  81993. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81994. */
  81995. albedoColor: BABYLON.Color3;
  81996. /**
  81997. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81998. */
  81999. renderBorders: boolean;
  82000. /**
  82001. * Gets or sets border width (default is 0.5)
  82002. */
  82003. borderWidth: number;
  82004. /**
  82005. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  82006. */
  82007. edgeSmoothingValue: number;
  82008. /**
  82009. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  82010. */
  82011. borderMinValue: number;
  82012. /**
  82013. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  82014. */
  82015. renderHoverLight: boolean;
  82016. /**
  82017. * Gets or sets the radius used to render the hover light (default is 1.0)
  82018. */
  82019. hoverRadius: number;
  82020. /**
  82021. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  82022. */
  82023. hoverColor: BABYLON.Color4;
  82024. /**
  82025. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  82026. */
  82027. hoverPosition: BABYLON.Vector3;
  82028. private _albedoTexture;
  82029. /** Gets or sets the texture to use for albedo color */
  82030. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82031. /**
  82032. * Creates a new Fluent material
  82033. * @param name defines the name of the material
  82034. * @param scene defines the hosting scene
  82035. */
  82036. constructor(name: string, scene: BABYLON.Scene);
  82037. needAlphaBlending(): boolean;
  82038. needAlphaTesting(): boolean;
  82039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82040. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82041. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82042. getActiveTextures(): BABYLON.BaseTexture[];
  82043. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82044. dispose(forceDisposeEffect?: boolean): void;
  82045. clone(name: string): FluentMaterial;
  82046. serialize(): any;
  82047. getClassName(): string;
  82048. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  82049. }
  82050. }
  82051. declare module BABYLON.GUI {
  82052. /**
  82053. * Class used to create a holographic button in 3D
  82054. */
  82055. export class HolographicButton extends Button3D {
  82056. private _backPlate;
  82057. private _textPlate;
  82058. private _frontPlate;
  82059. private _text;
  82060. private _imageUrl;
  82061. private _shareMaterials;
  82062. private _frontMaterial;
  82063. private _backMaterial;
  82064. private _plateMaterial;
  82065. private _pickedPointObserver;
  82066. private _tooltipFade;
  82067. private _tooltipTextBlock;
  82068. private _tooltipTexture;
  82069. private _tooltipMesh;
  82070. private _tooltipHoverObserver;
  82071. private _tooltipOutObserver;
  82072. private _disposeTooltip;
  82073. /**
  82074. * Rendering ground id of all the mesh in the button
  82075. */
  82076. set renderingGroupId(id: number);
  82077. get renderingGroupId(): number;
  82078. /**
  82079. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  82080. */
  82081. set tooltipText(text: BABYLON.Nullable<string>);
  82082. get tooltipText(): BABYLON.Nullable<string>;
  82083. /**
  82084. * Gets or sets text for the button
  82085. */
  82086. get text(): string;
  82087. set text(value: string);
  82088. /**
  82089. * Gets or sets the image url for the button
  82090. */
  82091. get imageUrl(): string;
  82092. set imageUrl(value: string);
  82093. /**
  82094. * Gets the back material used by this button
  82095. */
  82096. get backMaterial(): FluentMaterial;
  82097. /**
  82098. * Gets the front material used by this button
  82099. */
  82100. get frontMaterial(): FluentMaterial;
  82101. /**
  82102. * Gets the plate material used by this button
  82103. */
  82104. get plateMaterial(): BABYLON.StandardMaterial;
  82105. /**
  82106. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  82107. */
  82108. get shareMaterials(): boolean;
  82109. /**
  82110. * Creates a new button
  82111. * @param name defines the control name
  82112. */
  82113. constructor(name?: string, shareMaterials?: boolean);
  82114. protected _getTypeName(): string;
  82115. private _rebuildContent;
  82116. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82117. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  82118. private _createBackMaterial;
  82119. private _createFrontMaterial;
  82120. private _createPlateMaterial;
  82121. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  82122. /**
  82123. * Releases all associated resources
  82124. */
  82125. dispose(): void;
  82126. }
  82127. }
  82128. declare module BABYLON.GUI {
  82129. /**
  82130. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  82131. */
  82132. export class MeshButton3D extends Button3D {
  82133. /** @hidden */
  82134. protected _currentMesh: BABYLON.Mesh;
  82135. /**
  82136. * Creates a new 3D button based on a mesh
  82137. * @param mesh mesh to become a 3D button
  82138. * @param name defines the control name
  82139. */
  82140. constructor(mesh: BABYLON.Mesh, name?: string);
  82141. protected _getTypeName(): string;
  82142. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82143. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  82144. }
  82145. }
  82146. declare module BABYLON.GUI {
  82147. /**
  82148. * Class used to create a container panel deployed on the surface of a plane
  82149. */
  82150. export class PlanePanel extends VolumeBasedPanel {
  82151. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82152. }
  82153. }
  82154. declare module BABYLON.GUI {
  82155. /**
  82156. * Class used to create a container panel where items get randomized planar mapping
  82157. */
  82158. export class ScatterPanel extends VolumeBasedPanel {
  82159. private _iteration;
  82160. /**
  82161. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82162. */
  82163. get iteration(): BABYLON.float;
  82164. set iteration(value: BABYLON.float);
  82165. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82166. private _scatterMapping;
  82167. protected _finalProcessing(): void;
  82168. }
  82169. }
  82170. declare module BABYLON.GUI {
  82171. /**
  82172. * Class used to create a container panel deployed on the surface of a sphere
  82173. */
  82174. export class SpherePanel extends VolumeBasedPanel {
  82175. private _radius;
  82176. /**
  82177. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82178. */
  82179. get radius(): BABYLON.float;
  82180. set radius(value: BABYLON.float);
  82181. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82182. private _sphericalMapping;
  82183. }
  82184. }
  82185. declare module BABYLON.GUI {
  82186. /**
  82187. * Class used to create a stack panel in 3D on XY plane
  82188. */
  82189. export class StackPanel3D extends Container3D {
  82190. private _isVertical;
  82191. /**
  82192. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82193. */
  82194. get isVertical(): boolean;
  82195. set isVertical(value: boolean);
  82196. /**
  82197. * Gets or sets the distance between elements
  82198. */
  82199. margin: number;
  82200. /**
  82201. * Creates new StackPanel
  82202. * @param isVertical
  82203. */
  82204. constructor(isVertical?: boolean);
  82205. protected _arrangeChildren(): void;
  82206. }
  82207. }
  82208. declare module BABYLON {
  82209. /**
  82210. * Configuration for glTF validation
  82211. */
  82212. export interface IGLTFValidationConfiguration {
  82213. /**
  82214. * The url of the glTF validator.
  82215. */
  82216. url: string;
  82217. }
  82218. /**
  82219. * glTF validation
  82220. */
  82221. export class GLTFValidation {
  82222. /**
  82223. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82224. */
  82225. static Configuration: IGLTFValidationConfiguration;
  82226. private static _LoadScriptPromise;
  82227. /**
  82228. * Validate a glTF asset using the glTF-Validator.
  82229. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82230. * @param rootUrl The root url for the glTF
  82231. * @param fileName The file name for the glTF
  82232. * @param getExternalResource The callback to get external resources for the glTF validator
  82233. * @returns A promise that resolves with the glTF validation results once complete
  82234. */
  82235. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82236. }
  82237. }
  82238. declare module BABYLON {
  82239. /**
  82240. * Mode that determines the coordinate system to use.
  82241. */
  82242. export enum GLTFLoaderCoordinateSystemMode {
  82243. /**
  82244. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82245. */
  82246. AUTO = 0,
  82247. /**
  82248. * Sets the useRightHandedSystem flag on the scene.
  82249. */
  82250. FORCE_RIGHT_HANDED = 1
  82251. }
  82252. /**
  82253. * Mode that determines what animations will start.
  82254. */
  82255. export enum GLTFLoaderAnimationStartMode {
  82256. /**
  82257. * No animation will start.
  82258. */
  82259. NONE = 0,
  82260. /**
  82261. * The first animation will start.
  82262. */
  82263. FIRST = 1,
  82264. /**
  82265. * All animations will start.
  82266. */
  82267. ALL = 2
  82268. }
  82269. /**
  82270. * Interface that contains the data for the glTF asset.
  82271. */
  82272. export interface IGLTFLoaderData {
  82273. /**
  82274. * The object that represents the glTF JSON.
  82275. */
  82276. json: Object;
  82277. /**
  82278. * The BIN chunk of a binary glTF.
  82279. */
  82280. bin: Nullable<IDataBuffer>;
  82281. }
  82282. /**
  82283. * Interface for extending the loader.
  82284. */
  82285. export interface IGLTFLoaderExtension {
  82286. /**
  82287. * The name of this extension.
  82288. */
  82289. readonly name: string;
  82290. /**
  82291. * Defines whether this extension is enabled.
  82292. */
  82293. enabled: boolean;
  82294. /**
  82295. * Defines the order of this extension.
  82296. * The loader sorts the extensions using these values when loading.
  82297. */
  82298. order?: number;
  82299. }
  82300. /**
  82301. * Loader state.
  82302. */
  82303. export enum GLTFLoaderState {
  82304. /**
  82305. * The asset is loading.
  82306. */
  82307. LOADING = 0,
  82308. /**
  82309. * The asset is ready for rendering.
  82310. */
  82311. READY = 1,
  82312. /**
  82313. * The asset is completely loaded.
  82314. */
  82315. COMPLETE = 2
  82316. }
  82317. /** @hidden */
  82318. export interface IGLTFLoader extends IDisposable {
  82319. readonly state: Nullable<GLTFLoaderState>;
  82320. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82321. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82322. }
  82323. /**
  82324. * File loader for loading glTF files into a scene.
  82325. */
  82326. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82327. /** @hidden */
  82328. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82329. /** @hidden */
  82330. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82331. /**
  82332. * Raised when the asset has been parsed
  82333. */
  82334. onParsedObservable: Observable<IGLTFLoaderData>;
  82335. private _onParsedObserver;
  82336. /**
  82337. * Raised when the asset has been parsed
  82338. */
  82339. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82340. /**
  82341. * 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.
  82342. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82343. * Defaults to true.
  82344. * @hidden
  82345. */
  82346. static IncrementalLoading: boolean;
  82347. /**
  82348. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82349. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82350. * @hidden
  82351. */
  82352. static HomogeneousCoordinates: boolean;
  82353. /**
  82354. * The coordinate system mode. Defaults to AUTO.
  82355. */
  82356. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82357. /**
  82358. * The animation start mode. Defaults to FIRST.
  82359. */
  82360. animationStartMode: GLTFLoaderAnimationStartMode;
  82361. /**
  82362. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82363. */
  82364. compileMaterials: boolean;
  82365. /**
  82366. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82367. */
  82368. useClipPlane: boolean;
  82369. /**
  82370. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82371. */
  82372. compileShadowGenerators: boolean;
  82373. /**
  82374. * Defines if the Alpha blended materials are only applied as coverage.
  82375. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82376. * If true, no extra effects are applied to transparent pixels.
  82377. */
  82378. transparencyAsCoverage: boolean;
  82379. /**
  82380. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82381. * Enabling will disable offline support and glTF validator.
  82382. * Defaults to false.
  82383. */
  82384. useRangeRequests: boolean;
  82385. /**
  82386. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82387. */
  82388. createInstances: boolean;
  82389. /**
  82390. * 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.
  82391. */
  82392. alwaysComputeBoundingBox: boolean;
  82393. /**
  82394. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82395. */
  82396. loadAllMaterials: boolean;
  82397. /**
  82398. * Function called before loading a url referenced by the asset.
  82399. */
  82400. preprocessUrlAsync: (url: string) => Promise<string>;
  82401. /**
  82402. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82403. * 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, ...)
  82404. */
  82405. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82406. private _onMeshLoadedObserver;
  82407. /**
  82408. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82409. * 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, ...)
  82410. */
  82411. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82412. /**
  82413. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82414. */
  82415. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82416. private _onTextureLoadedObserver;
  82417. /**
  82418. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82419. */
  82420. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82421. /**
  82422. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82423. */
  82424. readonly onMaterialLoadedObservable: Observable<Material>;
  82425. private _onMaterialLoadedObserver;
  82426. /**
  82427. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82428. */
  82429. set onMaterialLoaded(callback: (material: Material) => void);
  82430. /**
  82431. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82432. */
  82433. readonly onCameraLoadedObservable: Observable<Camera>;
  82434. private _onCameraLoadedObserver;
  82435. /**
  82436. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82437. */
  82438. set onCameraLoaded(callback: (camera: Camera) => void);
  82439. /**
  82440. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82441. * For assets with LODs, raised when all of the LODs are complete.
  82442. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82443. */
  82444. readonly onCompleteObservable: Observable<void>;
  82445. private _onCompleteObserver;
  82446. /**
  82447. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82448. * For assets with LODs, raised when all of the LODs are complete.
  82449. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82450. */
  82451. set onComplete(callback: () => void);
  82452. /**
  82453. * Observable raised when an error occurs.
  82454. */
  82455. readonly onErrorObservable: Observable<any>;
  82456. private _onErrorObserver;
  82457. /**
  82458. * Callback raised when an error occurs.
  82459. */
  82460. set onError(callback: (reason: any) => void);
  82461. /**
  82462. * Observable raised after the loader is disposed.
  82463. */
  82464. readonly onDisposeObservable: Observable<void>;
  82465. private _onDisposeObserver;
  82466. /**
  82467. * Callback raised after the loader is disposed.
  82468. */
  82469. set onDispose(callback: () => void);
  82470. /**
  82471. * Observable raised after a loader extension is created.
  82472. * Set additional options for a loader extension in this event.
  82473. */
  82474. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82475. private _onExtensionLoadedObserver;
  82476. /**
  82477. * Callback raised after a loader extension is created.
  82478. */
  82479. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82480. /**
  82481. * Defines if the loader logging is enabled.
  82482. */
  82483. get loggingEnabled(): boolean;
  82484. set loggingEnabled(value: boolean);
  82485. /**
  82486. * Defines if the loader should capture performance counters.
  82487. */
  82488. get capturePerformanceCounters(): boolean;
  82489. set capturePerformanceCounters(value: boolean);
  82490. /**
  82491. * Defines if the loader should validate the asset.
  82492. */
  82493. validate: boolean;
  82494. /**
  82495. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82496. */
  82497. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82498. private _onValidatedObserver;
  82499. /**
  82500. * Callback raised after a loader extension is created.
  82501. */
  82502. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82503. private _loader;
  82504. private _progressCallback?;
  82505. private _requests;
  82506. private static magicBase64Encoded;
  82507. /**
  82508. * Name of the loader ("gltf")
  82509. */
  82510. name: string;
  82511. /** @hidden */
  82512. extensions: ISceneLoaderPluginExtensions;
  82513. /**
  82514. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82515. */
  82516. dispose(): void;
  82517. /** @hidden */
  82518. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82519. /** @hidden */
  82520. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82521. /** @hidden */
  82522. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82523. /** @hidden */
  82524. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82525. /** @hidden */
  82526. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82527. /** @hidden */
  82528. canDirectLoad(data: string): boolean;
  82529. /** @hidden */
  82530. directLoad(scene: Scene, data: string): Promise<any>;
  82531. /**
  82532. * The callback that allows custom handling of the root url based on the response url.
  82533. * @param rootUrl the original root url
  82534. * @param responseURL the response url if available
  82535. * @returns the new root url
  82536. */
  82537. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82538. /** @hidden */
  82539. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82540. /**
  82541. * The loader state or null if the loader is not active.
  82542. */
  82543. get loaderState(): Nullable<GLTFLoaderState>;
  82544. /**
  82545. * Returns a promise that resolves when the asset is completely loaded.
  82546. * @returns a promise that resolves when the asset is completely loaded.
  82547. */
  82548. whenCompleteAsync(): Promise<void>;
  82549. /** @hidden */
  82550. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82551. /** @hidden */
  82552. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82553. private _onProgress;
  82554. private _validate;
  82555. private _getLoader;
  82556. private _parseJson;
  82557. private _unpackBinaryAsync;
  82558. private _unpackBinaryV1Async;
  82559. private _unpackBinaryV2Async;
  82560. private static _parseVersion;
  82561. private static _compareVersion;
  82562. private static readonly _logSpaces;
  82563. private _logIndentLevel;
  82564. private _loggingEnabled;
  82565. /** @hidden */
  82566. _log: (message: string) => void;
  82567. /** @hidden */
  82568. _logOpen(message: string): void;
  82569. /** @hidden */
  82570. _logClose(): void;
  82571. private _logEnabled;
  82572. private _logDisabled;
  82573. private _capturePerformanceCounters;
  82574. /** @hidden */
  82575. _startPerformanceCounter: (counterName: string) => void;
  82576. /** @hidden */
  82577. _endPerformanceCounter: (counterName: string) => void;
  82578. private _startPerformanceCounterEnabled;
  82579. private _startPerformanceCounterDisabled;
  82580. private _endPerformanceCounterEnabled;
  82581. private _endPerformanceCounterDisabled;
  82582. }
  82583. }
  82584. declare module BABYLON.GLTF1 {
  82585. /**
  82586. * Enums
  82587. * @hidden
  82588. */
  82589. export enum EComponentType {
  82590. BYTE = 5120,
  82591. UNSIGNED_BYTE = 5121,
  82592. SHORT = 5122,
  82593. UNSIGNED_SHORT = 5123,
  82594. FLOAT = 5126
  82595. }
  82596. /** @hidden */
  82597. export enum EShaderType {
  82598. FRAGMENT = 35632,
  82599. VERTEX = 35633
  82600. }
  82601. /** @hidden */
  82602. export enum EParameterType {
  82603. BYTE = 5120,
  82604. UNSIGNED_BYTE = 5121,
  82605. SHORT = 5122,
  82606. UNSIGNED_SHORT = 5123,
  82607. INT = 5124,
  82608. UNSIGNED_INT = 5125,
  82609. FLOAT = 5126,
  82610. FLOAT_VEC2 = 35664,
  82611. FLOAT_VEC3 = 35665,
  82612. FLOAT_VEC4 = 35666,
  82613. INT_VEC2 = 35667,
  82614. INT_VEC3 = 35668,
  82615. INT_VEC4 = 35669,
  82616. BOOL = 35670,
  82617. BOOL_VEC2 = 35671,
  82618. BOOL_VEC3 = 35672,
  82619. BOOL_VEC4 = 35673,
  82620. FLOAT_MAT2 = 35674,
  82621. FLOAT_MAT3 = 35675,
  82622. FLOAT_MAT4 = 35676,
  82623. SAMPLER_2D = 35678
  82624. }
  82625. /** @hidden */
  82626. export enum ETextureWrapMode {
  82627. CLAMP_TO_EDGE = 33071,
  82628. MIRRORED_REPEAT = 33648,
  82629. REPEAT = 10497
  82630. }
  82631. /** @hidden */
  82632. export enum ETextureFilterType {
  82633. NEAREST = 9728,
  82634. LINEAR = 9728,
  82635. NEAREST_MIPMAP_NEAREST = 9984,
  82636. LINEAR_MIPMAP_NEAREST = 9985,
  82637. NEAREST_MIPMAP_LINEAR = 9986,
  82638. LINEAR_MIPMAP_LINEAR = 9987
  82639. }
  82640. /** @hidden */
  82641. export enum ETextureFormat {
  82642. ALPHA = 6406,
  82643. RGB = 6407,
  82644. RGBA = 6408,
  82645. LUMINANCE = 6409,
  82646. LUMINANCE_ALPHA = 6410
  82647. }
  82648. /** @hidden */
  82649. export enum ECullingType {
  82650. FRONT = 1028,
  82651. BACK = 1029,
  82652. FRONT_AND_BACK = 1032
  82653. }
  82654. /** @hidden */
  82655. export enum EBlendingFunction {
  82656. ZERO = 0,
  82657. ONE = 1,
  82658. SRC_COLOR = 768,
  82659. ONE_MINUS_SRC_COLOR = 769,
  82660. DST_COLOR = 774,
  82661. ONE_MINUS_DST_COLOR = 775,
  82662. SRC_ALPHA = 770,
  82663. ONE_MINUS_SRC_ALPHA = 771,
  82664. DST_ALPHA = 772,
  82665. ONE_MINUS_DST_ALPHA = 773,
  82666. CONSTANT_COLOR = 32769,
  82667. ONE_MINUS_CONSTANT_COLOR = 32770,
  82668. CONSTANT_ALPHA = 32771,
  82669. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82670. SRC_ALPHA_SATURATE = 776
  82671. }
  82672. /** @hidden */
  82673. export interface IGLTFProperty {
  82674. extensions?: {
  82675. [key: string]: any;
  82676. };
  82677. extras?: Object;
  82678. }
  82679. /** @hidden */
  82680. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82681. name?: string;
  82682. }
  82683. /** @hidden */
  82684. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82685. bufferView: string;
  82686. byteOffset: number;
  82687. byteStride: number;
  82688. count: number;
  82689. type: string;
  82690. componentType: EComponentType;
  82691. max?: number[];
  82692. min?: number[];
  82693. name?: string;
  82694. }
  82695. /** @hidden */
  82696. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82697. buffer: string;
  82698. byteOffset: number;
  82699. byteLength: number;
  82700. byteStride: number;
  82701. target?: number;
  82702. }
  82703. /** @hidden */
  82704. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82705. uri: string;
  82706. byteLength?: number;
  82707. type?: string;
  82708. }
  82709. /** @hidden */
  82710. export interface IGLTFShader extends IGLTFChildRootProperty {
  82711. uri: string;
  82712. type: EShaderType;
  82713. }
  82714. /** @hidden */
  82715. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82716. attributes: string[];
  82717. fragmentShader: string;
  82718. vertexShader: string;
  82719. }
  82720. /** @hidden */
  82721. export interface IGLTFTechniqueParameter {
  82722. type: number;
  82723. count?: number;
  82724. semantic?: string;
  82725. node?: string;
  82726. value?: number | boolean | string | Array<any>;
  82727. source?: string;
  82728. babylonValue?: any;
  82729. }
  82730. /** @hidden */
  82731. export interface IGLTFTechniqueCommonProfile {
  82732. lightingModel: string;
  82733. texcoordBindings: Object;
  82734. parameters?: Array<any>;
  82735. }
  82736. /** @hidden */
  82737. export interface IGLTFTechniqueStatesFunctions {
  82738. blendColor?: number[];
  82739. blendEquationSeparate?: number[];
  82740. blendFuncSeparate?: number[];
  82741. colorMask: boolean[];
  82742. cullFace: number[];
  82743. }
  82744. /** @hidden */
  82745. export interface IGLTFTechniqueStates {
  82746. enable: number[];
  82747. functions: IGLTFTechniqueStatesFunctions;
  82748. }
  82749. /** @hidden */
  82750. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82751. parameters: {
  82752. [key: string]: IGLTFTechniqueParameter;
  82753. };
  82754. program: string;
  82755. attributes: {
  82756. [key: string]: string;
  82757. };
  82758. uniforms: {
  82759. [key: string]: string;
  82760. };
  82761. states: IGLTFTechniqueStates;
  82762. }
  82763. /** @hidden */
  82764. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82765. technique?: string;
  82766. values: string[];
  82767. }
  82768. /** @hidden */
  82769. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82770. attributes: {
  82771. [key: string]: string;
  82772. };
  82773. indices: string;
  82774. material: string;
  82775. mode?: number;
  82776. }
  82777. /** @hidden */
  82778. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82779. primitives: IGLTFMeshPrimitive[];
  82780. }
  82781. /** @hidden */
  82782. export interface IGLTFImage extends IGLTFChildRootProperty {
  82783. uri: string;
  82784. }
  82785. /** @hidden */
  82786. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82787. magFilter?: number;
  82788. minFilter?: number;
  82789. wrapS?: number;
  82790. wrapT?: number;
  82791. }
  82792. /** @hidden */
  82793. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82794. sampler: string;
  82795. source: string;
  82796. format?: ETextureFormat;
  82797. internalFormat?: ETextureFormat;
  82798. target?: number;
  82799. type?: number;
  82800. babylonTexture?: Texture;
  82801. }
  82802. /** @hidden */
  82803. export interface IGLTFAmbienLight {
  82804. color?: number[];
  82805. }
  82806. /** @hidden */
  82807. export interface IGLTFDirectionalLight {
  82808. color?: number[];
  82809. }
  82810. /** @hidden */
  82811. export interface IGLTFPointLight {
  82812. color?: number[];
  82813. constantAttenuation?: number;
  82814. linearAttenuation?: number;
  82815. quadraticAttenuation?: number;
  82816. }
  82817. /** @hidden */
  82818. export interface IGLTFSpotLight {
  82819. color?: number[];
  82820. constantAttenuation?: number;
  82821. fallOfAngle?: number;
  82822. fallOffExponent?: number;
  82823. linearAttenuation?: number;
  82824. quadraticAttenuation?: number;
  82825. }
  82826. /** @hidden */
  82827. export interface IGLTFLight extends IGLTFChildRootProperty {
  82828. type: string;
  82829. }
  82830. /** @hidden */
  82831. export interface IGLTFCameraOrthographic {
  82832. xmag: number;
  82833. ymag: number;
  82834. zfar: number;
  82835. znear: number;
  82836. }
  82837. /** @hidden */
  82838. export interface IGLTFCameraPerspective {
  82839. aspectRatio: number;
  82840. yfov: number;
  82841. zfar: number;
  82842. znear: number;
  82843. }
  82844. /** @hidden */
  82845. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82846. type: string;
  82847. }
  82848. /** @hidden */
  82849. export interface IGLTFAnimationChannelTarget {
  82850. id: string;
  82851. path: string;
  82852. }
  82853. /** @hidden */
  82854. export interface IGLTFAnimationChannel {
  82855. sampler: string;
  82856. target: IGLTFAnimationChannelTarget;
  82857. }
  82858. /** @hidden */
  82859. export interface IGLTFAnimationSampler {
  82860. input: string;
  82861. output: string;
  82862. interpolation?: string;
  82863. }
  82864. /** @hidden */
  82865. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82866. channels?: IGLTFAnimationChannel[];
  82867. parameters?: {
  82868. [key: string]: string;
  82869. };
  82870. samplers?: {
  82871. [key: string]: IGLTFAnimationSampler;
  82872. };
  82873. }
  82874. /** @hidden */
  82875. export interface IGLTFNodeInstanceSkin {
  82876. skeletons: string[];
  82877. skin: string;
  82878. meshes: string[];
  82879. }
  82880. /** @hidden */
  82881. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82882. bindShapeMatrix: number[];
  82883. inverseBindMatrices: string;
  82884. jointNames: string[];
  82885. babylonSkeleton?: Skeleton;
  82886. }
  82887. /** @hidden */
  82888. export interface IGLTFNode extends IGLTFChildRootProperty {
  82889. camera?: string;
  82890. children: string[];
  82891. skin?: string;
  82892. jointName?: string;
  82893. light?: string;
  82894. matrix: number[];
  82895. mesh?: string;
  82896. meshes?: string[];
  82897. rotation?: number[];
  82898. scale?: number[];
  82899. translation?: number[];
  82900. babylonNode?: Node;
  82901. }
  82902. /** @hidden */
  82903. export interface IGLTFScene extends IGLTFChildRootProperty {
  82904. nodes: string[];
  82905. }
  82906. /** @hidden */
  82907. export interface IGLTFRuntime {
  82908. extensions: {
  82909. [key: string]: any;
  82910. };
  82911. accessors: {
  82912. [key: string]: IGLTFAccessor;
  82913. };
  82914. buffers: {
  82915. [key: string]: IGLTFBuffer;
  82916. };
  82917. bufferViews: {
  82918. [key: string]: IGLTFBufferView;
  82919. };
  82920. meshes: {
  82921. [key: string]: IGLTFMesh;
  82922. };
  82923. lights: {
  82924. [key: string]: IGLTFLight;
  82925. };
  82926. cameras: {
  82927. [key: string]: IGLTFCamera;
  82928. };
  82929. nodes: {
  82930. [key: string]: IGLTFNode;
  82931. };
  82932. images: {
  82933. [key: string]: IGLTFImage;
  82934. };
  82935. textures: {
  82936. [key: string]: IGLTFTexture;
  82937. };
  82938. shaders: {
  82939. [key: string]: IGLTFShader;
  82940. };
  82941. programs: {
  82942. [key: string]: IGLTFProgram;
  82943. };
  82944. samplers: {
  82945. [key: string]: IGLTFSampler;
  82946. };
  82947. techniques: {
  82948. [key: string]: IGLTFTechnique;
  82949. };
  82950. materials: {
  82951. [key: string]: IGLTFMaterial;
  82952. };
  82953. animations: {
  82954. [key: string]: IGLTFAnimation;
  82955. };
  82956. skins: {
  82957. [key: string]: IGLTFSkins;
  82958. };
  82959. currentScene?: Object;
  82960. scenes: {
  82961. [key: string]: IGLTFScene;
  82962. };
  82963. extensionsUsed: string[];
  82964. extensionsRequired?: string[];
  82965. buffersCount: number;
  82966. shaderscount: number;
  82967. scene: Scene;
  82968. rootUrl: string;
  82969. loadedBufferCount: number;
  82970. loadedBufferViews: {
  82971. [name: string]: ArrayBufferView;
  82972. };
  82973. loadedShaderCount: number;
  82974. importOnlyMeshes: boolean;
  82975. importMeshesNames?: string[];
  82976. dummyNodes: Node[];
  82977. forAssetContainer: boolean;
  82978. }
  82979. /** @hidden */
  82980. export interface INodeToRoot {
  82981. bone: Bone;
  82982. node: IGLTFNode;
  82983. id: string;
  82984. }
  82985. /** @hidden */
  82986. export interface IJointNode {
  82987. node: IGLTFNode;
  82988. id: string;
  82989. }
  82990. }
  82991. declare module BABYLON.GLTF1 {
  82992. /**
  82993. * Utils functions for GLTF
  82994. * @hidden
  82995. */
  82996. export class GLTFUtils {
  82997. /**
  82998. * Sets the given "parameter" matrix
  82999. * @param scene: the Scene object
  83000. * @param source: the source node where to pick the matrix
  83001. * @param parameter: the GLTF technique parameter
  83002. * @param uniformName: the name of the shader's uniform
  83003. * @param shaderMaterial: the shader material
  83004. */
  83005. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  83006. /**
  83007. * Sets the given "parameter" matrix
  83008. * @param shaderMaterial: the shader material
  83009. * @param uniform: the name of the shader's uniform
  83010. * @param value: the value of the uniform
  83011. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  83012. */
  83013. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  83014. /**
  83015. * Returns the wrap mode of the texture
  83016. * @param mode: the mode value
  83017. */
  83018. static GetWrapMode(mode: number): number;
  83019. /**
  83020. * Returns the byte stride giving an accessor
  83021. * @param accessor: the GLTF accessor objet
  83022. */
  83023. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  83024. /**
  83025. * Returns the texture filter mode giving a mode value
  83026. * @param mode: the filter mode value
  83027. */
  83028. static GetTextureFilterMode(mode: number): ETextureFilterType;
  83029. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  83030. /**
  83031. * Returns a buffer from its accessor
  83032. * @param gltfRuntime: the GLTF runtime
  83033. * @param accessor: the GLTF accessor
  83034. */
  83035. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  83036. /**
  83037. * Decodes a buffer view into a string
  83038. * @param view: the buffer view
  83039. */
  83040. static DecodeBufferToText(view: ArrayBufferView): string;
  83041. /**
  83042. * Returns the default material of gltf. Related to
  83043. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  83044. * @param scene: the Babylon.js scene
  83045. */
  83046. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  83047. private static _DefaultMaterial;
  83048. }
  83049. }
  83050. declare module BABYLON.GLTF1 {
  83051. /**
  83052. * Implementation of the base glTF spec
  83053. * @hidden
  83054. */
  83055. export class GLTFLoaderBase {
  83056. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  83057. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83058. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  83059. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83060. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  83061. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83062. }
  83063. /**
  83064. * glTF V1 Loader
  83065. * @hidden
  83066. */
  83067. export class GLTFLoader implements IGLTFLoader {
  83068. static Extensions: {
  83069. [name: string]: GLTFLoaderExtension;
  83070. };
  83071. static RegisterExtension(extension: GLTFLoaderExtension): void;
  83072. state: Nullable<GLTFLoaderState>;
  83073. dispose(): void;
  83074. private _importMeshAsync;
  83075. /**
  83076. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  83077. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83078. * @param scene the scene the meshes should be added to
  83079. * @param forAssetContainer defines if the entities must be stored in the scene
  83080. * @param data gltf data containing information of the meshes in a loaded file
  83081. * @param rootUrl root url to load from
  83082. * @param onProgress event that fires when loading progress has occured
  83083. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83084. */
  83085. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  83086. private _loadAsync;
  83087. /**
  83088. * Imports all objects from a loaded gltf file and adds them to the scene
  83089. * @param scene the scene the objects should be added to
  83090. * @param data gltf data containing information of the meshes in a loaded file
  83091. * @param rootUrl root url to load from
  83092. * @param onProgress event that fires when loading progress has occured
  83093. * @returns a promise which completes when objects have been loaded to the scene
  83094. */
  83095. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  83096. private _loadShadersAsync;
  83097. private _loadBuffersAsync;
  83098. private _createNodes;
  83099. }
  83100. /** @hidden */
  83101. export abstract class GLTFLoaderExtension {
  83102. private _name;
  83103. constructor(name: string);
  83104. get name(): string;
  83105. /**
  83106. * Defines an override for loading the runtime
  83107. * Return true to stop further extensions from loading the runtime
  83108. */
  83109. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  83110. /**
  83111. * Defines an onverride for creating gltf runtime
  83112. * Return true to stop further extensions from creating the runtime
  83113. */
  83114. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83115. /**
  83116. * Defines an override for loading buffers
  83117. * Return true to stop further extensions from loading this buffer
  83118. */
  83119. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  83120. /**
  83121. * Defines an override for loading texture buffers
  83122. * Return true to stop further extensions from loading this texture data
  83123. */
  83124. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83125. /**
  83126. * Defines an override for creating textures
  83127. * Return true to stop further extensions from loading this texture
  83128. */
  83129. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  83130. /**
  83131. * Defines an override for loading shader strings
  83132. * Return true to stop further extensions from loading this shader data
  83133. */
  83134. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83135. /**
  83136. * Defines an override for loading materials
  83137. * Return true to stop further extensions from loading this material
  83138. */
  83139. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83140. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  83141. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  83142. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83143. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83144. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  83145. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83146. private static LoadTextureBufferAsync;
  83147. private static CreateTextureAsync;
  83148. private static ApplyExtensions;
  83149. }
  83150. }
  83151. declare module BABYLON.GLTF1 {
  83152. /** @hidden */
  83153. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  83154. private _bin;
  83155. constructor();
  83156. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  83157. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83158. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83159. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83160. }
  83161. }
  83162. declare module BABYLON.GLTF1 {
  83163. /** @hidden */
  83164. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83165. constructor();
  83166. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83167. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83168. private _loadTexture;
  83169. }
  83170. }
  83171. declare module BABYLON.GLTF2.Loader {
  83172. /**
  83173. * Loader interface with an index field.
  83174. */
  83175. export interface IArrayItem {
  83176. /**
  83177. * The index of this item in the array.
  83178. */
  83179. index: number;
  83180. }
  83181. /**
  83182. * Loader interface with additional members.
  83183. */
  83184. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83185. /** @hidden */
  83186. _data?: Promise<ArrayBufferView>;
  83187. /** @hidden */
  83188. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83189. }
  83190. /**
  83191. * Loader interface with additional members.
  83192. */
  83193. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83194. }
  83195. /** @hidden */
  83196. export interface _IAnimationSamplerData {
  83197. input: Float32Array;
  83198. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83199. output: Float32Array;
  83200. }
  83201. /**
  83202. * Loader interface with additional members.
  83203. */
  83204. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83205. /** @hidden */
  83206. _data?: Promise<_IAnimationSamplerData>;
  83207. }
  83208. /**
  83209. * Loader interface with additional members.
  83210. */
  83211. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83212. channels: IAnimationChannel[];
  83213. samplers: IAnimationSampler[];
  83214. /** @hidden */
  83215. _babylonAnimationGroup?: AnimationGroup;
  83216. }
  83217. /**
  83218. * Loader interface with additional members.
  83219. */
  83220. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83221. /** @hidden */
  83222. _data?: Promise<ArrayBufferView>;
  83223. }
  83224. /**
  83225. * Loader interface with additional members.
  83226. */
  83227. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83228. /** @hidden */
  83229. _data?: Promise<ArrayBufferView>;
  83230. /** @hidden */
  83231. _babylonBuffer?: Promise<Buffer>;
  83232. }
  83233. /**
  83234. * Loader interface with additional members.
  83235. */
  83236. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83237. }
  83238. /**
  83239. * Loader interface with additional members.
  83240. */
  83241. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83242. /** @hidden */
  83243. _data?: Promise<ArrayBufferView>;
  83244. }
  83245. /**
  83246. * Loader interface with additional members.
  83247. */
  83248. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83249. }
  83250. /**
  83251. * Loader interface with additional members.
  83252. */
  83253. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83254. }
  83255. /**
  83256. * Loader interface with additional members.
  83257. */
  83258. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83259. baseColorTexture?: ITextureInfo;
  83260. metallicRoughnessTexture?: ITextureInfo;
  83261. }
  83262. /**
  83263. * Loader interface with additional members.
  83264. */
  83265. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83266. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83267. normalTexture?: IMaterialNormalTextureInfo;
  83268. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83269. emissiveTexture?: ITextureInfo;
  83270. /** @hidden */
  83271. _data?: {
  83272. [babylonDrawMode: number]: {
  83273. babylonMaterial: Material;
  83274. babylonMeshes: AbstractMesh[];
  83275. promise: Promise<void>;
  83276. };
  83277. };
  83278. }
  83279. /**
  83280. * Loader interface with additional members.
  83281. */
  83282. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83283. primitives: IMeshPrimitive[];
  83284. }
  83285. /**
  83286. * Loader interface with additional members.
  83287. */
  83288. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83289. /** @hidden */
  83290. _instanceData?: {
  83291. babylonSourceMesh: Mesh;
  83292. promise: Promise<any>;
  83293. };
  83294. }
  83295. /**
  83296. * Loader interface with additional members.
  83297. */
  83298. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83299. /**
  83300. * The parent glTF node.
  83301. */
  83302. parent?: INode;
  83303. /** @hidden */
  83304. _babylonTransformNode?: TransformNode;
  83305. /** @hidden */
  83306. _primitiveBabylonMeshes?: AbstractMesh[];
  83307. /** @hidden */
  83308. _babylonBones?: Bone[];
  83309. /** @hidden */
  83310. _numMorphTargets?: number;
  83311. }
  83312. /** @hidden */
  83313. export interface _ISamplerData {
  83314. noMipMaps: boolean;
  83315. samplingMode: number;
  83316. wrapU: number;
  83317. wrapV: number;
  83318. }
  83319. /**
  83320. * Loader interface with additional members.
  83321. */
  83322. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83323. /** @hidden */
  83324. _data?: _ISamplerData;
  83325. }
  83326. /**
  83327. * Loader interface with additional members.
  83328. */
  83329. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83330. }
  83331. /**
  83332. * Loader interface with additional members.
  83333. */
  83334. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83335. /** @hidden */
  83336. _data?: {
  83337. babylonSkeleton: Skeleton;
  83338. promise: Promise<void>;
  83339. };
  83340. }
  83341. /**
  83342. * Loader interface with additional members.
  83343. */
  83344. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83345. /** @hidden */
  83346. _textureInfo: ITextureInfo;
  83347. }
  83348. /**
  83349. * Loader interface with additional members.
  83350. */
  83351. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83352. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83353. nonColorData?: boolean;
  83354. }
  83355. /**
  83356. * Loader interface with additional members.
  83357. */
  83358. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83359. accessors?: IAccessor[];
  83360. animations?: IAnimation[];
  83361. buffers?: IBuffer[];
  83362. bufferViews?: IBufferView[];
  83363. cameras?: ICamera[];
  83364. images?: IImage[];
  83365. materials?: IMaterial[];
  83366. meshes?: IMesh[];
  83367. nodes?: INode[];
  83368. samplers?: ISampler[];
  83369. scenes?: IScene[];
  83370. skins?: ISkin[];
  83371. textures?: ITexture[];
  83372. }
  83373. }
  83374. declare module BABYLON.GLTF2 {
  83375. /**
  83376. * Interface for a glTF loader extension.
  83377. */
  83378. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83379. /**
  83380. * Called after the loader state changes to LOADING.
  83381. */
  83382. onLoading?(): void;
  83383. /**
  83384. * Called after the loader state changes to READY.
  83385. */
  83386. onReady?(): void;
  83387. /**
  83388. * Define this method to modify the default behavior when loading scenes.
  83389. * @param context The context when loading the asset
  83390. * @param scene The glTF scene property
  83391. * @returns A promise that resolves when the load is complete or null if not handled
  83392. */
  83393. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83394. /**
  83395. * Define this method to modify the default behavior when loading nodes.
  83396. * @param context The context when loading the asset
  83397. * @param node The glTF node property
  83398. * @param assign A function called synchronously after parsing the glTF properties
  83399. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83400. */
  83401. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83402. /**
  83403. * Define this method to modify the default behavior when loading cameras.
  83404. * @param context The context when loading the asset
  83405. * @param camera The glTF camera property
  83406. * @param assign A function called synchronously after parsing the glTF properties
  83407. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83408. */
  83409. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83410. /**
  83411. * @hidden
  83412. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83413. * @param context The context when loading the asset
  83414. * @param primitive The glTF mesh primitive property
  83415. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83416. */
  83417. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83418. /**
  83419. * @hidden
  83420. * Define this method to modify the default behavior when loading data for mesh primitives.
  83421. * @param context The context when loading the asset
  83422. * @param name The mesh name when loading the asset
  83423. * @param node The glTF node when loading the asset
  83424. * @param mesh The glTF mesh when loading the asset
  83425. * @param primitive The glTF mesh primitive property
  83426. * @param assign A function called synchronously after parsing the glTF properties
  83427. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83428. */
  83429. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83430. /**
  83431. * @hidden
  83432. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83433. * @param context The context when loading the asset
  83434. * @param material The glTF material property
  83435. * @param assign A function called synchronously after parsing the glTF properties
  83436. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83437. */
  83438. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83439. /**
  83440. * Define this method to modify the default behavior when creating materials.
  83441. * @param context The context when loading the asset
  83442. * @param material The glTF material property
  83443. * @param babylonDrawMode The draw mode for the Babylon material
  83444. * @returns The Babylon material or null if not handled
  83445. */
  83446. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83447. /**
  83448. * Define this method to modify the default behavior when loading material properties.
  83449. * @param context The context when loading the asset
  83450. * @param material The glTF material property
  83451. * @param babylonMaterial The Babylon material
  83452. * @returns A promise that resolves when the load is complete or null if not handled
  83453. */
  83454. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83455. /**
  83456. * Define this method to modify the default behavior when loading texture infos.
  83457. * @param context The context when loading the asset
  83458. * @param textureInfo The glTF texture info property
  83459. * @param assign A function called synchronously after parsing the glTF properties
  83460. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83461. */
  83462. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83463. /**
  83464. * @hidden
  83465. * Define this method to modify the default behavior when loading textures.
  83466. * @param context The context when loading the asset
  83467. * @param texture The glTF texture property
  83468. * @param assign A function called synchronously after parsing the glTF properties
  83469. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83470. */
  83471. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83472. /**
  83473. * Define this method to modify the default behavior when loading animations.
  83474. * @param context The context when loading the asset
  83475. * @param animation The glTF animation property
  83476. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83477. */
  83478. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83479. /**
  83480. * @hidden
  83481. * Define this method to modify the default behavior when loading skins.
  83482. * @param context The context when loading the asset
  83483. * @param node The glTF node property
  83484. * @param skin The glTF skin property
  83485. * @returns A promise that resolves when the load is complete or null if not handled
  83486. */
  83487. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83488. /**
  83489. * @hidden
  83490. * Define this method to modify the default behavior when loading uris.
  83491. * @param context The context when loading the asset
  83492. * @param property The glTF property associated with the uri
  83493. * @param uri The uri to load
  83494. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83495. */
  83496. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83497. /**
  83498. * Define this method to modify the default behavior when loading buffer views.
  83499. * @param context The context when loading the asset
  83500. * @param bufferView The glTF buffer view property
  83501. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83502. */
  83503. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83504. /**
  83505. * Define this method to modify the default behavior when loading buffers.
  83506. * @param context The context when loading the asset
  83507. * @param buffer The glTF buffer property
  83508. * @param byteOffset The byte offset to load
  83509. * @param byteLength The byte length to load
  83510. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83511. */
  83512. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83513. }
  83514. }
  83515. declare module BABYLON.GLTF2 {
  83516. /**
  83517. * Helper class for working with arrays when loading the glTF asset
  83518. */
  83519. export class ArrayItem {
  83520. /**
  83521. * Gets an item from the given array.
  83522. * @param context The context when loading the asset
  83523. * @param array The array to get the item from
  83524. * @param index The index to the array
  83525. * @returns The array item
  83526. */
  83527. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83528. /**
  83529. * Assign an `index` field to each item of the given array.
  83530. * @param array The array of items
  83531. */
  83532. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83533. }
  83534. /**
  83535. * The glTF 2.0 loader
  83536. */
  83537. export class GLTFLoader implements IGLTFLoader {
  83538. /** @hidden */
  83539. _completePromises: Promise<any>[];
  83540. /** @hidden */
  83541. _forAssetContainer: boolean;
  83542. /** Storage */
  83543. _babylonLights: Light[];
  83544. /** @hidden */
  83545. _disableInstancedMesh: number;
  83546. private _disposed;
  83547. private _parent;
  83548. private _state;
  83549. private _extensions;
  83550. private _rootUrl;
  83551. private _fileName;
  83552. private _uniqueRootUrl;
  83553. private _gltf;
  83554. private _bin;
  83555. private _babylonScene;
  83556. private _rootBabylonMesh;
  83557. private _defaultBabylonMaterialData;
  83558. private static _RegisteredExtensions;
  83559. /**
  83560. * The default glTF sampler.
  83561. */
  83562. static readonly DefaultSampler: ISampler;
  83563. /**
  83564. * Registers a loader extension.
  83565. * @param name The name of the loader extension.
  83566. * @param factory The factory function that creates the loader extension.
  83567. */
  83568. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83569. /**
  83570. * Unregisters a loader extension.
  83571. * @param name The name of the loader extension.
  83572. * @returns A boolean indicating whether the extension has been unregistered
  83573. */
  83574. static UnregisterExtension(name: string): boolean;
  83575. /**
  83576. * The loader state.
  83577. */
  83578. get state(): Nullable<GLTFLoaderState>;
  83579. /**
  83580. * The object that represents the glTF JSON.
  83581. */
  83582. get gltf(): IGLTF;
  83583. /**
  83584. * The BIN chunk of a binary glTF.
  83585. */
  83586. get bin(): Nullable<IDataBuffer>;
  83587. /**
  83588. * The parent file loader.
  83589. */
  83590. get parent(): GLTFFileLoader;
  83591. /**
  83592. * The Babylon scene when loading the asset.
  83593. */
  83594. get babylonScene(): Scene;
  83595. /**
  83596. * The root Babylon mesh when loading the asset.
  83597. */
  83598. get rootBabylonMesh(): Mesh;
  83599. /** @hidden */
  83600. constructor(parent: GLTFFileLoader);
  83601. /** @hidden */
  83602. dispose(): void;
  83603. /** @hidden */
  83604. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83605. /** @hidden */
  83606. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83607. private _loadAsync;
  83608. private _loadData;
  83609. private _setupData;
  83610. private _loadExtensions;
  83611. private _checkExtensions;
  83612. private _setState;
  83613. private _createRootNode;
  83614. /**
  83615. * Loads a glTF scene.
  83616. * @param context The context when loading the asset
  83617. * @param scene The glTF scene property
  83618. * @returns A promise that resolves when the load is complete
  83619. */
  83620. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83621. private _forEachPrimitive;
  83622. private _getGeometries;
  83623. private _getMeshes;
  83624. private _getTransformNodes;
  83625. private _getSkeletons;
  83626. private _getAnimationGroups;
  83627. private _startAnimations;
  83628. /**
  83629. * Loads a glTF node.
  83630. * @param context The context when loading the asset
  83631. * @param node The glTF node property
  83632. * @param assign A function called synchronously after parsing the glTF properties
  83633. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83634. */
  83635. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83636. private _loadMeshAsync;
  83637. /**
  83638. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83639. * @param context The context when loading the asset
  83640. * @param name The mesh name when loading the asset
  83641. * @param node The glTF node when loading the asset
  83642. * @param mesh The glTF mesh when loading the asset
  83643. * @param primitive The glTF mesh primitive property
  83644. * @param assign A function called synchronously after parsing the glTF properties
  83645. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83646. */
  83647. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83648. private _loadVertexDataAsync;
  83649. private _createMorphTargets;
  83650. private _loadMorphTargetsAsync;
  83651. private _loadMorphTargetVertexDataAsync;
  83652. private static _LoadTransform;
  83653. private _loadSkinAsync;
  83654. private _loadBones;
  83655. private _loadBone;
  83656. private _loadSkinInverseBindMatricesDataAsync;
  83657. private _updateBoneMatrices;
  83658. private _getNodeMatrix;
  83659. /**
  83660. * Loads a glTF camera.
  83661. * @param context The context when loading the asset
  83662. * @param camera The glTF camera property
  83663. * @param assign A function called synchronously after parsing the glTF properties
  83664. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83665. */
  83666. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83667. private _loadAnimationsAsync;
  83668. /**
  83669. * Loads a glTF animation.
  83670. * @param context The context when loading the asset
  83671. * @param animation The glTF animation property
  83672. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83673. */
  83674. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83675. /**
  83676. * @hidden Loads a glTF animation channel.
  83677. * @param context The context when loading the asset
  83678. * @param animationContext The context of the animation when loading the asset
  83679. * @param animation The glTF animation property
  83680. * @param channel The glTF animation channel property
  83681. * @param babylonAnimationGroup The babylon animation group property
  83682. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83683. * @returns A void promise when the channel load is complete
  83684. */
  83685. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83686. private _loadAnimationSamplerAsync;
  83687. private _loadBufferAsync;
  83688. /**
  83689. * Loads a glTF buffer view.
  83690. * @param context The context when loading the asset
  83691. * @param bufferView The glTF buffer view property
  83692. * @returns A promise that resolves with the loaded data when the load is complete
  83693. */
  83694. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83695. private _loadAccessorAsync;
  83696. /** @hidden */
  83697. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83698. private _loadIndicesAccessorAsync;
  83699. private _loadVertexBufferViewAsync;
  83700. private _loadVertexAccessorAsync;
  83701. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83702. /** @hidden */
  83703. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83704. private _createDefaultMaterial;
  83705. /**
  83706. * Creates a Babylon material from a glTF material.
  83707. * @param context The context when loading the asset
  83708. * @param material The glTF material property
  83709. * @param babylonDrawMode The draw mode for the Babylon material
  83710. * @returns The Babylon material
  83711. */
  83712. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83713. /**
  83714. * Loads properties from a glTF material into a Babylon material.
  83715. * @param context The context when loading the asset
  83716. * @param material The glTF material property
  83717. * @param babylonMaterial The Babylon material
  83718. * @returns A promise that resolves when the load is complete
  83719. */
  83720. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83721. /**
  83722. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83723. * @param context The context when loading the asset
  83724. * @param material The glTF material property
  83725. * @param babylonMaterial The Babylon material
  83726. * @returns A promise that resolves when the load is complete
  83727. */
  83728. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83729. /**
  83730. * Loads the alpha properties from a glTF material into a Babylon material.
  83731. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83732. * @param context The context when loading the asset
  83733. * @param material The glTF material property
  83734. * @param babylonMaterial The Babylon material
  83735. */
  83736. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83737. /**
  83738. * Loads a glTF texture info.
  83739. * @param context The context when loading the asset
  83740. * @param textureInfo The glTF texture info property
  83741. * @param assign A function called synchronously after parsing the glTF properties
  83742. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83743. */
  83744. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83745. /** @hidden */
  83746. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83747. /** @hidden */
  83748. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83749. private _loadSampler;
  83750. /**
  83751. * Loads a glTF image.
  83752. * @param context The context when loading the asset
  83753. * @param image The glTF image property
  83754. * @returns A promise that resolves with the loaded data when the load is complete
  83755. */
  83756. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83757. /**
  83758. * Loads a glTF uri.
  83759. * @param context The context when loading the asset
  83760. * @param property The glTF property associated with the uri
  83761. * @param uri The base64 or relative uri
  83762. * @returns A promise that resolves with the loaded data when the load is complete
  83763. */
  83764. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83765. /**
  83766. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83767. * @param babylonObject the Babylon object with metadata
  83768. * @param pointer the JSON pointer
  83769. */
  83770. static AddPointerMetadata(babylonObject: {
  83771. metadata: any;
  83772. }, pointer: string): void;
  83773. private static _GetTextureWrapMode;
  83774. private static _GetTextureSamplingMode;
  83775. private static _GetTypedArrayConstructor;
  83776. private static _GetTypedArray;
  83777. private static _GetNumComponents;
  83778. private static _ValidateUri;
  83779. /** @hidden */
  83780. static _GetDrawMode(context: string, mode: number | undefined): number;
  83781. private _compileMaterialsAsync;
  83782. private _compileShadowGeneratorsAsync;
  83783. private _forEachExtensions;
  83784. private _applyExtensions;
  83785. private _extensionsOnLoading;
  83786. private _extensionsOnReady;
  83787. private _extensionsLoadSceneAsync;
  83788. private _extensionsLoadNodeAsync;
  83789. private _extensionsLoadCameraAsync;
  83790. private _extensionsLoadVertexDataAsync;
  83791. private _extensionsLoadMeshPrimitiveAsync;
  83792. private _extensionsLoadMaterialAsync;
  83793. private _extensionsCreateMaterial;
  83794. private _extensionsLoadMaterialPropertiesAsync;
  83795. private _extensionsLoadTextureInfoAsync;
  83796. private _extensionsLoadTextureAsync;
  83797. private _extensionsLoadAnimationAsync;
  83798. private _extensionsLoadSkinAsync;
  83799. private _extensionsLoadUriAsync;
  83800. private _extensionsLoadBufferViewAsync;
  83801. private _extensionsLoadBufferAsync;
  83802. /**
  83803. * Helper method called by a loader extension to load an glTF extension.
  83804. * @param context The context when loading the asset
  83805. * @param property The glTF property to load the extension from
  83806. * @param extensionName The name of the extension to load
  83807. * @param actionAsync The action to run
  83808. * @returns The promise returned by actionAsync or null if the extension does not exist
  83809. */
  83810. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83811. /**
  83812. * Helper method called by a loader extension to load a glTF extra.
  83813. * @param context The context when loading the asset
  83814. * @param property The glTF property to load the extra from
  83815. * @param extensionName The name of the extension to load
  83816. * @param actionAsync The action to run
  83817. * @returns The promise returned by actionAsync or null if the extra does not exist
  83818. */
  83819. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83820. /**
  83821. * Checks for presence of an extension.
  83822. * @param name The name of the extension to check
  83823. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83824. */
  83825. isExtensionUsed(name: string): boolean;
  83826. /**
  83827. * Increments the indentation level and logs a message.
  83828. * @param message The message to log
  83829. */
  83830. logOpen(message: string): void;
  83831. /**
  83832. * Decrements the indentation level.
  83833. */
  83834. logClose(): void;
  83835. /**
  83836. * Logs a message
  83837. * @param message The message to log
  83838. */
  83839. log(message: string): void;
  83840. /**
  83841. * Starts a performance counter.
  83842. * @param counterName The name of the performance counter
  83843. */
  83844. startPerformanceCounter(counterName: string): void;
  83845. /**
  83846. * Ends a performance counter.
  83847. * @param counterName The name of the performance counter
  83848. */
  83849. endPerformanceCounter(counterName: string): void;
  83850. }
  83851. }
  83852. declare module BABYLON.GLTF2.Loader.Extensions {
  83853. /** @hidden */
  83854. interface IEXTLightsImageBased_LightImageBased {
  83855. _babylonTexture?: BaseTexture;
  83856. _loaded?: Promise<void>;
  83857. }
  83858. /**
  83859. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83860. */
  83861. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83862. /**
  83863. * The name of this extension.
  83864. */
  83865. readonly name: string;
  83866. /**
  83867. * Defines whether this extension is enabled.
  83868. */
  83869. enabled: boolean;
  83870. private _loader;
  83871. private _lights?;
  83872. /** @hidden */
  83873. constructor(loader: GLTFLoader);
  83874. /** @hidden */
  83875. dispose(): void;
  83876. /** @hidden */
  83877. onLoading(): void;
  83878. /** @hidden */
  83879. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83880. private _loadLightAsync;
  83881. }
  83882. }
  83883. declare module BABYLON.GLTF2.Loader.Extensions {
  83884. /**
  83885. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83886. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83887. * !!! Experimental Extension Subject to Changes !!!
  83888. */
  83889. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83890. /**
  83891. * The name of this extension.
  83892. */
  83893. readonly name: string;
  83894. /**
  83895. * Defines whether this extension is enabled.
  83896. */
  83897. enabled: boolean;
  83898. private _loader;
  83899. /** @hidden */
  83900. constructor(loader: GLTFLoader);
  83901. /** @hidden */
  83902. dispose(): void;
  83903. /** @hidden */
  83904. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83905. }
  83906. }
  83907. declare module BABYLON.GLTF2.Loader.Extensions {
  83908. /**
  83909. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83910. */
  83911. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83912. /** The name of this extension. */
  83913. readonly name: string;
  83914. /** Defines whether this extension is enabled. */
  83915. enabled: boolean;
  83916. private _loader;
  83917. /** @hidden */
  83918. constructor(loader: GLTFLoader);
  83919. /** @hidden */
  83920. dispose(): void;
  83921. /** @hidden */
  83922. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83923. }
  83924. }
  83925. declare module BABYLON.GLTF2.Loader.Extensions {
  83926. /**
  83927. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83928. */
  83929. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83930. /**
  83931. * The name of this extension.
  83932. */
  83933. readonly name: string;
  83934. /**
  83935. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83936. */
  83937. dracoCompression?: DracoCompression;
  83938. /**
  83939. * Defines whether this extension is enabled.
  83940. */
  83941. enabled: boolean;
  83942. private _loader;
  83943. /** @hidden */
  83944. constructor(loader: GLTFLoader);
  83945. /** @hidden */
  83946. dispose(): void;
  83947. /** @hidden */
  83948. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83949. }
  83950. }
  83951. declare module BABYLON.GLTF2.Loader.Extensions {
  83952. /**
  83953. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83954. */
  83955. export class KHR_lights implements IGLTFLoaderExtension {
  83956. /**
  83957. * The name of this extension.
  83958. */
  83959. readonly name: string;
  83960. /**
  83961. * Defines whether this extension is enabled.
  83962. */
  83963. enabled: boolean;
  83964. private _loader;
  83965. private _lights?;
  83966. /** @hidden */
  83967. constructor(loader: GLTFLoader);
  83968. /** @hidden */
  83969. dispose(): void;
  83970. /** @hidden */
  83971. onLoading(): void;
  83972. /** @hidden */
  83973. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83974. }
  83975. }
  83976. declare module BABYLON.GLTF2.Loader.Extensions {
  83977. /**
  83978. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83979. */
  83980. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83981. /**
  83982. * The name of this extension.
  83983. */
  83984. readonly name: string;
  83985. /**
  83986. * Defines whether this extension is enabled.
  83987. */
  83988. enabled: boolean;
  83989. /**
  83990. * Defines a number that determines the order the extensions are applied.
  83991. */
  83992. order: number;
  83993. private _loader;
  83994. /** @hidden */
  83995. constructor(loader: GLTFLoader);
  83996. /** @hidden */
  83997. dispose(): void;
  83998. /** @hidden */
  83999. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84000. private _loadSpecularGlossinessPropertiesAsync;
  84001. }
  84002. }
  84003. declare module BABYLON.GLTF2.Loader.Extensions {
  84004. /**
  84005. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  84006. */
  84007. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  84008. /**
  84009. * The name of this extension.
  84010. */
  84011. readonly name: string;
  84012. /**
  84013. * Defines whether this extension is enabled.
  84014. */
  84015. enabled: boolean;
  84016. /**
  84017. * Defines a number that determines the order the extensions are applied.
  84018. */
  84019. order: number;
  84020. private _loader;
  84021. /** @hidden */
  84022. constructor(loader: GLTFLoader);
  84023. /** @hidden */
  84024. dispose(): void;
  84025. /** @hidden */
  84026. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84027. private _loadUnlitPropertiesAsync;
  84028. }
  84029. }
  84030. declare module BABYLON.GLTF2.Loader.Extensions {
  84031. /**
  84032. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  84033. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  84034. */
  84035. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  84036. /**
  84037. * The name of this extension.
  84038. */
  84039. readonly name: string;
  84040. /**
  84041. * Defines whether this extension is enabled.
  84042. */
  84043. enabled: boolean;
  84044. /**
  84045. * Defines a number that determines the order the extensions are applied.
  84046. */
  84047. order: number;
  84048. private _loader;
  84049. /** @hidden */
  84050. constructor(loader: GLTFLoader);
  84051. /** @hidden */
  84052. dispose(): void;
  84053. /** @hidden */
  84054. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84055. private _loadClearCoatPropertiesAsync;
  84056. }
  84057. }
  84058. declare module BABYLON.GLTF2.Loader.Extensions {
  84059. /**
  84060. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  84061. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  84062. * !!! Experimental Extension Subject to Changes !!!
  84063. */
  84064. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  84065. /**
  84066. * The name of this extension.
  84067. */
  84068. readonly name: string;
  84069. /**
  84070. * Defines whether this extension is enabled.
  84071. */
  84072. enabled: boolean;
  84073. /**
  84074. * Defines a number that determines the order the extensions are applied.
  84075. */
  84076. order: number;
  84077. private _loader;
  84078. /** @hidden */
  84079. constructor(loader: GLTFLoader);
  84080. /** @hidden */
  84081. dispose(): void;
  84082. /** @hidden */
  84083. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84084. private _loadSheenPropertiesAsync;
  84085. }
  84086. }
  84087. declare module BABYLON.GLTF2.Loader.Extensions {
  84088. /**
  84089. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  84090. * !!! Experimental Extension Subject to Changes !!!
  84091. */
  84092. export class KHR_materials_specular implements IGLTFLoaderExtension {
  84093. /**
  84094. * The name of this extension.
  84095. */
  84096. readonly name: string;
  84097. /**
  84098. * Defines whether this extension is enabled.
  84099. */
  84100. enabled: boolean;
  84101. /**
  84102. * Defines a number that determines the order the extensions are applied.
  84103. */
  84104. order: number;
  84105. private _loader;
  84106. /** @hidden */
  84107. constructor(loader: GLTFLoader);
  84108. /** @hidden */
  84109. dispose(): void;
  84110. /** @hidden */
  84111. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84112. private _loadSpecularPropertiesAsync;
  84113. }
  84114. }
  84115. declare module BABYLON.GLTF2.Loader.Extensions {
  84116. /**
  84117. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  84118. * !!! Experimental Extension Subject to Changes !!!
  84119. */
  84120. export class KHR_materials_ior implements IGLTFLoaderExtension {
  84121. /**
  84122. * Default ior Value from the spec.
  84123. */
  84124. private static readonly _DEFAULT_IOR;
  84125. /**
  84126. * The name of this extension.
  84127. */
  84128. readonly name: string;
  84129. /**
  84130. * Defines whether this extension is enabled.
  84131. */
  84132. enabled: boolean;
  84133. /**
  84134. * Defines a number that determines the order the extensions are applied.
  84135. */
  84136. order: number;
  84137. private _loader;
  84138. /** @hidden */
  84139. constructor(loader: GLTFLoader);
  84140. /** @hidden */
  84141. dispose(): void;
  84142. /** @hidden */
  84143. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84144. private _loadIorPropertiesAsync;
  84145. }
  84146. }
  84147. declare module BABYLON.GLTF2.Loader.Extensions {
  84148. /**
  84149. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  84150. * !!! Experimental Extension Subject to Changes !!!
  84151. */
  84152. export class KHR_materials_variants implements IGLTFLoaderExtension {
  84153. /**
  84154. * The name of this extension.
  84155. */
  84156. readonly name: string;
  84157. /**
  84158. * Defines whether this extension is enabled.
  84159. */
  84160. enabled: boolean;
  84161. private _loader;
  84162. private _variants?;
  84163. /** @hidden */
  84164. constructor(loader: GLTFLoader);
  84165. /** @hidden */
  84166. dispose(): void;
  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. static GetAvailableVariants(rootMesh: Mesh): string[];
  84173. /**
  84174. * Gets the list of available variant names for this asset.
  84175. * @param rootMesh The glTF root mesh
  84176. * @returns the list of all the variant names for this model
  84177. */
  84178. getAvailableVariants(rootMesh: Mesh): string[];
  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. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84185. /**
  84186. * Select a variant given a variant name or a list of variant names.
  84187. * @param rootMesh The glTF root mesh
  84188. * @param variantName The variant name(s) to select.
  84189. */
  84190. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84191. /**
  84192. * Reset back to the original before selecting a variant.
  84193. * @param rootMesh The glTF root mesh
  84194. */
  84195. static Reset(rootMesh: Mesh): void;
  84196. /**
  84197. * Reset back to the original before selecting a variant.
  84198. * @param rootMesh The glTF root mesh
  84199. */
  84200. reset(rootMesh: Mesh): void;
  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. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84207. /**
  84208. * Gets the last selected variant name(s) or null if original.
  84209. * @param rootMesh The glTF root mesh
  84210. * @returns The selected variant name(s).
  84211. */
  84212. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84213. private static _GetExtensionMetadata;
  84214. /** @hidden */
  84215. onLoading(): void;
  84216. /** @hidden */
  84217. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84218. }
  84219. }
  84220. declare module BABYLON.GLTF2.Loader.Extensions {
  84221. /**
  84222. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84223. * !!! Experimental Extension Subject to Changes !!!
  84224. */
  84225. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84226. /**
  84227. * The name of this extension.
  84228. */
  84229. readonly name: string;
  84230. /**
  84231. * Defines whether this extension is enabled.
  84232. */
  84233. enabled: boolean;
  84234. /**
  84235. * Defines a number that determines the order the extensions are applied.
  84236. */
  84237. order: number;
  84238. private _loader;
  84239. /** @hidden */
  84240. constructor(loader: GLTFLoader);
  84241. /** @hidden */
  84242. dispose(): void;
  84243. /** @hidden */
  84244. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84245. private _loadTransparentPropertiesAsync;
  84246. }
  84247. }
  84248. declare module BABYLON.GLTF2.Loader.Extensions {
  84249. /**
  84250. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84251. * !!! Experimental Extension Subject to Changes !!!
  84252. */
  84253. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84254. /**
  84255. * The name of this extension.
  84256. */
  84257. readonly name: string;
  84258. /**
  84259. * Defines whether this extension is enabled.
  84260. */
  84261. enabled: boolean;
  84262. /**
  84263. * Defines a number that determines the order the extensions are applied.
  84264. */
  84265. order: number;
  84266. private _loader;
  84267. /** @hidden */
  84268. constructor(loader: GLTFLoader);
  84269. /** @hidden */
  84270. dispose(): void;
  84271. /** @hidden */
  84272. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84273. private _loadTranslucentPropertiesAsync;
  84274. }
  84275. }
  84276. declare module BABYLON.GLTF2.Loader.Extensions {
  84277. /**
  84278. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84279. */
  84280. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84281. /**
  84282. * The name of this extension.
  84283. */
  84284. readonly name: string;
  84285. /**
  84286. * Defines whether this extension is enabled.
  84287. */
  84288. enabled: boolean;
  84289. /** @hidden */
  84290. constructor(loader: GLTFLoader);
  84291. /** @hidden */
  84292. dispose(): void;
  84293. }
  84294. }
  84295. declare module BABYLON.GLTF2.Loader.Extensions {
  84296. /**
  84297. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84298. * !!! Experimental Extension Subject to Changes !!!
  84299. */
  84300. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84301. /** The name of this extension. */
  84302. readonly name: string;
  84303. /** Defines whether this extension is enabled. */
  84304. enabled: boolean;
  84305. private _loader;
  84306. /** @hidden */
  84307. constructor(loader: GLTFLoader);
  84308. /** @hidden */
  84309. dispose(): void;
  84310. /** @hidden */
  84311. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84312. }
  84313. }
  84314. declare module BABYLON.GLTF2.Loader.Extensions {
  84315. /**
  84316. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84317. */
  84318. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84319. /**
  84320. * The name of this extension.
  84321. */
  84322. readonly name: string;
  84323. /**
  84324. * Defines whether this extension is enabled.
  84325. */
  84326. enabled: boolean;
  84327. private _loader;
  84328. /** @hidden */
  84329. constructor(loader: GLTFLoader);
  84330. /** @hidden */
  84331. dispose(): void;
  84332. /** @hidden */
  84333. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84334. }
  84335. }
  84336. declare module BABYLON.GLTF2.Loader.Extensions {
  84337. /**
  84338. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84339. */
  84340. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84341. /**
  84342. * The name of this extension.
  84343. */
  84344. readonly name: string;
  84345. /**
  84346. * Defines whether this extension is enabled.
  84347. */
  84348. enabled: boolean;
  84349. private _loader;
  84350. private _clips;
  84351. private _emitters;
  84352. /** @hidden */
  84353. constructor(loader: GLTFLoader);
  84354. /** @hidden */
  84355. dispose(): void;
  84356. /** @hidden */
  84357. onLoading(): void;
  84358. /** @hidden */
  84359. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84360. /** @hidden */
  84361. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84362. /** @hidden */
  84363. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84364. private _loadClipAsync;
  84365. private _loadEmitterAsync;
  84366. private _getEventAction;
  84367. private _loadAnimationEventAsync;
  84368. }
  84369. }
  84370. declare module BABYLON.GLTF2.Loader.Extensions {
  84371. /**
  84372. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84373. */
  84374. export class MSFT_lod implements IGLTFLoaderExtension {
  84375. /**
  84376. * The name of this extension.
  84377. */
  84378. readonly name: string;
  84379. /**
  84380. * Defines whether this extension is enabled.
  84381. */
  84382. enabled: boolean;
  84383. /**
  84384. * Defines a number that determines the order the extensions are applied.
  84385. */
  84386. order: number;
  84387. /**
  84388. * Maximum number of LODs to load, starting from the lowest LOD.
  84389. */
  84390. maxLODsToLoad: number;
  84391. /**
  84392. * Observable raised when all node 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. onNodeLODsLoadedObservable: Observable<number>;
  84397. /**
  84398. * Observable raised when all material LODs of one level are loaded.
  84399. * The event data is the index of the loaded LOD starting from zero.
  84400. * Dispose the loader to cancel the loading of the next level of LODs.
  84401. */
  84402. onMaterialLODsLoadedObservable: Observable<number>;
  84403. private _loader;
  84404. private _bufferLODs;
  84405. private _nodeIndexLOD;
  84406. private _nodeSignalLODs;
  84407. private _nodePromiseLODs;
  84408. private _nodeBufferLODs;
  84409. private _materialIndexLOD;
  84410. private _materialSignalLODs;
  84411. private _materialPromiseLODs;
  84412. private _materialBufferLODs;
  84413. /** @hidden */
  84414. constructor(loader: GLTFLoader);
  84415. /** @hidden */
  84416. dispose(): void;
  84417. /** @hidden */
  84418. onReady(): void;
  84419. /** @hidden */
  84420. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84421. /** @hidden */
  84422. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84423. /** @hidden */
  84424. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84425. /** @hidden */
  84426. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84427. /** @hidden */
  84428. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84429. private _loadBufferLOD;
  84430. /**
  84431. * Gets an array of LOD properties from lowest to highest.
  84432. */
  84433. private _getLODs;
  84434. private _disposeTransformNode;
  84435. private _disposeMaterials;
  84436. }
  84437. }
  84438. declare module BABYLON.GLTF2.Loader.Extensions {
  84439. /** @hidden */
  84440. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84441. readonly name: string;
  84442. enabled: boolean;
  84443. private _loader;
  84444. constructor(loader: GLTFLoader);
  84445. dispose(): void;
  84446. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84447. }
  84448. }
  84449. declare module BABYLON.GLTF2.Loader.Extensions {
  84450. /** @hidden */
  84451. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84452. readonly name: string;
  84453. enabled: boolean;
  84454. private _loader;
  84455. constructor(loader: GLTFLoader);
  84456. dispose(): void;
  84457. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84458. }
  84459. }
  84460. declare module BABYLON.GLTF2.Loader.Extensions {
  84461. /**
  84462. * Store glTF extras (if present) in BJS objects' metadata
  84463. */
  84464. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84465. /**
  84466. * The name of this extension.
  84467. */
  84468. readonly name: string;
  84469. /**
  84470. * Defines whether this extension is enabled.
  84471. */
  84472. enabled: boolean;
  84473. private _loader;
  84474. private _assignExtras;
  84475. /** @hidden */
  84476. constructor(loader: GLTFLoader);
  84477. /** @hidden */
  84478. dispose(): void;
  84479. /** @hidden */
  84480. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84481. /** @hidden */
  84482. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84483. /** @hidden */
  84484. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84485. }
  84486. }
  84487. declare module BABYLON {
  84488. /**
  84489. * Class reading and parsing the MTL file bundled with the obj file.
  84490. */
  84491. export class MTLFileLoader {
  84492. /**
  84493. * Invert Y-Axis of referenced textures on load
  84494. */
  84495. static INVERT_TEXTURE_Y: boolean;
  84496. /**
  84497. * All material loaded from the mtl will be set here
  84498. */
  84499. materials: StandardMaterial[];
  84500. /**
  84501. * This function will read the mtl file and create each material described inside
  84502. * This function could be improve by adding :
  84503. * -some component missing (Ni, Tf...)
  84504. * -including the specific options available
  84505. *
  84506. * @param scene defines the scene the material will be created in
  84507. * @param data defines the mtl data to parse
  84508. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84509. * @param forAssetContainer defines if the material should be registered in the scene
  84510. */
  84511. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84512. /**
  84513. * Gets the texture for the material.
  84514. *
  84515. * If the material is imported from input file,
  84516. * We sanitize the url to ensure it takes the textre from aside the material.
  84517. *
  84518. * @param rootUrl The root url to load from
  84519. * @param value The value stored in the mtl
  84520. * @return The Texture
  84521. */
  84522. private static _getTexture;
  84523. }
  84524. }
  84525. declare module BABYLON {
  84526. /**
  84527. * Options for loading OBJ/MTL files
  84528. */
  84529. type MeshLoadOptions = {
  84530. /**
  84531. * Defines if UVs are optimized by default during load.
  84532. */
  84533. OptimizeWithUV: boolean;
  84534. /**
  84535. * Defines custom scaling of UV coordinates of loaded meshes.
  84536. */
  84537. UVScaling: Vector2;
  84538. /**
  84539. * Invert model on y-axis (does a model scaling inversion)
  84540. */
  84541. InvertY: boolean;
  84542. /**
  84543. * Invert Y-Axis of referenced textures on load
  84544. */
  84545. InvertTextureY: boolean;
  84546. /**
  84547. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84548. */
  84549. ImportVertexColors: boolean;
  84550. /**
  84551. * Compute the normals for the model, even if normals are present in the file.
  84552. */
  84553. ComputeNormals: boolean;
  84554. /**
  84555. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84556. */
  84557. SkipMaterials: boolean;
  84558. /**
  84559. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84560. */
  84561. MaterialLoadingFailsSilently: boolean;
  84562. };
  84563. /**
  84564. * OBJ file type loader.
  84565. * This is a babylon scene loader plugin.
  84566. */
  84567. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84568. /**
  84569. * Defines if UVs are optimized by default during load.
  84570. */
  84571. static OPTIMIZE_WITH_UV: boolean;
  84572. /**
  84573. * Invert model on y-axis (does a model scaling inversion)
  84574. */
  84575. static INVERT_Y: boolean;
  84576. /**
  84577. * Invert Y-Axis of referenced textures on load
  84578. */
  84579. static get INVERT_TEXTURE_Y(): boolean;
  84580. static set INVERT_TEXTURE_Y(value: boolean);
  84581. /**
  84582. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84583. */
  84584. static IMPORT_VERTEX_COLORS: boolean;
  84585. /**
  84586. * Compute the normals for the model, even if normals are present in the file.
  84587. */
  84588. static COMPUTE_NORMALS: boolean;
  84589. /**
  84590. * Defines custom scaling of UV coordinates of loaded meshes.
  84591. */
  84592. static UV_SCALING: Vector2;
  84593. /**
  84594. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84595. */
  84596. static SKIP_MATERIALS: boolean;
  84597. /**
  84598. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84599. *
  84600. * Defaults to true for backwards compatibility.
  84601. */
  84602. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84603. /**
  84604. * Defines the name of the plugin.
  84605. */
  84606. name: string;
  84607. /**
  84608. * Defines the extension the plugin is able to load.
  84609. */
  84610. extensions: string;
  84611. /** @hidden */
  84612. obj: RegExp;
  84613. /** @hidden */
  84614. group: RegExp;
  84615. /** @hidden */
  84616. mtllib: RegExp;
  84617. /** @hidden */
  84618. usemtl: RegExp;
  84619. /** @hidden */
  84620. smooth: RegExp;
  84621. /** @hidden */
  84622. vertexPattern: RegExp;
  84623. /** @hidden */
  84624. normalPattern: RegExp;
  84625. /** @hidden */
  84626. uvPattern: RegExp;
  84627. /** @hidden */
  84628. facePattern1: RegExp;
  84629. /** @hidden */
  84630. facePattern2: RegExp;
  84631. /** @hidden */
  84632. facePattern3: RegExp;
  84633. /** @hidden */
  84634. facePattern4: RegExp;
  84635. /** @hidden */
  84636. facePattern5: RegExp;
  84637. private _forAssetContainer;
  84638. private _meshLoadOptions;
  84639. /**
  84640. * Creates loader for .OBJ files
  84641. *
  84642. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84643. */
  84644. constructor(meshLoadOptions?: MeshLoadOptions);
  84645. private static get currentMeshLoadOptions();
  84646. /**
  84647. * Calls synchronously the MTL file attached to this obj.
  84648. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84649. * Without this function materials are not displayed in the first frame (but displayed after).
  84650. * In consequence it is impossible to get material information in your HTML file
  84651. *
  84652. * @param url The URL of the MTL file
  84653. * @param rootUrl
  84654. * @param onSuccess Callback function to be called when the MTL file is loaded
  84655. * @private
  84656. */
  84657. private _loadMTL;
  84658. /**
  84659. * Instantiates a OBJ file loader plugin.
  84660. * @returns the created plugin
  84661. */
  84662. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84663. /**
  84664. * If the data string can be loaded directly.
  84665. *
  84666. * @param data string containing the file data
  84667. * @returns if the data can be loaded directly
  84668. */
  84669. canDirectLoad(data: string): boolean;
  84670. /**
  84671. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84672. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84673. * @param scene the scene the meshes should be added to
  84674. * @param data the OBJ data to load
  84675. * @param rootUrl root url to load from
  84676. * @param onProgress event that fires when loading progress has occured
  84677. * @param fileName Defines the name of the file to load
  84678. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84679. */
  84680. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84681. /**
  84682. * Imports all objects from the loaded OBJ data and adds them to the scene
  84683. * @param scene the scene the objects should be added to
  84684. * @param data the OBJ data to load
  84685. * @param rootUrl root url to load from
  84686. * @param onProgress event that fires when loading progress has occured
  84687. * @param fileName Defines the name of the file to load
  84688. * @returns a promise which completes when objects have been loaded to the scene
  84689. */
  84690. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84691. /**
  84692. * Load into an asset container.
  84693. * @param scene The scene to load into
  84694. * @param data The data to import
  84695. * @param rootUrl The root url for scene and resources
  84696. * @param onProgress The callback when the load progresses
  84697. * @param fileName Defines the name of the file to load
  84698. * @returns The loaded asset container
  84699. */
  84700. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84701. /**
  84702. * Read the OBJ file and create an Array of meshes.
  84703. * Each mesh contains all information given by the OBJ and the MTL file.
  84704. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84705. *
  84706. * @param meshesNames
  84707. * @param scene Scene The scene where are displayed the data
  84708. * @param data String The content of the obj file
  84709. * @param rootUrl String The path to the folder
  84710. * @returns Array<AbstractMesh>
  84711. * @private
  84712. */
  84713. private _parseSolid;
  84714. }
  84715. }
  84716. declare module BABYLON {
  84717. /**
  84718. * STL file type loader.
  84719. * This is a babylon scene loader plugin.
  84720. */
  84721. export class STLFileLoader implements ISceneLoaderPlugin {
  84722. /** @hidden */
  84723. solidPattern: RegExp;
  84724. /** @hidden */
  84725. facetsPattern: RegExp;
  84726. /** @hidden */
  84727. normalPattern: RegExp;
  84728. /** @hidden */
  84729. vertexPattern: RegExp;
  84730. /**
  84731. * Defines the name of the plugin.
  84732. */
  84733. name: string;
  84734. /**
  84735. * Defines the extensions the stl loader is able to load.
  84736. * force data to come in as an ArrayBuffer
  84737. * we'll convert to string if it looks like it's an ASCII .stl
  84738. */
  84739. extensions: ISceneLoaderPluginExtensions;
  84740. /**
  84741. * Import meshes into a scene.
  84742. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84743. * @param scene The scene to import into
  84744. * @param data The data to import
  84745. * @param rootUrl The root url for scene and resources
  84746. * @param meshes The meshes array to import into
  84747. * @param particleSystems The particle systems array to import into
  84748. * @param skeletons The skeletons array to import into
  84749. * @param onError The callback when import fails
  84750. * @returns True if successful or false otherwise
  84751. */
  84752. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84753. /**
  84754. * Load into a scene.
  84755. * @param scene The scene to load into
  84756. * @param data The data to import
  84757. * @param rootUrl The root url for scene and resources
  84758. * @param onError The callback when import fails
  84759. * @returns true if successful or false otherwise
  84760. */
  84761. load(scene: Scene, data: any, rootUrl: string): boolean;
  84762. /**
  84763. * Load into an asset container.
  84764. * @param scene The scene to load into
  84765. * @param data The data to import
  84766. * @param rootUrl The root url for scene and resources
  84767. * @param onError The callback when import fails
  84768. * @returns The loaded asset container
  84769. */
  84770. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84771. private _isBinary;
  84772. private _parseBinary;
  84773. private _parseASCII;
  84774. }
  84775. }
  84776. declare module BABYLON {
  84777. /**
  84778. * Class for generating OBJ data from a Babylon scene.
  84779. */
  84780. export class OBJExport {
  84781. /**
  84782. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84783. * @param mesh defines the list of meshes to serialize
  84784. * @param materials defines if materials should be exported
  84785. * @param matlibname defines the name of the associated mtl file
  84786. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84787. * @returns the OBJ content
  84788. */
  84789. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84790. /**
  84791. * Exports the material(s) of a mesh in .MTL file format (text)
  84792. * @param mesh defines the mesh to extract the material from
  84793. * @returns the mtl content
  84794. */
  84795. static MTL(mesh: Mesh): string;
  84796. }
  84797. }
  84798. declare module BABYLON {
  84799. /** @hidden */
  84800. export var __IGLTFExporterExtension: number;
  84801. /**
  84802. * Interface for extending the exporter
  84803. * @hidden
  84804. */
  84805. export interface IGLTFExporterExtension {
  84806. /**
  84807. * The name of this extension
  84808. */
  84809. readonly name: string;
  84810. /**
  84811. * Defines whether this extension is enabled
  84812. */
  84813. enabled: boolean;
  84814. /**
  84815. * Defines whether this extension is required
  84816. */
  84817. required: boolean;
  84818. }
  84819. }
  84820. declare module BABYLON.GLTF2.Exporter {
  84821. /** @hidden */
  84822. export var __IGLTFExporterExtensionV2: number;
  84823. /**
  84824. * Interface for a glTF exporter extension
  84825. * @hidden
  84826. */
  84827. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84828. /**
  84829. * Define this method to modify the default behavior before exporting a texture
  84830. * @param context The context when loading the asset
  84831. * @param babylonTexture The Babylon.js texture
  84832. * @param mimeType The mime-type of the generated image
  84833. * @returns A promise that resolves with the exported texture
  84834. */
  84835. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84836. /**
  84837. * Define this method to get notified when a texture info is created
  84838. * @param context The context when loading the asset
  84839. * @param textureInfo The glTF texture info
  84840. * @param babylonTexture The Babylon.js texture
  84841. */
  84842. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84843. /**
  84844. * Define this method to modify the default behavior when exporting texture info
  84845. * @param context The context when loading the asset
  84846. * @param meshPrimitive glTF mesh primitive
  84847. * @param babylonSubMesh Babylon submesh
  84848. * @param binaryWriter glTF serializer binary writer instance
  84849. * @returns nullable IMeshPrimitive promise
  84850. */
  84851. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84852. /**
  84853. * Define this method to modify the default behavior when exporting a node
  84854. * @param context The context when exporting the node
  84855. * @param node glTF node
  84856. * @param babylonNode BabylonJS node
  84857. * @returns nullable INode promise
  84858. */
  84859. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84860. [key: number]: number;
  84861. }): Promise<Nullable<INode>>;
  84862. /**
  84863. * Define this method to modify the default behavior when exporting a material
  84864. * @param material glTF material
  84865. * @param babylonMaterial BabylonJS material
  84866. * @returns nullable IMaterial promise
  84867. */
  84868. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84869. /**
  84870. * Define this method to return additional textures to export from a material
  84871. * @param material glTF material
  84872. * @param babylonMaterial BabylonJS material
  84873. * @returns List of textures
  84874. */
  84875. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84876. /** Gets a boolean indicating that this extension was used */
  84877. wasUsed: boolean;
  84878. /** Gets a boolean indicating that this extension is required for the file to work */
  84879. required: boolean;
  84880. /**
  84881. * Called after the exporter state changes to EXPORTING
  84882. */
  84883. onExporting?(): void;
  84884. }
  84885. }
  84886. declare module BABYLON.GLTF2.Exporter {
  84887. /**
  84888. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84889. * @hidden
  84890. */
  84891. export class _GLTFMaterialExporter {
  84892. /**
  84893. * Represents the dielectric specular values for R, G and B
  84894. */
  84895. private static readonly _DielectricSpecular;
  84896. /**
  84897. * Allows the maximum specular power to be defined for material calculations
  84898. */
  84899. private static readonly _MaxSpecularPower;
  84900. /**
  84901. * Mapping to store textures
  84902. */
  84903. private _textureMap;
  84904. /**
  84905. * Numeric tolerance value
  84906. */
  84907. private static readonly _Epsilon;
  84908. /**
  84909. * Reference to the glTF Exporter
  84910. */
  84911. private _exporter;
  84912. constructor(exporter: _Exporter);
  84913. /**
  84914. * Specifies if two colors are approximately equal in value
  84915. * @param color1 first color to compare to
  84916. * @param color2 second color to compare to
  84917. * @param epsilon threshold value
  84918. */
  84919. private static FuzzyEquals;
  84920. /**
  84921. * Gets the materials from a Babylon scene and converts them to glTF materials
  84922. * @param scene babylonjs scene
  84923. * @param mimeType texture mime type
  84924. * @param images array of images
  84925. * @param textures array of textures
  84926. * @param materials array of materials
  84927. * @param imageData mapping of texture names to base64 textures
  84928. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84929. */
  84930. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84931. /**
  84932. * Makes a copy of the glTF material without the texture parameters
  84933. * @param originalMaterial original glTF material
  84934. * @returns glTF material without texture parameters
  84935. */
  84936. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84937. /**
  84938. * Specifies if the material has any texture parameters present
  84939. * @param material glTF Material
  84940. * @returns boolean specifying if texture parameters are present
  84941. */
  84942. _hasTexturesPresent(material: IMaterial): boolean;
  84943. /**
  84944. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84945. * @param babylonStandardMaterial
  84946. * @returns glTF Metallic Roughness Material representation
  84947. */
  84948. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84949. /**
  84950. * Computes the metallic factor
  84951. * @param diffuse diffused value
  84952. * @param specular specular value
  84953. * @param oneMinusSpecularStrength one minus the specular strength
  84954. * @returns metallic value
  84955. */
  84956. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84957. /**
  84958. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84959. * @param glTFMaterial glTF material
  84960. * @param babylonMaterial Babylon material
  84961. */
  84962. private static _SetAlphaMode;
  84963. /**
  84964. * Converts a Babylon Standard Material to a glTF Material
  84965. * @param babylonStandardMaterial BJS Standard Material
  84966. * @param mimeType mime type to use for the textures
  84967. * @param images array of glTF image interfaces
  84968. * @param textures array of glTF texture interfaces
  84969. * @param materials array of glTF material interfaces
  84970. * @param imageData map of image file name to data
  84971. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84972. */
  84973. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84974. private _finishMaterial;
  84975. /**
  84976. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84977. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84978. * @param mimeType mime type to use for the textures
  84979. * @param images array of glTF image interfaces
  84980. * @param textures array of glTF texture interfaces
  84981. * @param materials array of glTF material interfaces
  84982. * @param imageData map of image file name to data
  84983. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84984. */
  84985. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84986. /**
  84987. * Converts an image typed array buffer to a base64 image
  84988. * @param buffer typed array buffer
  84989. * @param width width of the image
  84990. * @param height height of the image
  84991. * @param mimeType mimetype of the image
  84992. * @returns base64 image string
  84993. */
  84994. private _createBase64FromCanvasAsync;
  84995. /**
  84996. * Generates a white texture based on the specified width and height
  84997. * @param width width of the texture in pixels
  84998. * @param height height of the texture in pixels
  84999. * @param scene babylonjs scene
  85000. * @returns white texture
  85001. */
  85002. private _createWhiteTexture;
  85003. /**
  85004. * 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
  85005. * @param texture1 first texture to resize
  85006. * @param texture2 second texture to resize
  85007. * @param scene babylonjs scene
  85008. * @returns resized textures or null
  85009. */
  85010. private _resizeTexturesToSameDimensions;
  85011. /**
  85012. * Converts an array of pixels to a Float32Array
  85013. * Throws an error if the pixel format is not supported
  85014. * @param pixels - array buffer containing pixel values
  85015. * @returns Float32 of pixels
  85016. */
  85017. private _convertPixelArrayToFloat32;
  85018. /**
  85019. * Convert Specular Glossiness Textures to Metallic Roughness
  85020. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  85021. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  85022. * @param diffuseTexture texture used to store diffuse information
  85023. * @param specularGlossinessTexture texture used to store specular and glossiness information
  85024. * @param factors specular glossiness material factors
  85025. * @param mimeType the mime type to use for the texture
  85026. * @returns pbr metallic roughness interface or null
  85027. */
  85028. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  85029. /**
  85030. * Converts specular glossiness material properties to metallic roughness
  85031. * @param specularGlossiness interface with specular glossiness material properties
  85032. * @returns interface with metallic roughness material properties
  85033. */
  85034. private _convertSpecularGlossinessToMetallicRoughness;
  85035. /**
  85036. * Calculates the surface reflectance, independent of lighting conditions
  85037. * @param color Color source to calculate brightness from
  85038. * @returns number representing the perceived brightness, or zero if color is undefined
  85039. */
  85040. private _getPerceivedBrightness;
  85041. /**
  85042. * Returns the maximum color component value
  85043. * @param color
  85044. * @returns maximum color component value, or zero if color is null or undefined
  85045. */
  85046. private _getMaxComponent;
  85047. /**
  85048. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  85049. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85050. * @param mimeType mime type to use for the textures
  85051. * @param images array of glTF image interfaces
  85052. * @param textures array of glTF texture interfaces
  85053. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85054. * @param imageData map of image file name to data
  85055. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85056. * @returns glTF PBR Metallic Roughness factors
  85057. */
  85058. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  85059. private _getGLTFTextureSampler;
  85060. private _getGLTFTextureWrapMode;
  85061. private _getGLTFTextureWrapModesSampler;
  85062. /**
  85063. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  85064. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85065. * @param mimeType mime type to use for the textures
  85066. * @param images array of glTF image interfaces
  85067. * @param textures array of glTF texture interfaces
  85068. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85069. * @param imageData map of image file name to data
  85070. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85071. * @returns glTF PBR Metallic Roughness factors
  85072. */
  85073. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  85074. /**
  85075. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85076. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85077. * @param mimeType mime type to use for the textures
  85078. * @param images array of glTF image interfaces
  85079. * @param textures array of glTF texture interfaces
  85080. * @param materials array of glTF material interfaces
  85081. * @param imageData map of image file name to data
  85082. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85083. */
  85084. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85085. private setMetallicRoughnessPbrMaterial;
  85086. private getPixelsFromTexture;
  85087. /**
  85088. * Extracts a texture from a Babylon texture into file data and glTF data
  85089. * @param babylonTexture Babylon texture to extract
  85090. * @param mimeType Mime Type of the babylonTexture
  85091. * @return glTF texture info, or null if the texture format is not supported
  85092. */
  85093. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85094. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85095. /**
  85096. * Builds a texture from base64 string
  85097. * @param base64Texture base64 texture string
  85098. * @param baseTextureName Name to use for the texture
  85099. * @param mimeType image mime type for the texture
  85100. * @param images array of images
  85101. * @param textures array of textures
  85102. * @param imageData map of image data
  85103. * @returns glTF texture info, or null if the texture format is not supported
  85104. */
  85105. private _getTextureInfoFromBase64;
  85106. }
  85107. }
  85108. declare module BABYLON {
  85109. /**
  85110. * Class for holding and downloading glTF file data
  85111. */
  85112. export class GLTFData {
  85113. /**
  85114. * Object which contains the file name as the key and its data as the value
  85115. */
  85116. glTFFiles: {
  85117. [fileName: string]: string | Blob;
  85118. };
  85119. /**
  85120. * Initializes the glTF file object
  85121. */
  85122. constructor();
  85123. /**
  85124. * Downloads the glTF data as files based on their names and data
  85125. */
  85126. downloadFiles(): void;
  85127. }
  85128. }
  85129. declare module BABYLON {
  85130. /**
  85131. * Holds a collection of exporter options and parameters
  85132. */
  85133. export interface IExportOptions {
  85134. /**
  85135. * Function which indicates whether a babylon node should be exported or not
  85136. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  85137. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  85138. */
  85139. shouldExportNode?(node: Node): boolean;
  85140. /**
  85141. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  85142. * @param metadata source metadata to read from
  85143. * @returns the data to store to glTF node extras
  85144. */
  85145. metadataSelector?(metadata: any): any;
  85146. /**
  85147. * The sample rate to bake animation curves
  85148. */
  85149. animationSampleRate?: number;
  85150. /**
  85151. * Begin serialization without waiting for the scene to be ready
  85152. */
  85153. exportWithoutWaitingForScene?: boolean;
  85154. /**
  85155. * Indicates if coordinate system swapping root nodes should be included in export
  85156. */
  85157. includeCoordinateSystemConversionNodes?: boolean;
  85158. }
  85159. /**
  85160. * Class for generating glTF data from a Babylon scene.
  85161. */
  85162. export class GLTF2Export {
  85163. /**
  85164. * Exports the geometry of the scene to .gltf file format asynchronously
  85165. * @param scene Babylon scene with scene hierarchy information
  85166. * @param filePrefix File prefix to use when generating the glTF file
  85167. * @param options Exporter options
  85168. * @returns Returns an object with a .gltf file and associates texture names
  85169. * as keys and their data and paths as values
  85170. */
  85171. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85172. private static _PreExportAsync;
  85173. private static _PostExportAsync;
  85174. /**
  85175. * Exports the geometry of the scene to .glb file format asychronously
  85176. * @param scene Babylon scene with scene hierarchy information
  85177. * @param filePrefix File prefix to use when generating glb file
  85178. * @param options Exporter options
  85179. * @returns Returns an object with a .glb filename as key and data as value
  85180. */
  85181. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85182. }
  85183. }
  85184. declare module BABYLON.GLTF2.Exporter {
  85185. /**
  85186. * @hidden
  85187. */
  85188. export class _GLTFUtilities {
  85189. /**
  85190. * Creates a buffer view based on the supplied arguments
  85191. * @param bufferIndex index value of the specified buffer
  85192. * @param byteOffset byte offset value
  85193. * @param byteLength byte length of the bufferView
  85194. * @param byteStride byte distance between conequential elements
  85195. * @param name name of the buffer view
  85196. * @returns bufferView for glTF
  85197. */
  85198. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85199. /**
  85200. * Creates an accessor based on the supplied arguments
  85201. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85202. * @param name The name of the accessor
  85203. * @param type The type of the accessor
  85204. * @param componentType The datatype of components in the attribute
  85205. * @param count The number of attributes referenced by this accessor
  85206. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85207. * @param min Minimum value of each component in this attribute
  85208. * @param max Maximum value of each component in this attribute
  85209. * @returns accessor for glTF
  85210. */
  85211. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85212. /**
  85213. * Calculates the minimum and maximum values of an array of position floats
  85214. * @param positions Positions array of a mesh
  85215. * @param vertexStart Starting vertex offset to calculate min and max values
  85216. * @param vertexCount Number of vertices to check for min and max values
  85217. * @returns min number array and max number array
  85218. */
  85219. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85220. min: number[];
  85221. max: number[];
  85222. };
  85223. /**
  85224. * Converts a new right-handed Vector3
  85225. * @param vector vector3 array
  85226. * @returns right-handed Vector3
  85227. */
  85228. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85229. /**
  85230. * Converts a Vector3 to right-handed
  85231. * @param vector Vector3 to convert to right-handed
  85232. */
  85233. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85234. /**
  85235. * Converts a three element number array to right-handed
  85236. * @param vector number array to convert to right-handed
  85237. */
  85238. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85239. /**
  85240. * Converts a new right-handed Vector3
  85241. * @param vector vector3 array
  85242. * @returns right-handed Vector3
  85243. */
  85244. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85245. /**
  85246. * Converts a Vector3 to right-handed
  85247. * @param vector Vector3 to convert to right-handed
  85248. */
  85249. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85250. /**
  85251. * Converts a three element number array to right-handed
  85252. * @param vector number array to convert to right-handed
  85253. */
  85254. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85255. /**
  85256. * Converts a Vector4 to right-handed
  85257. * @param vector Vector4 to convert to right-handed
  85258. */
  85259. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85260. /**
  85261. * Converts a Vector4 to right-handed
  85262. * @param vector Vector4 to convert to right-handed
  85263. */
  85264. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85265. /**
  85266. * Converts a Quaternion to right-handed
  85267. * @param quaternion Source quaternion to convert to right-handed
  85268. */
  85269. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85270. /**
  85271. * Converts a Quaternion to right-handed
  85272. * @param quaternion Source quaternion to convert to right-handed
  85273. */
  85274. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85275. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85276. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85277. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85278. }
  85279. }
  85280. declare module BABYLON.GLTF2.Exporter {
  85281. /**
  85282. * Converts Babylon Scene into glTF 2.0.
  85283. * @hidden
  85284. */
  85285. export class _Exporter {
  85286. /**
  85287. * Stores the glTF to export
  85288. */
  85289. _glTF: IGLTF;
  85290. /**
  85291. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85292. */
  85293. _bufferViews: IBufferView[];
  85294. /**
  85295. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85296. */
  85297. _accessors: IAccessor[];
  85298. /**
  85299. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85300. */
  85301. _nodes: INode[];
  85302. /**
  85303. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85304. */
  85305. private _scenes;
  85306. /**
  85307. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85308. */
  85309. private _meshes;
  85310. /**
  85311. * Stores all the generated material information, which represents the appearance of each primitive
  85312. */
  85313. _materials: IMaterial[];
  85314. _materialMap: {
  85315. [materialID: number]: number;
  85316. };
  85317. /**
  85318. * Stores all the generated texture information, which is referenced by glTF materials
  85319. */
  85320. _textures: ITexture[];
  85321. /**
  85322. * Stores all the generated image information, which is referenced by glTF textures
  85323. */
  85324. _images: IImage[];
  85325. /**
  85326. * Stores all the texture samplers
  85327. */
  85328. _samplers: ISampler[];
  85329. /**
  85330. * Stores all the generated glTF skins
  85331. */
  85332. _skins: ISkin[];
  85333. /**
  85334. * Stores all the generated animation samplers, which is referenced by glTF animations
  85335. */
  85336. /**
  85337. * Stores the animations for glTF models
  85338. */
  85339. private _animations;
  85340. /**
  85341. * Stores the total amount of bytes stored in the glTF buffer
  85342. */
  85343. private _totalByteLength;
  85344. /**
  85345. * Stores a reference to the Babylon scene containing the source geometry and material information
  85346. */
  85347. _babylonScene: Scene;
  85348. /**
  85349. * Stores a map of the image data, where the key is the file name and the value
  85350. * is the image data
  85351. */
  85352. _imageData: {
  85353. [fileName: string]: {
  85354. data: Uint8Array;
  85355. mimeType: ImageMimeType;
  85356. };
  85357. };
  85358. protected _orderedImageData: Array<{
  85359. data: Uint8Array;
  85360. mimeType: ImageMimeType;
  85361. }>;
  85362. /**
  85363. * Stores a map of the unique id of a node to its index in the node array
  85364. */
  85365. _nodeMap: {
  85366. [key: number]: number;
  85367. };
  85368. /**
  85369. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85370. */
  85371. _convertToRightHandedSystem: boolean;
  85372. /**
  85373. * Specifies if a Babylon node should be converted to right-handed on export
  85374. */
  85375. _convertToRightHandedSystemMap: {
  85376. [nodeId: number]: boolean;
  85377. };
  85378. _includeCoordinateSystemConversionNodes: boolean;
  85379. /**
  85380. * Baked animation sample rate
  85381. */
  85382. private _animationSampleRate;
  85383. private _options;
  85384. private _localEngine;
  85385. _glTFMaterialExporter: _GLTFMaterialExporter;
  85386. private _extensions;
  85387. private static _ExtensionNames;
  85388. private static _ExtensionFactories;
  85389. private _applyExtension;
  85390. private _applyExtensions;
  85391. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85392. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85393. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85394. [key: number]: number;
  85395. }): Promise<Nullable<INode>>;
  85396. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85397. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85398. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85399. private _forEachExtensions;
  85400. private _extensionsOnExporting;
  85401. /**
  85402. * Load glTF serializer extensions
  85403. */
  85404. private _loadExtensions;
  85405. /**
  85406. * Creates a glTF Exporter instance, which can accept optional exporter options
  85407. * @param babylonScene Babylon scene object
  85408. * @param options Options to modify the behavior of the exporter
  85409. */
  85410. constructor(babylonScene: Scene, options?: IExportOptions);
  85411. dispose(): void;
  85412. /**
  85413. * Registers a glTF exporter extension
  85414. * @param name Name of the extension to export
  85415. * @param factory The factory function that creates the exporter extension
  85416. */
  85417. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85418. /**
  85419. * Un-registers an exporter extension
  85420. * @param name The name fo the exporter extension
  85421. * @returns A boolean indicating whether the extension has been un-registered
  85422. */
  85423. static UnregisterExtension(name: string): boolean;
  85424. /**
  85425. * Lazy load a local engine
  85426. */
  85427. _getLocalEngine(): Engine;
  85428. private reorderIndicesBasedOnPrimitiveMode;
  85429. /**
  85430. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85431. * clock-wise during export to glTF
  85432. * @param submesh BabylonJS submesh
  85433. * @param primitiveMode Primitive mode of the mesh
  85434. * @param sideOrientation the winding order of the submesh
  85435. * @param vertexBufferKind The type of vertex attribute
  85436. * @param meshAttributeArray The vertex attribute data
  85437. * @param byteOffset The offset to the binary data
  85438. * @param binaryWriter The binary data for the glTF file
  85439. * @param convertToRightHandedSystem Converts the values to right-handed
  85440. */
  85441. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85442. /**
  85443. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85444. * clock-wise during export to glTF
  85445. * @param submesh BabylonJS submesh
  85446. * @param primitiveMode Primitive mode of the mesh
  85447. * @param sideOrientation the winding order of the submesh
  85448. * @param vertexBufferKind The type of vertex attribute
  85449. * @param meshAttributeArray The vertex attribute data
  85450. * @param byteOffset The offset to the binary data
  85451. * @param binaryWriter The binary data for the glTF file
  85452. * @param convertToRightHandedSystem Converts the values to right-handed
  85453. */
  85454. private reorderTriangleFillMode;
  85455. /**
  85456. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85457. * clock-wise during export to glTF
  85458. * @param submesh BabylonJS submesh
  85459. * @param primitiveMode Primitive mode of the mesh
  85460. * @param sideOrientation the winding order of the submesh
  85461. * @param vertexBufferKind The type of vertex attribute
  85462. * @param meshAttributeArray The vertex attribute data
  85463. * @param byteOffset The offset to the binary data
  85464. * @param binaryWriter The binary data for the glTF file
  85465. * @param convertToRightHandedSystem Converts the values to right-handed
  85466. */
  85467. private reorderTriangleStripDrawMode;
  85468. /**
  85469. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85470. * clock-wise during export to glTF
  85471. * @param submesh BabylonJS submesh
  85472. * @param primitiveMode Primitive mode of the mesh
  85473. * @param sideOrientation the winding order of the submesh
  85474. * @param vertexBufferKind The type of vertex attribute
  85475. * @param meshAttributeArray The vertex attribute data
  85476. * @param byteOffset The offset to the binary data
  85477. * @param binaryWriter The binary data for the glTF file
  85478. * @param convertToRightHandedSystem Converts the values to right-handed
  85479. */
  85480. private reorderTriangleFanMode;
  85481. /**
  85482. * Writes the vertex attribute data to binary
  85483. * @param vertices The vertices to write to the binary writer
  85484. * @param byteOffset The offset into the binary writer to overwrite binary data
  85485. * @param vertexAttributeKind The vertex attribute type
  85486. * @param meshAttributeArray The vertex attribute data
  85487. * @param binaryWriter The writer containing the binary data
  85488. * @param convertToRightHandedSystem Converts the values to right-handed
  85489. */
  85490. private writeVertexAttributeData;
  85491. /**
  85492. * Writes mesh attribute data to a data buffer
  85493. * Returns the bytelength of the data
  85494. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85495. * @param meshAttributeArray Array containing the attribute data
  85496. * @param byteStride Specifies the space between data
  85497. * @param binaryWriter The buffer to write the binary data to
  85498. * @param convertToRightHandedSystem Converts the values to right-handed
  85499. */
  85500. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85501. /**
  85502. * Writes mesh attribute data to a data buffer
  85503. * Returns the bytelength of the data
  85504. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85505. * @param meshAttributeArray Array containing the attribute data
  85506. * @param byteStride Specifies the space between data
  85507. * @param binaryWriter The buffer to write the binary data to
  85508. * @param convertToRightHandedSystem Converts the values to right-handed
  85509. */
  85510. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85511. /**
  85512. * Generates glTF json data
  85513. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85514. * @param glTFPrefix Text to use when prefixing a glTF file
  85515. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85516. * @returns json data as string
  85517. */
  85518. private generateJSON;
  85519. /**
  85520. * Generates data for .gltf and .bin files based on the glTF prefix string
  85521. * @param glTFPrefix Text to use when prefixing a glTF file
  85522. * @param dispose Dispose the exporter
  85523. * @returns GLTFData with glTF file data
  85524. */
  85525. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85526. /**
  85527. * Creates a binary buffer for glTF
  85528. * @returns array buffer for binary data
  85529. */
  85530. private _generateBinaryAsync;
  85531. /**
  85532. * Pads the number to a multiple of 4
  85533. * @param num number to pad
  85534. * @returns padded number
  85535. */
  85536. private _getPadding;
  85537. /**
  85538. * @hidden
  85539. */
  85540. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85541. /**
  85542. * Sets the TRS for each node
  85543. * @param node glTF Node for storing the transformation data
  85544. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85545. * @param convertToRightHandedSystem Converts the values to right-handed
  85546. */
  85547. private setNodeTransformation;
  85548. private getVertexBufferFromMesh;
  85549. /**
  85550. * Creates a bufferview based on the vertices type for the Babylon mesh
  85551. * @param kind Indicates the type of vertices data
  85552. * @param componentType Indicates the numerical type used to store the data
  85553. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85554. * @param binaryWriter The buffer to write the bufferview data to
  85555. * @param convertToRightHandedSystem Converts the values to right-handed
  85556. */
  85557. private createBufferViewKind;
  85558. /**
  85559. * Creates a bufferview based on the vertices type for the Babylon mesh
  85560. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85561. * @param babylonMorphTarget the morph target to be exported
  85562. * @param binaryWriter The buffer to write the bufferview data to
  85563. * @param convertToRightHandedSystem Converts the values to right-handed
  85564. */
  85565. private setMorphTargetAttributes;
  85566. /**
  85567. * The primitive mode of the Babylon mesh
  85568. * @param babylonMesh The BabylonJS mesh
  85569. */
  85570. private getMeshPrimitiveMode;
  85571. /**
  85572. * Sets the primitive mode of the glTF mesh primitive
  85573. * @param meshPrimitive glTF mesh primitive
  85574. * @param primitiveMode The primitive mode
  85575. */
  85576. private setPrimitiveMode;
  85577. /**
  85578. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85579. * @param meshPrimitive glTF mesh primitive
  85580. * @param attributeKind vertex attribute
  85581. * @returns boolean specifying if uv coordinates are present
  85582. */
  85583. private setAttributeKind;
  85584. /**
  85585. * Sets data for the primitive attributes of each submesh
  85586. * @param mesh glTF Mesh object to store the primitive attribute information
  85587. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85588. * @param binaryWriter Buffer to write the attribute data to
  85589. * @param convertToRightHandedSystem Converts the values to right-handed
  85590. */
  85591. private setPrimitiveAttributesAsync;
  85592. /**
  85593. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85594. * @param node The node to check
  85595. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85596. */
  85597. private isBabylonCoordinateSystemConvertingNode;
  85598. /**
  85599. * Creates a glTF scene based on the array of meshes
  85600. * Returns the the total byte offset
  85601. * @param babylonScene Babylon scene to get the mesh data from
  85602. * @param binaryWriter Buffer to write binary data to
  85603. */
  85604. private createSceneAsync;
  85605. /**
  85606. * Creates a mapping of Node unique id to node index and handles animations
  85607. * @param babylonScene Babylon Scene
  85608. * @param nodes Babylon transform nodes
  85609. * @param binaryWriter Buffer to write binary data to
  85610. * @returns Node mapping of unique id to index
  85611. */
  85612. private createNodeMapAndAnimationsAsync;
  85613. /**
  85614. * Creates a glTF node from a Babylon mesh
  85615. * @param babylonMesh Source Babylon mesh
  85616. * @param binaryWriter Buffer for storing geometry data
  85617. * @param convertToRightHandedSystem Converts the values to right-handed
  85618. * @param nodeMap Node mapping of unique id to glTF node index
  85619. * @returns glTF node
  85620. */
  85621. private createNodeAsync;
  85622. /**
  85623. * Creates a glTF skin from a Babylon skeleton
  85624. * @param babylonScene Babylon Scene
  85625. * @param nodes Babylon transform nodes
  85626. * @param binaryWriter Buffer to write binary data to
  85627. * @returns Node mapping of unique id to index
  85628. */
  85629. private createSkinsAsync;
  85630. }
  85631. /**
  85632. * @hidden
  85633. *
  85634. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85635. */
  85636. export class _BinaryWriter {
  85637. /**
  85638. * Array buffer which stores all binary data
  85639. */
  85640. private _arrayBuffer;
  85641. /**
  85642. * View of the array buffer
  85643. */
  85644. private _dataView;
  85645. /**
  85646. * byte offset of data in array buffer
  85647. */
  85648. private _byteOffset;
  85649. /**
  85650. * Initialize binary writer with an initial byte length
  85651. * @param byteLength Initial byte length of the array buffer
  85652. */
  85653. constructor(byteLength: number);
  85654. /**
  85655. * Resize the array buffer to the specified byte length
  85656. * @param byteLength
  85657. */
  85658. private resizeBuffer;
  85659. /**
  85660. * Get an array buffer with the length of the byte offset
  85661. * @returns ArrayBuffer resized to the byte offset
  85662. */
  85663. getArrayBuffer(): ArrayBuffer;
  85664. /**
  85665. * Get the byte offset of the array buffer
  85666. * @returns byte offset
  85667. */
  85668. getByteOffset(): number;
  85669. /**
  85670. * Stores an UInt8 in the array buffer
  85671. * @param entry
  85672. * @param byteOffset If defined, specifies where to set the value as an offset.
  85673. */
  85674. setUInt8(entry: number, byteOffset?: number): void;
  85675. /**
  85676. * Stores an UInt16 in the array buffer
  85677. * @param entry
  85678. * @param byteOffset If defined, specifies where to set the value as an offset.
  85679. */
  85680. setUInt16(entry: number, byteOffset?: number): void;
  85681. /**
  85682. * Gets an UInt32 in the array buffer
  85683. * @param entry
  85684. * @param byteOffset If defined, specifies where to set the value as an offset.
  85685. */
  85686. getUInt32(byteOffset: number): number;
  85687. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85688. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85689. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85690. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85691. /**
  85692. * Stores a Float32 in the array buffer
  85693. * @param entry
  85694. */
  85695. setFloat32(entry: number, byteOffset?: number): void;
  85696. /**
  85697. * Stores an UInt32 in the array buffer
  85698. * @param entry
  85699. * @param byteOffset If defined, specifies where to set the value as an offset.
  85700. */
  85701. setUInt32(entry: number, byteOffset?: number): void;
  85702. }
  85703. }
  85704. declare module BABYLON.GLTF2.Exporter {
  85705. /**
  85706. * @hidden
  85707. * Interface to store animation data.
  85708. */
  85709. export interface _IAnimationData {
  85710. /**
  85711. * Keyframe data.
  85712. */
  85713. inputs: number[];
  85714. /**
  85715. * Value data.
  85716. */
  85717. outputs: number[][];
  85718. /**
  85719. * Animation interpolation data.
  85720. */
  85721. samplerInterpolation: AnimationSamplerInterpolation;
  85722. /**
  85723. * Minimum keyframe value.
  85724. */
  85725. inputsMin: number;
  85726. /**
  85727. * Maximum keyframe value.
  85728. */
  85729. inputsMax: number;
  85730. }
  85731. /**
  85732. * @hidden
  85733. */
  85734. export interface _IAnimationInfo {
  85735. /**
  85736. * The target channel for the animation
  85737. */
  85738. animationChannelTargetPath: AnimationChannelTargetPath;
  85739. /**
  85740. * The glTF accessor type for the data.
  85741. */
  85742. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85743. /**
  85744. * Specifies if quaternions should be used.
  85745. */
  85746. useQuaternion: boolean;
  85747. }
  85748. /**
  85749. * @hidden
  85750. * Utility class for generating glTF animation data from BabylonJS.
  85751. */
  85752. export class _GLTFAnimation {
  85753. /**
  85754. * @ignore
  85755. *
  85756. * Creates glTF channel animation from BabylonJS animation.
  85757. * @param babylonTransformNode - BabylonJS mesh.
  85758. * @param animation - animation.
  85759. * @param animationChannelTargetPath - The target animation channel.
  85760. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85761. * @param useQuaternion - Specifies if quaternions are used.
  85762. * @returns nullable IAnimationData
  85763. */
  85764. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85765. private static _DeduceAnimationInfo;
  85766. /**
  85767. * @ignore
  85768. * Create node animations from the transform node animations
  85769. * @param babylonNode
  85770. * @param runtimeGLTFAnimation
  85771. * @param idleGLTFAnimations
  85772. * @param nodeMap
  85773. * @param nodes
  85774. * @param binaryWriter
  85775. * @param bufferViews
  85776. * @param accessors
  85777. * @param convertToRightHandedSystem
  85778. * @param animationSampleRate
  85779. */
  85780. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85781. [key: number]: number;
  85782. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85783. /**
  85784. * @ignore
  85785. * Create individual morph animations from the mesh's morph target animation tracks
  85786. * @param babylonNode
  85787. * @param runtimeGLTFAnimation
  85788. * @param idleGLTFAnimations
  85789. * @param nodeMap
  85790. * @param nodes
  85791. * @param binaryWriter
  85792. * @param bufferViews
  85793. * @param accessors
  85794. * @param convertToRightHandedSystem
  85795. * @param animationSampleRate
  85796. */
  85797. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85798. [key: number]: number;
  85799. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85800. /**
  85801. * @ignore
  85802. * Create node and morph animations from the animation groups
  85803. * @param babylonScene
  85804. * @param glTFAnimations
  85805. * @param nodeMap
  85806. * @param nodes
  85807. * @param binaryWriter
  85808. * @param bufferViews
  85809. * @param accessors
  85810. * @param convertToRightHandedSystemMap
  85811. * @param animationSampleRate
  85812. */
  85813. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85814. [key: number]: number;
  85815. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85816. [nodeId: number]: boolean;
  85817. }, animationSampleRate: number): void;
  85818. private static AddAnimation;
  85819. /**
  85820. * Create a baked animation
  85821. * @param babylonTransformNode BabylonJS mesh
  85822. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85823. * @param animationChannelTargetPath animation target channel
  85824. * @param minFrame minimum animation frame
  85825. * @param maxFrame maximum animation frame
  85826. * @param fps frames per second of the animation
  85827. * @param inputs input key frames of the animation
  85828. * @param outputs output key frame data of the animation
  85829. * @param convertToRightHandedSystem converts the values to right-handed
  85830. * @param useQuaternion specifies if quaternions should be used
  85831. */
  85832. private static _CreateBakedAnimation;
  85833. private static _ConvertFactorToVector3OrQuaternion;
  85834. private static _SetInterpolatedValue;
  85835. /**
  85836. * Creates linear animation from the animation key frames
  85837. * @param babylonTransformNode BabylonJS mesh
  85838. * @param animation BabylonJS animation
  85839. * @param animationChannelTargetPath The target animation channel
  85840. * @param frameDelta The difference between the last and first frame of the animation
  85841. * @param inputs Array to store the key frame times
  85842. * @param outputs Array to store the key frame data
  85843. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85844. * @param useQuaternion Specifies if quaternions are used in the animation
  85845. */
  85846. private static _CreateLinearOrStepAnimation;
  85847. /**
  85848. * Creates cubic spline animation from the animation key frames
  85849. * @param babylonTransformNode BabylonJS mesh
  85850. * @param animation BabylonJS animation
  85851. * @param animationChannelTargetPath The target animation channel
  85852. * @param frameDelta The difference between the last and first frame of the animation
  85853. * @param inputs Array to store the key frame times
  85854. * @param outputs Array to store the key frame data
  85855. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85856. * @param useQuaternion Specifies if quaternions are used in the animation
  85857. */
  85858. private static _CreateCubicSplineAnimation;
  85859. private static _GetBasePositionRotationOrScale;
  85860. /**
  85861. * Adds a key frame value
  85862. * @param keyFrame
  85863. * @param animation
  85864. * @param outputs
  85865. * @param animationChannelTargetPath
  85866. * @param basePositionRotationOrScale
  85867. * @param convertToRightHandedSystem
  85868. * @param useQuaternion
  85869. */
  85870. private static _AddKeyframeValue;
  85871. /**
  85872. * Determine the interpolation based on the key frames
  85873. * @param keyFrames
  85874. * @param animationChannelTargetPath
  85875. * @param useQuaternion
  85876. */
  85877. private static _DeduceInterpolation;
  85878. /**
  85879. * Adds an input tangent or output tangent to the output data
  85880. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85881. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85882. * @param outputs The animation data by keyframe
  85883. * @param animationChannelTargetPath The target animation channel
  85884. * @param interpolation The interpolation type
  85885. * @param keyFrame The key frame with the animation data
  85886. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85887. * @param useQuaternion Specifies if quaternions are used
  85888. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85889. */
  85890. private static AddSplineTangent;
  85891. /**
  85892. * Get the minimum and maximum key frames' frame values
  85893. * @param keyFrames animation key frames
  85894. * @returns the minimum and maximum key frame value
  85895. */
  85896. private static calculateMinMaxKeyFrames;
  85897. }
  85898. }
  85899. declare module BABYLON.GLTF2.Exporter {
  85900. /** @hidden */
  85901. export var textureTransformPixelShader: {
  85902. name: string;
  85903. shader: string;
  85904. };
  85905. }
  85906. declare module BABYLON.GLTF2.Exporter.Extensions {
  85907. /**
  85908. * @hidden
  85909. */
  85910. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85911. private _recordedTextures;
  85912. /** Name of this extension */
  85913. readonly name: string;
  85914. /** Defines whether this extension is enabled */
  85915. enabled: boolean;
  85916. /** Defines whether this extension is required */
  85917. required: boolean;
  85918. /** Reference to the glTF exporter */
  85919. private _wasUsed;
  85920. constructor(exporter: _Exporter);
  85921. dispose(): void;
  85922. /** @hidden */
  85923. get wasUsed(): boolean;
  85924. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85925. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85926. /**
  85927. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85928. * @param babylonTexture
  85929. * @param offset
  85930. * @param rotation
  85931. * @param scale
  85932. * @param scene
  85933. */
  85934. private _textureTransformTextureAsync;
  85935. }
  85936. }
  85937. declare module BABYLON.GLTF2.Exporter.Extensions {
  85938. /**
  85939. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85940. */
  85941. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85942. /** The name of this extension. */
  85943. readonly name: string;
  85944. /** Defines whether this extension is enabled. */
  85945. enabled: boolean;
  85946. /** Defines whether this extension is required */
  85947. required: boolean;
  85948. /** Reference to the glTF exporter */
  85949. private _exporter;
  85950. private _lights;
  85951. /** @hidden */
  85952. constructor(exporter: _Exporter);
  85953. /** @hidden */
  85954. dispose(): void;
  85955. /** @hidden */
  85956. get wasUsed(): boolean;
  85957. /** @hidden */
  85958. onExporting(): void;
  85959. /**
  85960. * Define this method to modify the default behavior when exporting a node
  85961. * @param context The context when exporting the node
  85962. * @param node glTF node
  85963. * @param babylonNode BabylonJS node
  85964. * @param nodeMap Node mapping of unique id to glTF node index
  85965. * @returns nullable INode promise
  85966. */
  85967. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85968. [key: number]: number;
  85969. }): Promise<Nullable<INode>>;
  85970. }
  85971. }
  85972. declare module BABYLON.GLTF2.Exporter.Extensions {
  85973. /**
  85974. * @hidden
  85975. */
  85976. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85977. /** Name of this extension */
  85978. readonly name: string;
  85979. /** Defines whether this extension is enabled */
  85980. enabled: boolean;
  85981. /** Defines whether this extension is required */
  85982. required: boolean;
  85983. /** Reference to the glTF exporter */
  85984. private _textureInfos;
  85985. private _exportedTextures;
  85986. private _wasUsed;
  85987. constructor(exporter: _Exporter);
  85988. dispose(): void;
  85989. /** @hidden */
  85990. get wasUsed(): boolean;
  85991. private _getTextureIndex;
  85992. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85993. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85994. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85995. }
  85996. }
  85997. declare module BABYLON.GLTF2.Exporter.Extensions {
  85998. /**
  85999. * @hidden
  86000. */
  86001. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  86002. /** Name of this extension */
  86003. readonly name: string;
  86004. /** Defines whether this extension is enabled */
  86005. enabled: boolean;
  86006. /** Defines whether this extension is required */
  86007. required: boolean;
  86008. private _wasUsed;
  86009. constructor(exporter: _Exporter);
  86010. /** @hidden */
  86011. get wasUsed(): boolean;
  86012. dispose(): void;
  86013. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  86014. }
  86015. }
  86016. declare module BABYLON {
  86017. /**
  86018. * Class for generating STL data from a Babylon scene.
  86019. */
  86020. export class STLExport {
  86021. /**
  86022. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  86023. * @param meshes list defines the mesh to serialize
  86024. * @param download triggers the automatic download of the file.
  86025. * @param fileName changes the downloads fileName.
  86026. * @param binary changes the STL to a binary type.
  86027. * @param isLittleEndian toggle for binary type exporter.
  86028. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  86029. * @returns the STL as UTF8 string
  86030. */
  86031. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  86032. }
  86033. }
  86034. declare module "babylonjs-gltf2interface" {
  86035. export = BABYLON.GLTF2;
  86036. }
  86037. /**
  86038. * Module for glTF 2.0 Interface
  86039. */
  86040. declare module BABYLON.GLTF2 {
  86041. /**
  86042. * The datatype of the components in the attribute
  86043. */
  86044. const enum AccessorComponentType {
  86045. /**
  86046. * Byte
  86047. */
  86048. BYTE = 5120,
  86049. /**
  86050. * Unsigned Byte
  86051. */
  86052. UNSIGNED_BYTE = 5121,
  86053. /**
  86054. * Short
  86055. */
  86056. SHORT = 5122,
  86057. /**
  86058. * Unsigned Short
  86059. */
  86060. UNSIGNED_SHORT = 5123,
  86061. /**
  86062. * Unsigned Int
  86063. */
  86064. UNSIGNED_INT = 5125,
  86065. /**
  86066. * Float
  86067. */
  86068. FLOAT = 5126,
  86069. }
  86070. /**
  86071. * Specifies if the attirbute is a scalar, vector, or matrix
  86072. */
  86073. const enum AccessorType {
  86074. /**
  86075. * Scalar
  86076. */
  86077. SCALAR = "SCALAR",
  86078. /**
  86079. * Vector2
  86080. */
  86081. VEC2 = "VEC2",
  86082. /**
  86083. * Vector3
  86084. */
  86085. VEC3 = "VEC3",
  86086. /**
  86087. * Vector4
  86088. */
  86089. VEC4 = "VEC4",
  86090. /**
  86091. * Matrix2x2
  86092. */
  86093. MAT2 = "MAT2",
  86094. /**
  86095. * Matrix3x3
  86096. */
  86097. MAT3 = "MAT3",
  86098. /**
  86099. * Matrix4x4
  86100. */
  86101. MAT4 = "MAT4",
  86102. }
  86103. /**
  86104. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86105. */
  86106. const enum AnimationChannelTargetPath {
  86107. /**
  86108. * Translation
  86109. */
  86110. TRANSLATION = "translation",
  86111. /**
  86112. * Rotation
  86113. */
  86114. ROTATION = "rotation",
  86115. /**
  86116. * Scale
  86117. */
  86118. SCALE = "scale",
  86119. /**
  86120. * Weights
  86121. */
  86122. WEIGHTS = "weights",
  86123. }
  86124. /**
  86125. * Interpolation algorithm
  86126. */
  86127. const enum AnimationSamplerInterpolation {
  86128. /**
  86129. * The animated values are linearly interpolated between keyframes
  86130. */
  86131. LINEAR = "LINEAR",
  86132. /**
  86133. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  86134. */
  86135. STEP = "STEP",
  86136. /**
  86137. * The animation's interpolation is computed using a cubic spline with specified tangents
  86138. */
  86139. CUBICSPLINE = "CUBICSPLINE",
  86140. }
  86141. /**
  86142. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86143. */
  86144. const enum CameraType {
  86145. /**
  86146. * A perspective camera containing properties to create a perspective projection matrix
  86147. */
  86148. PERSPECTIVE = "perspective",
  86149. /**
  86150. * An orthographic camera containing properties to create an orthographic projection matrix
  86151. */
  86152. ORTHOGRAPHIC = "orthographic",
  86153. }
  86154. /**
  86155. * The mime-type of the image
  86156. */
  86157. const enum ImageMimeType {
  86158. /**
  86159. * JPEG Mime-type
  86160. */
  86161. JPEG = "image/jpeg",
  86162. /**
  86163. * PNG Mime-type
  86164. */
  86165. PNG = "image/png",
  86166. }
  86167. /**
  86168. * The alpha rendering mode of the material
  86169. */
  86170. const enum MaterialAlphaMode {
  86171. /**
  86172. * The alpha value is ignored and the rendered output is fully opaque
  86173. */
  86174. OPAQUE = "OPAQUE",
  86175. /**
  86176. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86177. */
  86178. MASK = "MASK",
  86179. /**
  86180. * 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)
  86181. */
  86182. BLEND = "BLEND",
  86183. }
  86184. /**
  86185. * The type of the primitives to render
  86186. */
  86187. const enum MeshPrimitiveMode {
  86188. /**
  86189. * Points
  86190. */
  86191. POINTS = 0,
  86192. /**
  86193. * Lines
  86194. */
  86195. LINES = 1,
  86196. /**
  86197. * Line Loop
  86198. */
  86199. LINE_LOOP = 2,
  86200. /**
  86201. * Line Strip
  86202. */
  86203. LINE_STRIP = 3,
  86204. /**
  86205. * Triangles
  86206. */
  86207. TRIANGLES = 4,
  86208. /**
  86209. * Triangle Strip
  86210. */
  86211. TRIANGLE_STRIP = 5,
  86212. /**
  86213. * Triangle Fan
  86214. */
  86215. TRIANGLE_FAN = 6,
  86216. }
  86217. /**
  86218. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86219. */
  86220. const enum TextureMagFilter {
  86221. /**
  86222. * Nearest
  86223. */
  86224. NEAREST = 9728,
  86225. /**
  86226. * Linear
  86227. */
  86228. LINEAR = 9729,
  86229. }
  86230. /**
  86231. * Minification filter. All valid values correspond to WebGL enums
  86232. */
  86233. const enum TextureMinFilter {
  86234. /**
  86235. * Nearest
  86236. */
  86237. NEAREST = 9728,
  86238. /**
  86239. * Linear
  86240. */
  86241. LINEAR = 9729,
  86242. /**
  86243. * Nearest Mip-Map Nearest
  86244. */
  86245. NEAREST_MIPMAP_NEAREST = 9984,
  86246. /**
  86247. * Linear Mipmap Nearest
  86248. */
  86249. LINEAR_MIPMAP_NEAREST = 9985,
  86250. /**
  86251. * Nearest Mipmap Linear
  86252. */
  86253. NEAREST_MIPMAP_LINEAR = 9986,
  86254. /**
  86255. * Linear Mipmap Linear
  86256. */
  86257. LINEAR_MIPMAP_LINEAR = 9987,
  86258. }
  86259. /**
  86260. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86261. */
  86262. const enum TextureWrapMode {
  86263. /**
  86264. * Clamp to Edge
  86265. */
  86266. CLAMP_TO_EDGE = 33071,
  86267. /**
  86268. * Mirrored Repeat
  86269. */
  86270. MIRRORED_REPEAT = 33648,
  86271. /**
  86272. * Repeat
  86273. */
  86274. REPEAT = 10497,
  86275. }
  86276. /**
  86277. * glTF Property
  86278. */
  86279. interface IProperty {
  86280. /**
  86281. * Dictionary object with extension-specific objects
  86282. */
  86283. extensions?: {
  86284. [key: string]: any;
  86285. };
  86286. /**
  86287. * Application-Specific data
  86288. */
  86289. extras?: any;
  86290. }
  86291. /**
  86292. * glTF Child of Root Property
  86293. */
  86294. interface IChildRootProperty extends IProperty {
  86295. /**
  86296. * The user-defined name of this object
  86297. */
  86298. name?: string;
  86299. }
  86300. /**
  86301. * Indices of those attributes that deviate from their initialization value
  86302. */
  86303. interface IAccessorSparseIndices extends IProperty {
  86304. /**
  86305. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86306. */
  86307. bufferView: number;
  86308. /**
  86309. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86310. */
  86311. byteOffset?: number;
  86312. /**
  86313. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86314. */
  86315. componentType: AccessorComponentType;
  86316. }
  86317. /**
  86318. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86319. */
  86320. interface IAccessorSparseValues extends IProperty {
  86321. /**
  86322. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86323. */
  86324. bufferView: number;
  86325. /**
  86326. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86327. */
  86328. byteOffset?: number;
  86329. }
  86330. /**
  86331. * Sparse storage of attributes that deviate from their initialization value
  86332. */
  86333. interface IAccessorSparse extends IProperty {
  86334. /**
  86335. * The number of attributes encoded in this sparse accessor
  86336. */
  86337. count: number;
  86338. /**
  86339. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86340. */
  86341. indices: IAccessorSparseIndices;
  86342. /**
  86343. * 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
  86344. */
  86345. values: IAccessorSparseValues;
  86346. }
  86347. /**
  86348. * 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
  86349. */
  86350. interface IAccessor extends IChildRootProperty {
  86351. /**
  86352. * The index of the bufferview
  86353. */
  86354. bufferView?: number;
  86355. /**
  86356. * The offset relative to the start of the bufferView in bytes
  86357. */
  86358. byteOffset?: number;
  86359. /**
  86360. * The datatype of components in the attribute
  86361. */
  86362. componentType: AccessorComponentType;
  86363. /**
  86364. * Specifies whether integer data values should be normalized
  86365. */
  86366. normalized?: boolean;
  86367. /**
  86368. * The number of attributes referenced by this accessor
  86369. */
  86370. count: number;
  86371. /**
  86372. * Specifies if the attribute is a scalar, vector, or matrix
  86373. */
  86374. type: AccessorType;
  86375. /**
  86376. * Maximum value of each component in this attribute
  86377. */
  86378. max?: number[];
  86379. /**
  86380. * Minimum value of each component in this attribute
  86381. */
  86382. min?: number[];
  86383. /**
  86384. * Sparse storage of attributes that deviate from their initialization value
  86385. */
  86386. sparse?: IAccessorSparse;
  86387. }
  86388. /**
  86389. * Targets an animation's sampler at a node's property
  86390. */
  86391. interface IAnimationChannel extends IProperty {
  86392. /**
  86393. * The index of a sampler in this animation used to compute the value for the target
  86394. */
  86395. sampler: number;
  86396. /**
  86397. * The index of the node and TRS property to target
  86398. */
  86399. target: IAnimationChannelTarget;
  86400. }
  86401. /**
  86402. * The index of the node and TRS property that an animation channel targets
  86403. */
  86404. interface IAnimationChannelTarget extends IProperty {
  86405. /**
  86406. * The index of the node to target
  86407. */
  86408. node: number;
  86409. /**
  86410. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86411. */
  86412. path: AnimationChannelTargetPath;
  86413. }
  86414. /**
  86415. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86416. */
  86417. interface IAnimationSampler extends IProperty {
  86418. /**
  86419. * The index of an accessor containing keyframe input values, e.g., time
  86420. */
  86421. input: number;
  86422. /**
  86423. * Interpolation algorithm
  86424. */
  86425. interpolation?: AnimationSamplerInterpolation;
  86426. /**
  86427. * The index of an accessor, containing keyframe output values
  86428. */
  86429. output: number;
  86430. }
  86431. /**
  86432. * A keyframe animation
  86433. */
  86434. interface IAnimation extends IChildRootProperty {
  86435. /**
  86436. * An array of channels, each of which targets an animation's sampler at a node's property
  86437. */
  86438. channels: IAnimationChannel[];
  86439. /**
  86440. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86441. */
  86442. samplers: IAnimationSampler[];
  86443. }
  86444. /**
  86445. * Metadata about the glTF asset
  86446. */
  86447. interface IAsset extends IChildRootProperty {
  86448. /**
  86449. * A copyright message suitable for display to credit the content creator
  86450. */
  86451. copyright?: string;
  86452. /**
  86453. * Tool that generated this glTF model. Useful for debugging
  86454. */
  86455. generator?: string;
  86456. /**
  86457. * The glTF version that this asset targets
  86458. */
  86459. version: string;
  86460. /**
  86461. * The minimum glTF version that this asset targets
  86462. */
  86463. minVersion?: string;
  86464. }
  86465. /**
  86466. * A buffer points to binary geometry, animation, or skins
  86467. */
  86468. interface IBuffer extends IChildRootProperty {
  86469. /**
  86470. * 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
  86471. */
  86472. uri?: string;
  86473. /**
  86474. * The length of the buffer in bytes
  86475. */
  86476. byteLength: number;
  86477. }
  86478. /**
  86479. * A view into a buffer generally representing a subset of the buffer
  86480. */
  86481. interface IBufferView extends IChildRootProperty {
  86482. /**
  86483. * The index of the buffer
  86484. */
  86485. buffer: number;
  86486. /**
  86487. * The offset into the buffer in bytes
  86488. */
  86489. byteOffset?: number;
  86490. /**
  86491. * The lenth of the bufferView in bytes
  86492. */
  86493. byteLength: number;
  86494. /**
  86495. * The stride, in bytes
  86496. */
  86497. byteStride?: number;
  86498. }
  86499. /**
  86500. * An orthographic camera containing properties to create an orthographic projection matrix
  86501. */
  86502. interface ICameraOrthographic extends IProperty {
  86503. /**
  86504. * The floating-point horizontal magnification of the view. Must not be zero
  86505. */
  86506. xmag: number;
  86507. /**
  86508. * The floating-point vertical magnification of the view. Must not be zero
  86509. */
  86510. ymag: number;
  86511. /**
  86512. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86513. */
  86514. zfar: number;
  86515. /**
  86516. * The floating-point distance to the near clipping plane
  86517. */
  86518. znear: number;
  86519. }
  86520. /**
  86521. * A perspective camera containing properties to create a perspective projection matrix
  86522. */
  86523. interface ICameraPerspective extends IProperty {
  86524. /**
  86525. * The floating-point aspect ratio of the field of view
  86526. */
  86527. aspectRatio?: number;
  86528. /**
  86529. * The floating-point vertical field of view in radians
  86530. */
  86531. yfov: number;
  86532. /**
  86533. * The floating-point distance to the far clipping plane
  86534. */
  86535. zfar?: number;
  86536. /**
  86537. * The floating-point distance to the near clipping plane
  86538. */
  86539. znear: number;
  86540. }
  86541. /**
  86542. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86543. */
  86544. interface ICamera extends IChildRootProperty {
  86545. /**
  86546. * An orthographic camera containing properties to create an orthographic projection matrix
  86547. */
  86548. orthographic?: ICameraOrthographic;
  86549. /**
  86550. * A perspective camera containing properties to create a perspective projection matrix
  86551. */
  86552. perspective?: ICameraPerspective;
  86553. /**
  86554. * Specifies if the camera uses a perspective or orthographic projection
  86555. */
  86556. type: CameraType;
  86557. }
  86558. /**
  86559. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86560. */
  86561. interface IImage extends IChildRootProperty {
  86562. /**
  86563. * 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
  86564. */
  86565. uri?: string;
  86566. /**
  86567. * The image's MIME type
  86568. */
  86569. mimeType?: ImageMimeType;
  86570. /**
  86571. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86572. */
  86573. bufferView?: number;
  86574. }
  86575. /**
  86576. * Material Normal Texture Info
  86577. */
  86578. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86579. /**
  86580. * The scalar multiplier applied to each normal vector of the normal texture
  86581. */
  86582. scale?: number;
  86583. }
  86584. /**
  86585. * Material Occlusion Texture Info
  86586. */
  86587. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86588. /**
  86589. * A scalar multiplier controlling the amount of occlusion applied
  86590. */
  86591. strength?: number;
  86592. }
  86593. /**
  86594. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86595. */
  86596. interface IMaterialPbrMetallicRoughness {
  86597. /**
  86598. * The material's base color factor
  86599. */
  86600. baseColorFactor?: number[];
  86601. /**
  86602. * The base color texture
  86603. */
  86604. baseColorTexture?: ITextureInfo;
  86605. /**
  86606. * The metalness of the material
  86607. */
  86608. metallicFactor?: number;
  86609. /**
  86610. * The roughness of the material
  86611. */
  86612. roughnessFactor?: number;
  86613. /**
  86614. * The metallic-roughness texture
  86615. */
  86616. metallicRoughnessTexture?: ITextureInfo;
  86617. }
  86618. /**
  86619. * The material appearance of a primitive
  86620. */
  86621. interface IMaterial extends IChildRootProperty {
  86622. /**
  86623. * 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
  86624. */
  86625. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86626. /**
  86627. * The normal map texture
  86628. */
  86629. normalTexture?: IMaterialNormalTextureInfo;
  86630. /**
  86631. * The occlusion map texture
  86632. */
  86633. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86634. /**
  86635. * The emissive map texture
  86636. */
  86637. emissiveTexture?: ITextureInfo;
  86638. /**
  86639. * 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
  86640. */
  86641. emissiveFactor?: number[];
  86642. /**
  86643. * The alpha rendering mode of the material
  86644. */
  86645. alphaMode?: MaterialAlphaMode;
  86646. /**
  86647. * The alpha cutoff value of the material
  86648. */
  86649. alphaCutoff?: number;
  86650. /**
  86651. * Specifies whether the material is double sided
  86652. */
  86653. doubleSided?: boolean;
  86654. }
  86655. /**
  86656. * Geometry to be rendered with the given material
  86657. */
  86658. interface IMeshPrimitive extends IProperty {
  86659. /**
  86660. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86661. */
  86662. attributes: {
  86663. [name: string]: number;
  86664. };
  86665. /**
  86666. * The index of the accessor that contains the indices
  86667. */
  86668. indices?: number;
  86669. /**
  86670. * The index of the material to apply to this primitive when rendering
  86671. */
  86672. material?: number;
  86673. /**
  86674. * The type of primitives to render. All valid values correspond to WebGL enums
  86675. */
  86676. mode?: MeshPrimitiveMode;
  86677. /**
  86678. * 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
  86679. */
  86680. targets?: {
  86681. [name: string]: number;
  86682. }[];
  86683. }
  86684. /**
  86685. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86686. */
  86687. interface IMesh extends IChildRootProperty {
  86688. /**
  86689. * An array of primitives, each defining geometry to be rendered with a material
  86690. */
  86691. primitives: IMeshPrimitive[];
  86692. /**
  86693. * Array of weights to be applied to the Morph Targets
  86694. */
  86695. weights?: number[];
  86696. }
  86697. /**
  86698. * A node in the node hierarchy
  86699. */
  86700. interface INode extends IChildRootProperty {
  86701. /**
  86702. * The index of the camera referenced by this node
  86703. */
  86704. camera?: number;
  86705. /**
  86706. * The indices of this node's children
  86707. */
  86708. children?: number[];
  86709. /**
  86710. * The index of the skin referenced by this node
  86711. */
  86712. skin?: number;
  86713. /**
  86714. * A floating-point 4x4 transformation matrix stored in column-major order
  86715. */
  86716. matrix?: number[];
  86717. /**
  86718. * The index of the mesh in this node
  86719. */
  86720. mesh?: number;
  86721. /**
  86722. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86723. */
  86724. rotation?: number[];
  86725. /**
  86726. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86727. */
  86728. scale?: number[];
  86729. /**
  86730. * The node's translation along the x, y, and z axes
  86731. */
  86732. translation?: number[];
  86733. /**
  86734. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86735. */
  86736. weights?: number[];
  86737. }
  86738. /**
  86739. * Texture sampler properties for filtering and wrapping modes
  86740. */
  86741. interface ISampler extends IChildRootProperty {
  86742. /**
  86743. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86744. */
  86745. magFilter?: TextureMagFilter;
  86746. /**
  86747. * Minification filter. All valid values correspond to WebGL enums
  86748. */
  86749. minFilter?: TextureMinFilter;
  86750. /**
  86751. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86752. */
  86753. wrapS?: TextureWrapMode;
  86754. /**
  86755. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86756. */
  86757. wrapT?: TextureWrapMode;
  86758. }
  86759. /**
  86760. * The root nodes of a scene
  86761. */
  86762. interface IScene extends IChildRootProperty {
  86763. /**
  86764. * The indices of each root node
  86765. */
  86766. nodes: number[];
  86767. }
  86768. /**
  86769. * Joints and matrices defining a skin
  86770. */
  86771. interface ISkin extends IChildRootProperty {
  86772. /**
  86773. * 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
  86774. */
  86775. inverseBindMatrices?: number;
  86776. /**
  86777. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86778. */
  86779. skeleton?: number;
  86780. /**
  86781. * 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)
  86782. */
  86783. joints: number[];
  86784. }
  86785. /**
  86786. * A texture and its sampler
  86787. */
  86788. interface ITexture extends IChildRootProperty {
  86789. /**
  86790. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86791. */
  86792. sampler?: number;
  86793. /**
  86794. * The index of the image used by this texture
  86795. */
  86796. source: number;
  86797. }
  86798. /**
  86799. * Reference to a texture
  86800. */
  86801. interface ITextureInfo extends IProperty {
  86802. /**
  86803. * The index of the texture
  86804. */
  86805. index: number;
  86806. /**
  86807. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86808. */
  86809. texCoord?: number;
  86810. }
  86811. /**
  86812. * The root object for a glTF asset
  86813. */
  86814. interface IGLTF extends IProperty {
  86815. /**
  86816. * An array of accessors. An accessor is a typed view into a bufferView
  86817. */
  86818. accessors?: IAccessor[];
  86819. /**
  86820. * An array of keyframe animations
  86821. */
  86822. animations?: IAnimation[];
  86823. /**
  86824. * Metadata about the glTF asset
  86825. */
  86826. asset: IAsset;
  86827. /**
  86828. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86829. */
  86830. buffers?: IBuffer[];
  86831. /**
  86832. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86833. */
  86834. bufferViews?: IBufferView[];
  86835. /**
  86836. * An array of cameras
  86837. */
  86838. cameras?: ICamera[];
  86839. /**
  86840. * Names of glTF extensions used somewhere in this asset
  86841. */
  86842. extensionsUsed?: string[];
  86843. /**
  86844. * Names of glTF extensions required to properly load this asset
  86845. */
  86846. extensionsRequired?: string[];
  86847. /**
  86848. * An array of images. An image defines data used to create a texture
  86849. */
  86850. images?: IImage[];
  86851. /**
  86852. * An array of materials. A material defines the appearance of a primitive
  86853. */
  86854. materials?: IMaterial[];
  86855. /**
  86856. * An array of meshes. A mesh is a set of primitives to be rendered
  86857. */
  86858. meshes?: IMesh[];
  86859. /**
  86860. * An array of nodes
  86861. */
  86862. nodes?: INode[];
  86863. /**
  86864. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86865. */
  86866. samplers?: ISampler[];
  86867. /**
  86868. * The index of the default scene
  86869. */
  86870. scene?: number;
  86871. /**
  86872. * An array of scenes
  86873. */
  86874. scenes?: IScene[];
  86875. /**
  86876. * An array of skins. A skin is defined by joints and matrices
  86877. */
  86878. skins?: ISkin[];
  86879. /**
  86880. * An array of textures
  86881. */
  86882. textures?: ITexture[];
  86883. }
  86884. /**
  86885. * The glTF validation results
  86886. * @ignore
  86887. */
  86888. interface IGLTFValidationResults {
  86889. info: {
  86890. generator: string;
  86891. hasAnimations: boolean;
  86892. hasDefaultScene: boolean;
  86893. hasMaterials: boolean;
  86894. hasMorphTargets: boolean;
  86895. hasSkins: boolean;
  86896. hasTextures: boolean;
  86897. maxAttributesUsed: number;
  86898. primitivesCount: number
  86899. };
  86900. issues: {
  86901. messages: Array<string>;
  86902. numErrors: number;
  86903. numHints: number;
  86904. numInfos: number;
  86905. numWarnings: number;
  86906. truncated: boolean
  86907. };
  86908. mimeType: string;
  86909. uri: string;
  86910. validatedAt: string;
  86911. validatorVersion: string;
  86912. }
  86913. /**
  86914. * The glTF validation options
  86915. */
  86916. interface IGLTFValidationOptions {
  86917. /** Uri to use */
  86918. uri?: string;
  86919. /** Function used to load external resources */
  86920. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86921. /** Boolean indicating that we need to validate accessor data */
  86922. validateAccessorData?: boolean;
  86923. /** max number of issues allowed */
  86924. maxIssues?: number;
  86925. /** Ignored issues */
  86926. ignoredIssues?: Array<string>;
  86927. /** Value to override severy settings */
  86928. severityOverrides?: Object;
  86929. }
  86930. /**
  86931. * The glTF validator object
  86932. * @ignore
  86933. */
  86934. interface IGLTFValidator {
  86935. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86936. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86937. }
  86938. /**
  86939. * Interfaces from the EXT_lights_image_based extension
  86940. */
  86941. /** @hidden */
  86942. interface IEXTLightsImageBased_LightReferenceImageBased {
  86943. light: number;
  86944. }
  86945. /** @hidden */
  86946. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86947. intensity: number;
  86948. rotation: number[];
  86949. specularImageSize: number;
  86950. specularImages: number[][];
  86951. irradianceCoefficients: number[][];
  86952. }
  86953. /** @hidden */
  86954. interface IEXTLightsImageBased {
  86955. lights: IEXTLightsImageBased_LightImageBased[];
  86956. }
  86957. /**
  86958. * Interfaces from the EXT_mesh_gpu_instancing extension
  86959. * !!! Experimental Extension Subject to Changes !!!
  86960. */
  86961. /** @hidden */
  86962. interface IEXTMeshGpuInstancing {
  86963. mesh?: number;
  86964. attributes: { [name: string]: number };
  86965. }
  86966. /**
  86967. * Interfaces from the KHR_draco_mesh_compression extension
  86968. */
  86969. /** @hidden */
  86970. interface IKHRDracoMeshCompression {
  86971. bufferView: number;
  86972. attributes: { [name: string]: number };
  86973. }
  86974. /**
  86975. * Interfaces from the KHR_lights_punctual extension
  86976. */
  86977. /** @hidden */
  86978. const enum IKHRLightsPunctual_LightType {
  86979. DIRECTIONAL = "directional",
  86980. POINT = "point",
  86981. SPOT = "spot"
  86982. }
  86983. /** @hidden */
  86984. interface IKHRLightsPunctual_LightReference {
  86985. light: number;
  86986. }
  86987. /** @hidden */
  86988. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86989. type: IKHRLightsPunctual_LightType;
  86990. color?: number[];
  86991. intensity?: number;
  86992. range?: number;
  86993. spot?: {
  86994. innerConeAngle?: number;
  86995. outerConeAngle?: number;
  86996. };
  86997. }
  86998. /** @hidden */
  86999. interface IKHRLightsPunctual {
  87000. lights: IKHRLightsPunctual_Light[];
  87001. }
  87002. /**
  87003. * Interfaces from the KHR_materials_clearcoat extension
  87004. * !!! Experimental Extension Subject to Changes !!!
  87005. */
  87006. /** @hidden */
  87007. interface IKHRMaterialsClearcoat {
  87008. clearcoatFactor: number;
  87009. clearcoatTexture: ITextureInfo;
  87010. clearcoatRoughnessFactor: number;
  87011. clearcoatRoughnessTexture: ITextureInfo;
  87012. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  87013. }
  87014. /**
  87015. * Interfaces from the KHR_materials_ior extension
  87016. * !!! Experimental Extension Subject to Changes !!!
  87017. */
  87018. /** @hidden */
  87019. interface IKHRMaterialsIor {
  87020. ior: number;
  87021. }
  87022. /**
  87023. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  87024. */
  87025. /** @hidden */
  87026. interface IKHRMaterialsPbrSpecularGlossiness {
  87027. diffuseFactor: number[];
  87028. diffuseTexture: ITextureInfo;
  87029. specularFactor: number[];
  87030. glossinessFactor: number;
  87031. specularGlossinessTexture: ITextureInfo;
  87032. }
  87033. /**
  87034. * Interfaces from the KHR_materials_sheen extension
  87035. * !!! Experimental Extension Subject to Changes !!!
  87036. */
  87037. /** @hidden */
  87038. interface IKHRMaterialsSheen {
  87039. sheenColorFactor?: number[];
  87040. sheenColorTexture?: ITextureInfo;
  87041. sheenRoughnessFactor?: number;
  87042. sheenRoughnessTexture?: ITextureInfo;
  87043. }
  87044. /**
  87045. * Interfaces from the KHR_materials_specular extension
  87046. * !!! Experimental Extension Subject to Changes !!!
  87047. */
  87048. /** @hidden */
  87049. interface IKHRMaterialsSpecular {
  87050. specularFactor: number;
  87051. specularColorFactor: number[];
  87052. specularTexture: ITextureInfo;
  87053. }
  87054. /**
  87055. * Interfaces from the KHR_materials_transmission extension
  87056. * !!! Experimental Extension Subject to Changes !!!
  87057. */
  87058. /** @hidden */
  87059. interface IKHRMaterialsTransmission {
  87060. transmissionFactor?: number;
  87061. transmissionTexture?: ITextureInfo;
  87062. }
  87063. /**
  87064. * Interfaces from the KHR_materials_translucency extension
  87065. * !!! Experimental Extension Subject to Changes !!!
  87066. */
  87067. /** @hidden */
  87068. interface IKHRMaterialsTranslucency {
  87069. translucencyFactor?: number;
  87070. translucencyTexture?: ITextureInfo;
  87071. }
  87072. /**
  87073. * Interfaces from the KHR_materials_variants extension
  87074. * !!! Experimental Extension Subject to Changes !!!
  87075. */
  87076. /** @hidden */
  87077. interface IKHRMaterialVariants_Mapping extends IProperty {
  87078. mappings: Array<{
  87079. variants: number[];
  87080. material: number;
  87081. }>;
  87082. }
  87083. /** @hidden */
  87084. interface IKHRMaterialVariants_Variant extends IProperty {
  87085. name: string;
  87086. }
  87087. /** @hidden */
  87088. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  87089. variants: Array<IKHRMaterialVariants_Variant>;
  87090. }
  87091. /**
  87092. * Interfaces from the KHR_texture_basisu extension
  87093. * !!! Experimental Extension Subject to Changes !!!
  87094. */
  87095. /** @hidden */
  87096. interface IKHRTextureBasisU {
  87097. source: number;
  87098. }
  87099. /**
  87100. * Interfaces from the EXT_texture_webp extension
  87101. */
  87102. /** @hidden */
  87103. interface IEXTTextureWebP {
  87104. source: number;
  87105. }
  87106. /**
  87107. * Interfaces from the KHR_texture_transform extension
  87108. */
  87109. /** @hidden */
  87110. interface IKHRTextureTransform {
  87111. offset?: number[];
  87112. rotation?: number;
  87113. scale?: number[];
  87114. texCoord?: number;
  87115. }
  87116. /**
  87117. * Interfaces from the KHR_xmp extension
  87118. * !!! Experimental Extension Subject to Changes !!!
  87119. */
  87120. /** @hidden */
  87121. interface IKHRXmp_Data {
  87122. [key: string]: unknown;
  87123. }
  87124. /** @hidden */
  87125. interface IKHRXmp_Gltf {
  87126. packets: IKHRXmp_Data[];
  87127. }
  87128. /** @hidden */
  87129. interface IKHRXmp_Node {
  87130. packet: number;
  87131. }
  87132. /**
  87133. * Interfaces from the MSFT_audio_emitter extension
  87134. */
  87135. /** @hidden */
  87136. interface IMSFTAudioEmitter_ClipReference {
  87137. clip: number;
  87138. weight?: number;
  87139. }
  87140. /** @hidden */
  87141. interface IMSFTAudioEmitter_EmittersReference {
  87142. emitters: number[];
  87143. }
  87144. /** @hidden */
  87145. const enum IMSFTAudioEmitter_DistanceModel {
  87146. linear = "linear",
  87147. inverse = "inverse",
  87148. exponential = "exponential",
  87149. }
  87150. /** @hidden */
  87151. interface IMSFTAudioEmitter_Emitter {
  87152. name?: string;
  87153. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  87154. refDistance?: number;
  87155. maxDistance?: number;
  87156. rolloffFactor?: number;
  87157. innerAngle?: number;
  87158. outerAngle?: number;
  87159. loop?: boolean;
  87160. volume?: number;
  87161. clips: IMSFTAudioEmitter_ClipReference[];
  87162. }
  87163. /** @hidden */
  87164. const enum IMSFTAudioEmitter_AudioMimeType {
  87165. WAV = "audio/wav",
  87166. }
  87167. /** @hidden */
  87168. interface IMSFTAudioEmitter_Clip extends IProperty {
  87169. uri?: string;
  87170. bufferView?: number;
  87171. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87172. }
  87173. /** @hidden */
  87174. const enum IMSFTAudioEmitter_AnimationEventAction {
  87175. play = "play",
  87176. pause = "pause",
  87177. stop = "stop",
  87178. }
  87179. /** @hidden */
  87180. interface IMSFTAudioEmitter_AnimationEvent {
  87181. action: IMSFTAudioEmitter_AnimationEventAction;
  87182. emitter: number;
  87183. time: number;
  87184. startOffset?: number;
  87185. }
  87186. /**
  87187. * Interfaces from the MSFT_lod extension
  87188. */
  87189. /** @hidden */
  87190. interface IMSFTLOD {
  87191. ids: number[];
  87192. }
  87193. }
  87194. declare module BABYLON {
  87195. /** @hidden */
  87196. export var cellPixelShader: {
  87197. name: string;
  87198. shader: string;
  87199. };
  87200. }
  87201. declare module BABYLON {
  87202. /** @hidden */
  87203. export var cellVertexShader: {
  87204. name: string;
  87205. shader: string;
  87206. };
  87207. }
  87208. declare module BABYLON {
  87209. export class CellMaterial extends BABYLON.PushMaterial {
  87210. private _diffuseTexture;
  87211. diffuseTexture: BABYLON.BaseTexture;
  87212. diffuseColor: BABYLON.Color3;
  87213. _computeHighLevel: boolean;
  87214. computeHighLevel: boolean;
  87215. private _disableLighting;
  87216. disableLighting: boolean;
  87217. private _maxSimultaneousLights;
  87218. maxSimultaneousLights: number;
  87219. constructor(name: string, scene: BABYLON.Scene);
  87220. needAlphaBlending(): boolean;
  87221. needAlphaTesting(): boolean;
  87222. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87223. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87224. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87225. getAnimatables(): BABYLON.IAnimatable[];
  87226. getActiveTextures(): BABYLON.BaseTexture[];
  87227. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87228. dispose(forceDisposeEffect?: boolean): void;
  87229. getClassName(): string;
  87230. clone(name: string): CellMaterial;
  87231. serialize(): any;
  87232. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87233. }
  87234. }
  87235. declare module BABYLON {
  87236. export class CustomShaderStructure {
  87237. FragmentStore: string;
  87238. VertexStore: string;
  87239. constructor();
  87240. }
  87241. export class ShaderSpecialParts {
  87242. constructor();
  87243. Fragment_Begin: string;
  87244. Fragment_Definitions: string;
  87245. Fragment_MainBegin: string;
  87246. Fragment_Custom_Diffuse: string;
  87247. Fragment_Before_Lights: string;
  87248. Fragment_Before_Fog: string;
  87249. Fragment_Custom_Alpha: string;
  87250. Fragment_Before_FragColor: string;
  87251. Vertex_Begin: string;
  87252. Vertex_Definitions: string;
  87253. Vertex_MainBegin: string;
  87254. Vertex_Before_PositionUpdated: string;
  87255. Vertex_Before_NormalUpdated: string;
  87256. Vertex_After_WorldPosComputed: string;
  87257. Vertex_MainEnd: string;
  87258. }
  87259. export class CustomMaterial extends BABYLON.StandardMaterial {
  87260. static ShaderIndexer: number;
  87261. CustomParts: ShaderSpecialParts;
  87262. _isCreatedShader: boolean;
  87263. _createdShaderName: string;
  87264. _customUniform: string[];
  87265. _newUniforms: string[];
  87266. _newUniformInstances: {
  87267. [name: string]: any;
  87268. };
  87269. _newSamplerInstances: {
  87270. [name: string]: BABYLON.Texture;
  87271. };
  87272. _customAttributes: string[];
  87273. FragmentShader: string;
  87274. VertexShader: string;
  87275. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87276. ReviewUniform(name: string, arr: string[]): string[];
  87277. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87278. constructor(name: string, scene: BABYLON.Scene);
  87279. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87280. AddAttribute(name: string): CustomMaterial;
  87281. Fragment_Begin(shaderPart: string): CustomMaterial;
  87282. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87283. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87284. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87285. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87286. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87287. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87288. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87289. Vertex_Begin(shaderPart: string): CustomMaterial;
  87290. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87291. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87292. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87293. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87294. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87295. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87296. }
  87297. }
  87298. declare module BABYLON {
  87299. export class ShaderAlebdoParts {
  87300. constructor();
  87301. Fragment_Begin: string;
  87302. Fragment_Definitions: string;
  87303. Fragment_MainBegin: string;
  87304. Fragment_Custom_Albedo: string;
  87305. Fragment_Before_Lights: string;
  87306. Fragment_Custom_MetallicRoughness: string;
  87307. Fragment_Custom_MicroSurface: string;
  87308. Fragment_Before_Fog: string;
  87309. Fragment_Custom_Alpha: string;
  87310. Fragment_Before_FragColor: string;
  87311. Vertex_Begin: string;
  87312. Vertex_Definitions: string;
  87313. Vertex_MainBegin: string;
  87314. Vertex_Before_PositionUpdated: string;
  87315. Vertex_Before_NormalUpdated: string;
  87316. Vertex_After_WorldPosComputed: string;
  87317. Vertex_MainEnd: string;
  87318. }
  87319. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87320. static ShaderIndexer: number;
  87321. CustomParts: ShaderAlebdoParts;
  87322. _isCreatedShader: boolean;
  87323. _createdShaderName: string;
  87324. _customUniform: string[];
  87325. _newUniforms: string[];
  87326. _newUniformInstances: {
  87327. [name: string]: any;
  87328. };
  87329. _newSamplerInstances: {
  87330. [name: string]: BABYLON.Texture;
  87331. };
  87332. _customAttributes: string[];
  87333. FragmentShader: string;
  87334. VertexShader: string;
  87335. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87336. ReviewUniform(name: string, arr: string[]): string[];
  87337. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87338. constructor(name: string, scene: BABYLON.Scene);
  87339. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87340. AddAttribute(name: string): PBRCustomMaterial;
  87341. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87342. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87343. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87344. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87345. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87346. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87347. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87348. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87349. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87350. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87351. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87352. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87353. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87354. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87355. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87356. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87357. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87358. }
  87359. }
  87360. declare module BABYLON {
  87361. /** @hidden */
  87362. export var firePixelShader: {
  87363. name: string;
  87364. shader: string;
  87365. };
  87366. }
  87367. declare module BABYLON {
  87368. /** @hidden */
  87369. export var fireVertexShader: {
  87370. name: string;
  87371. shader: string;
  87372. };
  87373. }
  87374. declare module BABYLON {
  87375. export class FireMaterial extends BABYLON.PushMaterial {
  87376. private _diffuseTexture;
  87377. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87378. private _distortionTexture;
  87379. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87380. private _opacityTexture;
  87381. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87382. diffuseColor: BABYLON.Color3;
  87383. speed: number;
  87384. private _scaledDiffuse;
  87385. private _lastTime;
  87386. constructor(name: string, scene: BABYLON.Scene);
  87387. needAlphaBlending(): boolean;
  87388. needAlphaTesting(): boolean;
  87389. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87390. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87391. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87392. getAnimatables(): BABYLON.IAnimatable[];
  87393. getActiveTextures(): BABYLON.BaseTexture[];
  87394. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87395. getClassName(): string;
  87396. dispose(forceDisposeEffect?: boolean): void;
  87397. clone(name: string): FireMaterial;
  87398. serialize(): any;
  87399. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87400. }
  87401. }
  87402. declare module BABYLON {
  87403. /** @hidden */
  87404. export var furPixelShader: {
  87405. name: string;
  87406. shader: string;
  87407. };
  87408. }
  87409. declare module BABYLON {
  87410. /** @hidden */
  87411. export var furVertexShader: {
  87412. name: string;
  87413. shader: string;
  87414. };
  87415. }
  87416. declare module BABYLON {
  87417. export class FurMaterial extends BABYLON.PushMaterial {
  87418. private _diffuseTexture;
  87419. diffuseTexture: BABYLON.BaseTexture;
  87420. private _heightTexture;
  87421. heightTexture: BABYLON.BaseTexture;
  87422. diffuseColor: BABYLON.Color3;
  87423. furLength: number;
  87424. furAngle: number;
  87425. furColor: BABYLON.Color3;
  87426. furOffset: number;
  87427. furSpacing: number;
  87428. furGravity: BABYLON.Vector3;
  87429. furSpeed: number;
  87430. furDensity: number;
  87431. furOcclusion: number;
  87432. furTexture: BABYLON.DynamicTexture;
  87433. private _disableLighting;
  87434. disableLighting: boolean;
  87435. private _maxSimultaneousLights;
  87436. maxSimultaneousLights: number;
  87437. highLevelFur: boolean;
  87438. _meshes: BABYLON.AbstractMesh[];
  87439. private _furTime;
  87440. constructor(name: string, scene: BABYLON.Scene);
  87441. get furTime(): number;
  87442. set furTime(furTime: number);
  87443. needAlphaBlending(): boolean;
  87444. needAlphaTesting(): boolean;
  87445. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87446. updateFur(): void;
  87447. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87448. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87449. getAnimatables(): BABYLON.IAnimatable[];
  87450. getActiveTextures(): BABYLON.BaseTexture[];
  87451. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87452. dispose(forceDisposeEffect?: boolean): void;
  87453. clone(name: string): FurMaterial;
  87454. serialize(): any;
  87455. getClassName(): string;
  87456. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87457. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87458. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87459. }
  87460. }
  87461. declare module BABYLON {
  87462. /** @hidden */
  87463. export var gradientPixelShader: {
  87464. name: string;
  87465. shader: string;
  87466. };
  87467. }
  87468. declare module BABYLON {
  87469. /** @hidden */
  87470. export var gradientVertexShader: {
  87471. name: string;
  87472. shader: string;
  87473. };
  87474. }
  87475. declare module BABYLON {
  87476. export class GradientMaterial extends BABYLON.PushMaterial {
  87477. private _maxSimultaneousLights;
  87478. maxSimultaneousLights: number;
  87479. topColor: BABYLON.Color3;
  87480. topColorAlpha: number;
  87481. bottomColor: BABYLON.Color3;
  87482. bottomColorAlpha: number;
  87483. offset: number;
  87484. scale: number;
  87485. smoothness: number;
  87486. private _disableLighting;
  87487. disableLighting: boolean;
  87488. constructor(name: string, scene: BABYLON.Scene);
  87489. needAlphaBlending(): boolean;
  87490. needAlphaTesting(): boolean;
  87491. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87492. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87493. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87494. getAnimatables(): BABYLON.IAnimatable[];
  87495. dispose(forceDisposeEffect?: boolean): void;
  87496. clone(name: string): GradientMaterial;
  87497. serialize(): any;
  87498. getClassName(): string;
  87499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87500. }
  87501. }
  87502. declare module BABYLON {
  87503. /** @hidden */
  87504. export var gridPixelShader: {
  87505. name: string;
  87506. shader: string;
  87507. };
  87508. }
  87509. declare module BABYLON {
  87510. /** @hidden */
  87511. export var gridVertexShader: {
  87512. name: string;
  87513. shader: string;
  87514. };
  87515. }
  87516. declare module BABYLON {
  87517. /**
  87518. * The grid materials allows you to wrap any shape with a grid.
  87519. * Colors are customizable.
  87520. */
  87521. export class GridMaterial extends BABYLON.PushMaterial {
  87522. /**
  87523. * Main color of the grid (e.g. between lines)
  87524. */
  87525. mainColor: BABYLON.Color3;
  87526. /**
  87527. * Color of the grid lines.
  87528. */
  87529. lineColor: BABYLON.Color3;
  87530. /**
  87531. * The scale of the grid compared to unit.
  87532. */
  87533. gridRatio: number;
  87534. /**
  87535. * Allows setting an offset for the grid lines.
  87536. */
  87537. gridOffset: BABYLON.Vector3;
  87538. /**
  87539. * The frequency of thicker lines.
  87540. */
  87541. majorUnitFrequency: number;
  87542. /**
  87543. * The visibility of minor units in the grid.
  87544. */
  87545. minorUnitVisibility: number;
  87546. /**
  87547. * The grid opacity outside of the lines.
  87548. */
  87549. opacity: number;
  87550. /**
  87551. * Determine RBG output is premultiplied by alpha value.
  87552. */
  87553. preMultiplyAlpha: boolean;
  87554. private _opacityTexture;
  87555. opacityTexture: BABYLON.BaseTexture;
  87556. private _gridControl;
  87557. /**
  87558. * constructor
  87559. * @param name The name given to the material in order to identify it afterwards.
  87560. * @param scene The scene the material is used in.
  87561. */
  87562. constructor(name: string, scene: BABYLON.Scene);
  87563. /**
  87564. * Returns wehter or not the grid requires alpha blending.
  87565. */
  87566. needAlphaBlending(): boolean;
  87567. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87568. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87569. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87570. /**
  87571. * Dispose the material and its associated resources.
  87572. * @param forceDisposeEffect will also dispose the used effect when true
  87573. */
  87574. dispose(forceDisposeEffect?: boolean): void;
  87575. clone(name: string): GridMaterial;
  87576. serialize(): any;
  87577. getClassName(): string;
  87578. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87579. }
  87580. }
  87581. declare module BABYLON {
  87582. /** @hidden */
  87583. export var lavaPixelShader: {
  87584. name: string;
  87585. shader: string;
  87586. };
  87587. }
  87588. declare module BABYLON {
  87589. /** @hidden */
  87590. export var lavaVertexShader: {
  87591. name: string;
  87592. shader: string;
  87593. };
  87594. }
  87595. declare module BABYLON {
  87596. export class LavaMaterial extends BABYLON.PushMaterial {
  87597. private _diffuseTexture;
  87598. diffuseTexture: BABYLON.BaseTexture;
  87599. noiseTexture: BABYLON.BaseTexture;
  87600. fogColor: BABYLON.Color3;
  87601. speed: number;
  87602. movingSpeed: number;
  87603. lowFrequencySpeed: number;
  87604. fogDensity: number;
  87605. private _lastTime;
  87606. diffuseColor: BABYLON.Color3;
  87607. private _disableLighting;
  87608. disableLighting: boolean;
  87609. private _unlit;
  87610. unlit: boolean;
  87611. private _maxSimultaneousLights;
  87612. maxSimultaneousLights: number;
  87613. private _scaledDiffuse;
  87614. constructor(name: string, scene: BABYLON.Scene);
  87615. needAlphaBlending(): boolean;
  87616. needAlphaTesting(): boolean;
  87617. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87618. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87619. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87620. getAnimatables(): BABYLON.IAnimatable[];
  87621. getActiveTextures(): BABYLON.BaseTexture[];
  87622. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87623. dispose(forceDisposeEffect?: boolean): void;
  87624. clone(name: string): LavaMaterial;
  87625. serialize(): any;
  87626. getClassName(): string;
  87627. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87628. }
  87629. }
  87630. declare module BABYLON {
  87631. /** @hidden */
  87632. export var mixPixelShader: {
  87633. name: string;
  87634. shader: string;
  87635. };
  87636. }
  87637. declare module BABYLON {
  87638. /** @hidden */
  87639. export var mixVertexShader: {
  87640. name: string;
  87641. shader: string;
  87642. };
  87643. }
  87644. declare module BABYLON {
  87645. export class MixMaterial extends BABYLON.PushMaterial {
  87646. /**
  87647. * Mix textures
  87648. */
  87649. private _mixTexture1;
  87650. mixTexture1: BABYLON.BaseTexture;
  87651. private _mixTexture2;
  87652. mixTexture2: BABYLON.BaseTexture;
  87653. /**
  87654. * Diffuse textures
  87655. */
  87656. private _diffuseTexture1;
  87657. diffuseTexture1: BABYLON.Texture;
  87658. private _diffuseTexture2;
  87659. diffuseTexture2: BABYLON.Texture;
  87660. private _diffuseTexture3;
  87661. diffuseTexture3: BABYLON.Texture;
  87662. private _diffuseTexture4;
  87663. diffuseTexture4: BABYLON.Texture;
  87664. private _diffuseTexture5;
  87665. diffuseTexture5: BABYLON.Texture;
  87666. private _diffuseTexture6;
  87667. diffuseTexture6: BABYLON.Texture;
  87668. private _diffuseTexture7;
  87669. diffuseTexture7: BABYLON.Texture;
  87670. private _diffuseTexture8;
  87671. diffuseTexture8: BABYLON.Texture;
  87672. /**
  87673. * Uniforms
  87674. */
  87675. diffuseColor: BABYLON.Color3;
  87676. specularColor: BABYLON.Color3;
  87677. specularPower: number;
  87678. private _disableLighting;
  87679. disableLighting: boolean;
  87680. private _maxSimultaneousLights;
  87681. maxSimultaneousLights: number;
  87682. constructor(name: string, scene: BABYLON.Scene);
  87683. needAlphaBlending(): boolean;
  87684. needAlphaTesting(): boolean;
  87685. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87686. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87687. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87688. getAnimatables(): BABYLON.IAnimatable[];
  87689. getActiveTextures(): BABYLON.BaseTexture[];
  87690. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87691. dispose(forceDisposeEffect?: boolean): void;
  87692. clone(name: string): MixMaterial;
  87693. serialize(): any;
  87694. getClassName(): string;
  87695. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87696. }
  87697. }
  87698. declare module BABYLON {
  87699. /** @hidden */
  87700. export var normalPixelShader: {
  87701. name: string;
  87702. shader: string;
  87703. };
  87704. }
  87705. declare module BABYLON {
  87706. /** @hidden */
  87707. export var normalVertexShader: {
  87708. name: string;
  87709. shader: string;
  87710. };
  87711. }
  87712. declare module BABYLON {
  87713. export class NormalMaterial extends BABYLON.PushMaterial {
  87714. private _diffuseTexture;
  87715. diffuseTexture: BABYLON.BaseTexture;
  87716. diffuseColor: BABYLON.Color3;
  87717. private _disableLighting;
  87718. disableLighting: boolean;
  87719. private _maxSimultaneousLights;
  87720. maxSimultaneousLights: number;
  87721. constructor(name: string, scene: BABYLON.Scene);
  87722. needAlphaBlending(): boolean;
  87723. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87724. needAlphaTesting(): boolean;
  87725. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87726. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87727. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87728. getAnimatables(): BABYLON.IAnimatable[];
  87729. getActiveTextures(): BABYLON.BaseTexture[];
  87730. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87731. dispose(forceDisposeEffect?: boolean): void;
  87732. clone(name: string): NormalMaterial;
  87733. serialize(): any;
  87734. getClassName(): string;
  87735. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87736. }
  87737. }
  87738. declare module BABYLON {
  87739. /** @hidden */
  87740. export var shadowOnlyPixelShader: {
  87741. name: string;
  87742. shader: string;
  87743. };
  87744. }
  87745. declare module BABYLON {
  87746. /** @hidden */
  87747. export var shadowOnlyVertexShader: {
  87748. name: string;
  87749. shader: string;
  87750. };
  87751. }
  87752. declare module BABYLON {
  87753. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87754. private _activeLight;
  87755. private _needAlphaBlending;
  87756. constructor(name: string, scene: BABYLON.Scene);
  87757. shadowColor: BABYLON.Color3;
  87758. needAlphaBlending(): boolean;
  87759. needAlphaTesting(): boolean;
  87760. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87761. get activeLight(): BABYLON.IShadowLight;
  87762. set activeLight(light: BABYLON.IShadowLight);
  87763. private _getFirstShadowLightForMesh;
  87764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87765. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87766. clone(name: string): ShadowOnlyMaterial;
  87767. serialize(): any;
  87768. getClassName(): string;
  87769. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87770. }
  87771. }
  87772. declare module BABYLON {
  87773. /** @hidden */
  87774. export var simplePixelShader: {
  87775. name: string;
  87776. shader: string;
  87777. };
  87778. }
  87779. declare module BABYLON {
  87780. /** @hidden */
  87781. export var simpleVertexShader: {
  87782. name: string;
  87783. shader: string;
  87784. };
  87785. }
  87786. declare module BABYLON {
  87787. export class SimpleMaterial extends BABYLON.PushMaterial {
  87788. private _diffuseTexture;
  87789. diffuseTexture: BABYLON.BaseTexture;
  87790. diffuseColor: BABYLON.Color3;
  87791. private _disableLighting;
  87792. disableLighting: boolean;
  87793. private _maxSimultaneousLights;
  87794. maxSimultaneousLights: number;
  87795. constructor(name: string, scene: BABYLON.Scene);
  87796. needAlphaBlending(): boolean;
  87797. needAlphaTesting(): boolean;
  87798. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87799. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87800. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87801. getAnimatables(): BABYLON.IAnimatable[];
  87802. getActiveTextures(): BABYLON.BaseTexture[];
  87803. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87804. dispose(forceDisposeEffect?: boolean): void;
  87805. clone(name: string): SimpleMaterial;
  87806. serialize(): any;
  87807. getClassName(): string;
  87808. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87809. }
  87810. }
  87811. declare module BABYLON {
  87812. /** @hidden */
  87813. export var skyPixelShader: {
  87814. name: string;
  87815. shader: string;
  87816. };
  87817. }
  87818. declare module BABYLON {
  87819. /** @hidden */
  87820. export var skyVertexShader: {
  87821. name: string;
  87822. shader: string;
  87823. };
  87824. }
  87825. declare module BABYLON {
  87826. /**
  87827. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87828. * @see https://doc.babylonjs.com/extensions/sky
  87829. */
  87830. export class SkyMaterial extends BABYLON.PushMaterial {
  87831. /**
  87832. * Defines the overall luminance of sky in interval ]0, 1[.
  87833. */
  87834. luminance: number;
  87835. /**
  87836. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87837. */
  87838. turbidity: number;
  87839. /**
  87840. * Defines the sky appearance (light intensity).
  87841. */
  87842. rayleigh: number;
  87843. /**
  87844. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87845. */
  87846. mieCoefficient: number;
  87847. /**
  87848. * Defines the amount of haze particles following the Mie scattering theory.
  87849. */
  87850. mieDirectionalG: number;
  87851. /**
  87852. * Defines the distance of the sun according to the active scene camera.
  87853. */
  87854. distance: number;
  87855. /**
  87856. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87857. * "inclined".
  87858. */
  87859. inclination: number;
  87860. /**
  87861. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87862. * an object direction and a reference direction.
  87863. */
  87864. azimuth: number;
  87865. /**
  87866. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87867. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87868. */
  87869. sunPosition: BABYLON.Vector3;
  87870. /**
  87871. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87872. * .sunPosition property.
  87873. */
  87874. useSunPosition: boolean;
  87875. /**
  87876. * Defines an offset vector used to get a horizon offset.
  87877. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87878. */
  87879. cameraOffset: BABYLON.Vector3;
  87880. private _cameraPosition;
  87881. /**
  87882. * Instantiates a new sky material.
  87883. * This material allows to create dynamic and texture free
  87884. * effects for skyboxes by taking care of the atmosphere state.
  87885. * @see https://doc.babylonjs.com/extensions/sky
  87886. * @param name Define the name of the material in the scene
  87887. * @param scene Define the scene the material belong to
  87888. */
  87889. constructor(name: string, scene: BABYLON.Scene);
  87890. /**
  87891. * Specifies if the material will require alpha blending
  87892. * @returns a boolean specifying if alpha blending is needed
  87893. */
  87894. needAlphaBlending(): boolean;
  87895. /**
  87896. * Specifies if this material should be rendered in alpha test mode
  87897. * @returns false as the sky material doesn't need alpha testing.
  87898. */
  87899. needAlphaTesting(): boolean;
  87900. /**
  87901. * Get the texture used for alpha test purpose.
  87902. * @returns null as the sky material has no texture.
  87903. */
  87904. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87905. /**
  87906. * Get if the submesh is ready to be used and all its information available.
  87907. * Child classes can use it to update shaders
  87908. * @param mesh defines the mesh to check
  87909. * @param subMesh defines which submesh to check
  87910. * @param useInstances specifies that instances should be used
  87911. * @returns a boolean indicating that the submesh is ready or not
  87912. */
  87913. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87914. /**
  87915. * Binds the submesh to this material by preparing the effect and shader to draw
  87916. * @param world defines the world transformation matrix
  87917. * @param mesh defines the mesh containing the submesh
  87918. * @param subMesh defines the submesh to bind the material to
  87919. */
  87920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87921. /**
  87922. * Get the list of animatables in the material.
  87923. * @returns the list of animatables object used in the material
  87924. */
  87925. getAnimatables(): BABYLON.IAnimatable[];
  87926. /**
  87927. * Disposes the material
  87928. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87929. */
  87930. dispose(forceDisposeEffect?: boolean): void;
  87931. /**
  87932. * Makes a duplicate of the material, and gives it a new name
  87933. * @param name defines the new name for the duplicated material
  87934. * @returns the cloned material
  87935. */
  87936. clone(name: string): SkyMaterial;
  87937. /**
  87938. * Serializes this material in a JSON representation
  87939. * @returns the serialized material object
  87940. */
  87941. serialize(): any;
  87942. /**
  87943. * Gets the current class name of the material e.g. "SkyMaterial"
  87944. * Mainly use in serialization.
  87945. * @returns the class name
  87946. */
  87947. getClassName(): string;
  87948. /**
  87949. * Creates a sky material from parsed material data
  87950. * @param source defines the JSON representation of the material
  87951. * @param scene defines the hosting scene
  87952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87953. * @returns a new sky material
  87954. */
  87955. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87956. }
  87957. }
  87958. declare module BABYLON {
  87959. /** @hidden */
  87960. export var terrainPixelShader: {
  87961. name: string;
  87962. shader: string;
  87963. };
  87964. }
  87965. declare module BABYLON {
  87966. /** @hidden */
  87967. export var terrainVertexShader: {
  87968. name: string;
  87969. shader: string;
  87970. };
  87971. }
  87972. declare module BABYLON {
  87973. export class TerrainMaterial extends BABYLON.PushMaterial {
  87974. private _mixTexture;
  87975. mixTexture: BABYLON.BaseTexture;
  87976. private _diffuseTexture1;
  87977. diffuseTexture1: BABYLON.Texture;
  87978. private _diffuseTexture2;
  87979. diffuseTexture2: BABYLON.Texture;
  87980. private _diffuseTexture3;
  87981. diffuseTexture3: BABYLON.Texture;
  87982. private _bumpTexture1;
  87983. bumpTexture1: BABYLON.Texture;
  87984. private _bumpTexture2;
  87985. bumpTexture2: BABYLON.Texture;
  87986. private _bumpTexture3;
  87987. bumpTexture3: BABYLON.Texture;
  87988. diffuseColor: BABYLON.Color3;
  87989. specularColor: BABYLON.Color3;
  87990. specularPower: number;
  87991. private _disableLighting;
  87992. disableLighting: boolean;
  87993. private _maxSimultaneousLights;
  87994. maxSimultaneousLights: number;
  87995. constructor(name: string, scene: BABYLON.Scene);
  87996. needAlphaBlending(): boolean;
  87997. needAlphaTesting(): boolean;
  87998. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87999. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88000. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88001. getAnimatables(): BABYLON.IAnimatable[];
  88002. getActiveTextures(): BABYLON.BaseTexture[];
  88003. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88004. dispose(forceDisposeEffect?: boolean): void;
  88005. clone(name: string): TerrainMaterial;
  88006. serialize(): any;
  88007. getClassName(): string;
  88008. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  88009. }
  88010. }
  88011. declare module BABYLON {
  88012. /** @hidden */
  88013. export var triplanarPixelShader: {
  88014. name: string;
  88015. shader: string;
  88016. };
  88017. }
  88018. declare module BABYLON {
  88019. /** @hidden */
  88020. export var triplanarVertexShader: {
  88021. name: string;
  88022. shader: string;
  88023. };
  88024. }
  88025. declare module BABYLON {
  88026. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  88027. mixTexture: BABYLON.BaseTexture;
  88028. private _diffuseTextureX;
  88029. diffuseTextureX: BABYLON.BaseTexture;
  88030. private _diffuseTextureY;
  88031. diffuseTextureY: BABYLON.BaseTexture;
  88032. private _diffuseTextureZ;
  88033. diffuseTextureZ: BABYLON.BaseTexture;
  88034. private _normalTextureX;
  88035. normalTextureX: BABYLON.BaseTexture;
  88036. private _normalTextureY;
  88037. normalTextureY: BABYLON.BaseTexture;
  88038. private _normalTextureZ;
  88039. normalTextureZ: BABYLON.BaseTexture;
  88040. tileSize: number;
  88041. diffuseColor: BABYLON.Color3;
  88042. specularColor: BABYLON.Color3;
  88043. specularPower: number;
  88044. private _disableLighting;
  88045. disableLighting: boolean;
  88046. private _maxSimultaneousLights;
  88047. maxSimultaneousLights: number;
  88048. constructor(name: string, scene: BABYLON.Scene);
  88049. needAlphaBlending(): boolean;
  88050. needAlphaTesting(): boolean;
  88051. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88052. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88053. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88054. getAnimatables(): BABYLON.IAnimatable[];
  88055. getActiveTextures(): BABYLON.BaseTexture[];
  88056. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88057. dispose(forceDisposeEffect?: boolean): void;
  88058. clone(name: string): TriPlanarMaterial;
  88059. serialize(): any;
  88060. getClassName(): string;
  88061. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  88062. }
  88063. }
  88064. declare module BABYLON {
  88065. /** @hidden */
  88066. export var waterPixelShader: {
  88067. name: string;
  88068. shader: string;
  88069. };
  88070. }
  88071. declare module BABYLON {
  88072. /** @hidden */
  88073. export var waterVertexShader: {
  88074. name: string;
  88075. shader: string;
  88076. };
  88077. }
  88078. declare module BABYLON {
  88079. export class WaterMaterial extends BABYLON.PushMaterial {
  88080. renderTargetSize: BABYLON.Vector2;
  88081. private _bumpTexture;
  88082. bumpTexture: BABYLON.BaseTexture;
  88083. diffuseColor: BABYLON.Color3;
  88084. specularColor: BABYLON.Color3;
  88085. specularPower: number;
  88086. private _disableLighting;
  88087. disableLighting: boolean;
  88088. private _maxSimultaneousLights;
  88089. maxSimultaneousLights: number;
  88090. /**
  88091. * Defines the wind force.
  88092. */
  88093. windForce: number;
  88094. /**
  88095. * Defines the direction of the wind in the plane (X, Z).
  88096. */
  88097. windDirection: BABYLON.Vector2;
  88098. /**
  88099. * Defines the height of the waves.
  88100. */
  88101. waveHeight: number;
  88102. /**
  88103. * Defines the bump height related to the bump map.
  88104. */
  88105. bumpHeight: number;
  88106. /**
  88107. * Defines wether or not: to add a smaller moving bump to less steady waves.
  88108. */
  88109. private _bumpSuperimpose;
  88110. bumpSuperimpose: boolean;
  88111. /**
  88112. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  88113. */
  88114. private _fresnelSeparate;
  88115. fresnelSeparate: boolean;
  88116. /**
  88117. * Defines wether or not bump Wwves modify the reflection.
  88118. */
  88119. private _bumpAffectsReflection;
  88120. bumpAffectsReflection: boolean;
  88121. /**
  88122. * Defines the water color blended with the refraction (near).
  88123. */
  88124. waterColor: BABYLON.Color3;
  88125. /**
  88126. * Defines the blend factor related to the water color.
  88127. */
  88128. colorBlendFactor: number;
  88129. /**
  88130. * Defines the water color blended with the reflection (far).
  88131. */
  88132. waterColor2: BABYLON.Color3;
  88133. /**
  88134. * Defines the blend factor related to the water color (reflection, far).
  88135. */
  88136. colorBlendFactor2: number;
  88137. /**
  88138. * Defines the maximum length of a wave.
  88139. */
  88140. waveLength: number;
  88141. /**
  88142. * Defines the waves speed.
  88143. */
  88144. waveSpeed: number;
  88145. /**
  88146. * 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.
  88147. */
  88148. waveCount: number;
  88149. /**
  88150. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  88151. * will avoid calculating useless pixels in the pixel shader of the water material.
  88152. */
  88153. disableClipPlane: boolean;
  88154. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  88155. private _mesh;
  88156. private _refractionRTT;
  88157. private _reflectionRTT;
  88158. private _reflectionTransform;
  88159. private _lastTime;
  88160. private _lastDeltaTime;
  88161. private _useLogarithmicDepth;
  88162. private _waitingRenderList;
  88163. private _imageProcessingConfiguration;
  88164. private _imageProcessingObserver;
  88165. /**
  88166. * Gets a boolean indicating that current material needs to register RTT
  88167. */
  88168. get hasRenderTargetTextures(): boolean;
  88169. /**
  88170. * Constructor
  88171. */
  88172. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88173. get useLogarithmicDepth(): boolean;
  88174. set useLogarithmicDepth(value: boolean);
  88175. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88176. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88177. addToRenderList(node: any): void;
  88178. enableRenderTargets(enable: boolean): void;
  88179. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88180. get renderTargetsEnabled(): boolean;
  88181. needAlphaBlending(): boolean;
  88182. needAlphaTesting(): boolean;
  88183. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88186. private _createRenderTargets;
  88187. getAnimatables(): BABYLON.IAnimatable[];
  88188. getActiveTextures(): BABYLON.BaseTexture[];
  88189. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88190. dispose(forceDisposeEffect?: boolean): void;
  88191. clone(name: string): WaterMaterial;
  88192. serialize(): any;
  88193. getClassName(): string;
  88194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88195. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88196. }
  88197. }
  88198. declare module BABYLON {
  88199. /** @hidden */
  88200. export var asciiartPixelShader: {
  88201. name: string;
  88202. shader: string;
  88203. };
  88204. }
  88205. declare module BABYLON {
  88206. /**
  88207. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88208. *
  88209. * It basically takes care rendering the font front the given font size to a texture.
  88210. * This is used later on in the postprocess.
  88211. */
  88212. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88213. private _font;
  88214. private _text;
  88215. private _charSize;
  88216. /**
  88217. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88218. */
  88219. get charSize(): number;
  88220. /**
  88221. * Create a new instance of the Ascii Art FontTexture class
  88222. * @param name the name of the texture
  88223. * @param font the font to use, use the W3C CSS notation
  88224. * @param text the caracter set to use in the rendering.
  88225. * @param scene the scene that owns the texture
  88226. */
  88227. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88228. /**
  88229. * Gets the max char width of a font.
  88230. * @param font the font to use, use the W3C CSS notation
  88231. * @return the max char width
  88232. */
  88233. private getFontWidth;
  88234. /**
  88235. * Gets the max char height of a font.
  88236. * @param font the font to use, use the W3C CSS notation
  88237. * @return the max char height
  88238. */
  88239. private getFontHeight;
  88240. /**
  88241. * Clones the current AsciiArtTexture.
  88242. * @return the clone of the texture.
  88243. */
  88244. clone(): AsciiArtFontTexture;
  88245. /**
  88246. * Parses a json object representing the texture and returns an instance of it.
  88247. * @param source the source JSON representation
  88248. * @param scene the scene to create the texture for
  88249. * @return the parsed texture
  88250. */
  88251. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88252. }
  88253. /**
  88254. * Option available in the Ascii Art Post Process.
  88255. */
  88256. export interface IAsciiArtPostProcessOptions {
  88257. /**
  88258. * The font to use following the w3c font definition.
  88259. */
  88260. font?: string;
  88261. /**
  88262. * The character set to use in the postprocess.
  88263. */
  88264. characterSet?: string;
  88265. /**
  88266. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88267. * This number is defined between 0 and 1;
  88268. */
  88269. mixToTile?: number;
  88270. /**
  88271. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88272. * This number is defined between 0 and 1;
  88273. */
  88274. mixToNormal?: number;
  88275. }
  88276. /**
  88277. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88278. *
  88279. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88280. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88281. */
  88282. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88283. /**
  88284. * The font texture used to render the char in the post process.
  88285. */
  88286. private _asciiArtFontTexture;
  88287. /**
  88288. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88289. * This number is defined between 0 and 1;
  88290. */
  88291. mixToTile: number;
  88292. /**
  88293. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88294. * This number is defined between 0 and 1;
  88295. */
  88296. mixToNormal: number;
  88297. /**
  88298. * Instantiates a new Ascii Art Post Process.
  88299. * @param name the name to give to the postprocess
  88300. * @camera the camera to apply the post process to.
  88301. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88302. */
  88303. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88304. }
  88305. }
  88306. declare module BABYLON {
  88307. /** @hidden */
  88308. export var digitalrainPixelShader: {
  88309. name: string;
  88310. shader: string;
  88311. };
  88312. }
  88313. declare module BABYLON {
  88314. /**
  88315. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88316. *
  88317. * It basically takes care rendering the font front the given font size to a texture.
  88318. * This is used later on in the postprocess.
  88319. */
  88320. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88321. private _font;
  88322. private _text;
  88323. private _charSize;
  88324. /**
  88325. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88326. */
  88327. get charSize(): number;
  88328. /**
  88329. * Create a new instance of the Digital Rain FontTexture class
  88330. * @param name the name of the texture
  88331. * @param font the font to use, use the W3C CSS notation
  88332. * @param text the caracter set to use in the rendering.
  88333. * @param scene the scene that owns the texture
  88334. */
  88335. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88336. /**
  88337. * Gets the max char width of a font.
  88338. * @param font the font to use, use the W3C CSS notation
  88339. * @return the max char width
  88340. */
  88341. private getFontWidth;
  88342. /**
  88343. * Gets the max char height of a font.
  88344. * @param font the font to use, use the W3C CSS notation
  88345. * @return the max char height
  88346. */
  88347. private getFontHeight;
  88348. /**
  88349. * Clones the current DigitalRainFontTexture.
  88350. * @return the clone of the texture.
  88351. */
  88352. clone(): DigitalRainFontTexture;
  88353. /**
  88354. * Parses a json object representing the texture and returns an instance of it.
  88355. * @param source the source JSON representation
  88356. * @param scene the scene to create the texture for
  88357. * @return the parsed texture
  88358. */
  88359. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88360. }
  88361. /**
  88362. * Option available in the Digital Rain Post Process.
  88363. */
  88364. export interface IDigitalRainPostProcessOptions {
  88365. /**
  88366. * The font to use following the w3c font definition.
  88367. */
  88368. font?: string;
  88369. /**
  88370. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88371. * This number is defined between 0 and 1;
  88372. */
  88373. mixToTile?: number;
  88374. /**
  88375. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88376. * This number is defined between 0 and 1;
  88377. */
  88378. mixToNormal?: number;
  88379. }
  88380. /**
  88381. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88382. *
  88383. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88384. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88385. */
  88386. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88387. /**
  88388. * The font texture used to render the char in the post process.
  88389. */
  88390. private _digitalRainFontTexture;
  88391. /**
  88392. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88393. * This number is defined between 0 and 1;
  88394. */
  88395. mixToTile: number;
  88396. /**
  88397. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88398. * This number is defined between 0 and 1;
  88399. */
  88400. mixToNormal: number;
  88401. /**
  88402. * Instantiates a new Digital Rain Post Process.
  88403. * @param name the name to give to the postprocess
  88404. * @camera the camera to apply the post process to.
  88405. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88406. */
  88407. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88408. }
  88409. }
  88410. declare module BABYLON {
  88411. /** @hidden */
  88412. export var brickProceduralTexturePixelShader: {
  88413. name: string;
  88414. shader: string;
  88415. };
  88416. }
  88417. declare module BABYLON {
  88418. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88419. private _numberOfBricksHeight;
  88420. private _numberOfBricksWidth;
  88421. private _jointColor;
  88422. private _brickColor;
  88423. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88424. updateShaderUniforms(): void;
  88425. get numberOfBricksHeight(): number;
  88426. set numberOfBricksHeight(value: number);
  88427. get numberOfBricksWidth(): number;
  88428. set numberOfBricksWidth(value: number);
  88429. get jointColor(): BABYLON.Color3;
  88430. set jointColor(value: BABYLON.Color3);
  88431. get brickColor(): BABYLON.Color3;
  88432. set brickColor(value: BABYLON.Color3);
  88433. /**
  88434. * Serializes this brick procedural texture
  88435. * @returns a serialized brick procedural texture object
  88436. */
  88437. serialize(): any;
  88438. /**
  88439. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88440. * @param parsedTexture defines parsed texture data
  88441. * @param scene defines the current scene
  88442. * @param rootUrl defines the root URL containing brick procedural texture information
  88443. * @returns a parsed Brick Procedural BABYLON.Texture
  88444. */
  88445. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88446. }
  88447. }
  88448. declare module BABYLON {
  88449. /** @hidden */
  88450. export var cloudProceduralTexturePixelShader: {
  88451. name: string;
  88452. shader: string;
  88453. };
  88454. }
  88455. declare module BABYLON {
  88456. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88457. private _skyColor;
  88458. private _cloudColor;
  88459. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88460. updateShaderUniforms(): void;
  88461. get skyColor(): BABYLON.Color4;
  88462. set skyColor(value: BABYLON.Color4);
  88463. get cloudColor(): BABYLON.Color4;
  88464. set cloudColor(value: BABYLON.Color4);
  88465. /**
  88466. * Serializes this cloud procedural texture
  88467. * @returns a serialized cloud procedural texture object
  88468. */
  88469. serialize(): any;
  88470. /**
  88471. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88472. * @param parsedTexture defines parsed texture data
  88473. * @param scene defines the current scene
  88474. * @param rootUrl defines the root URL containing cloud procedural texture information
  88475. * @returns a parsed Cloud Procedural BABYLON.Texture
  88476. */
  88477. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88478. }
  88479. }
  88480. declare module BABYLON {
  88481. /** @hidden */
  88482. export var fireProceduralTexturePixelShader: {
  88483. name: string;
  88484. shader: string;
  88485. };
  88486. }
  88487. declare module BABYLON {
  88488. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88489. private _time;
  88490. private _speed;
  88491. private _autoGenerateTime;
  88492. private _fireColors;
  88493. private _alphaThreshold;
  88494. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88495. updateShaderUniforms(): void;
  88496. render(useCameraPostProcess?: boolean): void;
  88497. static get PurpleFireColors(): BABYLON.Color3[];
  88498. static get GreenFireColors(): BABYLON.Color3[];
  88499. static get RedFireColors(): BABYLON.Color3[];
  88500. static get BlueFireColors(): BABYLON.Color3[];
  88501. get autoGenerateTime(): boolean;
  88502. set autoGenerateTime(value: boolean);
  88503. get fireColors(): BABYLON.Color3[];
  88504. set fireColors(value: BABYLON.Color3[]);
  88505. get time(): number;
  88506. set time(value: number);
  88507. get speed(): BABYLON.Vector2;
  88508. set speed(value: BABYLON.Vector2);
  88509. get alphaThreshold(): number;
  88510. set alphaThreshold(value: number);
  88511. /**
  88512. * Serializes this fire procedural texture
  88513. * @returns a serialized fire procedural texture object
  88514. */
  88515. serialize(): any;
  88516. /**
  88517. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88518. * @param parsedTexture defines parsed texture data
  88519. * @param scene defines the current scene
  88520. * @param rootUrl defines the root URL containing fire procedural texture information
  88521. * @returns a parsed Fire Procedural BABYLON.Texture
  88522. */
  88523. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88524. }
  88525. }
  88526. declare module BABYLON {
  88527. /** @hidden */
  88528. export var grassProceduralTexturePixelShader: {
  88529. name: string;
  88530. shader: string;
  88531. };
  88532. }
  88533. declare module BABYLON {
  88534. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88535. private _grassColors;
  88536. private _groundColor;
  88537. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88538. updateShaderUniforms(): void;
  88539. get grassColors(): BABYLON.Color3[];
  88540. set grassColors(value: BABYLON.Color3[]);
  88541. get groundColor(): BABYLON.Color3;
  88542. set groundColor(value: BABYLON.Color3);
  88543. /**
  88544. * Serializes this grass procedural texture
  88545. * @returns a serialized grass procedural texture object
  88546. */
  88547. serialize(): any;
  88548. /**
  88549. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88550. * @param parsedTexture defines parsed texture data
  88551. * @param scene defines the current scene
  88552. * @param rootUrl defines the root URL containing grass procedural texture information
  88553. * @returns a parsed Grass Procedural BABYLON.Texture
  88554. */
  88555. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88556. }
  88557. }
  88558. declare module BABYLON {
  88559. /** @hidden */
  88560. export var marbleProceduralTexturePixelShader: {
  88561. name: string;
  88562. shader: string;
  88563. };
  88564. }
  88565. declare module BABYLON {
  88566. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88567. private _numberOfTilesHeight;
  88568. private _numberOfTilesWidth;
  88569. private _amplitude;
  88570. private _jointColor;
  88571. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88572. updateShaderUniforms(): void;
  88573. get numberOfTilesHeight(): number;
  88574. set numberOfTilesHeight(value: number);
  88575. get amplitude(): number;
  88576. set amplitude(value: number);
  88577. get numberOfTilesWidth(): number;
  88578. set numberOfTilesWidth(value: number);
  88579. get jointColor(): BABYLON.Color3;
  88580. set jointColor(value: BABYLON.Color3);
  88581. /**
  88582. * Serializes this marble procedural texture
  88583. * @returns a serialized marble procedural texture object
  88584. */
  88585. serialize(): any;
  88586. /**
  88587. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88588. * @param parsedTexture defines parsed texture data
  88589. * @param scene defines the current scene
  88590. * @param rootUrl defines the root URL containing marble procedural texture information
  88591. * @returns a parsed Marble Procedural BABYLON.Texture
  88592. */
  88593. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88594. }
  88595. }
  88596. declare module BABYLON {
  88597. /** @hidden */
  88598. export var normalMapProceduralTexturePixelShader: {
  88599. name: string;
  88600. shader: string;
  88601. };
  88602. }
  88603. declare module BABYLON {
  88604. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88605. private _baseTexture;
  88606. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88607. updateShaderUniforms(): void;
  88608. render(useCameraPostProcess?: boolean): void;
  88609. resize(size: any, generateMipMaps: any): void;
  88610. get baseTexture(): BABYLON.Texture;
  88611. set baseTexture(texture: BABYLON.Texture);
  88612. /**
  88613. * Serializes this normal map procedural texture
  88614. * @returns a serialized normal map procedural texture object
  88615. */
  88616. serialize(): any;
  88617. /**
  88618. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88619. * @param parsedTexture defines parsed texture data
  88620. * @param scene defines the current scene
  88621. * @param rootUrl defines the root URL containing normal map procedural texture information
  88622. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88623. */
  88624. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88625. }
  88626. }
  88627. declare module BABYLON {
  88628. /** @hidden */
  88629. export var perlinNoiseProceduralTexturePixelShader: {
  88630. name: string;
  88631. shader: string;
  88632. };
  88633. }
  88634. declare module BABYLON {
  88635. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88636. time: number;
  88637. timeScale: number;
  88638. translationSpeed: number;
  88639. private _currentTranslation;
  88640. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88641. updateShaderUniforms(): void;
  88642. render(useCameraPostProcess?: boolean): void;
  88643. resize(size: any, generateMipMaps: any): void;
  88644. /**
  88645. * Serializes this perlin noise procedural texture
  88646. * @returns a serialized perlin noise procedural texture object
  88647. */
  88648. serialize(): any;
  88649. /**
  88650. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88651. * @param parsedTexture defines parsed texture data
  88652. * @param scene defines the current scene
  88653. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88654. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88655. */
  88656. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88657. }
  88658. }
  88659. declare module BABYLON {
  88660. /** @hidden */
  88661. export var roadProceduralTexturePixelShader: {
  88662. name: string;
  88663. shader: string;
  88664. };
  88665. }
  88666. declare module BABYLON {
  88667. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88668. private _roadColor;
  88669. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88670. updateShaderUniforms(): void;
  88671. get roadColor(): BABYLON.Color3;
  88672. set roadColor(value: BABYLON.Color3);
  88673. /**
  88674. * Serializes this road procedural texture
  88675. * @returns a serialized road procedural texture object
  88676. */
  88677. serialize(): any;
  88678. /**
  88679. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88680. * @param parsedTexture defines parsed texture data
  88681. * @param scene defines the current scene
  88682. * @param rootUrl defines the root URL containing road procedural texture information
  88683. * @returns a parsed Road Procedural BABYLON.Texture
  88684. */
  88685. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88686. }
  88687. }
  88688. declare module BABYLON {
  88689. /** @hidden */
  88690. export var starfieldProceduralTexturePixelShader: {
  88691. name: string;
  88692. shader: string;
  88693. };
  88694. }
  88695. declare module BABYLON {
  88696. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88697. private _time;
  88698. private _alpha;
  88699. private _beta;
  88700. private _zoom;
  88701. private _formuparam;
  88702. private _stepsize;
  88703. private _tile;
  88704. private _brightness;
  88705. private _darkmatter;
  88706. private _distfading;
  88707. private _saturation;
  88708. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88709. updateShaderUniforms(): void;
  88710. get time(): number;
  88711. set time(value: number);
  88712. get alpha(): number;
  88713. set alpha(value: number);
  88714. get beta(): number;
  88715. set beta(value: number);
  88716. get formuparam(): number;
  88717. set formuparam(value: number);
  88718. get stepsize(): number;
  88719. set stepsize(value: number);
  88720. get zoom(): number;
  88721. set zoom(value: number);
  88722. get tile(): number;
  88723. set tile(value: number);
  88724. get brightness(): number;
  88725. set brightness(value: number);
  88726. get darkmatter(): number;
  88727. set darkmatter(value: number);
  88728. get distfading(): number;
  88729. set distfading(value: number);
  88730. get saturation(): number;
  88731. set saturation(value: number);
  88732. /**
  88733. * Serializes this starfield procedural texture
  88734. * @returns a serialized starfield procedural texture object
  88735. */
  88736. serialize(): any;
  88737. /**
  88738. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88739. * @param parsedTexture defines parsed texture data
  88740. * @param scene defines the current scene
  88741. * @param rootUrl defines the root URL containing startfield procedural texture information
  88742. * @returns a parsed Starfield Procedural BABYLON.Texture
  88743. */
  88744. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88745. }
  88746. }
  88747. declare module BABYLON {
  88748. /** @hidden */
  88749. export var woodProceduralTexturePixelShader: {
  88750. name: string;
  88751. shader: string;
  88752. };
  88753. }
  88754. declare module BABYLON {
  88755. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88756. private _ampScale;
  88757. private _woodColor;
  88758. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88759. updateShaderUniforms(): void;
  88760. get ampScale(): number;
  88761. set ampScale(value: number);
  88762. get woodColor(): BABYLON.Color3;
  88763. set woodColor(value: BABYLON.Color3);
  88764. /**
  88765. * Serializes this wood procedural texture
  88766. * @returns a serialized wood procedural texture object
  88767. */
  88768. serialize(): any;
  88769. /**
  88770. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88771. * @param parsedTexture defines parsed texture data
  88772. * @param scene defines the current scene
  88773. * @param rootUrl defines the root URL containing wood procedural texture information
  88774. * @returns a parsed Wood Procedural BABYLON.Texture
  88775. */
  88776. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88777. }
  88778. }